[Scummvm-cvs-logs] scummvm master -> 2e4ee0b2d0f687deb16ca18691042de1a21d7410

clone2727 clone2727 at gmail.com
Thu Sep 20 22:26:54 CEST 2012


This automated email contains information about 362 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
950676bf4c PEGASUS: Add my very WIP Pegasus Prime engine
850d776e62 PEGASUS: Fix cursor palettes
3b2283daf8 PEGASUS: Remove the rest of the svn keywords from the copyright
9cb600099f Merge remote branch 'upstream/master' into pegasus
6cfdd2529b PEGASUS: Make the nav movie rely on the current time zone instead of hardcoding it
01380d287a PEGASUS: Begin cleaning up the time zone movie code
6067a46e9d PEGASUS: Cleanup menu button handling
866a8dddd1 PEGASUS: Begin work on the interface overview
02b023e266 PEGASUS: Ignore meta keys in the overview
5a86c56b8c PEGASUS: Finish overview implementation
6b8a6f486c PEGASUS: Finish hotspot outline code in the overview
85b2a0574c PEGASUS: Add basic credits implementation
50e43a56e7 PEGASUS: Add a stub debugger
760f50f034 PEGASUS: Allow the console to be attached from the menu
d85dc010ed PEGASUS: Add support for using the original 'Opening/Closing' directory
7e2edf16b3 PEGASUS: Make the intro directory check only work in the full game
d4c9298392 Merge remote branch 'upstream/master' into pegasus
224c71e483 Merge remote branch 'upstream/master' into pegasus
d355475a04 Merge remote branch 'upstream/master' into pegasus
5e7acc83b7 PEGASUS: Update detection
4926c41e01 Merge remote branch 'upstream/master' into pegasus
a93a771753 PEGASUS: Begin porting over base MMShell classes
0e78eb0019 PEGASUS: Add the Game Shell CItem class
ea05bc5687 PEGASUS: Import the MMResourceFile class
ae1a932391 PEGASUS: Import the MMSound class
9aa9e6afcb PEGASUS: Switch sound playback to using the MMSound class
8d4e60d432 PEGASUS: Import MMUtilities functions
2211a4d713 PEGASUS: Import MMFunctionPtr class
e2e224176d PEGASUS: Import the CItemList class
9f3c689839 PEGASUS: Import the CInventory class
752e756135 PEGASUS: Import the MMAction class
0fc10033b5 PEGASUS: Import the CGameState class
fd8eaba47a PEGASUS: Fix typo in MMConstants.h
e789ab0d3b PEGASUS: Import the MMNotification classes
e5953a879b PEGASUS: Update the MMTypes with a TimeValue/TimeScale replacement
9dd9012ed8 PEGASUS: Import the MMTimeValue class
d7411acc2b PEGASUS: Update copyright with full Presto name
ad293b249e Merge remote branch 'upstream/master' into pegasus
4a69dc13d9 Merge remote branch 'upstream/master' into pegasus
8263f5a7b5 PEGASUS: Implement basic neighborhood resource parsing
3239002dae PEGASUS: Implement some more neighborhood code
e642906cdd PEGASUS: Begin restructuring the game state classes
cb7b382acf PEGASUS: Restructure remaining (already converted) Game Shell classes
bfb0de109a PEGASUS: Implement more item code
4f8cf1ea4b PEGASUS: Implement very basic hotspot loading
7070d886d9 PEGASUS: Fix bug in the credits
fe99e95319 PEGASUS: Stub off spot sound code
dbb538dd04 PEGASUS: Cleanup and hookup the notification code
74054cff2d PEGASUS: Remove unused MMResourceFile code
593aec681d PEGASUS: Restructure remaining MMShell code into the base code
cbcae58caf PEGASUS: Properly handle regions in hotspots
e56546a83d PEGASUS: Implement two of the base input classes
937c06c304 PEGASUS: Remove unused MMAction class
ecd81a9a6d PEGASUS: Add Idler framework
715c95ecfc PEGASUS: Fix stupid bugs in the item code
0e14012edd PEGASUS: Begin loading items
5a7ca3553c PEGASUS: Create separate Cursor class for cursors
e532af9318 PEGASUS: Add and hookup the InputHandler class
bbda19ab80 PEGASUS: Add DisplayElement class and begin porting over the graphics API
d3fde69770 PEGASUS: Implement two of the primitive-based DisplayElements
1ac6abaeff PEGASUS: Stub off the base timebase code
dc0254c1ce PEGASUS: Implement very basic screen updating (new API)
ecde87260c PEGASUS: Fix saving/loading the game state
2ae8a97c4d PEGASUS: Stub off loading/saving games
da74436aa4 PEGASUS: Implement fader support
3b9ab4f5cf COMMON: Add function to find the intersecting rectangle
544224b43a PEGASUS: Add transition classes
331da0377b PEGASUS: Add the fuse classes
e90287f7f1 COMMON: Add numerator/denominator getters for Rational
1390db1df1 PEGASUS: Rewrite TimeBase to be a bit more accurate with timing
8f6e603099 PEGASUS: Add the Tracker class
6ed2679cf1 PEGASUS: Add the Surface classes
d29e505041 PEGASUS: Update timer code a bit to make it friendlier for movies
635c8aa370 PEGASUS: Add first stab at the Movie class
fec7a123fd PEGASUS: Begin hooking the new code in as the main code
e21224ff9a PEGASUS: Fix copyToCurrentPort()
2dbf379d11 PEGASUS: Fix some movie bugs
dc0a98f655 PEGASUS: Make movie transparency be off by default
0193d0d019 PEGASUS: Fix a regression in checkCallBacks()
1c8213ad86 PEGASUS: Fix timebase looping
de23530a4e PEGASUS: Remove VideoManager code
335a043bd0 PEGASUS: Add picture class
6c47e909da PEGASUS: Remove remaining 'old' code
e310da1aa8 PEGASUS: Add new menu class
e3080fb251 PEGASUS: Add the JMPPPInput utility class
f9fff1809c PEGASUS: Fix auto bits setting in the input code
185f5fb054 PEGASUS: Only allow for keydown events
d4a731c0f3 PEGASUS: Fix updating elements when the bounds change
64d0b6df58 PEGASUS: Fix bug with drawing dirty rects
46bc7e6c4d PEGASUS: Fix bounds of Pictures
b4408d4527 PEGASUS: Implement main menu
02e7656b07 PEGASUS: Allow for backquote to be used as a tilde too
2bba1d0c11 PEGASUS: Allow redrawMovieWorld to be used without the video running
97072b5d4b PEGASUS: Remove scaling TODO
cb500d147e PEGASUS: Clamp the dirty rect to the screen size
0fd4a55492 PEGASUS: Fix DropHighlight
802fb1a97b PEGASUS: Add very simple mouse movement update checking
5b23d33a29 PEGASUS: Remove old graphics API
ea7ec27094 PEGASUS: Fix drawing movies to positions other than the origin
35cc9b5d0f PEGASUS: Implement the overview code
17d6f74867 PEGASUS: Implement demo credits
b92476ecb1 PEGASUS: Don't update movies if they're paused
c88e33abd7 PEGASUS: Make Movies use the normal TimeBase getTime()
2e9c7b5342 PEGASUS: Don't allow for seeking beyond the ends of the movie
3417e39c7a PEGASUS: Implement the credits
897c585f05 PEGASUS: Add the InventoryPicture class (and its derivatives)
c8752bb1d3 PEGASUS: Implement Item::getDragSprite()
dc463816af PEGASUS: Remove unused EnergyBar class
ea36ec452e PEGASUS: Add support for the console back
cde643cc17 PEGASUS: Allow for skipping the intro
84731ef872 PEGASUS: Add the EnergyMonitor class
97af18a5a3 PEGASUS: Allow for movies to be offset on a surface
ddcdcb67b5 PEGASUS: Should use moveMovieBoxTo instead of moveElementTo here
e5a2dec9c8 PEGASUS: Disable the alt key for now
59f7e1deea PEGASUS: Import AI code and relevant items
5275e16849 PEGASUS: Add remaining specialized inventory items
8de524b073 PEGASUS: Create the Interface biochip even if it's not used
5f0f9dae35 PEGASUS: Add retscan/shield biochips
0b83e0c491 PEGASUS: Add the compass class
647c83b514 PEGASUS: Add the interface class
4aed723368 PEGASUS: Fix startFaderSync
e97ddf2449 PEGASUS: Enable main menu sound fading now that it works
0905144985 GRAPHICS: Rewrite PictDecoder's opcode handling
161b4c9f2b GRAPHICS: Properly parse the CompressQuickTime header
8897c17884 GRAPHICS: Add support for multiple CompressedQuickTime calls
515b2501a7 PEGASUS: Show the demo quit/splash screens
85e7d2d9a9 PEGASUS: Update the GraphicsManager a bit
24cc9568cb PEGASUS: Implement the death menu
e412b62ffc PEGASUS: Implement the death code
e343e4c5d8 PEGASUS: Add a debugger command to die
4f358e7615 PEGASUS: Begin populating the Neighborhood class with more useful functions
122d484c4f PEGASUS: Import a bunch more neighborhood code
d205ac2e27 PEGASUS: Add the GameInteraction class
96198e7bdd PEGASUS: Import the remainder of the Neighborhood code
fe03cd1bfa PEGASUS: Partially revert 4aed723368b9a4e82205bc3ed950a4e04ba3d8dc
02781cf2ce PEGASUS: Make the menu music fade in but not block for now
59d6b036dc PEGASUS: Fader values should be signed
c581cb189a PEGASUS: Add the Prehistoric neighborhood
d0914e6dc3 PEGASUS: Push the sound spots file name to subclasses
20f18e447f PEGASUS: Add the remaining gameshell remnants
817f775da9 PEGASUS: Update copyright notice on pegasus.cpp/h
af78726e4f PEGASUS: Add the ItemDragger classes
a0a3cbd602 PEGASUS: Keep specific neighborhood code in subfolders
54dd0c266e PEGASUS: Import a bunch more code in preparation for actual gameplay
1659c82c37 PEGASUS: Fix frame sequences
426ab47067 PEGASUS: Fix bug in redrawMovieWorld
ffff1beb1b PEGASUS: Fix stupid inventory weight typo
81eff30b8e PEGASUS: Fix date positioning
cd744aa60e PEGASUS: Fix the movie box code
2e2f8d9168 PEGASUS: Fix stop time of movies
1112b11df9 PEGASUS: Fix valgrind warnings with the spots
03739c66aa PEGASUS: Fix exit table loading
16a25cd7fd PEGASUS: Start the demo off!
091df1815e PEGASUS: Use proper key for the right fire button
6440d4d5f6 PEGASUS: Implement the ScreenDimmer class
34fd248f8a PEGASUS: Add the SoundLevel class
878601b2a3 PEGASUS: Fix a typo in the SoundLevel code
69badbebc4 PEGASUS: Add the PauseMenu code
de5849b102 PEGASUS: Fix TimeBase::setTime
8bc240124a PEGASUS: Allow getting frames from videos
bbacb4e5c7 PEGASUS: Fix energy monitor not showing up
b54a6275cf PEGASUS: Fix sprites being drawn incorrectly
9ab6246123 PEGASUS: Fix compass not showing
7390d327f1 COMMON: Ensure numTypes is set to 0 on close
447b7204f3 PEGASUS: Returning from the pause menu works now
5be808fe20 PEGASUS: Fix use of Common::List::erase
956f3d4644 PEGASUS: Add the auto dragger code
1fe7ca1d38 PEGASUS: Update save/load code a bit
c4c83e2346 PEGASUS: Resolve some TODO's and cleanup
821813e808 PEGASUS: Allow saving/loading of AI rules
06e2dbaa43 PEGASUS: Fix stupid typo stopping the current biochip from being found
fdd50e8414 PEGASUS: Fix cursor not showing up
e299f0ac72 PEGASUS: Fix drag sprite transparency
035cf8a7b3 PEGASUS: Fix AI videos not updating
23c7b9f0dc PEGASUS: Introduce better cursor update code
ec67dfae30 GRAPHICS: Add support for true 32bpp DirectBits images
b5af4bfc76 PEGASUS: Fix typos in autoDragItemIntoInventory/Room
9be43b24ce PEGASUS: Fix auto dragging
485b427ed8 PEGASUS: Actually pause the game now
7227af4676 VIDEO: Ensure audio paused status remains after a QuickTime seek
ad784cd5e8 PEGASUS: Fix movie segment looping
bfb2ad4778 PEGASUS: Fix inventory looping positions
9718b8e803 PEGASUS: Ease off the CPU
05c774bb8b PEGASUS: Resolve a couple AI TODO's
a85165035c PEGASUS: Fix pausing normal TimeBases
ebb40e26cb PEGASUS: Fix AI movies playing in the wrong box
f3e34cde02 PEGASUS: Fix neighborhood callbacks
b24081c781 PEGASUS: Fix time forward callbacks
8c7ebc8033 PEGASUS: Add the basic Caldoria neighborhood
b31efb02b5 PEGASUS: Fix draw sync functions
a57b1de6ee PEGASUS: Add a hack to skip energy bar calibration for now
a432e3af29 PEGASUS: Fix Caldoria::updateCursor
2b4bd019ee PEGASUS: Fix extra sync
cc7680364a PEGASUS: Fix energy monitor calibration
5d8912a2ad PEGASUS: Fix Caldoria wake up video 2
0756f72c20 PEGASUS: Remove a change I made for testing
d2789a152f PEGASUS: Fix idlers freeing themselves
327ce7c64b VIDEO: Fix the first AI calibration video
05668dd684 PEGASUS: Fix moving forward
cbca2812a8 PEGASUS: Fix turning
3ecc16c9ae PEGASUS: Fix playSpotSoundSync playSoundSegment call
5381f5d56b PEGASUS: Implement basic jump console command
af24890807 PEGASUS: Add the Tiny TSA neighborhood
a80af5eb4d PEGASUS: Add the Full TSA neighborhood
172e97da15 VIDEO: Fix getNextFramePacket() to actually be efficient
deab5b2875 GRAPHICS: Fix PICT buffer overflow
e1dc4db7aa Merge remote branch 'upstream/master' into pegasus
8a717d28d8 PEGASUS: Fix frames after turning
188d951cb4 PEGASUS: Remove unused movie direct draw mode
89773a90ce PEGASUS: Only call callbacks once
09be0ed5c8 PEGASUS: Fix movie end trigger not always being sent
5dd625ebfb PEGASUS: Disable AI energy warnings in the demo
82cadf68e8 PEGASUS: Fix the historical log comparison screen
099f4ce9f5 PEGASUS: Add some missing Neighborhood destructor code
85dc2e5c65 PEGASUS: Stub off map handling
11b92529b0 PEGASUS: Fix loading continue points
820e424e98 PEGASUS: Fix saving/loading original-compatible saves
e998fb6c0e PEGASUS: Allow for loading games from the launcher/cli
5b62d069bc PEGASUS: Fix Full TSA briefing movies
5062aaffca PEGASUS: Implement the sub chase
13fef21fed PEGASUS: Fix shell notifications on loading games
753006ae1a PEGASUS: Add the WSC neighborhood
c9f31d3c6e PEGASUS: Fix drawing WSC molecules
64656342a9 PEGASUS: Add the Mars reactor element code
1c949d375a PEGASUS: Add the Mars neighborhood
4b9914104e PEGASUS: Remove the unused biochip AI warnings from WSC
77033ecc6c PEGASUS: Fix the Mars robot timer not stopping
802873d323 VIDEO: Fix QuickTime audio track ends
0dada6e231 PEGASUS: Implement screen shaking
5c2a89dc4a PEGASUS: Fix drop box highlight color
1529ed0891 PEGASUS: Implement deleting items when inventory is full
81ace6e105 PEGASUS: Fix TSA door locks
4af1fe25af PEGASUS: Add our TGWorldSaver replacement
422ff6c4c1 PEGASUS: Don't use the work area for screen shaking
d6dee9ff18 PEGASUS: Add the base Norad code
f9ecab1953 PEGASUS: Add Norad Alpha
c8526bf6c3 PEGASUS: Add support for scaled/glowing images/movies
de3962fbc8 PEGASUS: Add the Mars canyon chase sequence
c3d9a1cb35 PEGASUS: Add the hermite code for the space chase
cbcdf99092 PEGASUS: Add the basic 3D logic for the space chase
841f96868a PEGASUS: Add the planet mover for the space chase
b3059e75e2 PEGASUS: Add the space junk stuff
61311a2648 PEGASUS: Add the robot ship
9f1d9f3697 PEGASUS: Add the shuttle weapon base class
0990703779 PEGASUS: Add the graviton cannon!
1bd2480f5f PEGASUS: Add the tractor beam class
627684ca73 GRAPHICS: Make drawThickLine take a thickness in both x and y directions
c2af197edb GRAPHICS: Add a Surface wrapper for drawThickLine
015d81b742 PEGASUS: Add the energy beam weapon
e29d00e6b6 PEGASUS: Add the Shuttle HUD
3f69c195ae PEGASUS: Allow for initial support of the space chase
0ec655f410 PEGASUS: Fix timers not updating in playSpotSoundSync
59f7d432d1 PEGASUS: Implement dirty rect erase code (as used by the space chase)
88360741bd PEGASUS: Fix the planet mover
514d93622d PEGASUS: Fix RS232 draw call
020f384247 PEGASUS: Fix pitch of one bit images in the shuttle HUD
6550d85184 PEGASUS: Fix 1bpp cicn cursors
2f1c67ab59 PEGASUS: Clear movie bounds on release
6d01961158 PEGASUS: Disable erase when reinstating the monocle
1ca6da46ad PEGASUS: Fix destroying the robot shuttle
bcf5ea1dc2 PEGASUS: Keep the space junk from flying beyond the screen boundary
60ecf84365 PEGASUS: Fix dying when no interface is set up
74d08a1543 PEGASUS: Fix redrawMovieWorld() to only update when needed
0d6dbfa2cb PEGASUS: Add ability to draw masked surfaces
b3eb2c65e3 PEGASUS: Fix some old Surface comments
ae59e34446 PEGASUS: Fix some code formatting
963f209931 PEGASUS: Fix 4D system sprites
48cabb18d6 PEGASUS: Implement the rest of the mapping biochip
dec8fcdbbd PEGASUS: Add the panorama class
e781066cec PEGASUS: Add the panorama scroll class
faa6018cad PEGASUS: Just clip the junk from going off right or bottom too
59421ff1c6 PEGASUS: Add the ECR monitor
423ce6c442 PEGASUS: Fix the panorama time scale
8b62693c82 PEGASUS: Add a minimalist SoundTimeBase class
476f4b513d PEGASUS: Switch spot sounds to using SoundTimeBase
57405cee9e PEGASUS: Fix pressure door movie updates
053e1d6529 PEGASUS: Some sub control room interaction fixes
d932df79be PEGASUS: Fix segfault after sub chase sequence
00279659b2 Merge remote branch 'upstream/master' into pegasus
9c1fbbd1c2 PEGASUS: Implement shooting Sinclair
cd01d5dc1d PEGASUS: Add the bomb active AI rule
5f276bf4ac PEGASUS: Add a tickCount() function
bbabf27f61 PEGASUS: Add the bomb detonation game
d55aeeec0b PEGASUS: Fix displaying the end message
a328f32fed PEGASUS: Fix going from bomb game to the end game
4b93bc6456 PEGASUS: Add Norad Delta
693fcec6f5 PEGASUS: Fix info screen weirdness
b5565a4337 PEGASUS: Fix compilation on Windows
fdced472ab PEGASUS: Begin cleaning up pegasus-defined types
12efb47b53 PEGASUS: Remove t prefix from typedefs
f72884cb7b PEGASUS: Cleanup some constants
fa92148098 PEGASUS: Fix timers starting when paused
924e0b32ad PEGASUS: Implement saving/loading from the in-game pause menu
5fe762e7cd PEGASUS: Fix typo in the save code
a600dcb56a PEGASUS: Some space/misc cleanup
331da45ae3 PEGASUS: Make InputDevice into a Singleton
d29bde9abe PEGASUS: Remove another global construction
03eba05b09 PEGASUS: Use correct CD when outputting saves
71756bdf4e Merge remote branch 'upstream/master' into pegasus
b2c29410b9 PEGASUS: Add some more protection about junk flying off-screen
6a786129cf PEGASUS: Fix striding
1ec7e51682 PEGASUS: Implement the intro timer
1e8eea4268 CREDITS: Add pegasus
47ae65e495 PEGASUS: Clean up initializePegasusButtons
b6374a3103 Merge remote branch 'upstream/master' into pegasus
851c010feb PEGASUS: Remove stray semicolon
73f2244a56 PEGASUS: Remove some useless const modifiers
990f7c4ca4 PEGASUS: Add some braces
c6a74c6e1d PEGASUS: Add 'Demo' to the demo's extra field
e72f2c3c57 PEGASUS: Remove some ancient svn tags
d5341b2fc7 PEGASUS: Implement saving/restoring the in-game AI data
2f8e017524 PEGASUS: Add safety check around decodeNextFrame() when playing the Bandai logo
983bd16bb7 PEGASUS: Fix file permissions
87fd7e2d35 PEGASUS: Warn when a sound file can't be found
9b66f04db9 PEGASUS: Silence a gcc 4.6 warning
1646313214 PEGASUS: Fix setChar() call fail
3abacdae83 PEGASUS: Attempt to fix compilation on MSVC
2c2633e544 PEGASUS: More MSVC "fixes"
b07d03dedf PEGASUS: Silence an MSVC warning
a2454f6563 PEGASUS: Use an Array instead of a List for NotificationReceivers
1fb5238cf3 PEGASUS: Fix potentially uninitialized hotspot pointer
5dfa4333d1 COMMON: Hopefully fix AppleDouble files with directories
f58d834cda COMMON: Add a KBD_META key state flag
ec0b4f7b96 SDL: Allow for the meta key flag to be used
981833b34e PEGASUS: Add support for load/save keys
6ae0ff3778 PEGASUS: Mark the cursor as dirty when hiding it too
f087f20fa2 PEGASUS: Fix the pegasus biochip recall button highlight
5ee569bce6 PEGASUS: Fix ghosted biochips when loading saved games
9971e74c4c Merge remote branch 'upstream/master' into pegasus
99eb8762c4 PEGASUS: Allow control for the easter egg key as well
68438a2919 PEGASUS: Add a workaround for the canyon/space chase segfault
e80d622fa5 Merge remote branch 'upstream/master' into pegasus
974eb12fcc PEGASUS: Rewrite the input code to more closely emulate what the original did
175befc3f1 PEGASUS: Fix compilation with optimizations enabled
b2506abccf PEGASUS: Fix some warnings found with optimizations on
f1f6a82cd5 Merge remote branch 'upstream/master' into pegasus
9d7432a372 PEGASUS: Allow for keypad enter to be used
e67ba769b3 Merge remote branch 'upstream/master' into pegasus
f02b696573 PEGASUS: Implement setting movie volume
625f6cc716 Merge remote branch 'upstream/master' into pegasus
b5238756e2 PEGASUS: Make sure we check the pixel format of video frames
915a8399c9 PEGASUS: Don't manually close the load/save dialogs
91efe792d5 Merge remote branch 'upstream/master' into pegasus
3860f34136 PEGASUS: Implement screen fading
b625df1612 PEGASUS: Cleanup doFadeOutSync/doFadeInSync calls
7a49b3669a PEGASUS: Optimize the nearest neighbor frame scaling a bit
bb1e60e8b2 Merge remote branch 'upstream/master' into pegasus
c15369c26f Merge remote branch 'upstream/master' into pegasus
81e7c9a0c1 PEGASUS: Remove g_allHotspots global construction
f61146f327 PEGASUS: Remove g_allItems global construction
790a74ab9d Merge remote branch 'upstream/master' into pegasus
1043283e53 PEGASUS: Use setEndTime()
2f9b1b67b0 ALL: Mark off some things as used by Pegasus
f35e820e9f Merge remote branch 'upstream/master' into pegasus
b8bcbb46b4 PEGASUS: Make setting the start time of a movie also seek
9855f7b5d8 PEGASUS: Fix some memory leaks
428702ca49 PEGASUS: Fix some formatting issues
ff51a7661d PEGASUS: Fix minor filling station glitch
d5ed8b1901 Merge remote branch 'upstream/master' into pegasus
483989f72b Revert "PEGASUS: Make setting the start time of a movie also seek"
1677686692 PEGASUS: Disable save compression by default
2e4ee0b2d0 Merge pull request #275 from clone2727/pegasus


Commit: 950676bf4c8576f63db8dc21a0c89e06981378d5
    https://github.com/scummvm/scummvm/commit/950676bf4c8576f63db8dc21a0c89e06981378d5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-02-21T15:44:24-08:00

Commit Message:
PEGASUS: Add my very WIP Pegasus Prime engine

Changed paths:
  A engines/pegasus/detection.cpp
  A engines/pegasus/graphics.cpp
  A engines/pegasus/graphics.h
  A engines/pegasus/menu.cpp
  A engines/pegasus/module.mk
  A engines/pegasus/pegasus.cpp
  A engines/pegasus/pegasus.h
  A engines/pegasus/sound.cpp
  A engines/pegasus/sound.h
  A engines/pegasus/video.cpp
  A engines/pegasus/video.h
    base/plugins.cpp
    configure
    engines/engines.mk



diff --git a/base/plugins.cpp b/base/plugins.cpp
index 1db9c0d..21db7ff 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -139,6 +139,9 @@ public:
 		#if PLUGIN_ENABLED_STATIC(PARALLACTION)
 		LINK_PLUGIN(PARALLACTION)
 		#endif
+		#if PLUGIN_ENABLED_STATIC(PEGASUS)
+		LINK_PLUGIN(PEGASUS)
+		#endif
 		#if PLUGIN_ENABLED_STATIC(QUEEN)
 		LINK_PLUGIN(QUEEN)
 		#endif
diff --git a/configure b/configure
index 7144041..75bb726 100755
--- a/configure
+++ b/configure
@@ -97,6 +97,7 @@ add_engine m4 "M4/MADS" no
 add_engine made "MADE" yes
 add_engine mohawk "Mohawk" no
 add_engine parallaction "Parallaction" yes
+add_engine pegasus "The Journeyman Project: Pegasus Prime" no
 add_engine queen "Flight of the Amazon Queen" yes
 add_engine saga "SAGA" yes "ihnm saga2"
 add_engine ihnm "IHNM" yes
diff --git a/engines/engines.mk b/engines/engines.mk
index eea4ffc..5d62525 100644
--- a/engines/engines.mk
+++ b/engines/engines.mk
@@ -104,6 +104,11 @@ DEFINES += -DENABLE_PARALLACTION=$(ENABLE_PARALLACTION)
 MODULES += engines/parallaction
 endif
 
+ifdef ENABLE_PEGASUS
+DEFINES += -DENABLE_PEGASUS=$(ENABLE_PEGASUS)
+MODULES += engines/pegasus
+endif
+
 ifdef ENABLE_QUEEN
 DEFINES += -DENABLE_QUEEN=$(ENABLE_QUEEN)
 MODULES += engines/queen
diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
new file mode 100644
index 0000000..17dd7c3
--- /dev/null
+++ b/engines/pegasus/detection.cpp
@@ -0,0 +1,143 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "base/plugins.h"
+
+#include "engines/advancedDetector.h"
+#include "common/config-manager.h"
+#include "common/file.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+struct PegasusGameDescription {
+	ADGameDescription desc;
+};
+
+bool PegasusEngine::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsRTL);
+}
+
+bool PegasusEngine::isDemo() const {
+	return (_gameDescription->desc.flags & ADGF_DEMO) != 0;
+}
+
+} // End of namespace Pegasus
+
+static const PlainGameDescriptor pegasusGames[] = {
+	{"pegasus", "The Journeyman Project: Pegasus Prime"},
+	{0, 0}
+};
+
+
+namespace Pegasus {
+
+static const PegasusGameDescription gameDescriptions[] = {
+	{
+		{
+			"pegasus",
+			"",
+			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 2009943),
+			Common::EN_ANY,
+			Common::kPlatformMacintosh,
+			ADGF_MACRESFORK,
+			Common::GUIO_NONE
+		},
+	},
+
+	{
+		{
+			"pegasus",
+			"",
+			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 360129),
+			Common::EN_ANY,
+			Common::kPlatformMacintosh,
+			ADGF_MACRESFORK|ADGF_DEMO,
+			Common::GUIO_NONE
+		},
+	},
+
+	{ AD_TABLE_END_MARKER }
+};
+
+} // End of namespace Pegasus
+
+static const ADParams detectionParams = {
+	// Pointer to ADGameDescription or its superset structure
+	(const byte *)Pegasus::gameDescriptions,
+	// Size of that superset structure
+	sizeof(Pegasus::PegasusGameDescription),
+	// Number of bytes to compute MD5 sum for
+	5000,
+	// List of all engine targets
+	pegasusGames,
+	// Structure for autoupgrading obsolete targets
+	0,
+	// Name of single gameid (optional)
+	"pegasus",
+	// List of files for file-based fallback detection (optional)
+	0,
+	// Flags
+	0,
+	// Additional GUI options (for every game)
+	Common::GUIO_NONE,
+	// Maximum directory depth
+	1,
+	// List of directory globs
+	0
+};
+
+class PegasusMetaEngine : public AdvancedMetaEngine {
+public:
+	PegasusMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+
+	virtual const char *getName() const {
+		return "Pegasus Prime Engine";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "The Journeyman Project: Pegasus Prime (C) Presto Studios";
+	}
+
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+};
+
+bool PegasusMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const Pegasus::PegasusGameDescription *gd = (const Pegasus::PegasusGameDescription *)desc;
+
+	if (gd)
+		*engine = new Pegasus::PegasusEngine(syst, gd);
+
+	return (gd != 0);
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(PEGASUS)
+	REGISTER_PLUGIN_DYNAMIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
+#endif
+
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
new file mode 100644
index 0000000..a05e316
--- /dev/null
+++ b/engines/pegasus/graphics.cpp
@@ -0,0 +1,255 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+ 
+#include "pegasus/graphics.h"
+
+#include "common/endian.h"
+#include "common/file.h"
+#include "engines/util.h"
+#include "graphics/cursorman.h"
+
+namespace Pegasus {
+	
+GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
+	initGraphics(640, 480, true, NULL);
+	
+	_pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
+
+	for (int i = 0; i < kImageCacheSize; i++)
+		_cache[i].surface = 0;
+}
+	
+GraphicsManager::~GraphicsManager() {
+	delete _pictDecoder;
+
+	for (int i = 0; i < kImageCacheSize; i++) {
+		if (_cache[i].surface) {
+			_cache[i].surface->free();
+			delete _cache[i].surface;
+		}
+	}
+}
+
+Graphics::Surface *GraphicsManager::decodeImage(const Common::String &filename) {
+	int imageSlot = getImageSlot(filename);
+
+	if (_cache[imageSlot].surface)
+		return _cache[imageSlot].surface;
+
+	Common::File file;
+	if (!file.open(filename))
+		error("Could not open \'%s\'", filename.c_str());
+
+	byte palette[256 * 3];
+	Graphics::Surface *image = _pictDecoder->decodeImage(&file, palette);
+
+	// For <= 8bpp, we need to convert
+	if (image->bytesPerPixel == 1) {
+		Graphics::PixelFormat format = _vm->_system->getScreenFormat();
+		Graphics::Surface *output = new Graphics::Surface();
+		output->create(image->w, image->h, format.bytesPerPixel);
+
+		for (uint16 y = 0; y < image->h; y++) {
+			for (uint16 x = 0; x < image->w; x++) {
+				byte c = *((byte *)image->getBasePtr(x, y));
+				byte r = palette[c * 3];
+				byte g = palette[c * 3 + 1];
+				byte b = palette[c * 3 + 2];
+
+				if (format.bytesPerPixel == 2) {
+					uint16 color = format.RGBToColor(r, g, b);
+					memcpy(output->getBasePtr(x, y), &color, 2);
+				} else if (format.bytesPerPixel == 4) {
+					uint32 color = format.RGBToColor(r, g, b);
+					memcpy(output->getBasePtr(x, y), &color, 4);
+				}
+			}
+		}
+
+		image->free();
+		delete image;
+		image = output;
+	}
+
+	_cache[imageSlot].surface = image;
+	return image;
+}
+
+void GraphicsManager::drawPict(Common::String filename, int x, int y, bool updateScreen) {
+	Graphics::Surface *surface = decodeImage(filename);
+	
+	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, x, y, surface->w, surface->h);
+
+	if (updateScreen)
+		_vm->_system->updateScreen();
+}
+
+void GraphicsManager::drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen) {
+	if (_vm->_system->getScreenFormat().bytesPerPixel == 2)
+		transparency &= 0xffff;
+
+	Graphics::Surface *surface = decodeImage(filename);
+	Graphics::Surface *screen = _vm->_system->lockScreen();
+
+	for (uint16 i = 0; i < surface->h; i++) {
+		for (uint16 j = 0; j < surface->w; j++) {
+			if (_vm->_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = *((uint16 *)surface->getBasePtr(j, i));
+				if (color != transparency)
+					memcpy(screen->getBasePtr(j + x, i + y), &color, 2);
+			} else if (_vm->_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = *((uint32 *)surface->getBasePtr(j, i));
+				if (color != transparency)
+					memcpy(screen->getBasePtr(j + x, i + y), &color, 4);
+			}
+		}
+	}
+
+	_vm->_system->unlockScreen();
+
+	if (updateScreen)
+		_vm->_system->updateScreen();
+}
+
+uint32 GraphicsManager::getColor(byte r, byte g, byte b) {
+	return _vm->_system->getScreenFormat().RGBToColor(r, g, b);
+}
+
+void GraphicsManager::setCursor(uint16 cursor) {
+	Common::SeekableReadStream *cicnStream = _vm->_resFork->getResource(MKID_BE('cicn'), cursor);
+	
+	// PixMap section
+	Graphics::PictDecoder::PixMap pixMap = _pictDecoder->readPixMap(cicnStream);
+	
+	// Mask section
+	cicnStream->readUint32BE(); // mask baseAddr
+	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
+	cicnStream->skip(3 * 2); // mask rect
+	/* uint16 maskHeight = */ cicnStream->readUint16BE();
+
+	// Bitmap section
+	cicnStream->readUint32BE(); // baseAddr
+	uint16 rowBytes = cicnStream->readUint16BE();
+	cicnStream->readUint16BE(); // top
+	cicnStream->readUint16BE(); // left
+	uint16 height = cicnStream->readUint16BE(); // bottom
+	cicnStream->readUint16BE(); // right
+	
+	// Data section
+	cicnStream->readUint32BE(); // icon handle
+	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
+	cicnStream->skip(rowBytes * height);
+	
+	// Palette section
+	cicnStream->readUint32BE(); // always 0
+	cicnStream->readUint16BE(); // always 0
+	uint16 colorCount = cicnStream->readUint16BE() + 1;
+	
+	byte *colors = (byte *)malloc(256 * 4);
+	for (uint16 i = 0; i < colorCount; i++) {
+		cicnStream->readUint16BE();
+		colors[i * 4] = cicnStream->readByte();
+		cicnStream->readByte();
+		colors[i * 4 + 1] = cicnStream->readByte();
+		cicnStream->readByte();
+		colors[i * 4 + 2] = cicnStream->readByte();
+		cicnStream->readByte();
+	}
+	
+	// PixMap data
+	byte *data = (byte *)malloc(pixMap.rowBytes * pixMap.bounds.height());
+	cicnStream->read(data, pixMap.rowBytes * pixMap.bounds.height());
+	delete cicnStream;
+	
+	// Now to go get the hotspots
+	Common::SeekableReadStream *cursStream = NULL;
+	
+	if (cursor >= kMainCursor && cursor <= kGrabbingHand)
+		cursStream = _vm->_resFork->getResource(MKID_BE('Curs'), kMainCursor);
+	else // if (cursor == kTargetingReticle1 || cursor == kTargetingReticle2)
+		cursStream = _vm->_resFork->getResource(MKID_BE('Curs'), kTargetingReticle1);
+
+	// Go through the stream until we find the right cursor hotspot
+	uint16 x = 0, y = 0;
+	uint16 numHotspots = cursStream->readUint16BE();
+	
+	for (uint16 i = 0; i < numHotspots; i++) {
+		uint16 res = cursStream->readUint16BE();
+		uint16 tempX = cursStream->readUint16BE();
+		uint16 tempY = cursStream->readUint16BE();
+		
+		if (res == cursor) {
+			x = tempX;
+			y = tempY;
+			break;
+		}
+	}
+	
+	// We have the bitmap and the hotspot, let's do this!
+	CursorMan.replaceCursorPalette(colors, 0, colorCount);
+	CursorMan.replaceCursor(data, pixMap.rowBytes, pixMap.bounds.height(), x, y, 0);
+	CursorMan.showMouse(true);
+	_vm->_system->updateScreen();
+
+	free(colors);
+	free(data);
+}
+
+int GraphicsManager::getImageSlot(const Common::String &filename) {
+	// Let's find a match, an open slot, or the oldest image slot
+	uint32 oldestAge = 0xffffffff;
+	int slot = 0;
+
+	for (int i = 0; i < kImageCacheSize; i++) {
+		if (_cache[i].filename.equalsIgnoreCase(filename)) {
+			//warning("Found image %s at slot %d", filename.c_str(), i);
+			_cache[i].lastUsed = _vm->_system->getMillis();
+			return i;
+		}
+
+		if (!_cache[i].surface) {
+			//warning("Putting image %s in empty slot %d", filename.c_str(), i);
+			_cache[i].filename = filename;
+			_cache[i].lastUsed = _vm->_system->getMillis();
+			return i;
+		}
+
+		if (_cache[i].lastUsed < oldestAge) {
+			oldestAge = _cache[i].lastUsed;
+			slot = i;
+		}
+	}
+
+	// Let's make sure that's cleaned out
+	//warning("Replacing old image %s with %s in slot %d", _cache[slot].filename.c_str(), filename.c_str(), slot);
+	_cache[slot].filename = filename;
+	_cache[slot].surface->free();
+	delete _cache[slot].surface;
+	_cache[slot].surface = 0;
+	_cache[slot].lastUsed = _vm->_system->getMillis();
+	return slot;
+}
+	
+} // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
new file mode 100644
index 0000000..c184172
--- /dev/null
+++ b/engines/pegasus/graphics.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PEGASUS_GRAPHICS_H
+#define PEGASUS_GRAPHICS_H
+
+#include "common/rect.h"
+#include "common/str.h"
+#include "common/system.h"
+#include "graphics/pict.h"
+#include "graphics/surface.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+enum {
+	// The main cursors
+	kMainCursor = 128,
+	kZoomInCursor = 129,
+	kZoomOutCursor = 130,
+	kPointingCursor = 131,
+	kInteractHand = 132,
+	kGrabbingHand = 133,
+	
+	// Reticles when using the Mars shuttle
+	kTargetingReticle1 = 900,
+	kTargetingReticle2 = 901
+}; 
+
+enum {
+	kImageCacheSize = 10
+};
+
+struct ImageCache {
+	Common::String filename;
+	Graphics::Surface *surface;
+	uint32 lastUsed;
+};
+
+class PegasusEngine;
+
+class GraphicsManager {
+public:
+	GraphicsManager(PegasusEngine *vm);
+	~GraphicsManager();
+
+	void drawPict(Common::String filename, int x, int y, bool updateScreen = true);
+	void drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen = true);
+	void setCursor(uint16 cursor);
+	uint32 getColor(byte r, byte g, byte b);
+	
+private:		
+	PegasusEngine *_vm;
+	Graphics::PictDecoder *_pictDecoder;
+
+	Graphics::Surface *decodeImage(const Common::String &filename);
+	ImageCache _cache[kImageCacheSize];
+	int getImageSlot(const Common::String &filename);
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
new file mode 100644
index 0000000..a498a65
--- /dev/null
+++ b/engines/pegasus/menu.cpp
@@ -0,0 +1,192 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/events.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+enum {
+	kInterfaceOverviewButton = 0,
+	kStartButton = 1,
+	kRestoreButton = 2,
+	kDifficultyButton = 3,
+	kCreditsButton = 4,
+	kQuitButton = 5
+};
+
+enum {
+	kDemoStartButton = 0,
+	kDemoCreditsButton = 1,
+	kDemoQuitButton = 2
+};	
+
+void PegasusEngine::runMainMenu() {
+	_sound->playSound("Sounds/Main Menu.aiff", true);
+
+	// Note down how long since the last click
+	uint32 lastClickTime = _system->getMillis();
+
+	int buttonSelected = 0;
+	drawMenu(buttonSelected);
+
+	while (!shouldQuit() && _system->getMillis() - lastClickTime < 60 * 1000) {
+		Common::Event event;
+	
+		// Ignore events for now
+		while (_eventMan->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_UP:
+					if (buttonSelected > 0) {
+						buttonSelected--;
+						drawMenu(buttonSelected);
+					}
+					break;
+				case Common::KEYCODE_DOWN:
+					if ((isDemo() && buttonSelected < 2) || (!isDemo() && buttonSelected < 5)) {
+						buttonSelected++;
+						drawMenu(buttonSelected);
+					}
+					break;
+				case Common::KEYCODE_LEFT:
+				case Common::KEYCODE_RIGHT:
+					if (buttonSelected == kDifficultyButton) {
+						_adventureMode = !_adventureMode;
+						drawMenu(buttonSelected);
+					}
+					break;
+				case Common::KEYCODE_RETURN:
+					if (buttonSelected != kDifficultyButton) {
+						drawMenuButtonSelected(buttonSelected);
+						setGameMode(buttonSelected);
+						_sound->stopSound();
+						return;
+					}
+					break;
+				default:
+					break;
+				}
+
+				// Update our last press time too
+				lastClickTime = _system->getMillis();
+				break;
+			default:
+				break;
+			}
+		}
+		
+		//_system->updateScreen();
+		_system->delayMillis(10);
+	}
+
+	if (shouldQuit())
+		return;
+
+	// Too slow! Go back and show the intro again.
+	_sound->stopSound();
+	_video->playMovie("Images/Opening_Closing/LilMovie.movie");
+}
+
+void PegasusEngine::drawMenu(int buttonSelected) {
+	if (isDemo()) {
+		_gfx->drawPict("Images/Demo/DemoMenu.pict", 0, 0, false);
+	} else {
+		_gfx->drawPict("Images/Main Menu/MainMenu.mac", 0, 0, false);
+		if (!_adventureMode)
+			_gfx->drawPict("Images/Main Menu/BtnWlk.pict", 320, 340, false);
+	}
+
+	drawMenuButtonHighlighted(buttonSelected);
+}
+
+// FIXME: Most of these coordinates can use tweaking
+
+static const int kMainMenuButtonX = 152;
+static const char s_mainMenuButtonSuffix[] = { 'L', 'S', 'S', 'L', 'S', 'S' };
+static const int s_mainMenuButtonY[] = { 202, 252, 292, 337, 382, 422 };
+static const char s_demoMainMenuButtonSuffix[] = { 'S', 'S', 'L' }; // SSL!
+static const int s_demoMainMenuButtonX[] = { 38, 38, 28 };
+static const int s_demoMainMenuButtonY[] = { 332, 366, 408 };
+
+void PegasusEngine::drawMenuButtonHighlighted(int buttonSelected) {
+	if (isDemo())
+		_gfx->drawPictTransparent(Common::String("Images/Demo/Select") + s_demoMainMenuButtonSuffix[buttonSelected] + ".pict", s_demoMainMenuButtonX[buttonSelected], s_demoMainMenuButtonY[buttonSelected], _gfx->getColor(0xff, 0xff, 0xff), true);
+	else
+		_gfx->drawPictTransparent(Common::String("Images/Main Menu/Select") + s_mainMenuButtonSuffix[buttonSelected] + ".pict", kMainMenuButtonX, s_mainMenuButtonY[buttonSelected], _gfx->getColor(0xf8, 0xf8, 0xf8), true);
+}
+
+static const char *s_mainMenuButtonSelSuffix[] = { "Overvi", "Start", "Restor", "", "Credit", "Quit" };
+static const char *s_demoMainMenuButtonSel[] = { "Start", "Credits", "Quit" };
+static const int s_mainMenuSelButtonX[] = { 198, 210, 210, 0, 210, 210 };
+static const int s_demoMainMenuSelButtonX[] = { 43, 43, 34 };
+static const int s_demoMainMenuSelButtonY[] = { 338, 373, 410 };
+
+void PegasusEngine::drawMenuButtonSelected(int buttonSelected) {
+	if (isDemo())
+		_gfx->drawPict(Common::String("Images/Demo/") + s_demoMainMenuButtonSel[buttonSelected] + ".pict", s_demoMainMenuSelButtonX[buttonSelected], s_demoMainMenuSelButtonY[buttonSelected], false);
+	else
+		_gfx->drawPict(Common::String("Images/Main Menu/pb") + s_mainMenuButtonSelSuffix[buttonSelected] + ".pict", s_mainMenuSelButtonX[buttonSelected], s_mainMenuButtonY[buttonSelected] + 5, false);
+
+	drawMenuButtonHighlighted(buttonSelected);
+}
+
+void PegasusEngine::setGameMode(int buttonSelected) {
+	if (isDemo()) {
+		switch (buttonSelected) {
+		case kDemoStartButton:
+			_gameMode = kMainGameMode;
+			break;
+		case kDemoCreditsButton:
+			_gameMode = kCreditsMode;
+			break;
+		case kDemoQuitButton:
+			_gameMode = kQuitMode;
+			break;
+		}
+	} else {
+		switch (buttonSelected) {
+		case kInterfaceOverviewButton:
+			_gameMode = kInterfaceOverviewMode;
+			break;
+		case kStartButton:
+			_gameMode = kMainGameMode;
+			break;
+		case kRestoreButton:
+			_gameMode = kRestoreMode;
+			break;
+		case kCreditsButton:
+			_gameMode = kCreditsMode;
+			break;
+		case kQuitButton:
+			_gameMode = kQuitMode;
+			break;
+		}
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
new file mode 100644
index 0000000..28a92aa
--- /dev/null
+++ b/engines/pegasus/module.mk
@@ -0,0 +1,18 @@
+MODULE := engines/pegasus
+
+MODULE_OBJS = \
+	detection.o \
+	graphics.o \
+	menu.o \
+	pegasus.o \
+	sound.o \
+	video.o
+
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_PEGASUS), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
new file mode 100644
index 0000000..062ec10
--- /dev/null
+++ b/engines/pegasus/pegasus.cpp
@@ -0,0 +1,317 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/config-manager.h"
+#include "common/events.h"
+#include "base/plugins.h"
+#include "base/version.h"
+
+#include "pegasus/pegasus.h"
+
+#include "common/file.h"
+
+//#define RUN_SUB_MOVIE // :D :D :D :D :D :D
+//#define RUN_INTERFACE_TEST
+
+namespace Pegasus {
+
+PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
+}
+
+PegasusEngine::~PegasusEngine() {
+	delete _video;
+	delete _sound;
+	delete _gfx;
+	delete _resFork;
+	delete _inventoryLid;
+	delete _biochipLid;
+}
+
+Common::Error PegasusEngine::run() {
+	_gfx = new GraphicsManager(this);
+	_video = new VideoManager(this);
+	_sound = new SoundManager(this);
+	_resFork = new Common::MacResManager();
+	_inventoryLid = new Common::MacResManager();
+	_biochipLid = new Common::MacResManager();
+	_gameMode = kMainMenuMode;
+	_adventureMode = true;
+	
+	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
+		error("Could not load JMP PP Resources");
+
+	if (!_inventoryLid->open("Images/Lids/Inventory Lid Sequence") || !_inventoryLid->hasResFork())
+		error("Could not open Inventory Lid Sequence");
+
+	if (!_biochipLid->open("Images/Lids/Biochip Lid Sequence") || !_biochipLid->hasResFork())
+		error("Could not open Biochip Lid Sequence");
+
+	loadItemLocationData();
+
+#if 0
+	Common::MacResIDArray pictIds = _biochipLid->getResIDArray(MKID_BE('PICT'));
+	for (uint32 i = 0; i < pictIds.size(); i++) {
+		Common::String filename = Common::String::printf("PICT_%d.pict", pictIds[i]);
+		Common::DumpFile file;
+		assert(file.open(filename));
+		Common::SeekableReadStream *res = _biochipLid->getResource(MKID_BE('PICT'), pictIds[i]);
+		byte *data = new byte[res->size()];
+		res->read(data, res->size());
+		for (int j = 0; j < 512; j++)
+			file.writeByte(0);
+		file.write(data, res->size());
+		file.close();
+		delete res;
+		delete[] data;
+	}
+#endif
+
+#if defined(RUN_SUB_MOVIE)
+	_video->playMovie("Images/Norad Alpha/Sub Chase Movie");
+#elif defined(RUN_INTERFACE_TEST)
+	drawInterface();
+	_gfx->setCursor(kMainCursor);
+	_sound->playSound("Sounds/Caldoria/Apartment Music.aiff", true);
+
+	while (!shouldQuit()) {
+		Common::Event event;
+		// Ignore events for now
+		while (_eventMan->pollEvent(event)) {
+			if (event.type == Common::EVENT_MOUSEMOVE)
+				_system->updateScreen();
+		}
+		
+		_system->delayMillis(10);
+	}
+#else
+	while (!shouldQuit()) {
+		switch (_gameMode) {
+		case kMainMenuMode:
+			if (!isDemo())
+				runIntro();
+
+			runMainMenu();
+			break;
+		case kMainGameMode:
+			if (isDemo())
+				changeLocation(kLocPrehistoric);
+			else
+				changeLocation(kLocCaldoria);
+			mainGameLoop();
+			break;
+		case kQuitMode:
+			return Common::kNoError;
+		default:
+			_gameMode = kMainMenuMode;
+			break;
+		}
+	}
+#endif
+
+	return Common::kNoError;
+}
+
+void PegasusEngine::loadItemLocationData() {
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('NItm'), 0x80);
+
+	uint16 entryCount = res->readUint16BE();
+
+	for (uint16 i = 0; i < entryCount; i++) {
+		ItemLocationData loc;
+		loc.id = res->readUint16BE(); // Which is always == i, anyway
+		loc.location = (ItemLocation)res->readUint16BE();
+		loc.u0 = res->readUint16BE();
+		loc.u1 = res->readByte();
+		debug(1, "Item[%d]: ID = %d, location = %x, u0 = %d, u1 = %d", i, loc.id, loc.location, loc.u0, loc.u1);
+		res->readByte();
+		_itemLocationData.push_back(loc);
+	}
+
+	delete res;
+}
+
+void PegasusEngine::runIntro() {
+	// The Opening/Closing folder will need to be renamed to something else. Windows
+	// and other OS's/FS's do not support a '/' in the filename. I arbitrarily chose
+	// to rename my folder with the underscore.
+	_video->playMovieCentered("Images/Opening_Closing/BandaiLogo.movie");
+	VideoHandle handle = _video->playBackgroundMovie("Images/Opening_Closing/Big Movie.movie");
+	_video->seekToTime(handle, 10 * 600);
+	_video->waitUntilMovieEnds(handle);
+}
+
+static const int kViewScreenOffset = 64;
+
+void PegasusEngine::drawInterface() {
+	_gfx->drawPict("Images/Interface/3DInterface Top", 0, 0, false);
+	_gfx->drawPict("Images/Interface/3DInterface Left", 0, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/3DInterface Right", 640 - kViewScreenOffset, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/3DInterface Bottom", 0, kViewScreenOffset + 256, false);
+	//drawCompass();
+	_system->updateScreen();
+}
+
+void PegasusEngine::drawInterfaceOverview() {
+	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
+	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
+	_system->updateScreen();
+}
+
+void PegasusEngine::mainGameLoop() {
+	// TODO: Yeah...
+	_system->fillScreen(0);
+	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
+	drawInterface();
+	if (isDemo())
+		_video->playMovie("Images/Prehistoric/Prehistoric.movie", kViewScreenOffset, kViewScreenOffset);
+	else
+		_video->playMovie("Images/Caldoria/Caldoria.movie", kViewScreenOffset, kViewScreenOffset);
+	_gameMode = kQuitMode;
+}
+
+void PegasusEngine::changeLocation(TimeZone timeZone) {
+	_timeZone = timeZone;
+	loadViews(_timeZone);
+	//loadExits(_timeZone);
+	loadDoors(_timeZone);
+	//loadHSLs(_timeZone);
+	//loadHSIn(_timeZone);
+	loadSoundSpots(_timeZone);
+	//loadTurns(_timeZone);
+	loadZooms(_timeZone);
+	loadExtras(_timeZone);
+}
+
+void PegasusEngine::loadViews(TimeZone timeZone) {
+	_currentViews.clear();
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('View'), getTimeZoneDesc(timeZone));
+
+	uint32 entryCount = res->readUint32BE();
+
+	for (uint32 i = 0; i < entryCount; i++) {
+		View view;
+		view.u0 = res->readUint16BE(); // Compass reading?
+		view.u1 = res->readByte(); // Always 0-3, direction?
+		view.u2 = res->readByte(); // Usually 0, rarely 3
+		view.frameTime = res->readUint32BE();
+		debug(1, "View[%d]: u0 = %d, u1 = %d, u2 = %d, time = %d", i, view.u0, view.u1, view.u2, view.frameTime);
+		_currentViews.push_back(view);
+	}
+
+	delete res;
+}
+
+void PegasusEngine::loadDoors(TimeZone timeZone) {
+	_currentDoors.clear();
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Door'), getTimeZoneDesc(timeZone));
+
+	uint32 entryCount = res->readUint32BE();
+
+	for (uint32 i = 0; i < entryCount; i++) {
+		Door door;
+		door.u0 = res->readUint16BE();
+		door.u1 = res->readUint16BE(); // Always divisible by 256?
+		door.startTime = res->readUint32BE();
+		door.endTime = res->readUint32BE();
+		door.u2 = res->readUint16BE();
+		debug(1, "Door[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, door.u0, door.u1, door.startTime, door.endTime, door.u2);
+		_currentDoors.push_back(door);
+	}
+
+	delete res;
+}
+
+void PegasusEngine::loadSoundSpots(TimeZone timeZone) {
+	_currentSoundSpots.clear();
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Spot'), getTimeZoneDesc(timeZone));
+
+	uint32 entryCount = res->readUint32BE();
+
+	for (uint32 i = 0; i < entryCount; i++) {
+		SoundSpot spot;
+		spot.u0 = res->readUint16BE();
+		spot.u1 = res->readUint16BE();
+		spot.u2 = res->readUint16BE(); // 0/1 or 768/769
+		spot.startTime = res->readUint32BE();
+		spot.endTime = res->readUint32BE();
+		spot.u3 = res->readUint16BE();
+		debug(1, "Sound Spot[%d]: u0 = %d, u1 = %d, u2 = %d, startTime = %d, endTime = %d, u3 = %d", i, spot.u0, spot.u1, spot.u2, spot.startTime, spot.endTime, spot.u3);
+		_currentSoundSpots.push_back(spot);
+	}
+
+	delete res;
+}
+
+void PegasusEngine::loadZooms(TimeZone timeZone) {
+	_currentZooms.clear();
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Zoom'), getTimeZoneDesc(timeZone));
+
+	uint32 entryCount = res->readUint32BE();
+
+	for (uint32 i = 0; i < entryCount; i++) {
+		Zoom zoom;
+		zoom.u0 = res->readUint16BE();
+		zoom.u1 = res->readUint16BE();
+		zoom.startTime = res->readUint32BE();
+		zoom.endTime = res->readUint32BE();
+		zoom.u2 = res->readUint16BE();
+		debug(1, "Zoom[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, zoom.u0, zoom.u1, zoom.startTime, zoom.endTime, zoom.u2);
+		_currentZooms.push_back(zoom);
+	}
+
+	delete res;
+}
+
+void PegasusEngine::loadExtras(TimeZone timeZone) {
+	_currentExtras.clear();
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Xtra'), getTimeZoneDesc(timeZone));
+
+	uint32 entryCount = res->readUint32BE();
+
+	for (uint32 i = 0; i < entryCount; i++) {
+		Extra extra;
+		extra.u0 = res->readUint32BE();
+		extra.startTime = res->readUint32BE();
+		extra.endTime = res->readUint32BE();
+		debug(1, "Extra[%d]: u0 = %d, startTime = %d, endTime = %d", i, extra.u0, extra.startTime, extra.endTime);
+		_currentExtras.push_back(extra);
+	}
+
+	delete res;
+}
+
+Common::String PegasusEngine::getTimeZoneDesc(TimeZone timeZone) {
+	static const char *names[] = { "Prehistoric", "Mars", "WSC", "Tiny TSA", "Full TSA", "Norad Alpha", "Caldoria", "Norad Delta" };
+	return names[timeZone];
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
new file mode 100644
index 0000000..b4f4d8f
--- /dev/null
+++ b/engines/pegasus/pegasus.h
@@ -0,0 +1,250 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PEGASUS_H
+#define PEGASUS_H
+
+#include "common/macresman.h"
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/rect.h"
+#include "common/util.h"
+
+#include "engines/engine.h"
+
+#include "pegasus/sound.h"
+#include "pegasus/graphics.h"
+#include "pegasus/video.h"
+
+namespace Pegasus {
+
+struct PegasusGameDescription;
+class SoundManager;
+class VideoManager;
+class GraphicsManager;
+
+enum ItemLocation {
+	kItemLocationCaldoria = 0,
+	kItemLocationTSA = 1,
+	kItemLocationNorad = 4, // ???
+	kItemLocationMars = 5,
+	kItemLocationWSC = 6,
+	kItemLocationPrehistoric = 7,
+	kItemLocationBuiltIn = 0xffff
+};
+
+struct ItemLocationData {
+	uint16 id;
+	ItemLocation location;
+	uint16 u0;
+	byte u1;
+};
+
+struct View {
+	uint16 u0;
+	byte u1;
+	byte u2;
+	uint32 frameTime;
+};
+
+struct Door {
+	uint16 u0;
+	uint16 u1;
+	uint32 startTime;
+	uint32 endTime;
+	uint16 u2;
+};
+
+struct SoundSpot {
+	uint16 u0;
+	uint16 u1;
+	uint16 u2;
+	uint32 startTime;
+	uint32 endTime;
+	uint16 u3;
+};
+
+struct Zoom {
+	uint16 u0;
+	uint32 startTime;
+	uint32 endTime;
+	uint16 u1;
+	uint16 u2;
+};
+
+struct Extra {
+	uint32 u0;
+	uint32 startTime;
+	uint32 endTime;
+};
+
+struct InventoryPanelEntry {
+	uint32 startTime;
+	uint32 endTime;
+};
+
+struct InventoryItemData {
+	uint32 leftFrameTime;
+	uint32 rightStartTime;
+	uint32 rightEndTime;
+	uint16 pict;        // Cannot use item at this spot
+	uint16 usablePict;  // Can use item at this spot
+};
+
+struct InventoryExtra {
+	uint32 id;
+	uint16 movie;
+	uint32 startTime;
+	uint32 endTime;
+};
+
+struct LeftAreaData {
+	uint16 frame;
+	uint32 time;
+};
+
+struct MiddleAreaData {
+	uint16 id;
+	uint32 time;
+};
+
+struct RightAreaData {
+	uint16 frame;
+	uint32 time;
+};
+
+enum TimeZone {
+	kLocPrehistoric = 0,
+	kLocMars = 1,
+	kLocWSC = 2,
+	kLocTinyTSA = 3,
+	kLocFullTSA = 4,
+	kLocNoradAlpha = 5,
+	kLocCaldoria = 6,
+	kLocNoradDelta = 7
+};
+
+// Taken from JMP PP Resources
+enum Item {
+	kAIBiochip = 128,
+	kInterfaceBiochip = 129, // NOT USED!
+	kMapBiochip = 130,
+	kOpticalBiochip = 131,
+	kPegasusBiochip = 132,
+	kRetinalScanBiochip = 133,
+	kShieldBiochip = 134,
+	kAirMask = 135,
+	kAntidote = 136,
+	kArgonCanister = 137,
+	kCardBomb = 138,
+	kCrowbar = 139,
+	kGasCanister = 140,
+	kHistoricalLog = 141,
+	kJourneymanKey = 142,
+	kKeyCard = 143,
+	kMachineGun = 144, // What the hell is this?
+	kMarsCard = 145,
+	kNitrogenCanister = 146,
+	kOrangeJuiceGlassFull = 147,
+	kOrangeJuiceGlassEmpty = 148,
+	kPoisonDart = 149,
+	kSinclairKey = 150,
+	kStunGun = 151,
+	kArgonPickup = 152 // ???
+};
+
+enum GameMode {
+	kMainMenuMode,
+	kMainGameMode,
+	kCreditsMode,
+	kInterfaceOverviewMode,
+	kRestoreMode,
+	kQuitMode
+};
+
+class PegasusEngine : public ::Engine {
+protected:
+	Common::Error run();
+
+public:
+	PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc);
+	virtual ~PegasusEngine();
+	
+	const PegasusGameDescription *_gameDescription;
+	bool hasFeature(EngineFeature f) const;
+	
+	VideoManager *_video;
+	SoundManager *_sound;
+	GraphicsManager *_gfx;
+	Common::MacResManager *_resFork, *_inventoryLid, *_biochipLid;
+
+	bool isDemo() const;
+
+private:
+	// Intro
+	void runIntro();
+	void runMainMenu();
+	void drawMenu(int buttonSelected);
+	void drawMenuButtonHighlighted(int buttonSelected);
+	void drawMenuButtonSelected(int buttonSelected);
+	//void runInterfaceOverview();
+	void setGameMode(int buttonSelected);
+
+	// Interface
+	void drawInterface();
+	//void drawCompass();
+	//void runPauseMenu();
+
+	// Interface Overview
+	void drawInterfaceOverview();
+
+	// Main Game Functions
+	void mainGameLoop();
+	void loadItemLocationData();
+	void changeLocation(TimeZone timeZone);
+	void loadViews(TimeZone timeZone);
+	void loadDoors(TimeZone timeZone);
+	void loadSoundSpots(TimeZone timeZone);
+	void loadZooms(TimeZone timeZone);
+	void loadExtras(TimeZone timeZone);
+
+	// Misc Functions
+	static Common::String getTimeZoneDesc(TimeZone timeZone);
+
+	// Game Variables
+	bool _adventureMode;
+	GameMode _gameMode;
+	TimeZone _timeZone;
+	Common::Array<ItemLocationData> _itemLocationData;
+	Common::Array<View> _currentViews;
+	Common::Array<Door> _currentDoors;
+	Common::Array<SoundSpot> _currentSoundSpots;
+	Common::Array<Zoom> _currentZooms;
+	Common::Array<Extra> _currentExtras;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
new file mode 100644
index 0000000..c03e4be
--- /dev/null
+++ b/engines/pegasus/sound.cpp
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "pegasus/sound.h"
+
+#include "common/file.h"
+#include "audio/decoders/aiff.h"
+
+namespace Pegasus {
+
+SoundManager::SoundManager(PegasusEngine *vm) : _vm(vm) {
+}
+        
+void SoundManager::playSound(Common::String filename, bool loop) {
+	SndHandle *handle = getHandle();
+	handle->type = kUsedHandle;
+
+	Common::File *file = new Common::File();
+	if (!file->open(filename.c_str()))
+		error("Could not open file \'%s\'", filename.c_str());
+
+	Audio::AudioStream* audStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
+
+	if (loop)
+		audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream*)audStream, 0);
+	
+	if (audStream)
+		_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream);
+}
+
+SndHandle *SoundManager::getHandle() {
+	for (int i = 0; i < SOUND_HANDLES; i++) {
+		if (_handles[i].type == kFreeHandle)
+			return &_handles[i];
+
+		if (!_vm->_mixer->isSoundHandleActive(_handles[i].handle)) {
+			_handles[i].type = kFreeHandle;
+			return &_handles[i];
+		}
+	}
+
+	error("SoundManager::getHandle(): Too many sound handles");
+	return NULL;
+}
+
+bool SoundManager::isPlaying() {
+	for (int i = 0; i < SOUND_HANDLES; i++)
+		if (_handles[i].type == kUsedHandle)
+			if (_vm->_mixer->isSoundHandleActive(_handles[i].handle))
+				return true;
+	return false;
+}
+
+void SoundManager::stopSound() {
+	_vm->_mixer->stopAll();
+}
+
+void SoundManager::pauseSound() {
+	_vm->_mixer->pauseAll(true);
+}
+
+void SoundManager::resumeSound() {
+	_vm->_mixer->pauseAll(false);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
new file mode 100644
index 0000000..adfb502
--- /dev/null
+++ b/engines/pegasus/sound.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PEGASUS_SOUND_H
+#define PEGASUS_SOUND_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+#define SOUND_HANDLES 10
+
+enum sndHandleType {
+	kFreeHandle,
+	kUsedHandle
+};
+
+struct SndHandle {
+	Audio::SoundHandle handle;
+	sndHandleType type;
+};
+
+class PegasusEngine;
+
+class SoundManager {
+public:
+	SoundManager(PegasusEngine *vm);
+
+	void playSound(Common::String filename, bool loop = false);
+	void stopSound();
+	void pauseSound();
+	void resumeSound();
+	bool isPlaying();
+	
+private:
+	PegasusEngine *_vm;
+
+	SndHandle _handles[SOUND_HANDLES];
+	SndHandle *getHandle();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/video.cpp b/engines/pegasus/video.cpp
new file mode 100644
index 0000000..925c6d7
--- /dev/null
+++ b/engines/pegasus/video.cpp
@@ -0,0 +1,240 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/video.h"
+
+#include "common/events.h"
+#include "graphics/scaler.h"
+#include "video/qt_decoder.h"
+
+namespace Pegasus {
+	
+VideoManager::VideoManager(PegasusEngine *vm) : _vm(vm) {
+	_timeZoneVideo = new Video::QuickTimeDecoder();
+}
+	
+VideoManager::~VideoManager() {
+	stopVideos();
+	delete _timeZoneVideo;
+}
+
+void VideoManager::setTimeZoneVideo(const Common::String &filename) {
+	if (!_timeZoneVideo->loadFile(filename))
+		error("Could not load time zone video '%s'", filename.c_str());
+
+	// Set it on pause
+	_timeZoneVideo->pauseVideo(true);
+}
+
+void VideoManager::drawTimeZoneVideoFrame(uint32 time) {
+	assert(_timeZoneVideo->isVideoLoaded());
+
+	if (!_timeZoneVideo->isPaused())
+		_timeZoneVideo->pauseVideo(true);
+
+	_timeZoneVideo->seekToTime(Audio::Timestamp(0, time, 600));
+
+	const Graphics::Surface *frame = _timeZoneVideo->decodeNextFrame();
+
+	if (!frame)	
+		error("Could not find frame at time %d", time);
+
+	// TODO
+}
+
+void VideoManager::playTimeZoneVideoSegment(uint32 startTime, uint32 endTime) {
+	assert(_timeZoneVideo->isVideoLoaded());
+
+	if (_timeZoneVideo->isPaused())
+		_timeZoneVideo->pauseVideo(false);
+
+	_timeZoneVideo->seekToTime(Audio::Timestamp(0, startTime, 600));
+
+	// TODO
+}
+
+void VideoManager::pauseVideos() {
+	for (uint16 i = 0; i < _videoStreams.size(); i++)
+		_videoStreams[i]->pauseVideo(true);
+}
+
+void VideoManager::resumeVideos() {
+	for (uint16 i = 0; i < _videoStreams.size(); i++)
+		_videoStreams[i]->pauseVideo(false);
+}
+
+void VideoManager::stopVideos() {
+	for (uint16 i = 0; i < _videoStreams.size(); i++) {
+		delete _videoStreams[i].video;
+		_videoStreams[i].video = 0;
+	}
+}
+
+void VideoManager::playMovie(Common::String filename, uint16 x, uint16 y) {
+	VideoHandle videoHandle = playBackgroundMovie(filename, x, y, false);
+
+	if (videoHandle != NULL_VID_HANDLE)
+		waitUntilMovieEnds(videoHandle);
+}
+
+void VideoManager::playMovieCentered(Common::String filename) {
+	VideoHandle videoHandle = playBackgroundMovie(filename, 0, 0, false);
+
+	if (videoHandle == NULL_VID_HANDLE)
+		return;
+
+	_videoStreams[videoHandle].x = (_vm->_system->getWidth() - _videoStreams[videoHandle]->getWidth()) / 2;
+	_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
+
+	waitUntilMovieEnds(videoHandle);
+}
+	
+void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
+	bool continuePlaying = true;
+
+	while (!_videoStreams[videoHandle]->endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
+		if (updateBackgroundMovies())
+			_vm->_system->updateScreen();
+
+		Common::Event event;
+		while (_vm->_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RTL:
+			case Common::EVENT_QUIT:
+				continuePlaying = false;
+				break;
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_ESCAPE:
+					continuePlaying = false;
+					break;
+				default:
+					break;
+			}
+			default:
+				break;
+			}
+		}
+
+		// Cut down on CPU usage
+		_vm->_system->delayMillis(10);
+	}
+
+	delete _videoStreams[videoHandle].video;
+	_videoStreams.clear();
+}
+
+bool VideoManager::updateBackgroundMovies() {
+	bool updateScreen = false;
+
+	for (uint32 i = 0; i < _videoStreams.size() && !_vm->shouldQuit(); i++) {
+		// Skip deleted videos
+		if (!_videoStreams[i].video)
+			continue;
+
+		// Remove any videos that are over
+		if (_videoStreams[i]->endOfVideo()) {
+			if (_videoStreams[i].loop) {
+				_videoStreams[i]->rewind();
+			} else {
+				delete _videoStreams[i].video;
+				memset(&_videoStreams[i], 0, sizeof(VideoEntry));
+				_videoStreams[i].video = NULL;
+				continue;
+			}
+		}
+
+		// Check if we need to draw a frame
+		if (_videoStreams[i]->needsUpdate()) {
+			const Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
+
+			if (frame) {			
+				if (frame->bytesPerPixel == 1)
+					error("Unhandled 8bpp frames"); // Cut out because Pegasus Prime shouldn't need this
+				
+				// Clip the width/height to make sure we stay on the screen
+				uint16 width = MIN<int32>(_videoStreams[i]->getWidth(), _vm->_system->getWidth() - _videoStreams[i].x);
+				uint16 height = MIN<int32>(_videoStreams[i]->getHeight(), _vm->_system->getHeight() - _videoStreams[i].y);
+
+				if (width == 320 && height == 240) {
+					// TODO: Is this right? At least "Big Movie" and the "Sub Chase Movie" need to be scaled...
+					// FIXME: Normal2x is only compiled in when USE_SCALERS is defined
+					_videoStreams[i].x = 0;
+					_videoStreams[i].y = 0;
+					Graphics::Surface scaledSurf;
+					scaledSurf.create(frame->w * 2, frame->h * 2, frame->bytesPerPixel);
+					Normal2x((byte *)frame->pixels, frame->pitch, (byte *)scaledSurf.pixels, scaledSurf.pitch, frame->w, frame->h);
+					_vm->_system->copyRectToScreen((byte*)scaledSurf.pixels, scaledSurf.pitch, _videoStreams[i].x, _videoStreams[i].y, width * 2, height * 2);
+					scaledSurf.free();
+				} else
+					_vm->_system->copyRectToScreen((byte*)frame->pixels, frame->pitch, _videoStreams[i].x, _videoStreams[i].y, width, height);
+					
+
+				// We've drawn something to the screen, make sure we update it
+				updateScreen = true;
+			}
+		}
+	}
+
+	// Return true if we need to update the screen
+	return updateScreen;
+}
+
+VideoHandle VideoManager::playBackgroundMovie(Common::String filename, int x, int y, bool loop) {
+	// First, check to see if that video is already playing
+	for (uint32 i = 0; i < _videoStreams.size(); i++)
+		if (_videoStreams[i].filename == filename)
+			return i;
+
+	// Otherwise, create a new entry
+	VideoEntry entry;
+	entry.video = new Video::QuickTimeDecoder();
+	entry.x = x;
+	entry.y = y;
+	entry.filename = filename;
+	entry.loop = loop;
+	
+	if (!entry->loadFile(filename))
+		return NULL_VID_HANDLE;
+	
+	// Search for any deleted videos so we can take a formerly used slot
+	for (uint32 i = 0; i < _videoStreams.size(); i++)
+		if (!_videoStreams[i].video) {
+			_videoStreams[i] = entry;
+			return i;
+		}
+			
+	// Otherwise, just add it to the list
+	_videoStreams.push_back(entry);
+	return _videoStreams.size() - 1;
+}
+
+void VideoManager::seekToTime(VideoHandle handle, uint32 time) {
+	if (handle != NULL_VID_HANDLE)
+		_videoStreams[handle]->seekToTime(Audio::Timestamp(0, time, 600));
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/video.h b/engines/pegasus/video.h
new file mode 100644
index 0000000..03f0a51
--- /dev/null
+++ b/engines/pegasus/video.h
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PEGASUS_VIDEO_H
+#define PEGASUS_VIDEO_H
+
+#include "common/array.h"
+
+namespace Common {
+	class String;
+}
+
+namespace Video {
+	class QuickTimeDecoder;
+}
+
+namespace Pegasus {
+
+class PegasusEngine;
+
+struct VideoEntry {
+	Video::QuickTimeDecoder *video;
+	uint16 x;
+	uint16 y;
+	bool loop;
+	Common::String filename;
+
+	Video::QuickTimeDecoder *operator->() const { assert(video); return video; }
+};
+
+typedef int32 VideoHandle;
+
+enum {
+	NULL_VID_HANDLE = -1
+};
+
+class VideoManager {
+public:
+	VideoManager(PegasusEngine *vm);
+	~VideoManager();
+
+	void setTimeZoneVideo(const Common::String &filename);
+	void drawTimeZoneVideoFrame(uint32 time);
+	void playTimeZoneVideoSegment(uint32 startTime, uint32 endTime);
+	
+	// Generic movie functions
+	void playMovie(Common::String filename, uint16 x = 0, uint16 y = 0);
+	void playMovieCentered(Common::String filename);
+	VideoHandle playBackgroundMovie(Common::String filename, int x = 0, int y = 0, bool loop = false);
+	bool updateBackgroundMovies();
+	void pauseVideos();
+	void resumeVideos();
+	void stopVideos();
+	void waitUntilMovieEnds(VideoHandle videoHandle);
+
+	void seekToTime(VideoHandle handle, uint32 time);
+
+private:
+	PegasusEngine *_vm;
+
+	Video::QuickTimeDecoder *_timeZoneVideo;
+
+	// Keep tabs on any videos playing
+	Common::Array<VideoEntry> _videoStreams;
+	uint32 _pauseStart;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 850d776e6204e82f817fea7b9977bfa9eb1e76de
    https://github.com/scummvm/scummvm/commit/850d776e6204e82f817fea7b9977bfa9eb1e76de
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-02-21T15:44:24-08:00

Commit Message:
PEGASUS: Fix cursor palettes

Changed paths:
    engines/pegasus/graphics.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index a05e316..de3fe06 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
  
 #include "pegasus/graphics.h"
@@ -167,19 +164,16 @@ void GraphicsManager::setCursor(uint16 cursor) {
 	cicnStream->readUint16BE(); // always 0
 	uint16 colorCount = cicnStream->readUint16BE() + 1;
 	
-	byte *colors = (byte *)malloc(256 * 4);
+	byte *colors = new byte[256 * 3];;
 	for (uint16 i = 0; i < colorCount; i++) {
 		cicnStream->readUint16BE();
-		colors[i * 4] = cicnStream->readByte();
-		cicnStream->readByte();
-		colors[i * 4 + 1] = cicnStream->readByte();
-		cicnStream->readByte();
-		colors[i * 4 + 2] = cicnStream->readByte();
-		cicnStream->readByte();
+		colors[i * 3] = cicnStream->readUint16BE() >> 8;
+		colors[i * 3 + 1] = cicnStream->readUint16BE() >> 8;
+		colors[i * 3 + 2] = cicnStream->readUint16BE() >> 8;
 	}
 	
 	// PixMap data
-	byte *data = (byte *)malloc(pixMap.rowBytes * pixMap.bounds.height());
+	byte *data = new byte[pixMap.rowBytes * pixMap.bounds.height()];
 	cicnStream->read(data, pixMap.rowBytes * pixMap.bounds.height());
 	delete cicnStream;
 	
@@ -213,8 +207,8 @@ void GraphicsManager::setCursor(uint16 cursor) {
 	CursorMan.showMouse(true);
 	_vm->_system->updateScreen();
 
-	free(colors);
-	free(data);
+	delete[] colors;
+	delete[] data;
 }
 
 int GraphicsManager::getImageSlot(const Common::String &filename) {


Commit: 3b2283daf850605ca897002afbafe44489c35473
    https://github.com/scummvm/scummvm/commit/3b2283daf850605ca897002afbafe44489c35473
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-02-21T15:44:24-08:00

Commit Message:
PEGASUS: Remove the rest of the svn keywords from the copyright

Changed paths:
    engines/pegasus/detection.cpp
    engines/pegasus/graphics.h
    engines/pegasus/menu.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/sound.cpp
    engines/pegasus/sound.h
    engines/pegasus/video.cpp
    engines/pegasus/video.h



diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index 17dd7c3..1852429 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "base/plugins.h"
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index c184172..7607c62 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #ifndef PEGASUS_GRAPHICS_H
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index a498a65..d2cb584 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "common/events.h"
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 062ec10..5f95a58 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "common/config-manager.h"
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index b4f4d8f..2f05304 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #ifndef PEGASUS_H
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
index c03e4be..9ef89ab 100644
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "pegasus/sound.h"
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
index adfb502..ebe6f79 100644
--- a/engines/pegasus/sound.h
+++ b/engines/pegasus/sound.h
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #ifndef PEGASUS_SOUND_H
diff --git a/engines/pegasus/video.cpp b/engines/pegasus/video.cpp
index 925c6d7..6b850db 100644
--- a/engines/pegasus/video.cpp
+++ b/engines/pegasus/video.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "pegasus/pegasus.h"
diff --git a/engines/pegasus/video.h b/engines/pegasus/video.h
index 03f0a51..c0ddcdc 100644
--- a/engines/pegasus/video.h
+++ b/engines/pegasus/video.h
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #ifndef PEGASUS_VIDEO_H


Commit: 9cb600099f4c29298707787cafad2741a1cd6686
    https://github.com/scummvm/scummvm/commit/9cb600099f4c29298707787cafad2741a1cd6686
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-03T14:25:41-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A audio/decoders/adpcm_intern.h
  A audio/midiplayer.cpp
  A audio/midiplayer.h
  A audio/softsynth/eas.cpp
  A backends/events/gph/gph-events.cpp
  A backends/events/gph/gph-events.h
  A backends/events/openpandora/op-events.cpp
  A backends/events/openpandora/op-events.h
  A backends/events/webossdl/webossdl-events.cpp
  A backends/events/webossdl/webossdl-events.h
  A backends/events/wincesdl/wincesdl-events.cpp
  A backends/events/wincesdl/wincesdl-events.h
  A backends/fs/amigaos4/amigaos4-fs.h
  A backends/fs/n64/n64-fs.h
  A backends/fs/ps2/ps2-fs.h
  A backends/fs/psp/psp-fs.h
  A backends/fs/symbian/symbian-fs.h
  A backends/fs/wii/wii-fs.h
  A backends/fs/windows/windows-fs.h
  A backends/graphics/gph/gph-graphics.cpp
  A backends/graphics/gph/gph-graphics.h
  A backends/graphics/openpandora/op-graphics.cpp
  A backends/graphics/openpandora/op-graphics.h
  A backends/graphics/wincesdl/wincesdl-graphics.cpp
  A backends/graphics/wincesdl/wincesdl-graphics.h
  A backends/mixer/wincesdl/wincesdl-mixer.cpp
  A backends/mixer/wincesdl/wincesdl-mixer.h
  A backends/platform/android/events.cpp
  A backends/platform/android/gfx.cpp
  A backends/platform/android/jni.cpp
  A backends/platform/android/jni.h
  A backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
  A backends/platform/android/texture.cpp
  A backends/platform/android/texture.h
  A backends/platform/dc/plugins.cpp
  A backends/platform/gph/build/caanoo-build.sh
  A backends/platform/gph/build/caanoo-bundle-debug.sh
  A backends/platform/gph/build/caanoo-bundle.sh
  A backends/platform/gph/build/caanoo-config-alleng.sh
  A backends/platform/gph/build/caanoo-config.sh
  A backends/platform/gph/build/gp2x-build.sh
  A backends/platform/gph/build/gp2x-bundle.sh
  A backends/platform/gph/build/gp2x-config-alleng.sh
  A backends/platform/gph/build/gp2x-config.sh
  A backends/platform/gph/build/gp2xwiz-build.sh
  A backends/platform/gph/build/gp2xwiz-bundle-debug.sh
  A backends/platform/gph/build/gp2xwiz-bundle.sh
  A backends/platform/gph/build/gp2xwiz-config-alleng.sh
  A backends/platform/gph/build/gp2xwiz-config.sh
  A backends/platform/gph/devices/caanoo/scummvm-gdb.gpe
  A backends/platform/gph/devices/caanoo/scummvm.gpe
  A backends/platform/gph/devices/common/README-GPH
  A backends/platform/gph/devices/common/scummvm.ini
  A backends/platform/gph/devices/common/scummvm.png
  A backends/platform/gph/devices/common/scummvmb.png
  A backends/platform/gph/devices/gp2x/mmuhack/Makefile
  A backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h
  A backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s
  A backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c
  A backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o
  A backends/platform/gph/devices/gp2x/mmuhack/readme.txt
  A backends/platform/gph/devices/gp2x/scummvm.gpe
  A backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe
  A backends/platform/gph/devices/gp2xwiz/scummvm.gpe
  A backends/platform/gph/gp2x-bundle.mk
  A backends/platform/gph/gph-backend.cpp
  A backends/platform/openpandora/op-backend.cpp
  A backends/platform/symbian/mmp/scummvm_tsage.mmp.in
  A backends/platform/webos/main.cpp
  A backends/platform/webos/module.mk
  A backends/platform/webos/webos.cpp
  A backends/platform/webos/webos.h
  A backends/platform/webos/webos.mk
  A base/internal_revision.h.in
  A common/winexe.cpp
  A common/winexe.h
  A common/winexe_ne.cpp
  A common/winexe_ne.h
  A common/winexe_pe.cpp
  A common/winexe_pe.h
  A devtools/README
  A devtools/agi-palex.py
  A devtools/construct-pred-dict.pl
  A devtools/convbdf.c
  A devtools/create_drascula/Makefile
  A devtools/create_drascula/create_drascula.cpp
  A devtools/create_drascula/create_drascula.h
  A devtools/create_drascula/dists/msvc8/create_drascula.sln
  A devtools/create_drascula/dists/msvc8/create_drascula.vcproj
  A devtools/create_drascula/dists/msvc8_to_msvc9.bat
  A devtools/create_drascula/dists/msvc9/create_drascula.sln
  A devtools/create_drascula/dists/msvc9/create_drascula.vcproj
  A devtools/create_drascula/dists/msvc9_to_msvc8.bat
  A devtools/create_drascula/module.mk
  A devtools/create_drascula/staticdata.h
  A devtools/create_hugo/Data/Btn_1.bmp
  A devtools/create_hugo/Data/Btn_1_off.bmp
  A devtools/create_hugo/Data/Btn_2.bmp
  A devtools/create_hugo/Data/Btn_2_off.bmp
  A devtools/create_hugo/Data/Btn_3.bmp
  A devtools/create_hugo/Data/Btn_3_off.bmp
  A devtools/create_hugo/Data/Btn_4.bmp
  A devtools/create_hugo/Data/Btn_4_off.bmp
  A devtools/create_hugo/Data/Btn_5.bmp
  A devtools/create_hugo/Data/Btn_5_off.bmp
  A devtools/create_hugo/Data/Btn_6.bmp
  A devtools/create_hugo/Data/Btn_6_off.bmp
  A devtools/create_hugo/Data/Btn_7.bmp
  A devtools/create_hugo/Data/Btn_7_off.bmp
  A devtools/create_hugo/Data/Btn_8.bmp
  A devtools/create_hugo/Data/Btn_8_off.bmp
  A devtools/create_hugo/Data/Btn_9.bmp
  A devtools/create_hugo/Data/Btn_9_off.bmp
  A devtools/create_hugo/README
  A devtools/create_hugo/create_hugo.cpp
  A devtools/create_hugo/create_hugo.h
  A devtools/create_hugo/dists/msvc10/create_hugo.sln
  A devtools/create_hugo/dists/msvc10/create_hugo.vcxproj
  A devtools/create_hugo/dists/msvc9/create_hugo.sln
  A devtools/create_hugo/dists/msvc9/create_hugo.vcproj
  A devtools/create_hugo/enums.h
  A devtools/create_hugo/module.mk
  A devtools/create_hugo/staticdata.h
  A devtools/create_hugo/staticdisplay.h
  A devtools/create_hugo/staticengine.h
  A devtools/create_hugo/staticfont.h
  A devtools/create_hugo/staticintro.h
  A devtools/create_hugo/staticmouse.h
  A devtools/create_hugo/staticparser.h
  A devtools/create_hugo/staticutil.h
  A devtools/create_kyradat/create_kyradat.cpp
  A devtools/create_kyradat/create_kyradat.h
  A devtools/create_kyradat/extract.cpp
  A devtools/create_kyradat/extract.h
  A devtools/create_kyradat/games.cpp
  A devtools/create_kyradat/md5.cpp
  A devtools/create_kyradat/md5.h
  A devtools/create_kyradat/module.mk
  A devtools/create_kyradat/pak.cpp
  A devtools/create_kyradat/pak.h
  A devtools/create_kyradat/search.cpp
  A devtools/create_kyradat/search.h
  A devtools/create_kyradat/tables.cpp
  A devtools/create_kyradat/tables.h
  A devtools/create_kyradat/util.cpp
  A devtools/create_kyradat/util.h
  A devtools/create_lure/Makefile
  A devtools/create_lure/create_lure_dat.cpp
  A devtools/create_lure/create_lure_dat.h
  A devtools/create_lure/dists/msvc8/create_lure.sln
  A devtools/create_lure/dists/msvc8/create_lure.vcproj
  A devtools/create_lure/dists/msvc8_to_msvc9.bat
  A devtools/create_lure/dists/msvc9/create_lure.sln
  A devtools/create_lure/dists/msvc9/create_lure.vcproj
  A devtools/create_lure/dists/msvc9_to_msvc8.bat
  A devtools/create_lure/module.mk
  A devtools/create_lure/process_actions.cpp
  A devtools/create_mads/Makefile
  A devtools/create_mads/dists/msvc9/create_mads.sln
  A devtools/create_mads/dists/msvc9/create_mads.vcproj
  A devtools/create_mads/main.cpp
  A devtools/create_mads/module.mk
  A devtools/create_mads/parser.cpp
  A devtools/create_mads/parser.h
  A devtools/create_mads/scripts/rex_nebular.txt
  A devtools/create_project/codeblocks.cpp
  A devtools/create_project/codeblocks.h
  A devtools/create_project/codeblocks/create_project.cbp
  A devtools/create_project/config.h
  A devtools/create_project/create_project.cpp
  A devtools/create_project/create_project.h
  A devtools/create_project/module.mk
  A devtools/create_project/msbuild.cpp
  A devtools/create_project/msbuild.h
  A devtools/create_project/msvc.cpp
  A devtools/create_project/msvc.h
  A devtools/create_project/msvc10/create_project.sln
  A devtools/create_project/msvc10/create_project.vcxproj
  A devtools/create_project/msvc10/create_project.vcxproj.filters
  A devtools/create_project/msvc8/create_project.sln
  A devtools/create_project/msvc8/create_project.vcproj
  A devtools/create_project/msvc9/create_project.sln
  A devtools/create_project/msvc9/create_project.vcproj
  A devtools/create_project/scripts/postbuild.cmd
  A devtools/create_project/scripts/prebuild.cmd
  A devtools/create_project/scripts/revision.vbs
  A devtools/create_project/visualstudio.cpp
  A devtools/create_project/visualstudio.h
  A devtools/create_teenagent/create_teenagent.cpp
  A devtools/create_teenagent/md5.cpp
  A devtools/create_teenagent/md5.h
  A devtools/create_teenagent/module.mk
  A devtools/create_teenagent/util.h
  A devtools/create_toon/create_toon.cpp
  A devtools/create_toon/create_toon.h
  A devtools/create_toon/dists/msvc9/create_toon.sln
  A devtools/create_toon/dists/msvc9/create_toon.vcproj
  A devtools/create_toon/module.mk
  A devtools/create_toon/staticdata.h
  A devtools/create_translations/create_translations.cpp
  A devtools/create_translations/create_translations.h
  A devtools/create_translations/module.mk
  A devtools/create_translations/po_parser.cpp
  A devtools/create_translations/po_parser.h
  A devtools/credits.pl
  A devtools/dist-scummvm.sh
  A devtools/extract-words-tok.pl
  A devtools/make-scumm-fontdata.c
  A devtools/md5table.c
  A devtools/module.mk
  A devtools/qtable/fat_amiga_demo.h
  A devtools/qtable/fat_amiga_eng_floppy.h
  A devtools/qtable/fat_amiga_interview.h
  A devtools/qtable/fat_eng_cdrom.h
  A devtools/qtable/fat_eng_floppy.h
  A devtools/qtable/fat_fre_cdrom.h
  A devtools/qtable/fat_fre_floppy.h
  A devtools/qtable/fat_ger_cdrom.h
  A devtools/qtable/fat_ger_floppy.h
  A devtools/qtable/fat_heb_cdrom.h
  A devtools/qtable/fat_ita_cdrom.h
  A devtools/qtable/fat_ita_floppy.h
  A devtools/qtable/fat_pc_demo.h
  A devtools/qtable/fat_pc_demo_pcgames.h
  A devtools/qtable/fat_pc_interview.h
  A devtools/qtable/fat_spa_cdrom.h
  A devtools/qtable/module.mk
  A devtools/qtable/qtable.cpp
  A devtools/sci/musicplayer.cpp
  A devtools/sci/scidisasm.cpp
  A devtools/sci/scipack.cpp
  A devtools/sci/scitrace.asm
  A devtools/scumm-md5.txt
  A devtools/skycpt/288diff.txt
  A devtools/skycpt/AsciiCptCompile.cpp
  A devtools/skycpt/AsciiCptCompile.sln
  A devtools/skycpt/AsciiCptCompile.vcproj
  A devtools/skycpt/COMPACT.TXT
  A devtools/skycpt/KmpSearch.cpp
  A devtools/skycpt/KmpSearch.h
  A devtools/skycpt/README
  A devtools/skycpt/TextFile.cpp
  A devtools/skycpt/TextFile.h
  A devtools/skycpt/cptcompiler.cpp
  A devtools/skycpt/cpthelp.cpp
  A devtools/skycpt/cpthelp.h
  A devtools/skycpt/idFinder.cpp
  A devtools/skycpt/module.mk
  A devtools/skycpt/savedata.txt
  A devtools/skycpt/skycpt-engine.patch
  A devtools/skycpt/stdafx.cpp
  A devtools/skycpt/stdafx.h
  A devtools/themeparser.py
  A devtools/update-version.pl
  A dists/android/README.Android
  A dists/android/mkplugin.sh
  A dists/android/plugin-manifest.xml
  A dists/android/plugin-manifest.xml.in
  A dists/android/plugin-strings.xml
  A dists/webos/README.WebOS
  A dists/webos/mojo/appinfo.json
  A dists/webos/mojo/icon.png
  A dists/webos/mojo/package.properties
  A dists/webos/mojo/scummvmrc-default
  A dists/webos/mojo/start
  A dists/win32/ScummVM.iss
  A engines/hugo/dialogs.cpp
  A engines/hugo/dialogs.h
  A engines/scumm/actor_he.h
  A engines/scumm/imuse_digi/dimuse_codecs.h
  A engines/tinsel/adpcm.cpp
  A engines/tinsel/adpcm.h
  A engines/tsage/converse.cpp
  A engines/tsage/converse.h
  A engines/tsage/core.cpp
  A engines/tsage/core.h
  A engines/tsage/debugger.cpp
  A engines/tsage/debugger.h
  A engines/tsage/detection.cpp
  A engines/tsage/detection_tables.h
  A engines/tsage/dialogs.cpp
  A engines/tsage/dialogs.h
  A engines/tsage/events.cpp
  A engines/tsage/events.h
  A engines/tsage/globals.cpp
  A engines/tsage/globals.h
  A engines/tsage/graphics.cpp
  A engines/tsage/graphics.h
  A engines/tsage/module.mk
  A engines/tsage/resources.cpp
  A engines/tsage/resources.h
  A engines/tsage/ringworld_demo.cpp
  A engines/tsage/ringworld_demo.h
  A engines/tsage/ringworld_logic.cpp
  A engines/tsage/ringworld_logic.h
  A engines/tsage/ringworld_scenes1.cpp
  A engines/tsage/ringworld_scenes1.h
  A engines/tsage/ringworld_scenes10.cpp
  A engines/tsage/ringworld_scenes10.h
  A engines/tsage/ringworld_scenes2.cpp
  A engines/tsage/ringworld_scenes2.h
  A engines/tsage/ringworld_scenes3.cpp
  A engines/tsage/ringworld_scenes3.h
  A engines/tsage/ringworld_scenes4.cpp
  A engines/tsage/ringworld_scenes4.h
  A engines/tsage/ringworld_scenes5.cpp
  A engines/tsage/ringworld_scenes5.h
  A engines/tsage/ringworld_scenes6.cpp
  A engines/tsage/ringworld_scenes6.h
  A engines/tsage/ringworld_scenes8.cpp
  A engines/tsage/ringworld_scenes8.h
  A engines/tsage/saveload.cpp
  A engines/tsage/saveload.h
  A engines/tsage/scenes.cpp
  A engines/tsage/scenes.h
  A engines/tsage/sound.cpp
  A engines/tsage/sound.h
  A engines/tsage/staticres.cpp
  A engines/tsage/staticres.h
  A engines/tsage/tsage.cpp
  A engines/tsage/tsage.h
  A graphics/wincursor.cpp
  A graphics/wincursor.h
  A po/se_SE.po
  A test/common/endian.h
  R backends/platform/gph/gph-events.cpp
  R backends/platform/openpandora/op-events.cpp
  R engines/mohawk/myst_vars.h
  R backends/platform/gph/gph-graphics.cpp
  R backends/platform/openpandora/op-graphics.cpp
  R backends/platform/android/org/inodes/gus/scummvm/Event.java
  R backends/platform/android/video.cpp
  R backends/platform/android/video.h
  R backends/plugins/dc/dc-provider.cpp
  R backends/platform/gp2x/build/README-GP2X
  R backends/platform/gp2x/build/bundle.sh
  R backends/platform/gph/caanoo/build.sh
  R backends/platform/gph/caanoo/bundle-debug.sh
  R backends/platform/gph/caanoo/bundle.sh
  R backends/platform/gph/caanoo/config-alleng.sh
  R backends/platform/gph/caanoo/config.sh
  R backends/platform/gp2x/build/build.sh
  R backends/platform/gp2x/build/config-alleng.sh
  R backends/platform/gp2x/build/config.sh
  R backends/platform/gph/build/build.sh
  R backends/platform/gph/build/bundle-debug.sh
  R backends/platform/gph/build/bundle.sh
  R backends/platform/gph/build/config-alleng.sh
  R backends/platform/gph/build/config.sh
  R backends/platform/gph/build/scummvm.png
  R backends/platform/gph/caanoo/clean.sh
  R backends/platform/gph/build/scummvm-gdb.gpe
  R backends/platform/gph/caanoo/scummvm.gpe
  R backends/platform/gph/build/README-GPH
  R backends/platform/gph/build/scummvm.ini
  R backends/platform/gp2x/build/scummvm.png
  R backends/platform/gph/build/scummvmb.png
  R backends/platform/gp2x/mmuhack/Makefile
  R backends/platform/gp2x/mmuhack/flush_uppermem_cache.h
  R backends/platform/gp2x/mmuhack/flush_uppermem_cache.s
  R backends/platform/gp2x/mmuhack/mmuhack.c
  R backends/platform/gp2x/build/mmuhack.o
  R backends/platform/gp2x/mmuhack/readme.txt
  R backends/platform/gp2x/build/scummvm.gpe
  R backends/platform/gph/caanoo/scummvm-gdb.gpe
  R backends/platform/gph/build/scummvm.gpe
  R backends/platform/gp2x/gp2x-bundle.mk
  R common/ne_exe.cpp
  R common/ne_exe.h
  R tools/README
  R tools/agi-palex.py
  R tools/construct-pred-dict.pl
  R tools/convbdf.c
  R tools/create_drascula/Makefile
  R tools/create_drascula/create_drascula.cpp
  R tools/create_drascula/create_drascula.h
  R tools/create_drascula/dists/msvc8/create_drascula.sln
  R tools/create_drascula/dists/msvc8/create_drascula.vcproj
  R tools/create_drascula/dists/msvc8_to_msvc9.bat
  R tools/create_drascula/dists/msvc9/create_drascula.sln
  R tools/create_drascula/dists/msvc9/create_drascula.vcproj
  R tools/create_drascula/dists/msvc9_to_msvc8.bat
  R tools/create_drascula/module.mk
  R tools/create_drascula/staticdata.h
  R tools/create_hugo/Data/Btn_1.bmp
  R tools/create_hugo/Data/Btn_1_off.bmp
  R tools/create_hugo/Data/Btn_2.bmp
  R tools/create_hugo/Data/Btn_2_off.bmp
  R tools/create_hugo/Data/Btn_3.bmp
  R tools/create_hugo/Data/Btn_3_off.bmp
  R tools/create_hugo/Data/Btn_4.bmp
  R tools/create_hugo/Data/Btn_4_off.bmp
  R tools/create_hugo/Data/Btn_5.bmp
  R tools/create_hugo/Data/Btn_5_off.bmp
  R tools/create_hugo/Data/Btn_6.bmp
  R tools/create_hugo/Data/Btn_6_off.bmp
  R tools/create_hugo/Data/Btn_7.bmp
  R tools/create_hugo/Data/Btn_7_off.bmp
  R tools/create_hugo/Data/Btn_8.bmp
  R tools/create_hugo/Data/Btn_8_off.bmp
  R tools/create_hugo/Data/Btn_9.bmp
  R tools/create_hugo/Data/Btn_9_off.bmp
  R tools/create_hugo/README
  R tools/create_hugo/create_hugo.cpp
  R tools/create_hugo/create_hugo.h
  R tools/create_hugo/dists/msvc10/create_hugo.sln
  R tools/create_hugo/dists/msvc10/create_hugo.vcxproj
  R tools/create_hugo/dists/msvc9/create_hugo.sln
  R tools/create_hugo/dists/msvc9/create_hugo.vcproj
  R tools/create_hugo/enums.h
  R tools/create_hugo/module.mk
  R tools/create_hugo/staticdata.h
  R tools/create_hugo/staticdisplay.h
  R tools/create_hugo/staticengine.h
  R tools/create_hugo/staticfont.h
  R tools/create_hugo/staticintro.h
  R tools/create_hugo/staticmouse.h
  R tools/create_hugo/staticparser.h
  R tools/create_hugo/staticutil.h
  R tools/create_kyradat/create_kyradat.cpp
  R tools/create_kyradat/create_kyradat.h
  R tools/create_kyradat/extract.cpp
  R tools/create_kyradat/extract.h
  R tools/create_kyradat/games.cpp
  R tools/create_kyradat/md5.cpp
  R tools/create_kyradat/md5.h
  R tools/create_kyradat/module.mk
  R tools/create_kyradat/pak.cpp
  R tools/create_kyradat/pak.h
  R tools/create_kyradat/search.cpp
  R tools/create_kyradat/search.h
  R tools/create_kyradat/tables.cpp
  R tools/create_kyradat/tables.h
  R tools/create_kyradat/util.cpp
  R tools/create_kyradat/util.h
  R tools/create_lure/Makefile
  R tools/create_lure/create_lure_dat.cpp
  R tools/create_lure/create_lure_dat.h
  R tools/create_lure/dists/msvc8/create_lure.sln
  R tools/create_lure/dists/msvc8/create_lure.vcproj
  R tools/create_lure/dists/msvc8_to_msvc9.bat
  R tools/create_lure/dists/msvc9/create_lure.sln
  R tools/create_lure/dists/msvc9/create_lure.vcproj
  R tools/create_lure/dists/msvc9_to_msvc8.bat
  R tools/create_lure/module.mk
  R tools/create_lure/process_actions.cpp
  R tools/create_mads/Makefile
  R tools/create_mads/dists/msvc9/create_mads.sln
  R tools/create_mads/dists/msvc9/create_mads.vcproj
  R tools/create_mads/main.cpp
  R tools/create_mads/module.mk
  R tools/create_mads/parser.cpp
  R tools/create_mads/parser.h
  R tools/create_mads/scripts/rex_nebular.txt
  R tools/create_project/codeblocks.cpp
  R tools/create_project/codeblocks.h
  R tools/create_project/codeblocks/create_project.cbp
  R tools/create_project/create_project.cpp
  R tools/create_project/create_project.h
  R tools/create_project/module.mk
  R tools/create_project/msbuild.cpp
  R tools/create_project/msbuild.h
  R tools/create_project/msvc.cpp
  R tools/create_project/msvc.h
  R tools/create_project/msvc10/create_project.sln
  R tools/create_project/msvc10/create_project.vcxproj
  R tools/create_project/msvc10/create_project.vcxproj.filters
  R tools/create_project/msvc8/create_project.sln
  R tools/create_project/msvc8/create_project.vcproj
  R tools/create_project/msvc9/create_project.sln
  R tools/create_project/msvc9/create_project.vcproj
  R tools/create_project/scripts/postbuild.cmd
  R tools/create_project/scripts/prebuild.cmd
  R tools/create_project/scripts/revision.vbs
  R tools/create_project/visualstudio.cpp
  R tools/create_project/visualstudio.h
  R tools/create_teenagent/create_teenagent.cpp
  R tools/create_teenagent/md5.cpp
  R tools/create_teenagent/md5.h
  R tools/create_teenagent/module.mk
  R tools/create_teenagent/util.h
  R tools/create_toon/create_toon.cpp
  R tools/create_toon/create_toon.h
  R tools/create_toon/dists/msvc9/create_toon.sln
  R tools/create_toon/dists/msvc9/create_toon.vcproj
  R tools/create_toon/module.mk
  R tools/create_toon/staticdata.h
  R tools/create_translations/create_translations.cpp
  R tools/create_translations/create_translations.h
  R tools/create_translations/module.mk
  R tools/create_translations/po_parser.cpp
  R tools/create_translations/po_parser.h
  R tools/credits.pl
  R tools/dist-scummvm.sh
  R tools/extract-words-tok.pl
  R tools/make-scumm-fontdata.c
  R tools/md5table.c
  R tools/qtable/fat_amiga_demo.h
  R tools/qtable/fat_amiga_eng_floppy.h
  R tools/qtable/fat_amiga_interview.h
  R tools/qtable/fat_eng_cdrom.h
  R tools/qtable/fat_eng_floppy.h
  R tools/qtable/fat_fre_cdrom.h
  R tools/qtable/fat_fre_floppy.h
  R tools/qtable/fat_ger_cdrom.h
  R tools/qtable/fat_ger_floppy.h
  R tools/qtable/fat_heb_cdrom.h
  R tools/qtable/fat_ita_cdrom.h
  R tools/qtable/fat_ita_floppy.h
  R tools/qtable/fat_pc_demo.h
  R tools/qtable/fat_pc_demo_pcgames.h
  R tools/qtable/fat_pc_interview.h
  R tools/qtable/fat_spa_cdrom.h
  R tools/qtable/module.mk
  R tools/qtable/qtable.cpp
  R tools/sci/musicplayer.cpp
  R tools/sci/scidisasm.cpp
  R tools/sci/scipack.cpp
  R tools/sci/scitrace.asm
  R tools/scumm-md5.txt
  R tools/skycpt/288diff.txt
  R tools/skycpt/AsciiCptCompile.cpp
  R tools/skycpt/AsciiCptCompile.sln
  R tools/skycpt/AsciiCptCompile.vcproj
  R tools/skycpt/COMPACT.TXT
  R tools/skycpt/KmpSearch.cpp
  R tools/skycpt/KmpSearch.h
  R tools/skycpt/README
  R tools/skycpt/TextFile.cpp
  R tools/skycpt/TextFile.h
  R tools/skycpt/cptcompiler.cpp
  R tools/skycpt/cpthelp.cpp
  R tools/skycpt/cpthelp.h
  R tools/skycpt/idFinder.cpp
  R tools/skycpt/module.mk
  R tools/skycpt/savedata.txt
  R tools/skycpt/skycpt-engine.patch
  R tools/skycpt/stdafx.cpp
  R tools/skycpt/stdafx.h
  R tools/themeparser.py
  R tools/update-version.pl
  R dists/android/mkmanifest.pl
  R engines/hugo/menu.cpp
  R engines/hugo/menu.h
  R engines/mohawk/myst_vars.cpp
  R engines/mohawk/riven_cursors.h
  R backends/plugins/dc/dc-provider.h
  R engines/sword25/util/pluto/Makefile
  R engines/sword25/util/pluto/pdep/lauxlib.h
  R engines/sword25/util/pluto/pdep/ldo.h
  R engines/sword25/util/pluto/pdep/lfunc.h
  R engines/sword25/util/pluto/pdep/lgc.h
  R engines/sword25/util/pluto/pdep/llimits.h
  R engines/sword25/util/pluto/pdep/lobject.h
  R engines/sword25/util/pluto/pdep/lopcodes.h
  R engines/sword25/util/pluto/pdep/lstate.h
  R engines/sword25/util/pluto/pdep/lstring.h
  R engines/sword25/util/pluto/pdep/ltm.h
  R engines/sword25/util/pluto/pdep/lua.h
  R engines/sword25/util/pluto/pptest.cpp
  R engines/sword25/util/pluto/pptest.lua
  R engines/sword25/util/pluto/puptest.cpp
  R engines/sword25/util/pluto/puptest.lua
  R tools/module.mk
  R tools/svnpropset.sh
    .gitignore
    AUTHORS
    COPYRIGHT
    Makefile
    Makefile.common
    NEWS
    README
    audio/audiostream.cpp
    audio/audiostream.h
    audio/decoders/adpcm.cpp
    audio/decoders/adpcm.h
    audio/decoders/aiff.cpp
    audio/decoders/aiff.h
    audio/decoders/flac.cpp
    audio/decoders/flac.h
    audio/decoders/iff_sound.cpp
    audio/decoders/iff_sound.h
    audio/decoders/mac_snd.cpp
    audio/decoders/mac_snd.h
    audio/decoders/mp3.cpp
    audio/decoders/mp3.h
    audio/decoders/raw.cpp
    audio/decoders/raw.h
    audio/decoders/vag.h
    audio/decoders/voc.cpp
    audio/decoders/voc.h
    audio/decoders/vorbis.cpp
    audio/decoders/vorbis.h
    audio/decoders/wave.cpp
    audio/decoders/wave.h
    audio/fmopl.cpp
    audio/mididrv.cpp
    audio/mididrv.h
    audio/midiparser.cpp
    audio/midiparser.h
    audio/midiparser_smf.cpp
    audio/midiparser_xmidi.cpp
    audio/mixer.cpp
    audio/mixer.h
    audio/mixer_intern.h
    audio/mods/infogrames.cpp
    audio/mods/infogrames.h
    audio/mods/maxtrax.cpp
    audio/mods/module.cpp
    audio/mods/module.h
    audio/mods/protracker.cpp
    audio/mods/protracker.h
    audio/mods/rjp1.cpp
    audio/mods/rjp1.h
    audio/mods/soundfx.cpp
    audio/mods/soundfx.h
    audio/mods/tfmx.cpp
    audio/module.mk
    audio/mpu401.cpp
    audio/mpu401.h
    audio/musicplugin.h
    audio/null.cpp
    audio/null.h
    audio/rate.cpp
    audio/rate.h
    audio/rate_arm.cpp
    audio/softsynth/adlib.cpp
    audio/softsynth/emumidi.h
    audio/softsynth/fluidsynth.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.cpp
    audio/softsynth/fmtowns_pc98/towns_euphony.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
    audio/softsynth/mt32.cpp
    audio/softsynth/mt32/part.cpp
    audio/softsynth/mt32/part.h
    audio/softsynth/mt32/synth.cpp
    audio/softsynth/mt32/synth.h
    audio/softsynth/opl/dbopl.cpp
    audio/softsynth/opl/dosbox.cpp
    audio/softsynth/opl/mame.cpp
    audio/softsynth/opl/mame.h
    audio/softsynth/pcspk.cpp
    audio/softsynth/pcspk.h
    audio/softsynth/sid.cpp
    audio/softsynth/sid.h
    audio/softsynth/ym2612.cpp
    backends/audiocd/sdl/sdl-audiocd.cpp
    backends/base-backend.cpp
    backends/events/default/default-events.h
    backends/events/gp2xsdl/gp2xsdl-events.cpp
    backends/events/gp2xsdl/gp2xsdl-events.h
    backends/events/sdl/sdl-events.cpp
    backends/fs/amigaos4/amigaos4-fs-factory.cpp
    backends/fs/amigaos4/amigaos4-fs.cpp
    backends/fs/n64/n64-fs-factory.cpp
    backends/fs/n64/n64-fs-factory.h
    backends/fs/n64/n64-fs.cpp
    backends/fs/posix/posix-fs-factory.cpp
    backends/fs/posix/posix-fs.cpp
    backends/fs/posix/posix-fs.h
    backends/fs/ps2/ps2-fs-factory.cpp
    backends/fs/ps2/ps2-fs-factory.h
    backends/fs/ps2/ps2-fs.cpp
    backends/fs/psp/psp-fs-factory.cpp
    backends/fs/psp/psp-fs.cpp
    backends/fs/symbian/symbian-fs-factory.cpp
    backends/fs/symbian/symbian-fs.cpp
    backends/fs/wii/wii-fs-factory.cpp
    backends/fs/wii/wii-fs.cpp
    backends/fs/windows/windows-fs-factory.cpp
    backends/fs/windows/windows-fs.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
    backends/graphics/opengl/gltexture.cpp
    backends/graphics/opengl/gltexture.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.h
    backends/graphics/sdl/sdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.h
    backends/keymapper/hardware-key.h
    backends/keymapper/remap-dialog.cpp
    backends/keymapper/remap-dialog.h
    backends/midi/alsa.cpp
    backends/midi/camd.cpp
    backends/midi/coreaudio.cpp
    backends/midi/coremidi.cpp
    backends/midi/dmedia.cpp
    backends/midi/seq.cpp
    backends/midi/stmidi.cpp
    backends/midi/timidity.cpp
    backends/midi/windows.cpp
    backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.cpp
    backends/modular-backend.cpp
    backends/module.mk
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/android.mk
    backends/platform/android/asset-archive.cpp
    backends/platform/android/asset-archive.h
    backends/platform/android/module.mk
    backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
    backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
    backends/platform/android/org/inodes/gus/scummvm/Unpacker.java
    backends/platform/dc/Makefile
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/display.cpp
    backends/platform/dc/dreamcast.mk
    backends/platform/dc/module.mk
    backends/platform/dc/selector.cpp
    backends/platform/dc/vmsave.cpp
    backends/platform/dingux/main.cpp
    backends/platform/ds/arm9/source/fat/gba_nds_fat.c
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/ds/ds.mk
    backends/platform/ds/makefile
    backends/platform/gp2x/gp2x-common.h
    backends/platform/gp2x/gp2x-main.cpp
    backends/platform/gp2x/gp2x.cpp
    backends/platform/gph/build/clean.sh
    backends/platform/gph/caanoo-bundle.mk
    backends/platform/gph/gp2xwiz-bundle.mk
    backends/platform/gph/gph-main.cpp
    backends/platform/gph/gph-sdl.h
    backends/platform/gph/module.mk
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_video.cpp
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/osys_n64_events.cpp
    backends/platform/openpandora/module.mk
    backends/platform/openpandora/op-main.cpp
    backends/platform/openpandora/op-sdl.h
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Gs2dScreen.h
    backends/platform/ps2/irxboot.cpp
    backends/platform/ps2/ps2input.cpp
    backends/platform/ps2/ps2input.h
    backends/platform/ps2/ps2mutex.cpp
    backends/platform/ps2/ps2pad.cpp
    backends/platform/ps2/ps2time.cpp
    backends/platform/ps2/savefilemgr.cpp
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/README.PSP
    backends/platform/psp/cursor.cpp
    backends/platform/psp/default_display_client.cpp
    backends/platform/psp/display_client.cpp
    backends/platform/psp/mp3.cpp
    backends/platform/psp/mp3.h
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/osys_psp.h
    backends/platform/psp/portdefs.h
    backends/platform/psp/psp_main.cpp
    backends/platform/psp/trace.cpp
    backends/platform/samsungtv/main.cpp
    backends/platform/sdl/posix/posix-main.cpp
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/win32/win32.cpp
    backends/platform/symbian/AdaptAllMMPs.pl
    backends/platform/symbian/BuildPackageUpload_LocalSettings.pl
    backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
    backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
    backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
    backends/platform/symbian/mmp/scummvm_agi.mmp.in
    backends/platform/symbian/mmp/scummvm_agos.mmp.in
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/mmp/scummvm_cine.mmp.in
    backends/platform/symbian/mmp/scummvm_cruise.mmp.in
    backends/platform/symbian/mmp/scummvm_draci.mmp.in
    backends/platform/symbian/mmp/scummvm_drascula.mmp.in
    backends/platform/symbian/mmp/scummvm_gob.mmp.in
    backends/platform/symbian/mmp/scummvm_groovie.mmp.in
    backends/platform/symbian/mmp/scummvm_hugo.mmp.in
    backends/platform/symbian/mmp/scummvm_kyra.mmp.in
    backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
    backends/platform/symbian/mmp/scummvm_lure.mmp.in
    backends/platform/symbian/mmp/scummvm_m4.mmp.in
    backends/platform/symbian/mmp/scummvm_made.mmp.in
    backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
    backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
    backends/platform/symbian/mmp/scummvm_queen.mmp.in
    backends/platform/symbian/mmp/scummvm_saga.mmp.in
    backends/platform/symbian/mmp/scummvm_sci.mmp.in
    backends/platform/symbian/mmp/scummvm_scumm.mmp.in
    backends/platform/symbian/mmp/scummvm_sky.mmp.in
    backends/platform/symbian/mmp/scummvm_sword1.mmp.in
    backends/platform/symbian/mmp/scummvm_sword2.mmp.in
    backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
    backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
    backends/platform/symbian/mmp/scummvm_toon.mmp.in
    backends/platform/symbian/mmp/scummvm_touche.mmp.in
    backends/platform/symbian/mmp/scummvm_tucker.mmp.in
    backends/platform/symbian/src/portdefs.h
    backends/platform/symbian/src/vsnprintf.h
    backends/platform/wii/main.cpp
    backends/platform/wii/osystem.cpp
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_events.cpp
    backends/platform/wii/osystem_gfx.cpp
    backends/platform/wii/osystem_sfx.cpp
    backends/platform/wince/CEActionsPocket.cpp
    backends/platform/wince/CEActionsSmartphone.cpp
    backends/platform/wince/CEDevice.cpp
    backends/platform/wince/CEDevice.h
    backends/platform/wince/CEException.cpp
    backends/platform/wince/CELauncherDialog.cpp
    backends/platform/wince/CEgui/GUIElement.cpp
    backends/platform/wince/CEgui/ItemAction.cpp
    backends/platform/wince/CEgui/ItemSwitch.cpp
    backends/platform/wince/CEgui/Panel.cpp
    backends/platform/wince/CEgui/Panel.h
    backends/platform/wince/CEgui/PanelItem.h
    backends/platform/wince/CEgui/PanelKeyboard.cpp
    backends/platform/wince/CEgui/SDL_ImageResource.cpp
    backends/platform/wince/CEgui/SDL_ImageResource.h
    backends/platform/wince/CEgui/ToolbarHandler.cpp
    backends/platform/wince/CEgui/ToolbarHandler.h
    backends/platform/wince/CEkeys/EventsBuffer.cpp
    backends/platform/wince/CEkeys/EventsBuffer.h
    backends/platform/wince/Makefile
    backends/platform/wince/missing/io.h
    backends/platform/wince/missing/missing.cpp
    backends/platform/wince/missing/time.h
    backends/platform/wince/portdefs.h
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince-sdl.h
    backends/plugins/dynamic-plugin.h
    backends/plugins/elf/memory-manager.cpp
    backends/saves/default/default-saves.cpp
    backends/saves/posix/posix-saves.cpp
    backends/saves/psp/psp-saves.cpp
    backends/saves/savefile.cpp
    backends/timer/default/default-timer.cpp
    backends/timer/default/default-timer.h
    backends/timer/psp/timer.cpp
    backends/timer/sdl/sdl-timer.cpp
    backends/vkeybd/image-map.cpp
    backends/vkeybd/packs/vkeybd_default/vkeybd_default.xml
    backends/vkeybd/virtual-keyboard-gui.cpp
    backends/vkeybd/virtual-keyboard-parser.cpp
    backends/vkeybd/virtual-keyboard-parser.h
    backends/vkeybd/virtual-keyboard.cpp
    backends/vkeybd/virtual-keyboard.h
    base/commandLine.cpp
    base/commandLine.h
    base/internal_version.h
    base/internal_version.h.in
    base/main.cpp
    base/plugins.cpp
    base/plugins.h
    common/EventRecorder.cpp
    common/archive.cpp
    common/archive.h
    common/bufferedstream.h
    common/config-file.cpp
    common/config-file.h
    common/config-manager.cpp
    common/dcl.cpp
    common/debug.cpp
    common/endian.h
    common/error.cpp
    common/error.h
    common/events.h
    common/file.cpp
    common/file.h
    common/forbidden.h
    common/fs.cpp
    common/fs.h
    common/hashmap.h
    common/iff_container.h
    common/list.h
    common/macresman.cpp
    common/macresman.h
    common/md5.cpp
    common/md5.h
    common/memstream.h
    common/module.mk
    common/savefile.h
    common/scummsys.h
    common/stream.cpp
    common/stream.h
    common/substream.h
    common/system.cpp
    common/system.h
    common/textconsole.cpp
    common/textconsole.h
    common/translation.cpp
    common/translation.h
    common/unarj.cpp
    common/unarj.h
    common/unzip.cpp
    common/unzip.h
    common/util.cpp
    common/util.h
    common/xmlparser.cpp
    common/xmlparser.h
    common/zlib.cpp
    configure
    dists/android/AndroidManifest.xml
    dists/android/AndroidManifest.xml.in
    dists/android/res/layout/main.xml
    dists/engine-data/drascula.dat
    dists/iphone/Info.plist
    dists/irix/scummvm.spec
    dists/macosx/Info.plist
    dists/msvc10/readme.txt
    dists/msvc8/readme.txt
    dists/msvc9/readme.txt
    dists/redhat/scummvm-tools.spec
    dists/redhat/scummvm.spec
    dists/scummvm.rc
    dists/scummvm.rc.in
    dists/slackware/scummvm.SlackBuild
    dists/wii/meta.xml
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/detection.cpp
    engines/agi/detection_tables.h
    engines/agi/graphics.cpp
    engines/agi/inv.cpp
    engines/agi/keyboard.cpp
    engines/agi/loader_v2.cpp
    engines/agi/loader_v3.cpp
    engines/agi/lzw.cpp
    engines/agi/menu.cpp
    engines/agi/objects.cpp
    engines/agi/op_cmd.cpp
    engines/agi/op_test.cpp
    engines/agi/picture.cpp
    engines/agi/preagi.cpp
    engines/agi/preagi_mickey.cpp
    engines/agi/preagi_troll.cpp
    engines/agi/preagi_winnie.cpp
    engines/agi/predictive.cpp
    engines/agi/saveload.cpp
    engines/agi/sound.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agi/sound_midi.cpp
    engines/agi/sound_midi.h
    engines/agi/sound_sarien.cpp
    engines/agi/text.cpp
    engines/agi/wagparser.cpp
    engines/agi/words.cpp
    engines/agos/agos.cpp
    engines/agos/agos.h
    engines/agos/animation.cpp
    engines/agos/charset-fontdata.cpp
    engines/agos/debug.cpp
    engines/agos/debug.h
    engines/agos/detection.cpp
    engines/agos/draw.cpp
    engines/agos/event.cpp
    engines/agos/gfx.cpp
    engines/agos/icons.cpp
    engines/agos/items.cpp
    engines/agos/menus.cpp
    engines/agos/midi.cpp
    engines/agos/midi.h
    engines/agos/midiparser_s1d.cpp
    engines/agos/oracle.cpp
    engines/agos/res.cpp
    engines/agos/res_snd.cpp
    engines/agos/rooms.cpp
    engines/agos/saveload.cpp
    engines/agos/script.cpp
    engines/agos/script_dp.cpp
    engines/agos/script_ff.cpp
    engines/agos/script_pn.cpp
    engines/agos/script_s1.cpp
    engines/agos/script_s2.cpp
    engines/agos/sound.cpp
    engines/agos/string.cpp
    engines/agos/string_pn.cpp
    engines/agos/subroutine.cpp
    engines/agos/vga.cpp
    engines/agos/vga_e2.cpp
    engines/agos/vga_ff.cpp
    engines/agos/vga_ww.cpp
    engines/agos/window.cpp
    engines/cine/anim.cpp
    engines/cine/bg.cpp
    engines/cine/cine.cpp
    engines/cine/cine.h
    engines/cine/detection.cpp
    engines/cine/gfx.cpp
    engines/cine/msg.cpp
    engines/cine/pal.cpp
    engines/cine/part.cpp
    engines/cine/saveload.cpp
    engines/cine/saveload.h
    engines/cine/script_fw.cpp
    engines/cine/script_os.cpp
    engines/cine/sound.cpp
    engines/cine/sound.h
    engines/cine/texte.cpp
    engines/cine/various.cpp
    engines/cruise/actor.cpp
    engines/cruise/background.cpp
    engines/cruise/backgroundIncrust.cpp
    engines/cruise/cruise.cpp
    engines/cruise/cruise.h
    engines/cruise/cruise_main.cpp
    engines/cruise/ctp.cpp
    engines/cruise/ctp.h
    engines/cruise/dataLoader.cpp
    engines/cruise/detection.cpp
    engines/cruise/font.cpp
    engines/cruise/font.h
    engines/cruise/function.cpp
    engines/cruise/gfxModule.cpp
    engines/cruise/gfxModule.h
    engines/cruise/linker.cpp
    engines/cruise/mainDraw.cpp
    engines/cruise/menu.cpp
    engines/cruise/object.cpp
    engines/cruise/overlay.cpp
    engines/cruise/saveload.cpp
    engines/cruise/script.cpp
    engines/cruise/sound.cpp
    engines/dialogs.cpp
    engines/dialogs.h
    engines/draci/animation.cpp
    engines/draci/draci.cpp
    engines/draci/draci.h
    engines/draci/font.cpp
    engines/draci/font.h
    engines/draci/game.cpp
    engines/draci/game.h
    engines/draci/mouse.cpp
    engines/draci/music.cpp
    engines/draci/music.h
    engines/draci/screen.cpp
    engines/draci/screen.h
    engines/draci/script.cpp
    engines/draci/script.h
    engines/draci/sound.cpp
    engines/draci/sprite.cpp
    engines/draci/sprite.h
    engines/draci/surface.cpp
    engines/draci/surface.h
    engines/draci/walking.cpp
    engines/draci/walking.h
    engines/drascula/converse.cpp
    engines/drascula/drascula.cpp
    engines/drascula/graphics.cpp
    engines/drascula/objects.cpp
    engines/drascula/palette.cpp
    engines/drascula/rooms.cpp
    engines/drascula/saveload.cpp
    engines/drascula/sound.cpp
    engines/engine.cpp
    engines/engine.h
    engines/engines.mk
    engines/game.cpp
    engines/game.h
    engines/gob/databases.cpp
    engines/gob/dataio.h
    engines/gob/detection_tables.h
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/inter_v1.cpp
    engines/gob/inter_v2.cpp
    engines/gob/inter_v4.cpp
    engines/gob/inter_v5.cpp
    engines/gob/inter_v6.cpp
    engines/gob/resources.h
    engines/gob/save/savefile.cpp
    engines/gob/save/savefile.h
    engines/gob/save/saveload.cpp
    engines/gob/save/saveload.h
    engines/gob/save/saveload_inca2.cpp
    engines/gob/save/saveload_v3.cpp
    engines/gob/sound/adlib.cpp
    engines/gob/sound/bgatmosphere.cpp
    engines/gob/sound/bgatmosphere.h
    engines/gob/sound/cdrom.cpp
    engines/gob/sound/infogrames.cpp
    engines/gob/sound/sound.cpp
    engines/gob/sound/sounddesc.cpp
    engines/gob/sound/soundmixer.cpp
    engines/gob/surface.cpp
    engines/gob/surface.h
    engines/gob/totfile.h
    engines/gob/util.cpp
    engines/gob/video.cpp
    engines/gob/videoplayer.cpp
    engines/groovie/cursor.cpp
    engines/groovie/cursor.h
    engines/groovie/debug.cpp
    engines/groovie/font.cpp
    engines/groovie/graphics.cpp
    engines/groovie/groovie.cpp
    engines/groovie/groovie.h
    engines/groovie/music.cpp
    engines/groovie/music.h
    engines/groovie/player.cpp
    engines/groovie/resource.cpp
    engines/groovie/resource.h
    engines/groovie/roq.cpp
    engines/groovie/script.cpp
    engines/groovie/script.h
    engines/groovie/vdx.cpp
    engines/groovie/vdx.h
    engines/hugo/detection.cpp
    engines/hugo/display.cpp
    engines/hugo/display.h
    engines/hugo/file.cpp
    engines/hugo/file.h
    engines/hugo/file_v1d.cpp
    engines/hugo/file_v1w.cpp
    engines/hugo/file_v2d.cpp
    engines/hugo/file_v2w.cpp
    engines/hugo/file_v3d.cpp
    engines/hugo/hugo.cpp
    engines/hugo/hugo.h
    engines/hugo/intro.cpp
    engines/hugo/inventory.cpp
    engines/hugo/module.mk
    engines/hugo/mouse.cpp
    engines/hugo/object.cpp
    engines/hugo/object_v1d.cpp
    engines/hugo/object_v1w.cpp
    engines/hugo/object_v2d.cpp
    engines/hugo/object_v3d.cpp
    engines/hugo/parser.cpp
    engines/hugo/parser.h
    engines/hugo/parser_v1d.cpp
    engines/hugo/parser_v1w.cpp
    engines/hugo/parser_v2d.cpp
    engines/hugo/parser_v3d.cpp
    engines/hugo/route.cpp
    engines/hugo/schedule.cpp
    engines/hugo/schedule.h
    engines/hugo/sound.cpp
    engines/hugo/sound.h
    engines/hugo/util.cpp
    engines/hugo/util.h
    engines/kyra/animator_hof.cpp
    engines/kyra/animator_lok.cpp
    engines/kyra/animator_mr.cpp
    engines/kyra/animator_tim.cpp
    engines/kyra/animator_v2.cpp
    engines/kyra/debugger.cpp
    engines/kyra/detection.cpp
    engines/kyra/gui.cpp
    engines/kyra/gui_hof.cpp
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_lok.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_mr.cpp
    engines/kyra/gui_mr.h
    engines/kyra/gui_v2.cpp
    engines/kyra/items_hof.cpp
    engines/kyra/items_lok.cpp
    engines/kyra/items_mr.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_hof.h
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_lok.h
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_mr.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/kyra_v2.cpp
    engines/kyra/kyra_v2.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/resource.cpp
    engines/kyra/resource.h
    engines/kyra/resource_intern.cpp
    engines/kyra/saveload.cpp
    engines/kyra/saveload_hof.cpp
    engines/kyra/saveload_lok.cpp
    engines/kyra/saveload_lol.cpp
    engines/kyra/scene_hof.cpp
    engines/kyra/scene_lok.cpp
    engines/kyra/scene_lol.cpp
    engines/kyra/scene_mr.cpp
    engines/kyra/scene_v1.cpp
    engines/kyra/scene_v2.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen_hof.cpp
    engines/kyra/screen_lok.cpp
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_mr.cpp
    engines/kyra/script.cpp
    engines/kyra/script.h
    engines/kyra/script_hof.cpp
    engines/kyra/script_lok.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_mr.cpp
    engines/kyra/script_tim.cpp
    engines/kyra/script_tim.h
    engines/kyra/script_v1.cpp
    engines/kyra/script_v2.cpp
    engines/kyra/seqplayer.cpp
    engines/kyra/sequences_hof.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sequences_v2.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_amiga.cpp
    engines/kyra/sound_intern.h
    engines/kyra/sound_lok.cpp
    engines/kyra/sound_lol.cpp
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_towns.cpp
    engines/kyra/sprites.cpp
    engines/kyra/staticres.cpp
    engines/kyra/text.cpp
    engines/kyra/text_hof.cpp
    engines/kyra/text_lok.cpp
    engines/kyra/text_lol.cpp
    engines/kyra/text_lol.h
    engines/kyra/text_mr.cpp
    engines/kyra/timer.cpp
    engines/kyra/timer_lok.cpp
    engines/kyra/timer_lol.cpp
    engines/kyra/timer_mr.cpp
    engines/kyra/vqa.cpp
    engines/kyra/wsamovie.cpp
    engines/kyra/wsamovie.h
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/data/archive.h
    engines/lastexpress/data/background.cpp
    engines/lastexpress/data/font.cpp
    engines/lastexpress/data/font.h
    engines/lastexpress/data/scene.cpp
    engines/lastexpress/data/scene.h
    engines/lastexpress/data/sequence.cpp
    engines/lastexpress/data/sequence.h
    engines/lastexpress/data/snd.cpp
    engines/lastexpress/data/snd.h
    engines/lastexpress/data/subtitle.cpp
    engines/lastexpress/entities/entity.h
    engines/lastexpress/game/state.h
    engines/lastexpress/graphics.cpp
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/resource.cpp
    engines/lure/debugger.cpp
    engines/lure/decode.cpp
    engines/lure/disk.h
    engines/lure/fights.cpp
    engines/lure/hotspots.cpp
    engines/lure/hotspots.h
    engines/lure/lure.cpp
    engines/lure/lure.h
    engines/lure/luredefs.h
    engines/lure/memory.cpp
    engines/lure/menu.cpp
    engines/lure/palette.cpp
    engines/lure/res.cpp
    engines/lure/res_struct.cpp
    engines/lure/res_struct.h
    engines/lure/room.cpp
    engines/lure/screen.cpp
    engines/lure/sound.cpp
    engines/lure/sound.h
    engines/lure/surface.cpp
    engines/lure/surface.h
    engines/m4/actor.cpp
    engines/m4/animation.cpp
    engines/m4/assets.h
    engines/m4/compression.cpp
    engines/m4/console.cpp
    engines/m4/converse.cpp
    engines/m4/dialogs.cpp
    engines/m4/events.cpp
    engines/m4/font.cpp
    engines/m4/font.h
    engines/m4/globals.cpp
    engines/m4/graphics.cpp
    engines/m4/graphics.h
    engines/m4/gui.cpp
    engines/m4/m4.cpp
    engines/m4/m4.h
    engines/m4/m4_menus.cpp
    engines/m4/m4_scene.cpp
    engines/m4/m4_scene.h
    engines/m4/m4_views.cpp
    engines/m4/m4_views.h
    engines/m4/mads_anim.cpp
    engines/m4/mads_logic.cpp
    engines/m4/mads_menus.cpp
    engines/m4/mads_scene.cpp
    engines/m4/mads_views.cpp
    engines/m4/mads_views.h
    engines/m4/midi.cpp
    engines/m4/midi.h
    engines/m4/rails.cpp
    engines/m4/resource.cpp
    engines/m4/scene.cpp
    engines/m4/script.cpp
    engines/m4/sound.cpp
    engines/m4/sprite.cpp
    engines/m4/woodscript.cpp
    engines/m4/woodscript.h
    engines/m4/ws_sequence.cpp
    engines/made/database.cpp
    engines/made/graphics.cpp
    engines/made/made.cpp
    engines/made/music.cpp
    engines/made/music.h
    engines/made/pmvplayer.cpp
    engines/made/redreader.cpp
    engines/made/resource.cpp
    engines/made/resource.h
    engines/made/screen.cpp
    engines/made/script.h
    engines/made/scriptfuncs.cpp
    engines/made/scriptfuncs.h
    engines/metaengine.h
    engines/mohawk/bitmap.cpp
    engines/mohawk/bitmap.h
    engines/mohawk/console.cpp
    engines/mohawk/console.h
    engines/mohawk/cstime.cpp
    engines/mohawk/cstime_cases.cpp
    engines/mohawk/cstime_game.cpp
    engines/mohawk/cstime_ui.cpp
    engines/mohawk/cstime_ui.h
    engines/mohawk/cstime_view.cpp
    engines/mohawk/cursors.cpp
    engines/mohawk/cursors.h
    engines/mohawk/detection.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/dialogs.cpp
    engines/mohawk/dialogs.h
    engines/mohawk/graphics.cpp
    engines/mohawk/graphics.h
    engines/mohawk/installer_archive.cpp
    engines/mohawk/installer_archive.h
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h
    engines/mohawk/module.mk
    engines/mohawk/mohawk.cpp
    engines/mohawk/mohawk.h
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_areas.cpp
    engines/mohawk/myst_areas.h
    engines/mohawk/myst_scripts.cpp
    engines/mohawk/myst_stacks/channelwood.cpp
    engines/mohawk/myst_stacks/credits.cpp
    engines/mohawk/myst_stacks/dni.cpp
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/mechanical.h
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/preview.cpp
    engines/mohawk/myst_stacks/selenitic.cpp
    engines/mohawk/myst_stacks/slides.cpp
    engines/mohawk/myst_stacks/stoneship.cpp
    engines/mohawk/myst_state.cpp
    engines/mohawk/myst_state.h
    engines/mohawk/resource.cpp
    engines/mohawk/resource.h
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_external.cpp
    engines/mohawk/riven_external.h
    engines/mohawk/riven_saveload.cpp
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/riven_scripts.h
    engines/mohawk/riven_vars.cpp
    engines/mohawk/sound.cpp
    engines/mohawk/sound.h
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/mohawk/view.cpp
    engines/parallaction/balloons.cpp
    engines/parallaction/callables_br.cpp
    engines/parallaction/detection.cpp
    engines/parallaction/dialogue.cpp
    engines/parallaction/disk.cpp
    engines/parallaction/disk.h
    engines/parallaction/disk_br.cpp
    engines/parallaction/disk_ns.cpp
    engines/parallaction/exec_br.cpp
    engines/parallaction/exec_ns.cpp
    engines/parallaction/font.cpp
    engines/parallaction/gfxbase.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/gui.cpp
    engines/parallaction/gui_br.cpp
    engines/parallaction/gui_ns.cpp
    engines/parallaction/input.cpp
    engines/parallaction/inventory.cpp
    engines/parallaction/objects.cpp
    engines/parallaction/parallaction.cpp
    engines/parallaction/parallaction.h
    engines/parallaction/parallaction_br.cpp
    engines/parallaction/parallaction_ns.cpp
    engines/parallaction/parser.cpp
    engines/parallaction/parser_br.cpp
    engines/parallaction/parser_ns.cpp
    engines/parallaction/saveload.cpp
    engines/parallaction/sound.h
    engines/parallaction/sound_br.cpp
    engines/parallaction/sound_ns.cpp
    engines/pegasus/graphics.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/sound.cpp
    engines/pegasus/video.cpp
    engines/queen/command.cpp
    engines/queen/cutaway.cpp
    engines/queen/display.cpp
    engines/queen/display.h
    engines/queen/graphics.cpp
    engines/queen/input.cpp
    engines/queen/journal.cpp
    engines/queen/logic.cpp
    engines/queen/midiadlib.cpp
    engines/queen/music.cpp
    engines/queen/music.h
    engines/queen/queen.cpp
    engines/queen/queen.h
    engines/queen/resource.cpp
    engines/queen/sound.cpp
    engines/queen/sound.h
    engines/queen/talk.cpp
    engines/queen/walk.cpp
    engines/saga/detection.cpp
    engines/saga/font.cpp
    engines/saga/gfx.cpp
    engines/saga/gfx.h
    engines/saga/image.cpp
    engines/saga/interface.cpp
    engines/saga/interface.h
    engines/saga/introproc_saga2.cpp
    engines/saga/music.cpp
    engines/saga/music.h
    engines/saga/render.cpp
    engines/saga/resource_hrs.cpp
    engines/saga/resource_rsc.cpp
    engines/saga/saga.cpp
    engines/saga/saga.h
    engines/saga/saveload.cpp
    engines/saga/script.cpp
    engines/saga/shorten.cpp
    engines/saga/sound.cpp
    engines/savestate.cpp
    engines/savestate.h
    engines/sci/console.cpp
    engines/sci/console.h
    engines/sci/debug.h
    engines/sci/decompressor.cpp
    engines/sci/decompressor.h
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/gc.cpp
    engines/sci/engine/gc.h
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kevent.cpp
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kmath.cpp
    engines/sci/engine/kmenu.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/kmovement.cpp
    engines/sci/engine/kparse.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/ksound.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/segment.cpp
    engines/sci/engine/segment.h
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/static_selectors.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/vm_types.cpp
    engines/sci/engine/vm_types.h
    engines/sci/engine/workarounds.cpp
    engines/sci/engine/workarounds.h
    engines/sci/event.cpp
    engines/sci/event.h
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/animate.h
    engines/sci/graphics/compare.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/fontsjis.h
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/helpers.h
    engines/sci/graphics/maciconbar.cpp
    engines/sci/graphics/maciconbar.h
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/paint.cpp
    engines/sci/graphics/paint.h
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/paint16.h
    engines/sci/graphics/paint32.cpp
    engines/sci/graphics/paint32.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/portrait.cpp
    engines/sci/graphics/ports.cpp
    engines/sci/graphics/ports.h
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/screen.h
    engines/sci/graphics/text16.cpp
    engines/sci/graphics/transitions.cpp
    engines/sci/graphics/transitions.h
    engines/sci/graphics/view.cpp
    engines/sci/graphics/view.h
    engines/sci/parser/grammar.cpp
    engines/sci/parser/said.cpp
    engines/sci/parser/vocabulary.cpp
    engines/sci/parser/vocabulary.h
    engines/sci/resource.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp
    engines/sci/resource_intern.h
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/audio.cpp
    engines/sci/sound/drivers/adlib.cpp
    engines/sci/sound/drivers/amigamac.cpp
    engines/sci/sound/drivers/cms.cpp
    engines/sci/sound/drivers/fb01.cpp
    engines/sci/sound/drivers/midi.cpp
    engines/sci/sound/drivers/mididriver.h
    engines/sci/sound/drivers/pcjr.cpp
    engines/sci/sound/music.cpp
    engines/sci/sound/soundcmd.cpp
    engines/sci/util.cpp
    engines/sci/util.h
    engines/sci/video/robot_decoder.cpp
    engines/sci/video/robot_decoder.h
    engines/sci/video/seq_decoder.cpp
    engines/sci/video/seq_decoder.h
    engines/scumm/actor.cpp
    engines/scumm/actor.h
    engines/scumm/akos.cpp
    engines/scumm/charset.cpp
    engines/scumm/costume.cpp
    engines/scumm/cursor.cpp
    engines/scumm/debugger.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/dialogs.h
    engines/scumm/file_nes.cpp
    engines/scumm/gfx.cpp
    engines/scumm/gfx.h
    engines/scumm/gfxARM.s
    engines/scumm/gfx_towns.cpp
    engines/scumm/he/animation_he.cpp
    engines/scumm/he/cup_player_he.cpp
    engines/scumm/he/floodfill_he.cpp
    engines/scumm/he/intern_he.h
    engines/scumm/he/logic_he.cpp
    engines/scumm/he/logic_he.h
    engines/scumm/he/palette_he.cpp
    engines/scumm/he/resource_he.cpp
    engines/scumm/he/resource_he.h
    engines/scumm/he/script_v100he.cpp
    engines/scumm/he/script_v60he.cpp
    engines/scumm/he/script_v71he.cpp
    engines/scumm/he/script_v72he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/he/sound_he.cpp
    engines/scumm/he/sprite_he.cpp
    engines/scumm/he/wiz_he.cpp
    engines/scumm/help.cpp
    engines/scumm/imuse/imuse.cpp
    engines/scumm/imuse/imuse.h
    engines/scumm/imuse/imuse_internal.h
    engines/scumm/imuse/imuse_part.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/imuse/sysex_scumm.cpp
    engines/scumm/imuse_digi/dimuse.cpp
    engines/scumm/imuse_digi/dimuse.h
    engines/scumm/imuse_digi/dimuse_bndmgr.cpp
    engines/scumm/imuse_digi/dimuse_bndmgr.h
    engines/scumm/imuse_digi/dimuse_codecs.cpp
    engines/scumm/imuse_digi/dimuse_sndmgr.cpp
    engines/scumm/insane/insane.cpp
    engines/scumm/insane/insane_iact.cpp
    engines/scumm/midiparser_ro.cpp
    engines/scumm/nut_renderer.cpp
    engines/scumm/object.cpp
    engines/scumm/palette.cpp
    engines/scumm/player_mod.h
    engines/scumm/player_nes.h
    engines/scumm/player_pce.cpp
    engines/scumm/player_pce.h
    engines/scumm/player_sid.cpp
    engines/scumm/player_towns.cpp
    engines/scumm/player_v4a.h
    engines/scumm/proc3ARM.s
    engines/scumm/resource.cpp
    engines/scumm/resource_v3.cpp
    engines/scumm/resource_v4.cpp
    engines/scumm/room.cpp
    engines/scumm/saveload.cpp
    engines/scumm/saveload.h
    engines/scumm/script.cpp
    engines/scumm/script.h
    engines/scumm/script_v5.cpp
    engines/scumm/script_v6.cpp
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/scumm_v3.h
    engines/scumm/scumm_v4.h
    engines/scumm/smush/channel.cpp
    engines/scumm/smush/channel.h
    engines/scumm/smush/codec37.cpp
    engines/scumm/smush/codec47.cpp
    engines/scumm/smush/imuse_channel.cpp
    engines/scumm/smush/saud_channel.cpp
    engines/scumm/smush/smush_mixer.h
    engines/scumm/smush/smush_player.cpp
    engines/scumm/sound.cpp
    engines/scumm/util.cpp
    engines/scumm/verbs.cpp
    engines/sky/autoroute.cpp
    engines/sky/compact.cpp
    engines/sky/compact.h
    engines/sky/control.cpp
    engines/sky/control.h
    engines/sky/debug.cpp
    engines/sky/detection.cpp
    engines/sky/disk.cpp
    engines/sky/disk.h
    engines/sky/intro.cpp
    engines/sky/logic.cpp
    engines/sky/mouse.cpp
    engines/sky/music/adlibchannel.cpp
    engines/sky/music/gmchannel.cpp
    engines/sky/music/gmmusic.cpp
    engines/sky/music/mt32music.cpp
    engines/sky/music/musicbase.cpp
    engines/sky/screen.cpp
    engines/sky/screen.h
    engines/sky/sky.cpp
    engines/sky/sky.h
    engines/sky/skydefs.h
    engines/sky/sound.cpp
    engines/sky/struc.h
    engines/sky/text.cpp
    engines/sky/text.h
    engines/sword1/animation.cpp
    engines/sword1/control.cpp
    engines/sword1/control.h
    engines/sword1/detection.cpp
    engines/sword1/eventman.cpp
    engines/sword1/logic.cpp
    engines/sword1/memman.cpp
    engines/sword1/menu.cpp
    engines/sword1/mouse.cpp
    engines/sword1/mouse.h
    engines/sword1/music.cpp
    engines/sword1/objectman.cpp
    engines/sword1/resman.cpp
    engines/sword1/router.cpp
    engines/sword1/screen.cpp
    engines/sword1/sound.cpp
    engines/sword1/sound.h
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h
    engines/sword1/text.cpp
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    engines/sword2/controls.cpp
    engines/sword2/events.cpp
    engines/sword2/function.cpp
    engines/sword2/header.h
    engines/sword2/icons.cpp
    engines/sword2/interpreter.cpp
    engines/sword2/layers.cpp
    engines/sword2/logic.cpp
    engines/sword2/logic.h
    engines/sword2/maketext.cpp
    engines/sword2/maketext.h
    engines/sword2/memory.cpp
    engines/sword2/mouse.cpp
    engines/sword2/music.cpp
    engines/sword2/object.h
    engines/sword2/palette.cpp
    engines/sword2/protocol.cpp
    engines/sword2/render.cpp
    engines/sword2/resman.cpp
    engines/sword2/resman.h
    engines/sword2/router.cpp
    engines/sword2/router.h
    engines/sword2/saveload.cpp
    engines/sword2/screen.cpp
    engines/sword2/screen.h
    engines/sword2/scroll.cpp
    engines/sword2/sound.cpp
    engines/sword2/sound.h
    engines/sword2/speech.cpp
    engines/sword2/sprite.cpp
    engines/sword2/startup.cpp
    engines/sword2/sword2.cpp
    engines/sword2/sync.cpp
    engines/sword25/detection.cpp
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/fmv/theora_decoder.h
    engines/sword25/gfx/graphicengine.cpp
    engines/sword25/gfx/graphicengine_script.cpp
    engines/sword25/gfx/image/art.cpp
    engines/sword25/gfx/image/art.h
    engines/sword25/gfx/image/image.h
    engines/sword25/gfx/image/pngloader.cpp
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/image/renderedimage.h
    engines/sword25/gfx/image/swimage.cpp
    engines/sword25/gfx/image/vectorimage.cpp
    engines/sword25/gfx/image/vectorimagerenderer.cpp
    engines/sword25/gfx/screenshot.cpp
    engines/sword25/gfx/text.cpp
    engines/sword25/kernel/filesystemutil.cpp
    engines/sword25/kernel/inputpersistenceblock.cpp
    engines/sword25/kernel/kernel.cpp
    engines/sword25/kernel/kernel.h
    engines/sword25/kernel/objectregistry.h
    engines/sword25/kernel/persistenceservice.cpp
    engines/sword25/math/geometry_script.cpp
    engines/sword25/script/luabindhelper.cpp
    engines/sword25/script/luabindhelper.h
    engines/sword25/script/luacallback.cpp
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/sword25.cpp
    engines/sword25/sword25.h
    engines/sword25/util/lua/lmathlib.cpp
    engines/sword25/util/pluto/pdep/lzio.h
    engines/sword25/util/pluto/pdep/pdep.h
    engines/teenagent/actor.cpp
    engines/teenagent/animation.cpp
    engines/teenagent/callbacks.cpp
    engines/teenagent/console.h
    engines/teenagent/font.cpp
    engines/teenagent/font.h
    engines/teenagent/inventory.cpp
    engines/teenagent/music.cpp
    engines/teenagent/resources.cpp
    engines/teenagent/scene.cpp
    engines/teenagent/scene.h
    engines/teenagent/segment.cpp
    engines/teenagent/surface.cpp
    engines/teenagent/surface.h
    engines/teenagent/teenagent.cpp
    engines/testbed/detection.cpp
    engines/testbed/events.cpp
    engines/testbed/graphics.cpp
    engines/testbed/midi.cpp
    engines/testbed/savegame.cpp
    engines/testbed/sound.cpp
    engines/testbed/testbed.cpp
    engines/testbed/testbed.h
    engines/testbed/testsuite.h
    engines/tinsel/actors.cpp
    engines/tinsel/actors.h
    engines/tinsel/anim.cpp
    engines/tinsel/background.cpp
    engines/tinsel/background.h
    engines/tinsel/bg.cpp
    engines/tinsel/bmv.cpp
    engines/tinsel/bmv.h
    engines/tinsel/detection.cpp
    engines/tinsel/dialogs.cpp
    engines/tinsel/dialogs.h
    engines/tinsel/drives.cpp
    engines/tinsel/dw.h
    engines/tinsel/faders.cpp
    engines/tinsel/faders.h
    engines/tinsel/font.cpp
    engines/tinsel/graphics.cpp
    engines/tinsel/graphics.h
    engines/tinsel/handle.cpp
    engines/tinsel/mareels.cpp
    engines/tinsel/module.mk
    engines/tinsel/move.cpp
    engines/tinsel/music.cpp
    engines/tinsel/music.h
    engines/tinsel/object.cpp
    engines/tinsel/object.h
    engines/tinsel/palette.cpp
    engines/tinsel/palette.h
    engines/tinsel/pcode.cpp
    engines/tinsel/pcode.h
    engines/tinsel/pdisplay.cpp
    engines/tinsel/pid.h
    engines/tinsel/polygons.cpp
    engines/tinsel/polygons.h
    engines/tinsel/rince.cpp
    engines/tinsel/rince.h
    engines/tinsel/saveload.cpp
    engines/tinsel/savescn.cpp
    engines/tinsel/scene.cpp
    engines/tinsel/sched.cpp
    engines/tinsel/scn.cpp
    engines/tinsel/sound.cpp
    engines/tinsel/strres.cpp
    engines/tinsel/sysvar.cpp
    engines/tinsel/sysvar.h
    engines/tinsel/text.cpp
    engines/tinsel/text.h
    engines/tinsel/timers.cpp
    engines/tinsel/timers.h
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinlib.h
    engines/tinsel/tinsel.cpp
    engines/tinsel/tinsel.h
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/audio.cpp
    engines/toon/audio.h
    engines/toon/character.cpp
    engines/toon/character.h
    engines/toon/conversation.cpp
    engines/toon/conversation.h
    engines/toon/detection.cpp
    engines/toon/drew.cpp
    engines/toon/drew.h
    engines/toon/flux.cpp
    engines/toon/flux.h
    engines/toon/font.cpp
    engines/toon/hotspot.cpp
    engines/toon/movie.cpp
    engines/toon/movie.h
    engines/toon/path.cpp
    engines/toon/path.h
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/resource.cpp
    engines/toon/resource.h
    engines/toon/script.cpp
    engines/toon/script.h
    engines/toon/script_func.cpp
    engines/toon/state.cpp
    engines/toon/state.h
    engines/toon/text.cpp
    engines/toon/tools.cpp
    engines/toon/tools.h
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/menu.cpp
    engines/touche/midi.cpp
    engines/touche/midi.h
    engines/touche/resource.cpp
    engines/touche/saveload.cpp
    engines/touche/staticres.cpp
    engines/touche/touche.cpp
    engines/tucker/detection.cpp
    engines/tucker/locations.cpp
    engines/tucker/resource.cpp
    engines/tucker/saveload.cpp
    engines/tucker/sequences.cpp
    engines/tucker/tucker.cpp
    engines/tucker/tucker.h
    graphics/VectorRenderer.cpp
    graphics/VectorRenderer.h
    graphics/VectorRendererSpec.cpp
    graphics/conversion.cpp
    graphics/conversion.h
    graphics/dither.cpp
    graphics/font.cpp
    graphics/font.h
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/fonts/scummfont.cpp
    graphics/fonts/winfont.cpp
    graphics/fonts/winfont.h
    graphics/iff.cpp
    graphics/iff.h
    graphics/imagedec.cpp
    graphics/imagedec.h
    graphics/jpeg.cpp
    graphics/module.mk
    graphics/palette.h
    graphics/pict.cpp
    graphics/pict.h
    graphics/png.cpp
    graphics/png.h
    graphics/scaler/2xsai.cpp
    graphics/scaler/scale2x.cpp
    graphics/scaler/scale3x.cpp
    graphics/scaler/scalebit.cpp
    graphics/scaler/thumbnail_intern.cpp
    graphics/sjis.cpp
    graphics/surface.cpp
    graphics/surface.h
    graphics/thumbnail.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeEval.cpp
    gui/ThemeEval.h
    gui/ThemeLayout.cpp
    gui/ThemeLayout.h
    gui/ThemeParser.cpp
    gui/Tooltip.cpp
    gui/Tooltip.h
    gui/about.cpp
    gui/about.h
    gui/browser.cpp
    gui/browser.h
    gui/chooser.cpp
    gui/chooser.h
    gui/console.cpp
    gui/credits.h
    gui/debugger.cpp
    gui/dialog.cpp
    gui/dialog.h
    gui/error.cpp
    gui/error.h
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/launcher.cpp
    gui/launcher.h
    gui/massadd.cpp
    gui/massadd.h
    gui/message.cpp
    gui/message.h
    gui/object.cpp
    gui/object.h
    gui/options.cpp
    gui/options.h
    gui/saveload.h
    gui/themebrowser.h
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/classic_gfx.stx
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    gui/widgets/editable.cpp
    gui/widgets/editable.h
    gui/widgets/edittext.cpp
    gui/widgets/edittext.h
    gui/widgets/list.cpp
    gui/widgets/popup.cpp
    gui/widgets/scrollbar.cpp
    gui/widgets/tab.cpp
    icons/scummvm.icns
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/module.mk
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/uk_UA.po
    ports.mk
    rules.mk
    test/audio/helper.h
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/codecs/cdtoons.cpp
    video/codecs/cinepak.cpp
    video/codecs/cinepak.h
    video/codecs/indeo3.cpp
    video/codecs/mjpeg.cpp
    video/codecs/mjpeg.h
    video/codecs/msrle.cpp
    video/codecs/msvideo1.cpp
    video/codecs/qdm2.cpp
    video/codecs/qdm2.h
    video/codecs/qtrle.cpp
    video/codecs/rpza.cpp
    video/codecs/smc.cpp
    video/codecs/truemotion1.cpp
    video/coktel_decoder.cpp
    video/coktel_decoder.h
    video/dxa_decoder.cpp
    video/dxa_decoder.h
    video/flic_decoder.cpp
    video/flic_decoder.h
    video/mpeg_player.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp
    video/smk_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h



diff --cc configure
index 75bb726,e4167f3..1871253
--- a/configure
+++ b/configure
@@@ -95,9 -95,11 +95,12 @@@ add_engine lastexpress "The Last Expres
  add_engine lure "Lure of the Temptress" yes
  add_engine m4 "M4/MADS" no
  add_engine made "MADE" yes
- add_engine mohawk "Mohawk" no
+ add_engine mohawk "Mohawk" yes "cstime myst riven"
+ add_engine cstime "Where in Time is Carmen Sandiego?" no
+ add_engine riven "Riven: The Sequel to Myst" no
+ add_engine myst "Myst" no
  add_engine parallaction "Parallaction" yes
 +add_engine pegasus "The Journeyman Project: Pegasus Prime" no
  add_engine queen "Flight of the Amazon Queen" yes
  add_engine saga "SAGA" yes "ihnm saga2"
  add_engine ihnm "IHNM" yes
diff --cc engines/pegasus/graphics.cpp
index de3fe06,0000000..2042b8f
mode 100644,000000..100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@@ -1,249 -1,0 +1,250 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 + 
 +#include "pegasus/graphics.h"
 +
 +#include "common/endian.h"
 +#include "common/file.h"
++#include "common/textconsole.h"
 +#include "engines/util.h"
 +#include "graphics/cursorman.h"
 +
 +namespace Pegasus {
 +	
 +GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 +	initGraphics(640, 480, true, NULL);
 +	
 +	_pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
 +
 +	for (int i = 0; i < kImageCacheSize; i++)
 +		_cache[i].surface = 0;
 +}
 +	
 +GraphicsManager::~GraphicsManager() {
 +	delete _pictDecoder;
 +
 +	for (int i = 0; i < kImageCacheSize; i++) {
 +		if (_cache[i].surface) {
 +			_cache[i].surface->free();
 +			delete _cache[i].surface;
 +		}
 +	}
 +}
 +
 +Graphics::Surface *GraphicsManager::decodeImage(const Common::String &filename) {
 +	int imageSlot = getImageSlot(filename);
 +
 +	if (_cache[imageSlot].surface)
 +		return _cache[imageSlot].surface;
 +
 +	Common::File file;
 +	if (!file.open(filename))
 +		error("Could not open \'%s\'", filename.c_str());
 +
 +	byte palette[256 * 3];
 +	Graphics::Surface *image = _pictDecoder->decodeImage(&file, palette);
 +
 +	// For <= 8bpp, we need to convert
- 	if (image->bytesPerPixel == 1) {
++	if (image->format.bytesPerPixel == 1) {
 +		Graphics::PixelFormat format = _vm->_system->getScreenFormat();
 +		Graphics::Surface *output = new Graphics::Surface();
- 		output->create(image->w, image->h, format.bytesPerPixel);
++		output->create(image->w, image->h, format);
 +
 +		for (uint16 y = 0; y < image->h; y++) {
 +			for (uint16 x = 0; x < image->w; x++) {
 +				byte c = *((byte *)image->getBasePtr(x, y));
 +				byte r = palette[c * 3];
 +				byte g = palette[c * 3 + 1];
 +				byte b = palette[c * 3 + 2];
 +
 +				if (format.bytesPerPixel == 2) {
 +					uint16 color = format.RGBToColor(r, g, b);
 +					memcpy(output->getBasePtr(x, y), &color, 2);
 +				} else if (format.bytesPerPixel == 4) {
 +					uint32 color = format.RGBToColor(r, g, b);
 +					memcpy(output->getBasePtr(x, y), &color, 4);
 +				}
 +			}
 +		}
 +
 +		image->free();
 +		delete image;
 +		image = output;
 +	}
 +
 +	_cache[imageSlot].surface = image;
 +	return image;
 +}
 +
 +void GraphicsManager::drawPict(Common::String filename, int x, int y, bool updateScreen) {
 +	Graphics::Surface *surface = decodeImage(filename);
 +	
 +	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, x, y, surface->w, surface->h);
 +
 +	if (updateScreen)
 +		_vm->_system->updateScreen();
 +}
 +
 +void GraphicsManager::drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen) {
 +	if (_vm->_system->getScreenFormat().bytesPerPixel == 2)
 +		transparency &= 0xffff;
 +
 +	Graphics::Surface *surface = decodeImage(filename);
 +	Graphics::Surface *screen = _vm->_system->lockScreen();
 +
 +	for (uint16 i = 0; i < surface->h; i++) {
 +		for (uint16 j = 0; j < surface->w; j++) {
 +			if (_vm->_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = *((uint16 *)surface->getBasePtr(j, i));
 +				if (color != transparency)
 +					memcpy(screen->getBasePtr(j + x, i + y), &color, 2);
 +			} else if (_vm->_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = *((uint32 *)surface->getBasePtr(j, i));
 +				if (color != transparency)
 +					memcpy(screen->getBasePtr(j + x, i + y), &color, 4);
 +			}
 +		}
 +	}
 +
 +	_vm->_system->unlockScreen();
 +
 +	if (updateScreen)
 +		_vm->_system->updateScreen();
 +}
 +
 +uint32 GraphicsManager::getColor(byte r, byte g, byte b) {
 +	return _vm->_system->getScreenFormat().RGBToColor(r, g, b);
 +}
 +
 +void GraphicsManager::setCursor(uint16 cursor) {
- 	Common::SeekableReadStream *cicnStream = _vm->_resFork->getResource(MKID_BE('cicn'), cursor);
++	Common::SeekableReadStream *cicnStream = _vm->_resFork->getResource(MKTAG('c', 'i', 'c', 'n'), cursor);
 +	
 +	// PixMap section
 +	Graphics::PictDecoder::PixMap pixMap = _pictDecoder->readPixMap(cicnStream);
 +	
 +	// Mask section
 +	cicnStream->readUint32BE(); // mask baseAddr
 +	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
 +	cicnStream->skip(3 * 2); // mask rect
 +	/* uint16 maskHeight = */ cicnStream->readUint16BE();
 +
 +	// Bitmap section
 +	cicnStream->readUint32BE(); // baseAddr
 +	uint16 rowBytes = cicnStream->readUint16BE();
 +	cicnStream->readUint16BE(); // top
 +	cicnStream->readUint16BE(); // left
 +	uint16 height = cicnStream->readUint16BE(); // bottom
 +	cicnStream->readUint16BE(); // right
 +	
 +	// Data section
 +	cicnStream->readUint32BE(); // icon handle
 +	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
 +	cicnStream->skip(rowBytes * height);
 +	
 +	// Palette section
 +	cicnStream->readUint32BE(); // always 0
 +	cicnStream->readUint16BE(); // always 0
 +	uint16 colorCount = cicnStream->readUint16BE() + 1;
 +	
 +	byte *colors = new byte[256 * 3];;
 +	for (uint16 i = 0; i < colorCount; i++) {
 +		cicnStream->readUint16BE();
 +		colors[i * 3] = cicnStream->readUint16BE() >> 8;
 +		colors[i * 3 + 1] = cicnStream->readUint16BE() >> 8;
 +		colors[i * 3 + 2] = cicnStream->readUint16BE() >> 8;
 +	}
 +	
 +	// PixMap data
 +	byte *data = new byte[pixMap.rowBytes * pixMap.bounds.height()];
 +	cicnStream->read(data, pixMap.rowBytes * pixMap.bounds.height());
 +	delete cicnStream;
 +	
 +	// Now to go get the hotspots
 +	Common::SeekableReadStream *cursStream = NULL;
 +	
 +	if (cursor >= kMainCursor && cursor <= kGrabbingHand)
- 		cursStream = _vm->_resFork->getResource(MKID_BE('Curs'), kMainCursor);
++		cursStream = _vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), kMainCursor);
 +	else // if (cursor == kTargetingReticle1 || cursor == kTargetingReticle2)
- 		cursStream = _vm->_resFork->getResource(MKID_BE('Curs'), kTargetingReticle1);
++		cursStream = _vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), kTargetingReticle1);
 +
 +	// Go through the stream until we find the right cursor hotspot
 +	uint16 x = 0, y = 0;
 +	uint16 numHotspots = cursStream->readUint16BE();
 +	
 +	for (uint16 i = 0; i < numHotspots; i++) {
 +		uint16 res = cursStream->readUint16BE();
 +		uint16 tempX = cursStream->readUint16BE();
 +		uint16 tempY = cursStream->readUint16BE();
 +		
 +		if (res == cursor) {
 +			x = tempX;
 +			y = tempY;
 +			break;
 +		}
 +	}
 +	
 +	// We have the bitmap and the hotspot, let's do this!
 +	CursorMan.replaceCursorPalette(colors, 0, colorCount);
 +	CursorMan.replaceCursor(data, pixMap.rowBytes, pixMap.bounds.height(), x, y, 0);
 +	CursorMan.showMouse(true);
 +	_vm->_system->updateScreen();
 +
 +	delete[] colors;
 +	delete[] data;
 +}
 +
 +int GraphicsManager::getImageSlot(const Common::String &filename) {
 +	// Let's find a match, an open slot, or the oldest image slot
 +	uint32 oldestAge = 0xffffffff;
 +	int slot = 0;
 +
 +	for (int i = 0; i < kImageCacheSize; i++) {
 +		if (_cache[i].filename.equalsIgnoreCase(filename)) {
 +			//warning("Found image %s at slot %d", filename.c_str(), i);
 +			_cache[i].lastUsed = _vm->_system->getMillis();
 +			return i;
 +		}
 +
 +		if (!_cache[i].surface) {
 +			//warning("Putting image %s in empty slot %d", filename.c_str(), i);
 +			_cache[i].filename = filename;
 +			_cache[i].lastUsed = _vm->_system->getMillis();
 +			return i;
 +		}
 +
 +		if (_cache[i].lastUsed < oldestAge) {
 +			oldestAge = _cache[i].lastUsed;
 +			slot = i;
 +		}
 +	}
 +
 +	// Let's make sure that's cleaned out
 +	//warning("Replacing old image %s with %s in slot %d", _cache[slot].filename.c_str(), filename.c_str(), slot);
 +	_cache[slot].filename = filename;
 +	_cache[slot].surface->free();
 +	delete _cache[slot].surface;
 +	_cache[slot].surface = 0;
 +	_cache[slot].lastUsed = _vm->_system->getMillis();
 +	return slot;
 +}
 +	
 +} // End of namespace Pegasus
diff --cc engines/pegasus/pegasus.cpp
index 5f95a58,0000000..35d1a9f
mode 100644,000000..100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@@ -1,314 -1,0 +1,316 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/config-manager.h"
++#include "common/error.h"
 +#include "common/events.h"
++#include "common/textconsole.h"
 +#include "base/plugins.h"
 +#include "base/version.h"
 +
 +#include "pegasus/pegasus.h"
 +
 +#include "common/file.h"
 +
 +//#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 +//#define RUN_INTERFACE_TEST
 +
 +namespace Pegasus {
 +
 +PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
 +}
 +
 +PegasusEngine::~PegasusEngine() {
 +	delete _video;
 +	delete _sound;
 +	delete _gfx;
 +	delete _resFork;
 +	delete _inventoryLid;
 +	delete _biochipLid;
 +}
 +
 +Common::Error PegasusEngine::run() {
 +	_gfx = new GraphicsManager(this);
 +	_video = new VideoManager(this);
 +	_sound = new SoundManager(this);
 +	_resFork = new Common::MacResManager();
 +	_inventoryLid = new Common::MacResManager();
 +	_biochipLid = new Common::MacResManager();
 +	_gameMode = kMainMenuMode;
 +	_adventureMode = true;
 +	
 +	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 +		error("Could not load JMP PP Resources");
 +
 +	if (!_inventoryLid->open("Images/Lids/Inventory Lid Sequence") || !_inventoryLid->hasResFork())
 +		error("Could not open Inventory Lid Sequence");
 +
 +	if (!_biochipLid->open("Images/Lids/Biochip Lid Sequence") || !_biochipLid->hasResFork())
 +		error("Could not open Biochip Lid Sequence");
 +
 +	loadItemLocationData();
 +
 +#if 0
 +	Common::MacResIDArray pictIds = _biochipLid->getResIDArray(MKID_BE('PICT'));
 +	for (uint32 i = 0; i < pictIds.size(); i++) {
 +		Common::String filename = Common::String::printf("PICT_%d.pict", pictIds[i]);
 +		Common::DumpFile file;
 +		assert(file.open(filename));
 +		Common::SeekableReadStream *res = _biochipLid->getResource(MKID_BE('PICT'), pictIds[i]);
 +		byte *data = new byte[res->size()];
 +		res->read(data, res->size());
 +		for (int j = 0; j < 512; j++)
 +			file.writeByte(0);
 +		file.write(data, res->size());
 +		file.close();
 +		delete res;
 +		delete[] data;
 +	}
 +#endif
 +
 +#if defined(RUN_SUB_MOVIE)
 +	_video->playMovie("Images/Norad Alpha/Sub Chase Movie");
 +#elif defined(RUN_INTERFACE_TEST)
 +	drawInterface();
 +	_gfx->setCursor(kMainCursor);
 +	_sound->playSound("Sounds/Caldoria/Apartment Music.aiff", true);
 +
 +	while (!shouldQuit()) {
 +		Common::Event event;
 +		// Ignore events for now
 +		while (_eventMan->pollEvent(event)) {
 +			if (event.type == Common::EVENT_MOUSEMOVE)
 +				_system->updateScreen();
 +		}
 +		
 +		_system->delayMillis(10);
 +	}
 +#else
 +	while (!shouldQuit()) {
 +		switch (_gameMode) {
 +		case kMainMenuMode:
 +			if (!isDemo())
 +				runIntro();
 +
 +			runMainMenu();
 +			break;
 +		case kMainGameMode:
 +			if (isDemo())
 +				changeLocation(kLocPrehistoric);
 +			else
 +				changeLocation(kLocCaldoria);
 +			mainGameLoop();
 +			break;
 +		case kQuitMode:
 +			return Common::kNoError;
 +		default:
 +			_gameMode = kMainMenuMode;
 +			break;
 +		}
 +	}
 +#endif
 +
 +	return Common::kNoError;
 +}
 +
 +void PegasusEngine::loadItemLocationData() {
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('NItm'), 0x80);
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 +
 +	uint16 entryCount = res->readUint16BE();
 +
 +	for (uint16 i = 0; i < entryCount; i++) {
 +		ItemLocationData loc;
 +		loc.id = res->readUint16BE(); // Which is always == i, anyway
 +		loc.location = (ItemLocation)res->readUint16BE();
 +		loc.u0 = res->readUint16BE();
 +		loc.u1 = res->readByte();
 +		debug(1, "Item[%d]: ID = %d, location = %x, u0 = %d, u1 = %d", i, loc.id, loc.location, loc.u0, loc.u1);
 +		res->readByte();
 +		_itemLocationData.push_back(loc);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::runIntro() {
 +	// The Opening/Closing folder will need to be renamed to something else. Windows
 +	// and other OS's/FS's do not support a '/' in the filename. I arbitrarily chose
 +	// to rename my folder with the underscore.
 +	_video->playMovieCentered("Images/Opening_Closing/BandaiLogo.movie");
 +	VideoHandle handle = _video->playBackgroundMovie("Images/Opening_Closing/Big Movie.movie");
 +	_video->seekToTime(handle, 10 * 600);
 +	_video->waitUntilMovieEnds(handle);
 +}
 +
 +static const int kViewScreenOffset = 64;
 +
 +void PegasusEngine::drawInterface() {
 +	_gfx->drawPict("Images/Interface/3DInterface Top", 0, 0, false);
 +	_gfx->drawPict("Images/Interface/3DInterface Left", 0, kViewScreenOffset, false);
 +	_gfx->drawPict("Images/Interface/3DInterface Right", 640 - kViewScreenOffset, kViewScreenOffset, false);
 +	_gfx->drawPict("Images/Interface/3DInterface Bottom", 0, kViewScreenOffset + 256, false);
 +	//drawCompass();
 +	_system->updateScreen();
 +}
 +
 +void PegasusEngine::drawInterfaceOverview() {
 +	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
 +	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
 +	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
 +	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
 +	_system->updateScreen();
 +}
 +
 +void PegasusEngine::mainGameLoop() {
 +	// TODO: Yeah...
 +	_system->fillScreen(0);
 +	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
 +	drawInterface();
 +	if (isDemo())
 +		_video->playMovie("Images/Prehistoric/Prehistoric.movie", kViewScreenOffset, kViewScreenOffset);
 +	else
 +		_video->playMovie("Images/Caldoria/Caldoria.movie", kViewScreenOffset, kViewScreenOffset);
 +	_gameMode = kQuitMode;
 +}
 +
 +void PegasusEngine::changeLocation(TimeZone timeZone) {
 +	_timeZone = timeZone;
 +	loadViews(_timeZone);
 +	//loadExits(_timeZone);
 +	loadDoors(_timeZone);
 +	//loadHSLs(_timeZone);
 +	//loadHSIn(_timeZone);
 +	loadSoundSpots(_timeZone);
 +	//loadTurns(_timeZone);
 +	loadZooms(_timeZone);
 +	loadExtras(_timeZone);
 +}
 +
 +void PegasusEngine::loadViews(TimeZone timeZone) {
 +	_currentViews.clear();
 +
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('View'), getTimeZoneDesc(timeZone));
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('V', 'i', 'e', 'w'), getTimeZoneDesc(timeZone));
 +
 +	uint32 entryCount = res->readUint32BE();
 +
 +	for (uint32 i = 0; i < entryCount; i++) {
 +		View view;
 +		view.u0 = res->readUint16BE(); // Compass reading?
 +		view.u1 = res->readByte(); // Always 0-3, direction?
 +		view.u2 = res->readByte(); // Usually 0, rarely 3
 +		view.frameTime = res->readUint32BE();
 +		debug(1, "View[%d]: u0 = %d, u1 = %d, u2 = %d, time = %d", i, view.u0, view.u1, view.u2, view.frameTime);
 +		_currentViews.push_back(view);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::loadDoors(TimeZone timeZone) {
 +	_currentDoors.clear();
 +
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Door'), getTimeZoneDesc(timeZone));
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('D', 'o', 'o', 'r'), getTimeZoneDesc(timeZone));
 +
 +	uint32 entryCount = res->readUint32BE();
 +
 +	for (uint32 i = 0; i < entryCount; i++) {
 +		Door door;
 +		door.u0 = res->readUint16BE();
 +		door.u1 = res->readUint16BE(); // Always divisible by 256?
 +		door.startTime = res->readUint32BE();
 +		door.endTime = res->readUint32BE();
 +		door.u2 = res->readUint16BE();
 +		debug(1, "Door[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, door.u0, door.u1, door.startTime, door.endTime, door.u2);
 +		_currentDoors.push_back(door);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::loadSoundSpots(TimeZone timeZone) {
 +	_currentSoundSpots.clear();
 +
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Spot'), getTimeZoneDesc(timeZone));
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('S', 'p', 'o', 't'), getTimeZoneDesc(timeZone));
 +
 +	uint32 entryCount = res->readUint32BE();
 +
 +	for (uint32 i = 0; i < entryCount; i++) {
 +		SoundSpot spot;
 +		spot.u0 = res->readUint16BE();
 +		spot.u1 = res->readUint16BE();
 +		spot.u2 = res->readUint16BE(); // 0/1 or 768/769
 +		spot.startTime = res->readUint32BE();
 +		spot.endTime = res->readUint32BE();
 +		spot.u3 = res->readUint16BE();
 +		debug(1, "Sound Spot[%d]: u0 = %d, u1 = %d, u2 = %d, startTime = %d, endTime = %d, u3 = %d", i, spot.u0, spot.u1, spot.u2, spot.startTime, spot.endTime, spot.u3);
 +		_currentSoundSpots.push_back(spot);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::loadZooms(TimeZone timeZone) {
 +	_currentZooms.clear();
 +
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Zoom'), getTimeZoneDesc(timeZone));
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('Z', 'o', 'o', 'm'), getTimeZoneDesc(timeZone));
 +
 +	uint32 entryCount = res->readUint32BE();
 +
 +	for (uint32 i = 0; i < entryCount; i++) {
 +		Zoom zoom;
 +		zoom.u0 = res->readUint16BE();
 +		zoom.u1 = res->readUint16BE();
 +		zoom.startTime = res->readUint32BE();
 +		zoom.endTime = res->readUint32BE();
 +		zoom.u2 = res->readUint16BE();
 +		debug(1, "Zoom[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, zoom.u0, zoom.u1, zoom.startTime, zoom.endTime, zoom.u2);
 +		_currentZooms.push_back(zoom);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::loadExtras(TimeZone timeZone) {
 +	_currentExtras.clear();
 +
- 	Common::SeekableReadStream *res = _resFork->getResource(MKID_BE('Xtra'), getTimeZoneDesc(timeZone));
++	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('X', 't', 'r', 'a'), getTimeZoneDesc(timeZone));
 +
 +	uint32 entryCount = res->readUint32BE();
 +
 +	for (uint32 i = 0; i < entryCount; i++) {
 +		Extra extra;
 +		extra.u0 = res->readUint32BE();
 +		extra.startTime = res->readUint32BE();
 +		extra.endTime = res->readUint32BE();
 +		debug(1, "Extra[%d]: u0 = %d, startTime = %d, endTime = %d", i, extra.u0, extra.startTime, extra.endTime);
 +		_currentExtras.push_back(extra);
 +	}
 +
 +	delete res;
 +}
 +
 +Common::String PegasusEngine::getTimeZoneDesc(TimeZone timeZone) {
 +	static const char *names[] = { "Prehistoric", "Mars", "WSC", "Tiny TSA", "Full TSA", "Norad Alpha", "Caldoria", "Norad Delta" };
 +	return names[timeZone];
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/sound.cpp
index 9ef89ab,0000000..b87bff4
mode 100644,000000..100644
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@@ -1,85 -1,0 +1,86 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "pegasus/sound.h"
 +
 +#include "common/file.h"
++#include "common/textconsole.h"
 +#include "audio/decoders/aiff.h"
 +
 +namespace Pegasus {
 +
 +SoundManager::SoundManager(PegasusEngine *vm) : _vm(vm) {
 +}
 +        
 +void SoundManager::playSound(Common::String filename, bool loop) {
 +	SndHandle *handle = getHandle();
 +	handle->type = kUsedHandle;
 +
 +	Common::File *file = new Common::File();
 +	if (!file->open(filename.c_str()))
 +		error("Could not open file \'%s\'", filename.c_str());
 +
 +	Audio::AudioStream* audStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
 +
 +	if (loop)
 +		audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream*)audStream, 0);
 +	
 +	if (audStream)
 +		_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream);
 +}
 +
 +SndHandle *SoundManager::getHandle() {
 +	for (int i = 0; i < SOUND_HANDLES; i++) {
 +		if (_handles[i].type == kFreeHandle)
 +			return &_handles[i];
 +
 +		if (!_vm->_mixer->isSoundHandleActive(_handles[i].handle)) {
 +			_handles[i].type = kFreeHandle;
 +			return &_handles[i];
 +		}
 +	}
 +
 +	error("SoundManager::getHandle(): Too many sound handles");
 +	return NULL;
 +}
 +
 +bool SoundManager::isPlaying() {
 +	for (int i = 0; i < SOUND_HANDLES; i++)
 +		if (_handles[i].type == kUsedHandle)
 +			if (_vm->_mixer->isSoundHandleActive(_handles[i].handle))
 +				return true;
 +	return false;
 +}
 +
 +void SoundManager::stopSound() {
 +	_vm->_mixer->stopAll();
 +}
 +
 +void SoundManager::pauseSound() {
 +	_vm->_mixer->pauseAll(true);
 +}
 +
 +void SoundManager::resumeSound() {
 +	_vm->_mixer->pauseAll(false);
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/video.cpp
index 6b850db,0000000..277065b
mode 100644,000000..100644
--- a/engines/pegasus/video.cpp
+++ b/engines/pegasus/video.cpp
@@@ -1,237 -1,0 +1,238 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "pegasus/pegasus.h"
 +#include "pegasus/video.h"
 +
 +#include "common/events.h"
++#include "common/textconsole.h"
 +#include "graphics/scaler.h"
 +#include "video/qt_decoder.h"
 +
 +namespace Pegasus {
 +	
 +VideoManager::VideoManager(PegasusEngine *vm) : _vm(vm) {
 +	_timeZoneVideo = new Video::QuickTimeDecoder();
 +}
 +	
 +VideoManager::~VideoManager() {
 +	stopVideos();
 +	delete _timeZoneVideo;
 +}
 +
 +void VideoManager::setTimeZoneVideo(const Common::String &filename) {
 +	if (!_timeZoneVideo->loadFile(filename))
 +		error("Could not load time zone video '%s'", filename.c_str());
 +
 +	// Set it on pause
 +	_timeZoneVideo->pauseVideo(true);
 +}
 +
 +void VideoManager::drawTimeZoneVideoFrame(uint32 time) {
 +	assert(_timeZoneVideo->isVideoLoaded());
 +
 +	if (!_timeZoneVideo->isPaused())
 +		_timeZoneVideo->pauseVideo(true);
 +
 +	_timeZoneVideo->seekToTime(Audio::Timestamp(0, time, 600));
 +
 +	const Graphics::Surface *frame = _timeZoneVideo->decodeNextFrame();
 +
 +	if (!frame)	
 +		error("Could not find frame at time %d", time);
 +
 +	// TODO
 +}
 +
 +void VideoManager::playTimeZoneVideoSegment(uint32 startTime, uint32 endTime) {
 +	assert(_timeZoneVideo->isVideoLoaded());
 +
 +	if (_timeZoneVideo->isPaused())
 +		_timeZoneVideo->pauseVideo(false);
 +
 +	_timeZoneVideo->seekToTime(Audio::Timestamp(0, startTime, 600));
 +
 +	// TODO
 +}
 +
 +void VideoManager::pauseVideos() {
 +	for (uint16 i = 0; i < _videoStreams.size(); i++)
 +		_videoStreams[i]->pauseVideo(true);
 +}
 +
 +void VideoManager::resumeVideos() {
 +	for (uint16 i = 0; i < _videoStreams.size(); i++)
 +		_videoStreams[i]->pauseVideo(false);
 +}
 +
 +void VideoManager::stopVideos() {
 +	for (uint16 i = 0; i < _videoStreams.size(); i++) {
 +		delete _videoStreams[i].video;
 +		_videoStreams[i].video = 0;
 +	}
 +}
 +
 +void VideoManager::playMovie(Common::String filename, uint16 x, uint16 y) {
 +	VideoHandle videoHandle = playBackgroundMovie(filename, x, y, false);
 +
 +	if (videoHandle != NULL_VID_HANDLE)
 +		waitUntilMovieEnds(videoHandle);
 +}
 +
 +void VideoManager::playMovieCentered(Common::String filename) {
 +	VideoHandle videoHandle = playBackgroundMovie(filename, 0, 0, false);
 +
 +	if (videoHandle == NULL_VID_HANDLE)
 +		return;
 +
 +	_videoStreams[videoHandle].x = (_vm->_system->getWidth() - _videoStreams[videoHandle]->getWidth()) / 2;
 +	_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
 +
 +	waitUntilMovieEnds(videoHandle);
 +}
 +	
 +void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
 +	bool continuePlaying = true;
 +
 +	while (!_videoStreams[videoHandle]->endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
 +		if (updateBackgroundMovies())
 +			_vm->_system->updateScreen();
 +
 +		Common::Event event;
 +		while (_vm->_system->getEventManager()->pollEvent(event)) {
 +			switch (event.type) {
 +			case Common::EVENT_RTL:
 +			case Common::EVENT_QUIT:
 +				continuePlaying = false;
 +				break;
 +			case Common::EVENT_KEYDOWN:
 +				switch (event.kbd.keycode) {
 +				case Common::KEYCODE_ESCAPE:
 +					continuePlaying = false;
 +					break;
 +				default:
 +					break;
 +			}
 +			default:
 +				break;
 +			}
 +		}
 +
 +		// Cut down on CPU usage
 +		_vm->_system->delayMillis(10);
 +	}
 +
 +	delete _videoStreams[videoHandle].video;
 +	_videoStreams.clear();
 +}
 +
 +bool VideoManager::updateBackgroundMovies() {
 +	bool updateScreen = false;
 +
 +	for (uint32 i = 0; i < _videoStreams.size() && !_vm->shouldQuit(); i++) {
 +		// Skip deleted videos
 +		if (!_videoStreams[i].video)
 +			continue;
 +
 +		// Remove any videos that are over
 +		if (_videoStreams[i]->endOfVideo()) {
 +			if (_videoStreams[i].loop) {
 +				_videoStreams[i]->rewind();
 +			} else {
 +				delete _videoStreams[i].video;
 +				memset(&_videoStreams[i], 0, sizeof(VideoEntry));
 +				_videoStreams[i].video = NULL;
 +				continue;
 +			}
 +		}
 +
 +		// Check if we need to draw a frame
 +		if (_videoStreams[i]->needsUpdate()) {
 +			const Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
 +
 +			if (frame) {			
- 				if (frame->bytesPerPixel == 1)
++				if (frame->format.bytesPerPixel == 1)
 +					error("Unhandled 8bpp frames"); // Cut out because Pegasus Prime shouldn't need this
 +				
 +				// Clip the width/height to make sure we stay on the screen
 +				uint16 width = MIN<int32>(_videoStreams[i]->getWidth(), _vm->_system->getWidth() - _videoStreams[i].x);
 +				uint16 height = MIN<int32>(_videoStreams[i]->getHeight(), _vm->_system->getHeight() - _videoStreams[i].y);
 +
 +				if (width == 320 && height == 240) {
 +					// TODO: Is this right? At least "Big Movie" and the "Sub Chase Movie" need to be scaled...
 +					// FIXME: Normal2x is only compiled in when USE_SCALERS is defined
 +					_videoStreams[i].x = 0;
 +					_videoStreams[i].y = 0;
 +					Graphics::Surface scaledSurf;
- 					scaledSurf.create(frame->w * 2, frame->h * 2, frame->bytesPerPixel);
++					scaledSurf.create(frame->w * 2, frame->h * 2, frame->format);
 +					Normal2x((byte *)frame->pixels, frame->pitch, (byte *)scaledSurf.pixels, scaledSurf.pitch, frame->w, frame->h);
 +					_vm->_system->copyRectToScreen((byte*)scaledSurf.pixels, scaledSurf.pitch, _videoStreams[i].x, _videoStreams[i].y, width * 2, height * 2);
 +					scaledSurf.free();
 +				} else
 +					_vm->_system->copyRectToScreen((byte*)frame->pixels, frame->pitch, _videoStreams[i].x, _videoStreams[i].y, width, height);
 +					
 +
 +				// We've drawn something to the screen, make sure we update it
 +				updateScreen = true;
 +			}
 +		}
 +	}
 +
 +	// Return true if we need to update the screen
 +	return updateScreen;
 +}
 +
 +VideoHandle VideoManager::playBackgroundMovie(Common::String filename, int x, int y, bool loop) {
 +	// First, check to see if that video is already playing
 +	for (uint32 i = 0; i < _videoStreams.size(); i++)
 +		if (_videoStreams[i].filename == filename)
 +			return i;
 +
 +	// Otherwise, create a new entry
 +	VideoEntry entry;
 +	entry.video = new Video::QuickTimeDecoder();
 +	entry.x = x;
 +	entry.y = y;
 +	entry.filename = filename;
 +	entry.loop = loop;
 +	
 +	if (!entry->loadFile(filename))
 +		return NULL_VID_HANDLE;
 +	
 +	// Search for any deleted videos so we can take a formerly used slot
 +	for (uint32 i = 0; i < _videoStreams.size(); i++)
 +		if (!_videoStreams[i].video) {
 +			_videoStreams[i] = entry;
 +			return i;
 +		}
 +			
 +	// Otherwise, just add it to the list
 +	_videoStreams.push_back(entry);
 +	return _videoStreams.size() - 1;
 +}
 +
 +void VideoManager::seekToTime(VideoHandle handle, uint32 time) {
 +	if (handle != NULL_VID_HANDLE)
 +		_videoStreams[handle]->seekToTime(Audio::Timestamp(0, time, 600));
 +}
 +
 +} // End of namespace Pegasus


Commit: 6cfdd2529b5340e1d59cab15659c405067583cbd
    https://github.com/scummvm/scummvm/commit/6cfdd2529b5340e1d59cab15659c405067583cbd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-10T20:38:54-07:00

Commit Message:
PEGASUS: Make the nav movie rely on the current time zone instead of hardcoding it

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 35d1a9f..60fe531 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -185,10 +185,16 @@ void PegasusEngine::mainGameLoop() {
 	_system->fillScreen(0);
 	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
 	drawInterface();
-	if (isDemo())
-		_video->playMovie("Images/Prehistoric/Prehistoric.movie", kViewScreenOffset, kViewScreenOffset);
+
+	Common::String navMovieFolder;
+	if (_timeZone == kLocTinyTSA || _timeZone == kLocFullTSA)
+		navMovieFolder = "TSA";
 	else
-		_video->playMovie("Images/Caldoria/Caldoria.movie", kViewScreenOffset, kViewScreenOffset);
+		navMovieFolder = getTimeZoneDesc(_timeZone);
+
+	Common::String navMovie = Common::String::format("Images/%s/%s.movie", navMovieFolder.c_str(), getTimeZoneDesc(_timeZone).c_str());
+	_video->playMovie(navMovie, kViewScreenOffset, kViewScreenOffset);
+
 	_gameMode = kQuitMode;
 }
 


Commit: 01380d287ab582099dc632329389fc70186b0b73
    https://github.com/scummvm/scummvm/commit/01380d287ab582099dc632329389fc70186b0b73
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-11T18:07:33-07:00

Commit Message:
PEGASUS: Begin cleaning up the time zone movie code

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/video.cpp
    engines/pegasus/video.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 60fe531..c8958a0 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -161,8 +161,6 @@ void PegasusEngine::runIntro() {
 	_video->waitUntilMovieEnds(handle);
 }
 
-static const int kViewScreenOffset = 64;
-
 void PegasusEngine::drawInterface() {
 	_gfx->drawPict("Images/Interface/3DInterface Top", 0, 0, false);
 	_gfx->drawPict("Images/Interface/3DInterface Left", 0, kViewScreenOffset, false);
@@ -186,13 +184,7 @@ void PegasusEngine::mainGameLoop() {
 	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
 	drawInterface();
 
-	Common::String navMovieFolder;
-	if (_timeZone == kLocTinyTSA || _timeZone == kLocFullTSA)
-		navMovieFolder = "TSA";
-	else
-		navMovieFolder = getTimeZoneDesc(_timeZone);
-
-	Common::String navMovie = Common::String::format("Images/%s/%s.movie", navMovieFolder.c_str(), getTimeZoneDesc(_timeZone).c_str());
+	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(_timeZone).c_str(), getTimeZoneDesc(_timeZone).c_str());
 	_video->playMovie(navMovie, kViewScreenOffset, kViewScreenOffset);
 
 	_gameMode = kQuitMode;
@@ -319,4 +311,11 @@ Common::String PegasusEngine::getTimeZoneDesc(TimeZone timeZone) {
 	return names[timeZone];
 }
 
+Common::String PegasusEngine::getTimeZoneFolder(TimeZone timeZone) {
+	if (timeZone == kLocFullTSA || timeZone == kLocTinyTSA)
+		return "TSA";
+
+	return getTimeZoneDesc(timeZone);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 2f05304..a0b98a5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -52,6 +52,8 @@ enum ItemLocation {
 	kItemLocationBuiltIn = 0xffff
 };
 
+static const int kViewScreenOffset = 64;
+
 struct ItemLocationData {
 	uint16 id;
 	ItemLocation location;
@@ -228,6 +230,7 @@ private:
 	void loadExtras(TimeZone timeZone);
 
 	// Misc Functions
+	static Common::String getTimeZoneFolder(TimeZone timeZone);
 	static Common::String getTimeZoneDesc(TimeZone timeZone);
 
 	// Game Variables
diff --git a/engines/pegasus/video.cpp b/engines/pegasus/video.cpp
index 277065b..89884e0 100644
--- a/engines/pegasus/video.cpp
+++ b/engines/pegasus/video.cpp
@@ -31,7 +31,7 @@
 namespace Pegasus {
 	
 VideoManager::VideoManager(PegasusEngine *vm) : _vm(vm) {
-	_timeZoneVideo = new Video::QuickTimeDecoder();
+	_timeZoneVideo = 0;
 }
 	
 VideoManager::~VideoManager() {
@@ -39,16 +39,24 @@ VideoManager::~VideoManager() {
 	delete _timeZoneVideo;
 }
 
-void VideoManager::setTimeZoneVideo(const Common::String &filename) {
-	if (!_timeZoneVideo->loadFile(filename))
-		error("Could not load time zone video '%s'", filename.c_str());
+bool VideoManager::loadTimeZoneVideo(const Common::String &filename) {
+	Video::QuickTimeDecoder *video = new Video::QuickTimeDecoder();
+
+	if (!video->loadFile(filename)) {
+		delete video;
+		return false;
+	}
+
+	delete _timeZoneVideo;
+	_timeZoneVideo = video;
 
 	// Set it on pause
 	_timeZoneVideo->pauseVideo(true);
+	return true;
 }
 
 void VideoManager::drawTimeZoneVideoFrame(uint32 time) {
-	assert(_timeZoneVideo->isVideoLoaded());
+	assert(_timeZoneVideo);
 
 	if (!_timeZoneVideo->isPaused())
 		_timeZoneVideo->pauseVideo(true);
@@ -60,18 +68,58 @@ void VideoManager::drawTimeZoneVideoFrame(uint32 time) {
 	if (!frame)	
 		error("Could not find frame at time %d", time);
 
-	// TODO
+	copyFrameToScreen(frame, _timeZoneVideo->getWidth(), _timeZoneVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
+	_vm->_system->updateScreen();
 }
 
 void VideoManager::playTimeZoneVideoSegment(uint32 startTime, uint32 endTime) {
-	assert(_timeZoneVideo->isVideoLoaded());
+	assert(_timeZoneVideo);
+
+	_timeZoneVideo->seekToTime(Audio::Timestamp(0, startTime, 600));
 
 	if (_timeZoneVideo->isPaused())
 		_timeZoneVideo->pauseVideo(false);
 
-	_timeZoneVideo->seekToTime(Audio::Timestamp(0, startTime, 600));
+	// Convert the end time to ms
+	endTime = Audio::Timestamp(0, endTime, 600).msecs();
+
+	bool continuePlaying = true;
+	while (!_timeZoneVideo->endOfVideo() && _timeZoneVideo->getElapsedTime() < endTime && !_vm->shouldQuit() && continuePlaying) {
+		if (_timeZoneVideo->needsUpdate()) {
+			const Graphics::Surface *frame = _timeZoneVideo->decodeNextFrame();
 
-	// TODO
+			if (frame) {
+				copyFrameToScreen(frame, _timeZoneVideo->getWidth(), _timeZoneVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
+				_vm->_system->updateScreen();
+			}
+		}
+
+		Common::Event event;
+		while (_vm->_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RTL:
+			case Common::EVENT_QUIT:
+				continuePlaying = false;
+				break;
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_ESCAPE:
+					continuePlaying = false;
+					break;
+				default:
+					break;
+				}
+				break;
+			default:
+				break;
+			}
+		}
+
+		// Cut down on CPU usage
+		_vm->_system->delayMillis(10);
+	}
+
+	_timeZoneVideo->pauseVideo(true);
 }
 
 void VideoManager::pauseVideos() {
@@ -131,7 +179,8 @@ void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
 					break;
 				default:
 					break;
-			}
+				}
+				break;
 			default:
 				break;
 			}
@@ -169,27 +218,8 @@ bool VideoManager::updateBackgroundMovies() {
 		if (_videoStreams[i]->needsUpdate()) {
 			const Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
 
-			if (frame) {			
-				if (frame->format.bytesPerPixel == 1)
-					error("Unhandled 8bpp frames"); // Cut out because Pegasus Prime shouldn't need this
-				
-				// Clip the width/height to make sure we stay on the screen
-				uint16 width = MIN<int32>(_videoStreams[i]->getWidth(), _vm->_system->getWidth() - _videoStreams[i].x);
-				uint16 height = MIN<int32>(_videoStreams[i]->getHeight(), _vm->_system->getHeight() - _videoStreams[i].y);
-
-				if (width == 320 && height == 240) {
-					// TODO: Is this right? At least "Big Movie" and the "Sub Chase Movie" need to be scaled...
-					// FIXME: Normal2x is only compiled in when USE_SCALERS is defined
-					_videoStreams[i].x = 0;
-					_videoStreams[i].y = 0;
-					Graphics::Surface scaledSurf;
-					scaledSurf.create(frame->w * 2, frame->h * 2, frame->format);
-					Normal2x((byte *)frame->pixels, frame->pitch, (byte *)scaledSurf.pixels, scaledSurf.pitch, frame->w, frame->h);
-					_vm->_system->copyRectToScreen((byte*)scaledSurf.pixels, scaledSurf.pitch, _videoStreams[i].x, _videoStreams[i].y, width * 2, height * 2);
-					scaledSurf.free();
-				} else
-					_vm->_system->copyRectToScreen((byte*)frame->pixels, frame->pitch, _videoStreams[i].x, _videoStreams[i].y, width, height);
-					
+			if (frame) {				
+				copyFrameToScreen(frame, _videoStreams[i]->getWidth(), _videoStreams[i]->getHeight(), _videoStreams[i].x, _videoStreams[i].y);
 
 				// We've drawn something to the screen, make sure we update it
 				updateScreen = true;
@@ -235,4 +265,24 @@ void VideoManager::seekToTime(VideoHandle handle, uint32 time) {
 		_videoStreams[handle]->seekToTime(Audio::Timestamp(0, time, 600));
 }
 
+void VideoManager::copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y) {
+	if (frame->format.bytesPerPixel == 1)
+		error("Unhandled 8bpp frames"); // Cut out because Pegasus Prime shouldn't need this
+
+	// Clip the width/height to make sure we stay on the screen
+	width = MIN<int32>(width, _vm->_system->getWidth() - x);
+	height = MIN<int32>(height, _vm->_system->getHeight() - y);
+
+	if (width == 320 && height == 240) {
+		// TODO: Is this right? At least "Big Movie" and the "Sub Chase Movie" need to be scaled...
+		// FIXME: Normal2x is only compiled in when USE_SCALERS is defined
+		Graphics::Surface scaledSurf;
+		scaledSurf.create(frame->w * 2, frame->h * 2, frame->format);
+		Normal2x((byte *)frame->pixels, frame->pitch, (byte *)scaledSurf.pixels, scaledSurf.pitch, frame->w, frame->h);
+		_vm->_system->copyRectToScreen((byte *)scaledSurf.pixels, scaledSurf.pitch, 0, 0, width * 2, height * 2);
+		scaledSurf.free();
+	} else
+		_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, width, height);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/video.h b/engines/pegasus/video.h
index c0ddcdc..ac071c0 100644
--- a/engines/pegasus/video.h
+++ b/engines/pegasus/video.h
@@ -58,7 +58,7 @@ public:
 	VideoManager(PegasusEngine *vm);
 	~VideoManager();
 
-	void setTimeZoneVideo(const Common::String &filename);
+	bool loadTimeZoneVideo(const Common::String &filename);
 	void drawTimeZoneVideoFrame(uint32 time);
 	void playTimeZoneVideoSegment(uint32 startTime, uint32 endTime);
 	
@@ -79,6 +79,9 @@ private:
 
 	Video::QuickTimeDecoder *_timeZoneVideo;
 
+	// Helper functions
+	void copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y);
+
 	// Keep tabs on any videos playing
 	Common::Array<VideoEntry> _videoStreams;
 	uint32 _pauseStart;


Commit: 6067a46e9d4ac580d3dca7d38dfe4cc4a6c3f0cd
    https://github.com/scummvm/scummvm/commit/6067a46e9d4ac580d3dca7d38dfe4cc4a6c3f0cd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-11T18:28:28-07:00

Commit Message:
PEGASUS: Cleanup menu button handling

Also, hooked the Restore button up to the load dialog

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index d2cb584..8f587c3 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "common/events.h"
+#include "common/textconsole.h"
 
 #include "pegasus/pegasus.h"
 
@@ -81,8 +82,13 @@ void PegasusEngine::runMainMenu() {
 					if (buttonSelected != kDifficultyButton) {
 						drawMenuButtonSelected(buttonSelected);
 						setGameMode(buttonSelected);
-						_sound->stopSound();
-						return;
+
+						if (_gameMode != kMainMenuMode) {
+							_sound->stopSound();
+							return;
+						}
+
+						drawMenu(buttonSelected);
 					}
 					break;
 				default:
@@ -107,6 +113,7 @@ void PegasusEngine::runMainMenu() {
 	// Too slow! Go back and show the intro again.
 	_sound->stopSound();
 	_video->playMovie("Images/Opening_Closing/LilMovie.movie");
+	_gameMode = kIntroMode;
 }
 
 void PegasusEngine::drawMenu(int buttonSelected) {
@@ -159,7 +166,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 			_gameMode = kMainGameMode;
 			break;
 		case kDemoCreditsButton:
-			_gameMode = kCreditsMode;
+			warning("No credits just yet");
 			break;
 		case kDemoQuitButton:
 			_gameMode = kQuitMode;
@@ -168,16 +175,16 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 	} else {
 		switch (buttonSelected) {
 		case kInterfaceOverviewButton:
-			_gameMode = kInterfaceOverviewMode;
+			warning("No overview just yet");
 			break;
 		case kStartButton:
 			_gameMode = kMainGameMode;
 			break;
 		case kRestoreButton:
-			_gameMode = kRestoreMode;
+			showLoadDialog();
 			break;
 		case kCreditsButton:
-			_gameMode = kCreditsMode;
+			warning("No credits just yet");
 			break;
 		case kQuitButton:
 			_gameMode = kQuitMode;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index c8958a0..9688a99 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -23,14 +23,15 @@
 #include "common/config-manager.h"
 #include "common/error.h"
 #include "common/events.h"
+#include "common/file.h"
 #include "common/textconsole.h"
+#include "common/translation.h"
 #include "base/plugins.h"
 #include "base/version.h"
+#include "gui/saveload.h"
 
 #include "pegasus/pegasus.h"
 
-#include "common/file.h"
-
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
 
@@ -55,7 +56,7 @@ Common::Error PegasusEngine::run() {
 	_resFork = new Common::MacResManager();
 	_inventoryLid = new Common::MacResManager();
 	_biochipLid = new Common::MacResManager();
-	_gameMode = kMainMenuMode;
+	_gameMode = kIntroMode;
 	_adventureMode = true;
 	
 	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
@@ -107,10 +108,12 @@ Common::Error PegasusEngine::run() {
 #else
 	while (!shouldQuit()) {
 		switch (_gameMode) {
-		case kMainMenuMode:
+		case kIntroMode:
 			if (!isDemo())
 				runIntro();
-
+			_gameMode = kMainMenuMode;
+			break;
+		case kMainMenuMode:
 			runMainMenu();
 			break;
 		case kMainGameMode:
@@ -306,6 +309,25 @@ void PegasusEngine::loadExtras(TimeZone timeZone) {
 	delete res;
 }
 
+void PegasusEngine::showLoadDialog() {
+	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
+	slc.setSaveMode(false);
+
+	Common::String gameId = ConfMan.get("gameid");
+
+	const EnginePlugin *plugin = 0;
+	EngineMan.findGame(gameId, &plugin);
+
+	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
+
+	if (slot >= 0) {
+		warning("TODO: Load game");
+		_gameMode = kMainGameMode;
+	}
+
+	slc.close();
+}
+
 Common::String PegasusEngine::getTimeZoneDesc(TimeZone timeZone) {
 	static const char *names[] = { "Prehistoric", "Mars", "WSC", "Tiny TSA", "Full TSA", "Norad Alpha", "Caldoria", "Norad Delta" };
 	return names[timeZone];
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index a0b98a5..30199f1 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -175,11 +175,9 @@ enum Item {
 };
 
 enum GameMode {
+	kIntroMode,
 	kMainMenuMode,
 	kMainGameMode,
-	kCreditsMode,
-	kInterfaceOverviewMode,
-	kRestoreMode,
 	kQuitMode
 };
 
@@ -215,6 +213,7 @@ private:
 	void drawInterface();
 	//void drawCompass();
 	//void runPauseMenu();
+	void showLoadDialog();
 
 	// Interface Overview
 	void drawInterfaceOverview();


Commit: 866a8dddd1733734eb47091a21ccff00c416120b
    https://github.com/scummvm/scummvm/commit/866a8dddd1733734eb47091a21ccff00c416120b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-11T19:48:42-07:00

Commit Message:
PEGASUS: Begin work on the interface overview

Changed paths:
  A engines/pegasus/overview.cpp
    engines/pegasus/menu.cpp
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/video.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 8f587c3..ae8fba5 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -175,7 +175,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 	} else {
 		switch (buttonSelected) {
 		case kInterfaceOverviewButton:
-			warning("No overview just yet");
+			runInterfaceOverview();
 			break;
 		case kStartButton:
 			_gameMode = kMainGameMode;
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 28a92aa..5222c81 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS = \
 	detection.o \
 	graphics.o \
 	menu.o \
+	overview.o \
 	pegasus.o \
 	sound.o \
 	video.o
diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
new file mode 100644
index 0000000..249d76a
--- /dev/null
+++ b/engines/pegasus/overview.cpp
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/events.h"
+#include "common/textconsole.h"
+#include "graphics/cursorman.h"
+#include "video/qt_decoder.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+void PegasusEngine::runInterfaceOverview() {
+	CursorMan.showMouse(true);
+	_gfx->setCursor(kPointingCursor);
+
+	Video::QuickTimeDecoder *overviewVideo = new Video::QuickTimeDecoder();
+	if (!overviewVideo->loadFile("Images/Interface/Overview Mac.movie"))
+		error("Could not open overview video");
+
+	// Pause the video, we're only getting frames from it
+	overviewVideo->pauseVideo(true);
+
+	// Draw the main image
+	overviewVideo->seekToTime(1000);
+	_video->copyFrameToScreen(overviewVideo->decodeNextFrame(), overviewVideo->getWidth(), overviewVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
+
+	// Draw the rest of the interface
+	drawInterfaceOverview();
+
+	bool continueLooping = true;
+	while (!shouldQuit() && continueLooping) {
+		Common::Event event;
+		while (_eventMan->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_MOUSEMOVE:
+				_system->updateScreen();
+				break;
+			case Common::EVENT_KEYDOWN:
+				continueLooping = false;
+				break;
+			default:
+				break;
+			}
+		}
+
+		_system->delayMillis(10);
+	}
+
+	CursorMan.showMouse(false);
+	delete overviewVideo;
+}
+
+void PegasusEngine::drawInterfaceOverview() {
+	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
+	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
+	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
+	_system->updateScreen();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 9688a99..bd281cd 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -173,14 +173,6 @@ void PegasusEngine::drawInterface() {
 	_system->updateScreen();
 }
 
-void PegasusEngine::drawInterfaceOverview() {
-	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
-	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
-	_system->updateScreen();
-}
-
 void PegasusEngine::mainGameLoop() {
 	// TODO: Yeah...
 	_system->fillScreen(0);
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 30199f1..1f9f92a 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -214,6 +214,7 @@ private:
 	//void drawCompass();
 	//void runPauseMenu();
 	void showLoadDialog();
+	void runInterfaceOverview();
 
 	// Interface Overview
 	void drawInterfaceOverview();
diff --git a/engines/pegasus/video.h b/engines/pegasus/video.h
index ac071c0..56339e4 100644
--- a/engines/pegasus/video.h
+++ b/engines/pegasus/video.h
@@ -74,14 +74,14 @@ public:
 
 	void seekToTime(VideoHandle handle, uint32 time);
 
+	// Helper functions
+	void copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y);
+
 private:
 	PegasusEngine *_vm;
 
 	Video::QuickTimeDecoder *_timeZoneVideo;
 
-	// Helper functions
-	void copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y);
-
 	// Keep tabs on any videos playing
 	Common::Array<VideoEntry> _videoStreams;
 	uint32 _pauseStart;


Commit: 02b023e2660612f7dadc8cca0233c123ae41b950
    https://github.com/scummvm/scummvm/commit/02b023e2660612f7dadc8cca0233c123ae41b950
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-11T19:59:36-07:00

Commit Message:
PEGASUS: Ignore meta keys in the overview

Changed paths:
    engines/pegasus/overview.cpp



diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
index 249d76a..7ba4d65 100644
--- a/engines/pegasus/overview.cpp
+++ b/engines/pegasus/overview.cpp
@@ -53,10 +53,13 @@ void PegasusEngine::runInterfaceOverview() {
 		while (_eventMan->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_MOUSEMOVE:
+				// TODO: Highlighted images and changing the viewscreen image
 				_system->updateScreen();
 				break;
 			case Common::EVENT_KEYDOWN:
-				continueLooping = false;
+				// Break on any keypress, but ignore the meta keys
+				// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
+				continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
 				break;
 			default:
 				break;


Commit: 5a86c56b8ccefcbb3111148f93ab774bc0e13372
    https://github.com/scummvm/scummvm/commit/5a86c56b8ccefcbb3111148f93ab774bc0e13372
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T09:14:47-07:00

Commit Message:
PEGASUS: Finish overview implementation

Only thick rects remain there

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/overview.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index ae8fba5..0febdd6 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -175,7 +175,9 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 	} else {
 		switch (buttonSelected) {
 		case kInterfaceOverviewButton:
+			_sound->stopSound();
 			runInterfaceOverview();
+			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kStartButton:
 			_gameMode = kMainGameMode;
diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
index 7ba4d65..5772707 100644
--- a/engines/pegasus/overview.cpp
+++ b/engines/pegasus/overview.cpp
@@ -39,31 +39,65 @@ void PegasusEngine::runInterfaceOverview() {
 
 	// Pause the video, we're only getting frames from it
 	overviewVideo->pauseVideo(true);
-
-	// Draw the main image
-	overviewVideo->seekToTime(1000);
-	_video->copyFrameToScreen(overviewVideo->decodeNextFrame(), overviewVideo->getWidth(), overviewVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
+	
+	static const OverviewHotspot overviewHotspots[] = {
+		{ Common::Rect(0, 0, 640, 480), 1000 },     // Main
+		{ Common::Rect(131, 39, 212, 63), 660 },    // Date
+		{ Common::Rect(210, 33, 326, 63), 330 },    // Compass
+		{ Common::Rect(324, 39, 448, 63), 800 },    // Energy Bar
+		{ Common::Rect(531, 35, 601, 57), 2330 },   // Energy Alert
+		{ Common::Rect(63, 63, 577, 321), 1730 },   // View Window
+		{ Common::Rect(69, 317, 355, 331), 1360 },  // Inventory Panel
+		{ Common::Rect(353, 317, 559, 331), 130 },  // BioChip Panel
+		{ Common::Rect(75, 333, 173, 431), 1460 },  // Inventory Box
+		{ Common::Rect(171, 333, 365, 431), 2060 }, // Inventory/BioChip Display
+		{ Common::Rect(363, 333, 461, 431), 1860 }, // BioChip Box
+		{ Common::Rect(540, 348, 640, 468), 530 },  // Keyboard
+	};
 
 	// Draw the rest of the interface
-	drawInterfaceOverview();
+	int curHotspot;
+	for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
+		if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
+			curHotspot = i;
+	drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
+	_system->updateScreen();
 
 	bool continueLooping = true;
 	while (!shouldQuit() && continueLooping) {
 		Common::Event event;
 		while (_eventMan->pollEvent(event)) {
+			bool updateScreen = false;
+
 			switch (event.type) {
 			case Common::EVENT_MOUSEMOVE:
-				// TODO: Highlighted images and changing the viewscreen image
-				_system->updateScreen();
+				updateScreen = true;
 				break;
 			case Common::EVENT_KEYDOWN:
 				// Break on any keypress, but ignore the meta keys
 				// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
 				continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
 				break;
+			case Common::EVENT_LBUTTONDOWN:
+				continueLooping = false;
+				break;
 			default:
 				break;
 			}
+
+			int oldHotspot = curHotspot;
+
+			for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
+				if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
+					curHotspot = i;
+
+			if (oldHotspot != curHotspot) {
+				drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
+				updateScreen = true;
+			}
+
+			if (updateScreen)
+				_system->updateScreen();
 		}
 
 		_system->delayMillis(10);
@@ -73,12 +107,27 @@ void PegasusEngine::runInterfaceOverview() {
 	delete overviewVideo;
 }
 
-void PegasusEngine::drawInterfaceOverview() {
+void PegasusEngine::drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video) {
 	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
 	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
 	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
 	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
-	_system->updateScreen();
+
+	video->seekToTime(hotspot.time);
+	_video->copyFrameToScreen(video->decodeNextFrame(), video->getWidth(), video->getHeight(), kViewScreenOffset, kViewScreenOffset);
+
+	if (hotspot.time == 530) {
+		// The keyboard is special
+		// Interesting how the file is "controller" and not keyboard. The PlayStation/Pippin versions probably
+		// had similar names...
+		_gfx->drawPict("Images/Interface/OVcontrollerHilite.mac", hotspot.rect.left, hotspot.rect.top, false);
+	} else if (hotspot.time != 1000) {
+		// TODO: Thicker line (=4px) with rounded edges
+		uint32 color = _system->getScreenFormat().RGBToColor(232, 232, 0); // Yellow
+		Graphics::Surface *screen = _system->lockScreen();
+		screen->frameRect(hotspot.rect, color);
+		_system->unlockScreen();
+	}
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 1f9f92a..bb69429 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -35,6 +35,10 @@
 #include "pegasus/graphics.h"
 #include "pegasus/video.h"
 
+namespace Video {
+	class Video::QuickTimeDecoder;
+}
+
 namespace Pegasus {
 
 struct PegasusGameDescription;
@@ -134,6 +138,11 @@ struct RightAreaData {
 	uint32 time;
 };
 
+struct OverviewHotspot {
+	Common::Rect rect;
+	uint32 time;
+};
+
 enum TimeZone {
 	kLocPrehistoric = 0,
 	kLocMars = 1,
@@ -214,10 +223,10 @@ private:
 	//void drawCompass();
 	//void runPauseMenu();
 	void showLoadDialog();
-	void runInterfaceOverview();
 
 	// Interface Overview
-	void drawInterfaceOverview();
+	void runInterfaceOverview();
+	void drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video);
 
 	// Main Game Functions
 	void mainGameLoop();


Commit: 6b8a6f486cd1235009cfb354e407878d3b2b77e9
    https://github.com/scummvm/scummvm/commit/6b8a6f486cd1235009cfb354e407878d3b2b77e9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T10:00:46-07:00

Commit Message:
PEGASUS: Finish hotspot outline code in the overview

Changed paths:
    engines/pegasus/overview.cpp



diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
index 5772707..adbfbdb 100644
--- a/engines/pegasus/overview.cpp
+++ b/engines/pegasus/overview.cpp
@@ -122,10 +122,19 @@ void PegasusEngine::drawInterfaceOverview(const OverviewHotspot &hotspot, Video:
 		// had similar names...
 		_gfx->drawPict("Images/Interface/OVcontrollerHilite.mac", hotspot.rect.left, hotspot.rect.top, false);
 	} else if (hotspot.time != 1000) {
-		// TODO: Thicker line (=4px) with rounded edges
+		// Draw a yellow outline around the hotspot
+		Common::Rect rect = hotspot.rect;
 		uint32 color = _system->getScreenFormat().RGBToColor(232, 232, 0); // Yellow
 		Graphics::Surface *screen = _system->lockScreen();
-		screen->frameRect(hotspot.rect, color);
+		screen->frameRect(rect, color);
+		rect.grow(1);
+		screen->frameRect(rect, color);
+		rect.grow(1);
+		screen->frameRect(rect, color);
+		screen->hLine(rect.left + 1, rect.top - 1, rect.right - 2, color);
+		screen->hLine(rect.left + 1, rect.bottom, rect.right - 2, color);
+		screen->vLine(rect.left - 1, rect.top + 1, rect.bottom - 2, color);
+		screen->vLine(rect.right, rect.top + 1, rect.bottom - 2, color);
 		_system->unlockScreen();
 	}
 }


Commit: 85b2a0574c68b2d4b211b5739f251708b2cd5873
    https://github.com/scummvm/scummvm/commit/85b2a0574c68b2d4b211b5739f251708b2cd5873
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T13:02:41-07:00

Commit Message:
PEGASUS: Add basic credits implementation

Changed paths:
  A engines/pegasus/credits.cpp
    engines/pegasus/menu.cpp
    engines/pegasus/module.mk
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/credits.cpp b/engines/pegasus/credits.cpp
new file mode 100644
index 0000000..3c625fa
--- /dev/null
+++ b/engines/pegasus/credits.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/events.h"
+#include "common/textconsole.h"
+#include "video/qt_decoder.h"
+
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+enum {
+	kCreditsCore = 0,
+	kCreditsSupport,
+	kCreditsOriginal,
+	kCreditsTalent,
+	kCreditsOther,
+	kCreditsMainMenu
+};
+
+static const int s_startCreditsSegment[] = { 0, 16, 25, 37, 39 };
+
+static int findButtonForFrame(int frame) {
+	int button = kCreditsCore;
+	for (int i = kCreditsCore; i < kCreditsMainMenu; i++)
+		if (frame >= s_startCreditsSegment[i])
+			button = i;
+
+	return button;
+}
+
+void PegasusEngine::runCredits() {
+	Video::QuickTimeDecoder *creditsVideo = new Video::QuickTimeDecoder();
+	if (!creditsVideo->loadFile("Images/Credits/Credits.movie"))
+		error("Could not open credits movie");
+
+	// We're not playing, just retrieving frames
+	creditsVideo->pauseVideo(true);
+
+	int curButton = kCreditsCore;
+	int frame = 0;
+
+	drawCredits(curButton, false, frame, creditsVideo);
+	_system->updateScreen();
+
+	bool continueLooping = true;
+	while (!shouldQuit() && continueLooping) {
+		Common::Event event;
+		while (_eventMan->pollEvent(event)) {
+			bool needsUpdate = false;
+
+			switch (event.type) {
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_UP:
+					if (curButton != kCreditsCore)
+						curButton--;
+					frame = s_startCreditsSegment[curButton];
+					needsUpdate = true;
+					break;
+				case Common::KEYCODE_DOWN:
+					if (curButton != kCreditsMainMenu) {
+						curButton++;
+						if (curButton == kCreditsMainMenu)
+							frame = 43;
+						else
+							frame = s_startCreditsSegment[curButton];
+						needsUpdate = true;
+					}
+					break;
+				case Common::KEYCODE_LEFT:
+					if (frame > 0) {
+						frame--;
+						curButton = findButtonForFrame(frame);
+						needsUpdate = true;
+					}
+					break;
+				case Common::KEYCODE_RIGHT:
+					if (frame < 43) {
+						frame++;
+						curButton = findButtonForFrame(frame);
+						needsUpdate = true;
+					}
+					break;
+				case Common::KEYCODE_RETURN:
+					drawCredits(curButton, true, frame, creditsVideo);
+					_system->updateScreen();
+					continueLooping = (curButton != kCreditsMainMenu);
+					break;
+				default:
+					break;
+				}
+				break;
+			default:
+				break;
+			}
+
+			if (needsUpdate) {
+				drawCredits(curButton, false, frame, creditsVideo);
+				_system->updateScreen();
+			}
+		}
+
+		_system->delayMillis(10);
+	}
+
+	delete creditsVideo;
+}
+
+void PegasusEngine::drawCredits(int button, bool highlight, int frame, Video::QuickTimeDecoder *video) {
+	static const int s_creditsButtonY[] = { 224, 260, 296, 332, 366, 407 };
+
+	_gfx->drawPict("Images/Credits/CredScrn.pict", 0, 0, false);
+
+	if (highlight)
+		_gfx->drawPict("Images/Credits/MainMenu.pict", 32, 412, false);
+
+	if (button == kCreditsMainMenu)
+		_gfx->drawPictTransparent("Images/Credits/SelectL.pict", 30, s_creditsButtonY[button], _gfx->getColor(0xf8, 0xf8, 0xf8));
+	else
+		_gfx->drawPictTransparent("Images/Credits/SelectS.pict", 40, s_creditsButtonY[button], _gfx->getColor(0xf8, 0xf8, 0xf8));
+
+	video->seekToTime(frame * 200);
+	_video->copyFrameToScreen(video->decodeNextFrame(), video->getWidth(), video->getHeight(), 288, 0);
+}
+
+void PegasusEngine::runDemoCredits() {
+	_gfx->drawPict("Images/Demo/DemoCredits.pict", 0, 0, true);
+
+	bool continueLooping = true;
+	while (!shouldQuit() && continueLooping) {
+		Common::Event event;
+		while (_eventMan->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_MOUSEMOVE:
+				_system->updateScreen();
+				break;
+			case Common::EVENT_KEYDOWN:
+				// Break on any keypress, but ignore the meta keys
+				// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
+				continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
+				break;
+			case Common::EVENT_LBUTTONDOWN:
+				continueLooping = false;
+				break;
+			default:
+				break;
+			}				
+		}
+
+		_system->delayMillis(10);
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 0febdd6..98cf59a 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -166,7 +166,9 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 			_gameMode = kMainGameMode;
 			break;
 		case kDemoCreditsButton:
-			warning("No credits just yet");
+			_sound->stopSound();
+			runDemoCredits();
+			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kDemoQuitButton:
 			_gameMode = kQuitMode;
@@ -186,7 +188,9 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 			showLoadDialog();
 			break;
 		case kCreditsButton:
-			warning("No credits just yet");
+			_sound->stopSound();
+			runCredits();
+			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kQuitButton:
 			_gameMode = kQuitMode;
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 5222c81..507c6b1 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/pegasus
 
 MODULE_OBJS = \
+	credits.o \
 	detection.o \
 	graphics.o \
 	menu.o \
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index bb69429..ad069eb 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -228,6 +228,11 @@ private:
 	void runInterfaceOverview();
 	void drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video);
 
+	// Credits
+	void runCredits();
+	void drawCredits(int button, bool highlight, int frame, Video::QuickTimeDecoder *video);
+	void runDemoCredits();
+
 	// Main Game Functions
 	void mainGameLoop();
 	void loadItemLocationData();


Commit: 50e43a56e76ac0fa82560d0e5e42f5dd330313f1
    https://github.com/scummvm/scummvm/commit/50e43a56e76ac0fa82560d0e5e42f5dd330313f1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T13:17:12-07:00

Commit Message:
PEGASUS: Add a stub debugger

Changed paths:
  A engines/pegasus/console.cpp
  A engines/pegasus/console.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
new file mode 100644
index 0000000..d6a8c1e
--- /dev/null
+++ b/engines/pegasus/console.cpp
@@ -0,0 +1,38 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "pegasus/console.h"
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+PegasusConsole::PegasusConsole(PegasusEngine *vm) : GUI::Debugger(), _vm(vm) {
+	// TODO! :P
+}
+
+PegasusConsole::~PegasusConsole() {
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/console.h b/engines/pegasus/console.h
new file mode 100644
index 0000000..f544344
--- /dev/null
+++ b/engines/pegasus/console.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef PEGASUS_CONSOLE_H
+#define PEGASUS_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Pegasus {
+
+class PegasusEngine;
+
+class PegasusConsole : public GUI::Debugger {
+public:
+	PegasusConsole(PegasusEngine *vm);
+	virtual ~PegasusConsole();
+
+private:
+	PegasusEngine *_vm;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 507c6b1..5855750 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/pegasus
 
 MODULE_OBJS = \
+	console.o \
 	credits.o \
 	detection.o \
 	graphics.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index bd281cd..ae83a05 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -30,6 +30,7 @@
 #include "base/version.h"
 #include "gui/saveload.h"
 
+#include "pegasus/console.h"
 #include "pegasus/pegasus.h"
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
@@ -47,9 +48,11 @@ PegasusEngine::~PegasusEngine() {
 	delete _resFork;
 	delete _inventoryLid;
 	delete _biochipLid;
+	delete _console;
 }
 
 Common::Error PegasusEngine::run() {
+	_console = new PegasusConsole(this);
 	_gfx = new GraphicsManager(this);
 	_video = new VideoManager(this);
 	_sound = new SoundManager(this);
@@ -332,4 +335,8 @@ Common::String PegasusEngine::getTimeZoneFolder(TimeZone timeZone) {
 	return getTimeZoneDesc(timeZone);
 }
 
+GUI::Debugger *PegasusEngine::getDebugger() {
+	return _console;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index ad069eb..2e07862 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -41,6 +41,7 @@ namespace Video {
 
 namespace Pegasus {
 
+class PegasusConsole;
 struct PegasusGameDescription;
 class SoundManager;
 class VideoManager;
@@ -200,6 +201,7 @@ public:
 	
 	const PegasusGameDescription *_gameDescription;
 	bool hasFeature(EngineFeature f) const;
+	GUI::Debugger *getDebugger();
 	
 	VideoManager *_video;
 	SoundManager *_sound;
@@ -257,6 +259,9 @@ private:
 	Common::Array<SoundSpot> _currentSoundSpots;
 	Common::Array<Zoom> _currentZooms;
 	Common::Array<Extra> _currentExtras;
+
+	// Console
+	PegasusConsole *_console;
 };
 
 } // End of namespace Pegasus


Commit: 760f50f034b54d7e109692b4d5219560b065cf3a
    https://github.com/scummvm/scummvm/commit/760f50f034b54d7e109692b4d5219560b065cf3a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T13:24:02-07:00

Commit Message:
PEGASUS: Allow the console to be attached from the menu

Changed paths:
    engines/pegasus/menu.cpp



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 98cf59a..dd32e36 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -23,6 +23,7 @@
 #include "common/events.h"
 #include "common/textconsole.h"
 
+#include "pegasus/console.h"
 #include "pegasus/pegasus.h"
 
 namespace Pegasus {
@@ -91,6 +92,12 @@ void PegasusEngine::runMainMenu() {
 						drawMenu(buttonSelected);
 					}
 					break;
+				case Common::KEYCODE_d:
+					if (event.kbd.flags & Common::KBD_CTRL) {
+						_console->attach();
+						_console->onFrame();
+					}
+					break;
 				default:
 					break;
 				}


Commit: d85dc010edb88f42493f434887fd45f29c213afd
    https://github.com/scummvm/scummvm/commit/d85dc010edb88f42493f434887fd45f29c213afd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T18:30:09-07:00

Commit Message:
PEGASUS: Add support for using the original 'Opening/Closing' directory

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index dd32e36..33e8df3 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -119,7 +119,7 @@ void PegasusEngine::runMainMenu() {
 
 	// Too slow! Go back and show the intro again.
 	_sound->stopSound();
-	_video->playMovie("Images/Opening_Closing/LilMovie.movie");
+	_video->playMovie(_introDirectory + "/LilMovie.movie");
 	_gameMode = kIntroMode;
 }
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ae83a05..a3a3822 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -24,6 +24,7 @@
 #include "common/error.h"
 #include "common/events.h"
 #include "common/file.h"
+#include "common/fs.h"
 #include "common/textconsole.h"
 #include "common/translation.h"
 #include "base/plugins.h"
@@ -73,6 +74,21 @@ Common::Error PegasusEngine::run() {
 
 	loadItemLocationData();
 
+	if (!detectOpeningClosingDirectory()) {
+		Common::String message = "Missing intro directory. ";
+
+		// Give Mac OS X a more specific message because we can
+#ifdef MACOSX
+		message += "Make sure \"Opening/Closing\" is present.";
+#else
+		message += "Be sure to rename \"Opening/Closing\" to \"Opening_Closing\".";
+#endif
+
+		GUIErrorMessage(message);
+		warning("%s", message.c_str());
+		return Common::kNoGameDataFoundError;
+	}
+
 #if 0
 	Common::MacResIDArray pictIds = _biochipLid->getResIDArray(MKID_BE('PICT'));
 	for (uint32 i = 0; i < pictIds.size(); i++) {
@@ -138,6 +154,39 @@ Common::Error PegasusEngine::run() {
 	return Common::kNoError;
 }
 
+bool PegasusEngine::detectOpeningClosingDirectory() {
+	// We need to detect what our Opening/Closing directory is listed as
+	// On the original disc, it was 'Opening/Closing' but only HFS(+) supports the slash
+	// Mac OS X will display this as 'Opening:Closing' and we can use that directly
+	// On other systems, users will need to rename to "Opening_Closing"
+
+	Common::FSNode gameDataDir(ConfMan.get("path"));
+	gameDataDir = gameDataDir.getChild("Images");
+
+	if (!gameDataDir.exists())
+		return false;
+
+	Common::FSList fsList;
+	if (!gameDataDir.getChildren(fsList, Common::FSNode::kListDirectoriesOnly, true))
+		return false;
+
+	for (uint i = 0; i < fsList.size() && _introDirectory.empty(); i++) {
+		Common::String name = fsList[i].getName();
+
+		if (name.equalsIgnoreCase("Opening:Closing"))
+			_introDirectory = name;
+		else if (name.equalsIgnoreCase("Opening_Closing"))
+			_introDirectory = name;
+	}
+
+	if (_introDirectory.empty())
+		return false;
+
+	debug(0, "Detected intro location as '%s'", _introDirectory.c_str());
+	_introDirectory = Common::String("Images/") + _introDirectory;
+	return true;
+}
+
 void PegasusEngine::loadItemLocationData() {
 	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 
@@ -158,11 +207,8 @@ void PegasusEngine::loadItemLocationData() {
 }
 
 void PegasusEngine::runIntro() {
-	// The Opening/Closing folder will need to be renamed to something else. Windows
-	// and other OS's/FS's do not support a '/' in the filename. I arbitrarily chose
-	// to rename my folder with the underscore.
-	_video->playMovieCentered("Images/Opening_Closing/BandaiLogo.movie");
-	VideoHandle handle = _video->playBackgroundMovie("Images/Opening_Closing/Big Movie.movie");
+	_video->playMovieCentered(_introDirectory + "/BandaiLogo.movie");
+	VideoHandle handle = _video->playBackgroundMovie(_introDirectory + "/Big Movie.movie");
 	_video->seekToTime(handle, 10 * 600);
 	_video->waitUntilMovieEnds(handle);
 }
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 2e07862..ee5dc76 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -262,6 +262,10 @@ private:
 
 	// Console
 	PegasusConsole *_console;
+
+	// Intro Directory Code
+	bool detectOpeningClosingDirectory();
+	Common::String _introDirectory;
 };
 
 } // End of namespace Pegasus


Commit: 7e2edf16b3e2bf1d2b31999979a60802514df6cb
    https://github.com/scummvm/scummvm/commit/7e2edf16b3e2bf1d2b31999979a60802514df6cb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-12T19:18:31-07:00

Commit Message:
PEGASUS: Make the intro directory check only work in the full game

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a3a3822..cf79900 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -74,7 +74,7 @@ Common::Error PegasusEngine::run() {
 
 	loadItemLocationData();
 
-	if (!detectOpeningClosingDirectory()) {
+	if (!isDemo() && !detectOpeningClosingDirectory()) {
 		Common::String message = "Missing intro directory. ";
 
 		// Give Mac OS X a more specific message because we can


Commit: d4c92983920cfe3b25a22d91e12c750e591b917e
    https://github.com/scummvm/scummvm/commit/d4c92983920cfe3b25a22d91e12c750e591b917e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-05-18T15:23:37-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A audio/softsynth/fmtowns_pc98/towns_midi.cpp
  A audio/softsynth/fmtowns_pc98/towns_midi.h
  A audio/softsynth/fmtowns_pc98/towns_pc98_plugins.cpp
  A backends/platform/n64/pad_rom.sh
  A devtools/create_project/scripts/installer.vbs
  A dists/nsis/graphics/left.bmp
  A dists/nsis/graphics/scummvm-install.ico
  A dists/nsis/scummvm.nsi
  A dists/nsis/scummvm.nsi.in
  A doc/translations/README-de.txt
  A doc/translations/README-fr.txt
  A doc/translations/README-translation_template.txt
  A engines/tsage/blueforce_logic.cpp
  A engines/tsage/blueforce_logic.h
  A graphics/maccursor.cpp
  A graphics/maccursor.h
  A graphics/yuv_to_rgb.cpp
  A graphics/yuv_to_rgb.h
  R audio/softsynth/ym2612.cpp
  R audio/softsynth/ym2612.h
  R backends/platform/n64/pad_rom.sh
    .gitignore
    AUTHORS
    Makefile
    Makefile.common
    NEWS
    audio/audiostream.cpp
    audio/audiostream.h
    audio/decoders/adpcm.cpp
    audio/decoders/adpcm.h
    audio/decoders/adpcm_intern.h
    audio/decoders/aiff.cpp
    audio/decoders/aiff.h
    audio/decoders/flac.cpp
    audio/decoders/flac.h
    audio/decoders/iff_sound.cpp
    audio/decoders/iff_sound.h
    audio/decoders/mac_snd.cpp
    audio/decoders/mac_snd.h
    audio/decoders/mp3.cpp
    audio/decoders/mp3.h
    audio/decoders/raw.cpp
    audio/decoders/raw.h
    audio/decoders/vag.cpp
    audio/decoders/vag.h
    audio/decoders/voc.cpp
    audio/decoders/voc.h
    audio/decoders/vorbis.cpp
    audio/decoders/vorbis.h
    audio/decoders/wave.cpp
    audio/decoders/wave.h
    audio/fmopl.cpp
    audio/fmopl.h
    audio/mididrv.cpp
    audio/mididrv.h
    audio/midiparser.cpp
    audio/midiparser.h
    audio/midiparser_smf.cpp
    audio/midiparser_xmidi.cpp
    audio/midiplayer.cpp
    audio/midiplayer.h
    audio/mixer.cpp
    audio/mixer.h
    audio/mixer_intern.h
    audio/mods/infogrames.cpp
    audio/mods/infogrames.h
    audio/mods/maxtrax.cpp
    audio/mods/maxtrax.h
    audio/mods/module.cpp
    audio/mods/module.h
    audio/mods/paula.cpp
    audio/mods/paula.h
    audio/mods/protracker.cpp
    audio/mods/protracker.h
    audio/mods/rjp1.cpp
    audio/mods/rjp1.h
    audio/mods/soundfx.cpp
    audio/mods/soundfx.h
    audio/mods/tfmx.cpp
    audio/mods/tfmx.h
    audio/module.mk
    audio/mpu401.cpp
    audio/mpu401.h
    audio/musicplugin.cpp
    audio/musicplugin.h
    audio/null.cpp
    audio/null.h
    audio/rate.cpp
    audio/rate.h
    audio/rate_arm.cpp
    audio/rate_arm_asm.s
    audio/softsynth/adlib.cpp
    audio/softsynth/appleiigs.cpp
    audio/softsynth/cms.cpp
    audio/softsynth/cms.h
    audio/softsynth/eas.cpp
    audio/softsynth/emumidi.h
    audio/softsynth/fluidsynth.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.h
    audio/softsynth/fmtowns_pc98/towns_euphony.cpp
    audio/softsynth/fmtowns_pc98/towns_euphony.h
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.h
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
    audio/softsynth/mt32.cpp
    audio/softsynth/mt32/freeverb.cpp
    audio/softsynth/mt32/freeverb.h
    audio/softsynth/mt32/partial.cpp
    audio/softsynth/mt32/synth.cpp
    audio/softsynth/mt32/tables.cpp
    audio/softsynth/opl/dosbox.cpp
    audio/softsynth/opl/dosbox.h
    audio/softsynth/opl/mame.cpp
    audio/softsynth/opl/mame.h
    audio/softsynth/pcspk.cpp
    audio/softsynth/pcspk.h
    audio/softsynth/sid.cpp
    audio/softsynth/sid.h
    audio/softsynth/wave6581.cpp
    audio/timestamp.cpp
    audio/timestamp.h
    backends/audiocd/audiocd.h
    backends/audiocd/default/default-audiocd.cpp
    backends/audiocd/default/default-audiocd.h
    backends/audiocd/sdl/sdl-audiocd.cpp
    backends/audiocd/sdl/sdl-audiocd.h
    backends/base-backend.cpp
    backends/base-backend.h
    backends/events/default/default-events.cpp
    backends/events/default/default-events.h
    backends/events/dinguxsdl/dinguxsdl-events.cpp
    backends/events/dinguxsdl/dinguxsdl-events.h
    backends/events/linuxmotosdl/linuxmotosdl-events.cpp
    backends/events/linuxmotosdl/linuxmotosdl-events.h
    backends/events/samsungtvsdl/samsungtvsdl-events.cpp
    backends/events/samsungtvsdl/samsungtvsdl-events.h
    backends/events/sdl/sdl-events.cpp
    backends/events/sdl/sdl-events.h
    backends/events/symbiansdl/symbiansdl-events.cpp
    backends/events/symbiansdl/symbiansdl-events.h
    backends/events/webossdl/webossdl-events.cpp
    backends/events/webossdl/webossdl-events.h
    backends/events/wincesdl/wincesdl-events.cpp
    backends/events/wincesdl/wincesdl-events.h
    backends/fs/abstract-fs.cpp
    backends/fs/abstract-fs.h
    backends/fs/amigaos4/amigaos4-fs-factory.cpp
    backends/fs/amigaos4/amigaos4-fs-factory.h
    backends/fs/amigaos4/amigaos4-fs.cpp
    backends/fs/amigaos4/amigaos4-fs.h
    backends/fs/ds/ds-fs-factory.cpp
    backends/fs/ds/ds-fs-factory.h
    backends/fs/ds/ds-fs.cpp
    backends/fs/ds/ds-fs.h
    backends/fs/fs-factory.h
    backends/fs/n64/n64-fs-factory.cpp
    backends/fs/n64/n64-fs-factory.h
    backends/fs/n64/n64-fs.h
    backends/fs/posix/posix-fs-factory.cpp
    backends/fs/posix/posix-fs-factory.h
    backends/fs/posix/posix-fs.cpp
    backends/fs/posix/posix-fs.h
    backends/fs/ps2/ps2-fs-factory.cpp
    backends/fs/ps2/ps2-fs-factory.h
    backends/fs/ps2/ps2-fs.cpp
    backends/fs/ps2/ps2-fs.h
    backends/fs/psp/psp-fs-factory.cpp
    backends/fs/psp/psp-fs-factory.h
    backends/fs/psp/psp-fs.cpp
    backends/fs/psp/psp-fs.h
    backends/fs/psp/psp-stream.cpp
    backends/fs/psp/psp-stream.h
    backends/fs/stdiostream.cpp
    backends/fs/stdiostream.h
    backends/fs/symbian/symbian-fs-factory.cpp
    backends/fs/symbian/symbian-fs-factory.h
    backends/fs/symbian/symbian-fs.cpp
    backends/fs/symbian/symbian-fs.h
    backends/fs/symbian/symbianstream.cpp
    backends/fs/symbian/symbianstream.h
    backends/fs/wii/wii-fs.h
    backends/fs/windows/windows-fs-factory.cpp
    backends/fs/windows/windows-fs-factory.h
    backends/fs/windows/windows-fs.cpp
    backends/fs/windows/windows-fs.h
    backends/graphics/default-palette.h
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.h
    backends/graphics/gp2xsdl/gp2xsdl-graphics.h
    backends/graphics/graphics.h
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/glerrorcheck.cpp
    backends/graphics/opengl/glerrorcheck.h
    backends/graphics/opengl/gltexture.cpp
    backends/graphics/opengl/gltexture.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.h
    backends/graphics/sdl/sdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.h
    backends/graphics/symbiansdl/symbiansdl-graphics.cpp
    backends/graphics/symbiansdl/symbiansdl-graphics.h
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/keymapper/action.cpp
    backends/keymapper/action.h
    backends/keymapper/hardware-key.h
    backends/keymapper/keymap.cpp
    backends/keymapper/keymap.h
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    backends/keymapper/remap-dialog.cpp
    backends/keymapper/remap-dialog.h
    backends/keymapper/types.h
    backends/log/log.cpp
    backends/log/log.h
    backends/midi/alsa.cpp
    backends/midi/camd.cpp
    backends/midi/coreaudio.cpp
    backends/midi/coremidi.cpp
    backends/midi/dmedia.cpp
    backends/midi/seq.cpp
    backends/midi/stmidi.cpp
    backends/midi/timidity.cpp
    backends/midi/windows.cpp
    backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
    backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h
    backends/mixer/sdl/sdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.h
    backends/mixer/symbiansdl/symbiansdl-mixer.cpp
    backends/mixer/symbiansdl/symbiansdl-mixer.h
    backends/mixer/wincesdl/wincesdl-mixer.cpp
    backends/mixer/wincesdl/wincesdl-mixer.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/module.mk
    backends/mutex/mutex.h
    backends/mutex/null/null-mutex.h
    backends/mutex/sdl/sdl-mutex.cpp
    backends/mutex/sdl/sdl-mutex.h
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/asset-archive.cpp
    backends/platform/android/asset-archive.h
    backends/platform/android/events.cpp
    backends/platform/android/gfx.cpp
    backends/platform/android/jni.cpp
    backends/platform/android/jni.h
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h
    backends/platform/dc/DCLauncherDialog.h
    backends/platform/dc/Makefile
    backends/platform/dc/audio.cpp
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcloader.cpp
    backends/platform/dc/dcloader.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/display.cpp
    backends/platform/dc/dreamcast.mk
    backends/platform/dc/icon.cpp
    backends/platform/dc/icon.h
    backends/platform/dc/input.cpp
    backends/platform/dc/label.cpp
    backends/platform/dc/label.h
    backends/platform/dc/plugins.cpp
    backends/platform/dc/portdefs.h
    backends/platform/dc/selector.cpp
    backends/platform/dc/softkbd.cpp
    backends/platform/dc/softkbd.h
    backends/platform/dc/time.cpp
    backends/platform/dc/vmsave.cpp
    backends/platform/dingux/dingux.cpp
    backends/platform/dingux/dingux.h
    backends/platform/dingux/main.cpp
    backends/platform/ds/arm7/source/main.cpp
    backends/platform/ds/arm9/source/adpcm_arm.s
    backends/platform/ds/arm9/source/blitters.cpp
    backends/platform/ds/arm9/source/blitters.h
    backends/platform/ds/arm9/source/blitters_arm.s
    backends/platform/ds/arm9/source/cdaudio.cpp
    backends/platform/ds/arm9/source/cdaudio.h
    backends/platform/ds/arm9/source/dsmain.cpp
    backends/platform/ds/arm9/source/dsmain.h
    backends/platform/ds/arm9/source/dsoptions.cpp
    backends/platform/ds/arm9/source/dsoptions.h
    backends/platform/ds/arm9/source/gbampsave.cpp
    backends/platform/ds/arm9/source/gbampsave.h
    backends/platform/ds/arm9/source/keys.h
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/ds/arm9/source/portdefs.h
    backends/platform/ds/arm9/source/scummhelp.cpp
    backends/platform/ds/arm9/source/scummhelp.h
    backends/platform/ds/arm9/source/touchkeyboard.h
    backends/platform/ds/arm9/source/wordcompletion.cpp
    backends/platform/ds/arm9/source/wordcompletion.h
    backends/platform/ds/arm9/source/zipreader.cpp
    backends/platform/ds/arm9/source/zipreader.h
    backends/platform/ds/commoninclude/NDS/scummvm_ipc.h
    backends/platform/gp2x/gp2x-common.h
    backends/platform/gp2x/gp2x-hw.cpp
    backends/platform/gp2x/gp2x-hw.h
    backends/platform/gp2x/gp2x-mem.cpp
    backends/platform/gp2x/gp2x-mem.h
    backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c
    backends/platform/gph/gph-hw.cpp
    backends/platform/gph/gph-hw.h
    backends/platform/iphone/blit.cpp
    backends/platform/iphone/blit_arm.h
    backends/platform/iphone/blit_arm.s
    backends/platform/iphone/iphone_common.h
    backends/platform/iphone/iphone_keyboard.h
    backends/platform/iphone/iphone_keyboard.m
    backends/platform/iphone/iphone_main.m
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.m
    backends/platform/iphone/osys_events.cpp
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_sound.cpp
    backends/platform/iphone/osys_video.cpp
    backends/platform/linuxmoto/hardwarekeys.cpp
    backends/platform/linuxmoto/linuxmoto-main.cpp
    backends/platform/linuxmoto/linuxmoto-sdl.cpp
    backends/platform/linuxmoto/linuxmoto-sdl.h
    backends/platform/n64/framfs_save_manager.cpp
    backends/platform/n64/framfs_save_manager.h
    backends/platform/n64/nintendo64.cpp
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/osys_n64_events.cpp
    backends/platform/n64/osys_n64_utilities.cpp
    backends/platform/n64/pakfs_save_manager.cpp
    backends/platform/n64/pakfs_save_manager.h
    backends/platform/n64/portdefs.h
    backends/platform/null/null.cpp
    backends/platform/openpandora/op-options.cpp
    backends/platform/openpandora/op-options.h
    backends/platform/ps2/DmaPipe.cpp
    backends/platform/ps2/DmaPipe.h
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Gs2dScreen.h
    backends/platform/ps2/GsDefs.h
    backends/platform/ps2/asyncfio.cpp
    backends/platform/ps2/asyncfio.h
    backends/platform/ps2/eecodyvdfs.c
    backends/platform/ps2/eecodyvdfs.h
    backends/platform/ps2/fileio.cpp
    backends/platform/ps2/fileio.h
    backends/platform/ps2/icon.cpp
    backends/platform/ps2/iop/CoDyVDfs/common/codyvdirx.h
    backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
    backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
    backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
    backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
    backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.h
    backends/platform/ps2/iop/CoDyVDfs/iop/irx_imports.h
    backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
    backends/platform/ps2/iop/rpckbd/src/irx_imports.h
    backends/platform/ps2/irxboot.cpp
    backends/platform/ps2/irxboot.h
    backends/platform/ps2/ps2debug.h
    backends/platform/ps2/ps2input.cpp
    backends/platform/ps2/ps2input.h
    backends/platform/ps2/ps2mutex.cpp
    backends/platform/ps2/ps2pad.cpp
    backends/platform/ps2/ps2pad.h
    backends/platform/ps2/ps2time.cpp
    backends/platform/ps2/savefilemgr.cpp
    backends/platform/ps2/savefilemgr.h
    backends/platform/ps2/sysdefs.h
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/Makefile
    backends/platform/psp/audio.cpp
    backends/platform/psp/audio.h
    backends/platform/psp/cursor.cpp
    backends/platform/psp/cursor.h
    backends/platform/psp/default_display_client.cpp
    backends/platform/psp/default_display_client.h
    backends/platform/psp/display_client.cpp
    backends/platform/psp/display_client.h
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/display_manager.h
    backends/platform/psp/dummy.cpp
    backends/platform/psp/image_viewer.cpp
    backends/platform/psp/image_viewer.h
    backends/platform/psp/input.cpp
    backends/platform/psp/input.h
    backends/platform/psp/memory.cpp
    backends/platform/psp/memory.h
    backends/platform/psp/mp3.cpp
    backends/platform/psp/mp3.h
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/osys_psp.h
    backends/platform/psp/png_loader.cpp
    backends/platform/psp/png_loader.h
    backends/platform/psp/portdefs.h
    backends/platform/psp/powerman.cpp
    backends/platform/psp/powerman.h
    backends/platform/psp/psp_main.cpp
    backends/platform/psp/pspkeyboard.cpp
    backends/platform/psp/pspkeyboard.h
    backends/platform/psp/psppixelformat.cpp
    backends/platform/psp/psppixelformat.h
    backends/platform/psp/rtc.cpp
    backends/platform/psp/rtc.h
    backends/platform/psp/tests.cpp
    backends/platform/psp/tests.h
    backends/platform/psp/thread.cpp
    backends/platform/psp/thread.h
    backends/platform/psp/trace.cpp
    backends/platform/psp/trace.h
    backends/platform/samsungtv/main.cpp
    backends/platform/samsungtv/samsungtv.cpp
    backends/platform/samsungtv/samsungtv.h
    backends/platform/sdl/amigaos/amigaos-main.cpp
    backends/platform/sdl/amigaos/amigaos.cpp
    backends/platform/sdl/amigaos/amigaos.h
    backends/platform/sdl/hardwarekeys.cpp
    backends/platform/sdl/macosx/macosx-main.cpp
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx.h
    backends/platform/sdl/main.cpp
    backends/platform/sdl/posix/posix-main.cpp
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/posix/posix.h
    backends/platform/sdl/sdl-sys.h
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    backends/platform/sdl/win32/win32-main.cpp
    backends/platform/sdl/win32/win32.cpp
    backends/platform/sdl/win32/win32.h
    backends/platform/symbian/README
    backends/platform/symbian/S60/ScummVM_S60.mmp.in
    backends/platform/symbian/S60/ScummVM_S60_App.mmp
    backends/platform/symbian/S60/scummvm-CVS-SymbianS60v1.pkg
    backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg
    backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
    backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
    backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
    backends/platform/symbian/S80/ScummVM_S80.mmp.in
    backends/platform/symbian/S80/ScummVM_S80_App.mmp
    backends/platform/symbian/S80/scummvm-CVS-SymbianS80.pkg
    backends/platform/symbian/S90/Scummvm_S90.mmp.in
    backends/platform/symbian/S90/Scummvm_S90_App.mmp
    backends/platform/symbian/S90/scummvm-CVS-SymbianS90.pkg
    backends/platform/symbian/UIQ2/ScummVM.rss
    backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in
    backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2.pkg
    backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg
    backends/platform/symbian/UIQ3/ScummVM.rss
    backends/platform/symbian/UIQ3/ScummVM_A0000658.rss
    backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
    backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss
    backends/platform/symbian/mmp/scummvm_agi.mmp.in
    backends/platform/symbian/mmp/scummvm_agos.mmp.in
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/mmp/scummvm_cine.mmp.in
    backends/platform/symbian/mmp/scummvm_cruise.mmp.in
    backends/platform/symbian/mmp/scummvm_draci.mmp.in
    backends/platform/symbian/mmp/scummvm_drascula.mmp.in
    backends/platform/symbian/mmp/scummvm_gob.mmp.in
    backends/platform/symbian/mmp/scummvm_groovie.mmp.in
    backends/platform/symbian/mmp/scummvm_hugo.mmp.in
    backends/platform/symbian/mmp/scummvm_kyra.mmp.in
    backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
    backends/platform/symbian/mmp/scummvm_lure.mmp.in
    backends/platform/symbian/mmp/scummvm_m4.mmp.in
    backends/platform/symbian/mmp/scummvm_made.mmp.in
    backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
    backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
    backends/platform/symbian/mmp/scummvm_queen.mmp.in
    backends/platform/symbian/mmp/scummvm_saga.mmp.in
    backends/platform/symbian/mmp/scummvm_sci.mmp.in
    backends/platform/symbian/mmp/scummvm_scumm.mmp.in
    backends/platform/symbian/mmp/scummvm_sky.mmp.in
    backends/platform/symbian/mmp/scummvm_sword1.mmp.in
    backends/platform/symbian/mmp/scummvm_sword2.mmp.in
    backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
    backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
    backends/platform/symbian/mmp/scummvm_toon.mmp.in
    backends/platform/symbian/mmp/scummvm_touche.mmp.in
    backends/platform/symbian/mmp/scummvm_tsage.mmp.in
    backends/platform/symbian/mmp/scummvm_tucker.mmp.in
    backends/platform/symbian/res/ScummVmAif.rss
    backends/platform/symbian/res/scummvm.rss
    backends/platform/symbian/res/scummvm_A0000658.rss
    backends/platform/symbian/src/ScummApp.cpp
    backends/platform/symbian/src/ScummApp.h
    backends/platform/symbian/src/ScummVMApp.h
    backends/platform/symbian/src/ScummVm.hrh
    backends/platform/symbian/src/SymbianActions.cpp
    backends/platform/symbian/src/SymbianActions.h
    backends/platform/symbian/src/SymbianMain.cpp
    backends/platform/symbian/src/SymbianOS.cpp
    backends/platform/symbian/src/SymbianOS.h
    backends/platform/symbian/src/portdefs.h
    backends/platform/webos/main.cpp
    backends/platform/webos/webos.cpp
    backends/platform/webos/webos.h
    backends/platform/webos/webos.mk
    backends/platform/wince/CEActionsPocket.cpp
    backends/platform/wince/CEActionsPocket.h
    backends/platform/wince/CEActionsSmartphone.cpp
    backends/platform/wince/CEActionsSmartphone.h
    backends/platform/wince/CEDevice.cpp
    backends/platform/wince/CEDevice.h
    backends/platform/wince/CEException.cpp
    backends/platform/wince/CEException.h
    backends/platform/wince/CELauncherDialog.cpp
    backends/platform/wince/CELauncherDialog.h
    backends/platform/wince/CEScaler.cpp
    backends/platform/wince/CEScaler.h
    backends/platform/wince/CEgui/CEGUI.h
    backends/platform/wince/CEgui/GUIElement.cpp
    backends/platform/wince/CEgui/GUIElement.h
    backends/platform/wince/CEgui/ItemAction.cpp
    backends/platform/wince/CEgui/ItemAction.h
    backends/platform/wince/CEgui/ItemSwitch.cpp
    backends/platform/wince/CEgui/ItemSwitch.h
    backends/platform/wince/CEgui/Panel.cpp
    backends/platform/wince/CEgui/Panel.h
    backends/platform/wince/CEgui/PanelItem.cpp
    backends/platform/wince/CEgui/PanelItem.h
    backends/platform/wince/CEgui/PanelKeyboard.cpp
    backends/platform/wince/CEgui/PanelKeyboard.h
    backends/platform/wince/CEgui/SDL_ImageResource.cpp
    backends/platform/wince/CEgui/SDL_ImageResource.h
    backends/platform/wince/CEgui/Toolbar.cpp
    backends/platform/wince/CEgui/Toolbar.h
    backends/platform/wince/CEgui/ToolbarHandler.cpp
    backends/platform/wince/CEgui/ToolbarHandler.h
    backends/platform/wince/CEkeys/CEKeys.h
    backends/platform/wince/CEkeys/EventsBuffer.cpp
    backends/platform/wince/CEkeys/EventsBuffer.h
    backends/platform/wince/Makefile
    backends/platform/wince/missing/missing.cpp
    backends/platform/wince/module.mk
    backends/platform/wince/portdefs.h
    backends/platform/wince/smartLandScale.s
    backends/platform/wince/stub.cpp
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince-sdl.h
    backends/platform/wince/wince.mk
    backends/plugins/ds/ds-provider.cpp
    backends/plugins/ds/ds-provider.h
    backends/plugins/dynamic-plugin.h
    backends/plugins/elf/arm-loader.cpp
    backends/plugins/elf/arm-loader.h
    backends/plugins/elf/elf-loader.cpp
    backends/plugins/elf/elf-loader.h
    backends/plugins/elf/elf-provider.cpp
    backends/plugins/elf/elf-provider.h
    backends/plugins/elf/elf32.h
    backends/plugins/elf/memory-manager.cpp
    backends/plugins/elf/memory-manager.h
    backends/plugins/elf/mips-loader.cpp
    backends/plugins/elf/mips-loader.h
    backends/plugins/elf/ppc-loader.cpp
    backends/plugins/elf/ppc-loader.h
    backends/plugins/elf/shorts-segment-manager.cpp
    backends/plugins/elf/shorts-segment-manager.h
    backends/plugins/elf/version.cpp
    backends/plugins/elf/version.h
    backends/plugins/posix/posix-provider.cpp
    backends/plugins/posix/posix-provider.h
    backends/plugins/ps2/ps2-provider.cpp
    backends/plugins/ps2/ps2-provider.h
    backends/plugins/psp/psp-provider.cpp
    backends/plugins/psp/psp-provider.h
    backends/plugins/sdl/sdl-provider.cpp
    backends/plugins/sdl/sdl-provider.h
    backends/plugins/wii/wii-provider.cpp
    backends/plugins/wii/wii-provider.h
    backends/plugins/win32/win32-provider.cpp
    backends/plugins/win32/win32-provider.h
    backends/saves/default/default-saves.cpp
    backends/saves/default/default-saves.h
    backends/saves/posix/posix-saves.cpp
    backends/saves/posix/posix-saves.h
    backends/saves/psp/psp-saves.cpp
    backends/saves/psp/psp-saves.h
    backends/saves/savefile.cpp
    backends/timer/default/default-timer.cpp
    backends/timer/default/default-timer.h
    backends/timer/psp/timer.cpp
    backends/timer/psp/timer.h
    backends/timer/sdl/sdl-timer.cpp
    backends/timer/sdl/sdl-timer.h
    backends/vkeybd/image-map.cpp
    backends/vkeybd/image-map.h
    backends/vkeybd/packs/vkeybd_default.zip
    backends/vkeybd/polygon.cpp
    backends/vkeybd/polygon.h
    backends/vkeybd/virtual-keyboard-gui.cpp
    backends/vkeybd/virtual-keyboard-gui.h
    backends/vkeybd/virtual-keyboard-parser.cpp
    backends/vkeybd/virtual-keyboard-parser.h
    backends/vkeybd/virtual-keyboard.cpp
    backends/vkeybd/virtual-keyboard.h
    base/commandLine.cpp
    base/commandLine.h
    base/main.cpp
    base/main.h
    base/plugins.cpp
    base/plugins.h
    base/version.cpp
    base/version.h
    common/EventDispatcher.cpp
    common/EventRecorder.cpp
    common/EventRecorder.h
    common/algorithm.h
    common/archive.cpp
    common/archive.h
    common/array.h
    common/bufferedstream.h
    common/config-file.cpp
    common/config-file.h
    common/config-manager.cpp
    common/config-manager.h
    common/dcl.cpp
    common/dcl.h
    common/debug-channels.h
    common/debug.cpp
    common/debug.h
    common/endian.h
    common/error.cpp
    common/error.h
    common/events.h
    common/file.cpp
    common/file.h
    common/forbidden.h
    common/frac.h
    common/fs.cpp
    common/fs.h
    common/func.h
    common/hash-str.h
    common/hashmap.cpp
    common/hashmap.h
    common/iff_container.cpp
    common/iff_container.h
    common/keyboard.h
    common/list.h
    common/list_intern.h
    common/macresman.cpp
    common/macresman.h
    common/md5.cpp
    common/md5.h
    common/memorypool.cpp
    common/memorypool.h
    common/memstream.h
    common/mutex.cpp
    common/mutex.h
    common/noncopyable.h
    common/pack-end.h
    common/pack-start.h
    common/ptr.h
    common/queue.h
    common/random.cpp
    common/random.h
    common/rational.cpp
    common/rational.h
    common/rect.h
    common/savefile.h
    common/scummsys.h
    common/serializer.h
    common/singleton.h
    common/stack.h
    common/str-array.h
    common/str.cpp
    common/str.h
    common/stream.cpp
    common/stream.h
    common/substream.h
    common/system.cpp
    common/system.h
    common/textconsole.cpp
    common/textconsole.h
    common/timer.h
    common/tokenizer.cpp
    common/tokenizer.h
    common/translation.cpp
    common/translation.h
    common/types.h
    common/unarj.cpp
    common/unarj.h
    common/unzip.cpp
    common/unzip.h
    common/util.cpp
    common/util.h
    common/winexe.cpp
    common/winexe.h
    common/winexe_ne.cpp
    common/winexe_ne.h
    common/winexe_pe.cpp
    common/winexe_pe.h
    common/xmlparser.cpp
    common/xmlparser.h
    common/zlib.cpp
    common/zlib.h
    configure
    devtools/construct-pred-dict.pl
    devtools/convbdf.c
    devtools/create_drascula/create_drascula.cpp
    devtools/create_drascula/create_drascula.h
    devtools/create_drascula/module.mk
    devtools/create_drascula/staticdata.h
    devtools/create_hugo/create_hugo.cpp
    devtools/create_hugo/create_hugo.h
    devtools/create_hugo/staticdata.h
    devtools/create_hugo/staticdisplay.h
    devtools/create_hugo/staticengine.h
    devtools/create_hugo/staticfont.h
    devtools/create_hugo/staticintro.h
    devtools/create_hugo/staticmouse.h
    devtools/create_hugo/staticparser.h
    devtools/create_hugo/staticutil.h
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/create_kyradat.h
    devtools/create_kyradat/extract.cpp
    devtools/create_kyradat/extract.h
    devtools/create_kyradat/games.cpp
    devtools/create_kyradat/md5.cpp
    devtools/create_kyradat/md5.h
    devtools/create_kyradat/module.mk
    devtools/create_kyradat/pak.cpp
    devtools/create_kyradat/pak.h
    devtools/create_kyradat/search.cpp
    devtools/create_kyradat/search.h
    devtools/create_kyradat/tables.cpp
    devtools/create_kyradat/tables.h
    devtools/create_kyradat/util.cpp
    devtools/create_kyradat/util.h
    devtools/create_lure/create_lure_dat.cpp
    devtools/create_lure/create_lure_dat.h
    devtools/create_lure/module.mk
    devtools/create_lure/process_actions.cpp
    devtools/create_mads/main.cpp
    devtools/create_mads/module.mk
    devtools/create_mads/parser.cpp
    devtools/create_mads/parser.h
    devtools/create_project/codeblocks.cpp
    devtools/create_project/codeblocks.h
    devtools/create_project/config.h
    devtools/create_project/create_project.cpp
    devtools/create_project/create_project.h
    devtools/create_project/module.mk
    devtools/create_project/msbuild.cpp
    devtools/create_project/msbuild.h
    devtools/create_project/msvc.cpp
    devtools/create_project/msvc.h
    devtools/create_project/msvc10/create_project.vcxproj
    devtools/create_project/msvc10/create_project.vcxproj.filters
    devtools/create_project/msvc8/create_project.vcproj
    devtools/create_project/msvc9/create_project.vcproj
    devtools/create_project/scripts/postbuild.cmd
    devtools/create_project/scripts/prebuild.cmd
    devtools/create_project/scripts/revision.vbs
    devtools/create_project/visualstudio.cpp
    devtools/create_project/visualstudio.h
    devtools/create_teenagent/create_teenagent.cpp
    devtools/create_teenagent/md5.cpp
    devtools/create_teenagent/md5.h
    devtools/create_teenagent/module.mk
    devtools/create_teenagent/util.h
    devtools/create_toon/create_toon.cpp
    devtools/create_toon/create_toon.h
    devtools/create_toon/staticdata.h
    devtools/credits.pl
    devtools/dist-scummvm.sh
    devtools/extract-words-tok.pl
    devtools/make-scumm-fontdata.c
    devtools/md5table.c
    devtools/module.mk
    devtools/qtable/module.mk
    devtools/sci/musicplayer.cpp
    devtools/sci/scidisasm.cpp
    devtools/sci/scipack.cpp
    devtools/sci/scitrace.asm
    devtools/skycpt/AsciiCptCompile.cpp
    devtools/skycpt/KmpSearch.cpp
    devtools/skycpt/KmpSearch.h
    devtools/skycpt/TextFile.cpp
    devtools/skycpt/TextFile.h
    devtools/skycpt/cptcompiler.cpp
    devtools/skycpt/cpthelp.cpp
    devtools/skycpt/cpthelp.h
    devtools/skycpt/idFinder.cpp
    devtools/skycpt/module.mk
    devtools/skycpt/stdafx.cpp
    devtools/skycpt/stdafx.h
    devtools/themeparser.py
    devtools/update-version.pl
    dists/iphone/scummvm.xcodeproj/project.pbxproj
    dists/scummvm.rc
    dists/scummvm.rc.in
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/checks.cpp
    engines/agi/console.cpp
    engines/agi/console.h
    engines/agi/cycle.cpp
    engines/agi/detection.cpp
    engines/agi/detection_tables.h
    engines/agi/font.h
    engines/agi/global.cpp
    engines/agi/graphics.cpp
    engines/agi/graphics.h
    engines/agi/id.cpp
    engines/agi/inv.cpp
    engines/agi/keyboard.cpp
    engines/agi/keyboard.h
    engines/agi/loader_v2.cpp
    engines/agi/loader_v3.cpp
    engines/agi/logic.cpp
    engines/agi/logic.h
    engines/agi/lzw.cpp
    engines/agi/lzw.h
    engines/agi/menu.cpp
    engines/agi/menu.h
    engines/agi/motion.cpp
    engines/agi/objects.cpp
    engines/agi/op_cmd.cpp
    engines/agi/op_dbg.cpp
    engines/agi/op_test.cpp
    engines/agi/opcodes.h
    engines/agi/picture.cpp
    engines/agi/picture.h
    engines/agi/preagi.cpp
    engines/agi/preagi.h
    engines/agi/preagi_common.cpp
    engines/agi/preagi_common.h
    engines/agi/preagi_mickey.cpp
    engines/agi/preagi_mickey.h
    engines/agi/preagi_troll.cpp
    engines/agi/preagi_troll.h
    engines/agi/preagi_winnie.cpp
    engines/agi/preagi_winnie.h
    engines/agi/predictive.cpp
    engines/agi/saveload.cpp
    engines/agi/sound.cpp
    engines/agi/sound.h
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agi/sound_coco3.cpp
    engines/agi/sound_coco3.h
    engines/agi/sound_midi.cpp
    engines/agi/sound_midi.h
    engines/agi/sound_pcjr.cpp
    engines/agi/sound_pcjr.h
    engines/agi/sound_sarien.cpp
    engines/agi/sound_sarien.h
    engines/agi/sprite.cpp
    engines/agi/sprite.h
    engines/agi/text.cpp
    engines/agi/view.cpp
    engines/agi/view.h
    engines/agi/wagparser.cpp
    engines/agi/wagparser.h
    engines/agi/words.cpp
    engines/agos/agos.cpp
    engines/agos/agos.h
    engines/agos/animation.cpp
    engines/agos/animation.h
    engines/agos/charset-fontdata.cpp
    engines/agos/charset.cpp
    engines/agos/contain.cpp
    engines/agos/cursor.cpp
    engines/agos/debug.cpp
    engines/agos/debug.h
    engines/agos/debugger.cpp
    engines/agos/debugger.h
    engines/agos/detection.cpp
    engines/agos/detection_tables.h
    engines/agos/draw.cpp
    engines/agos/event.cpp
    engines/agos/feeble.cpp
    engines/agos/gfx.cpp
    engines/agos/icons.cpp
    engines/agos/input.cpp
    engines/agos/input_pn.cpp
    engines/agos/intern.h
    engines/agos/items.cpp
    engines/agos/menus.cpp
    engines/agos/midi.cpp
    engines/agos/midi.h
    engines/agos/midiparser_s1d.cpp
    engines/agos/oracle.cpp
    engines/agos/pn.cpp
    engines/agos/res.cpp
    engines/agos/res_ami.cpp
    engines/agos/res_snd.cpp
    engines/agos/rooms.cpp
    engines/agos/saveload.cpp
    engines/agos/script.cpp
    engines/agos/script_dp.cpp
    engines/agos/script_e1.cpp
    engines/agos/script_e2.cpp
    engines/agos/script_ff.cpp
    engines/agos/script_pn.cpp
    engines/agos/script_pp.cpp
    engines/agos/script_s1.cpp
    engines/agos/script_s2.cpp
    engines/agos/script_ww.cpp
    engines/agos/sound.cpp
    engines/agos/sound.h
    engines/agos/string.cpp
    engines/agos/string_pn.cpp
    engines/agos/subroutine.cpp
    engines/agos/verb.cpp
    engines/agos/verb_pn.cpp
    engines/agos/vga.cpp
    engines/agos/vga.h
    engines/agos/vga_e2.cpp
    engines/agos/vga_ff.cpp
    engines/agos/vga_pn.cpp
    engines/agos/vga_s1.cpp
    engines/agos/vga_s2.cpp
    engines/agos/vga_ww.cpp
    engines/agos/window.cpp
    engines/agos/zones.cpp
    engines/cine/anim.cpp
    engines/cine/anim.h
    engines/cine/bg.cpp
    engines/cine/bg.h
    engines/cine/bg_list.cpp
    engines/cine/bg_list.h
    engines/cine/cine.cpp
    engines/cine/cine.h
    engines/cine/console.cpp
    engines/cine/console.h
    engines/cine/detection.cpp
    engines/cine/detection_tables.h
    engines/cine/gfx.cpp
    engines/cine/gfx.h
    engines/cine/main_loop.cpp
    engines/cine/main_loop.h
    engines/cine/msg.cpp
    engines/cine/msg.h
    engines/cine/object.cpp
    engines/cine/object.h
    engines/cine/pal.cpp
    engines/cine/pal.h
    engines/cine/part.cpp
    engines/cine/part.h
    engines/cine/prc.cpp
    engines/cine/prc.h
    engines/cine/rel.cpp
    engines/cine/rel.h
    engines/cine/saveload.cpp
    engines/cine/saveload.h
    engines/cine/script.h
    engines/cine/script_fw.cpp
    engines/cine/script_os.cpp
    engines/cine/sound.cpp
    engines/cine/sound.h
    engines/cine/texte.cpp
    engines/cine/texte.h
    engines/cine/unpack.cpp
    engines/cine/unpack.h
    engines/cine/various.cpp
    engines/cine/various.h
    engines/cruise/actor.cpp
    engines/cruise/actor.h
    engines/cruise/background.cpp
    engines/cruise/background.h
    engines/cruise/backgroundIncrust.cpp
    engines/cruise/backgroundIncrust.h
    engines/cruise/cell.cpp
    engines/cruise/cell.h
    engines/cruise/cruise.cpp
    engines/cruise/cruise.h
    engines/cruise/cruise_main.cpp
    engines/cruise/cruise_main.h
    engines/cruise/ctp.cpp
    engines/cruise/ctp.h
    engines/cruise/dataLoader.cpp
    engines/cruise/dataLoader.h
    engines/cruise/debugger.cpp
    engines/cruise/debugger.h
    engines/cruise/decompiler.cpp
    engines/cruise/delphine-unpack.cpp
    engines/cruise/detection.cpp
    engines/cruise/font.cpp
    engines/cruise/font.h
    engines/cruise/function.cpp
    engines/cruise/function.h
    engines/cruise/gfxModule.cpp
    engines/cruise/gfxModule.h
    engines/cruise/linker.cpp
    engines/cruise/linker.h
    engines/cruise/mainDraw.cpp
    engines/cruise/mainDraw.h
    engines/cruise/menu.cpp
    engines/cruise/menu.h
    engines/cruise/mouse.cpp
    engines/cruise/mouse.h
    engines/cruise/object.cpp
    engines/cruise/object.h
    engines/cruise/overlay.cpp
    engines/cruise/overlay.h
    engines/cruise/perso.cpp
    engines/cruise/perso.h
    engines/cruise/polys.cpp
    engines/cruise/polys.h
    engines/cruise/saveload.cpp
    engines/cruise/saveload.h
    engines/cruise/script.cpp
    engines/cruise/script.h
    engines/cruise/sound.cpp
    engines/cruise/sound.h
    engines/cruise/stack.cpp
    engines/cruise/stack.h
    engines/cruise/staticres.cpp
    engines/cruise/staticres.h
    engines/cruise/various.cpp
    engines/cruise/various.h
    engines/cruise/vars.cpp
    engines/cruise/vars.h
    engines/cruise/volume.cpp
    engines/cruise/volume.h
    engines/dialogs.cpp
    engines/dialogs.h
    engines/draci/animation.cpp
    engines/draci/animation.h
    engines/draci/barchive.cpp
    engines/draci/barchive.h
    engines/draci/console.cpp
    engines/draci/console.h
    engines/draci/detection.cpp
    engines/draci/draci.cpp
    engines/draci/draci.h
    engines/draci/font.cpp
    engines/draci/font.h
    engines/draci/game.cpp
    engines/draci/game.h
    engines/draci/mouse.cpp
    engines/draci/mouse.h
    engines/draci/music.cpp
    engines/draci/music.h
    engines/draci/saveload.cpp
    engines/draci/saveload.h
    engines/draci/screen.cpp
    engines/draci/screen.h
    engines/draci/script.cpp
    engines/draci/script.h
    engines/draci/sound.cpp
    engines/draci/sound.h
    engines/draci/sprite.cpp
    engines/draci/sprite.h
    engines/draci/surface.cpp
    engines/draci/surface.h
    engines/draci/walking.cpp
    engines/draci/walking.h
    engines/drascula/actors.cpp
    engines/drascula/animation.cpp
    engines/drascula/console.cpp
    engines/drascula/console.h
    engines/drascula/converse.cpp
    engines/drascula/detection.cpp
    engines/drascula/drascula.cpp
    engines/drascula/drascula.h
    engines/drascula/graphics.cpp
    engines/drascula/interface.cpp
    engines/drascula/objects.cpp
    engines/drascula/palette.cpp
    engines/drascula/resource.cpp
    engines/drascula/rooms.cpp
    engines/drascula/saveload.cpp
    engines/drascula/sound.cpp
    engines/drascula/talk.cpp
    engines/engine.cpp
    engines/engine.h
    engines/game.cpp
    engines/game.h
    engines/gob/console.cpp
    engines/gob/console.h
    engines/gob/databases.cpp
    engines/gob/databases.h
    engines/gob/dataio.cpp
    engines/gob/dataio.h
    engines/gob/dbase.cpp
    engines/gob/dbase.h
    engines/gob/demos/batplayer.cpp
    engines/gob/demos/batplayer.h
    engines/gob/demos/demoplayer.cpp
    engines/gob/demos/demoplayer.h
    engines/gob/demos/scnplayer.cpp
    engines/gob/demos/scnplayer.h
    engines/gob/detection.cpp
    engines/gob/detection_tables.h
    engines/gob/draw.cpp
    engines/gob/draw.h
    engines/gob/draw_bargon.cpp
    engines/gob/draw_fascin.cpp
    engines/gob/draw_playtoons.cpp
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/expression.cpp
    engines/gob/expression.h
    engines/gob/game.cpp
    engines/gob/game.h
    engines/gob/global.cpp
    engines/gob/global.h
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/goblin.cpp
    engines/gob/goblin.h
    engines/gob/goblin_v1.cpp
    engines/gob/goblin_v2.cpp
    engines/gob/goblin_v3.cpp
    engines/gob/goblin_v4.cpp
    engines/gob/hotspots.cpp
    engines/gob/hotspots.h
    engines/gob/iniconfig.cpp
    engines/gob/iniconfig.h
    engines/gob/init.cpp
    engines/gob/init.h
    engines/gob/init_fascin.cpp
    engines/gob/init_v1.cpp
    engines/gob/init_v2.cpp
    engines/gob/init_v3.cpp
    engines/gob/init_v4.cpp
    engines/gob/init_v6.cpp
    engines/gob/init_v7.cpp
    engines/gob/inter.cpp
    engines/gob/inter.h
    engines/gob/inter_bargon.cpp
    engines/gob/inter_fascin.cpp
    engines/gob/inter_inca2.cpp
    engines/gob/inter_playtoons.cpp
    engines/gob/inter_v1.cpp
    engines/gob/inter_v2.cpp
    engines/gob/inter_v3.cpp
    engines/gob/inter_v4.cpp
    engines/gob/inter_v5.cpp
    engines/gob/inter_v6.cpp
    engines/gob/inter_v7.cpp
    engines/gob/map.cpp
    engines/gob/map.h
    engines/gob/map_v1.cpp
    engines/gob/map_v2.cpp
    engines/gob/mult.cpp
    engines/gob/mult.h
    engines/gob/mult_v1.cpp
    engines/gob/mult_v2.cpp
    engines/gob/palanim.cpp
    engines/gob/palanim.h
    engines/gob/resources.cpp
    engines/gob/resources.h
    engines/gob/save/saveconverter.cpp
    engines/gob/save/saveconverter.h
    engines/gob/save/saveconverter_v2.cpp
    engines/gob/save/saveconverter_v3.cpp
    engines/gob/save/saveconverter_v4.cpp
    engines/gob/save/savefile.cpp
    engines/gob/save/savefile.h
    engines/gob/save/savehandler.cpp
    engines/gob/save/savehandler.h
    engines/gob/save/saveload.cpp
    engines/gob/save/saveload.h
    engines/gob/save/saveload_fascin.cpp
    engines/gob/save/saveload_inca2.cpp
    engines/gob/save/saveload_playtoons.cpp
    engines/gob/save/saveload_v2.cpp
    engines/gob/save/saveload_v3.cpp
    engines/gob/save/saveload_v4.cpp
    engines/gob/save/saveload_v6.cpp
    engines/gob/save/saveload_v7.cpp
    engines/gob/scenery.cpp
    engines/gob/scenery.h
    engines/gob/scenery_v1.cpp
    engines/gob/scenery_v2.cpp
    engines/gob/script.cpp
    engines/gob/script.h
    engines/gob/sound/adlib.cpp
    engines/gob/sound/adlib.h
    engines/gob/sound/bgatmosphere.cpp
    engines/gob/sound/bgatmosphere.h
    engines/gob/sound/cdrom.cpp
    engines/gob/sound/cdrom.h
    engines/gob/sound/infogrames.cpp
    engines/gob/sound/infogrames.h
    engines/gob/sound/pcspeaker.cpp
    engines/gob/sound/pcspeaker.h
    engines/gob/sound/protracker.cpp
    engines/gob/sound/protracker.h
    engines/gob/sound/sound.cpp
    engines/gob/sound/sound.h
    engines/gob/sound/soundblaster.cpp
    engines/gob/sound/soundblaster.h
    engines/gob/sound/sounddesc.cpp
    engines/gob/sound/sounddesc.h
    engines/gob/sound/soundmixer.cpp
    engines/gob/sound/soundmixer.h
    engines/gob/surface.cpp
    engines/gob/surface.h
    engines/gob/totfile.cpp
    engines/gob/totfile.h
    engines/gob/util.cpp
    engines/gob/util.h
    engines/gob/variables.cpp
    engines/gob/variables.h
    engines/gob/video.cpp
    engines/gob/video.h
    engines/gob/video_v1.cpp
    engines/gob/video_v2.cpp
    engines/gob/video_v6.cpp
    engines/gob/videoplayer.cpp
    engines/gob/videoplayer.h
    engines/groovie/cell.cpp
    engines/groovie/cell.h
    engines/groovie/cursor.cpp
    engines/groovie/cursor.h
    engines/groovie/debug.cpp
    engines/groovie/debug.h
    engines/groovie/detection.cpp
    engines/groovie/detection.h
    engines/groovie/font.cpp
    engines/groovie/font.h
    engines/groovie/graphics.cpp
    engines/groovie/graphics.h
    engines/groovie/groovie.cpp
    engines/groovie/groovie.h
    engines/groovie/lzss.cpp
    engines/groovie/lzss.h
    engines/groovie/music.cpp
    engines/groovie/music.h
    engines/groovie/player.cpp
    engines/groovie/player.h
    engines/groovie/resource.cpp
    engines/groovie/resource.h
    engines/groovie/roq.cpp
    engines/groovie/roq.h
    engines/groovie/saveload.cpp
    engines/groovie/saveload.h
    engines/groovie/script.cpp
    engines/groovie/script.h
    engines/groovie/vdx.cpp
    engines/groovie/vdx.h
    engines/hugo/console.cpp
    engines/hugo/console.h
    engines/hugo/detection.cpp
    engines/hugo/dialogs.cpp
    engines/hugo/dialogs.h
    engines/hugo/display.cpp
    engines/hugo/display.h
    engines/hugo/file.cpp
    engines/hugo/file.h
    engines/hugo/file_v1d.cpp
    engines/hugo/file_v1w.cpp
    engines/hugo/file_v2d.cpp
    engines/hugo/file_v2w.cpp
    engines/hugo/file_v3d.cpp
    engines/hugo/game.h
    engines/hugo/hugo.cpp
    engines/hugo/hugo.h
    engines/hugo/intro.cpp
    engines/hugo/intro.h
    engines/hugo/inventory.cpp
    engines/hugo/inventory.h
    engines/hugo/mouse.cpp
    engines/hugo/mouse.h
    engines/hugo/object.cpp
    engines/hugo/object.h
    engines/hugo/object_v1d.cpp
    engines/hugo/object_v1w.cpp
    engines/hugo/object_v2d.cpp
    engines/hugo/object_v3d.cpp
    engines/hugo/parser.cpp
    engines/hugo/parser.h
    engines/hugo/parser_v1d.cpp
    engines/hugo/parser_v1w.cpp
    engines/hugo/parser_v2d.cpp
    engines/hugo/parser_v3d.cpp
    engines/hugo/route.cpp
    engines/hugo/route.h
    engines/hugo/schedule.cpp
    engines/hugo/schedule.h
    engines/hugo/sound.cpp
    engines/hugo/sound.h
    engines/hugo/text.cpp
    engines/hugo/text.h
    engines/hugo/util.cpp
    engines/hugo/util.h
    engines/kyra/animator_hof.cpp
    engines/kyra/animator_lok.cpp
    engines/kyra/animator_lok.h
    engines/kyra/animator_mr.cpp
    engines/kyra/animator_tim.cpp
    engines/kyra/animator_v2.cpp
    engines/kyra/debugger.cpp
    engines/kyra/debugger.h
    engines/kyra/detection.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui.cpp
    engines/kyra/gui.h
    engines/kyra/gui_hof.cpp
    engines/kyra/gui_hof.h
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_lok.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_lol.h
    engines/kyra/gui_mr.cpp
    engines/kyra/gui_mr.h
    engines/kyra/gui_v2.cpp
    engines/kyra/gui_v2.h
    engines/kyra/item.h
    engines/kyra/items_hof.cpp
    engines/kyra/items_lok.cpp
    engines/kyra/items_lol.cpp
    engines/kyra/items_mr.cpp
    engines/kyra/items_v2.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_hof.h
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_lok.h
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_mr.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/kyra_v2.cpp
    engines/kyra/kyra_v2.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/resource.cpp
    engines/kyra/resource.h
    engines/kyra/resource_intern.cpp
    engines/kyra/resource_intern.h
    engines/kyra/saveload.cpp
    engines/kyra/saveload_hof.cpp
    engines/kyra/saveload_lok.cpp
    engines/kyra/saveload_lol.cpp
    engines/kyra/saveload_mr.cpp
    engines/kyra/scene_hof.cpp
    engines/kyra/scene_lok.cpp
    engines/kyra/scene_lol.cpp
    engines/kyra/scene_mr.cpp
    engines/kyra/scene_v1.cpp
    engines/kyra/scene_v2.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen.h
    engines/kyra/screen_hof.cpp
    engines/kyra/screen_hof.h
    engines/kyra/screen_lok.cpp
    engines/kyra/screen_lok.h
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_lol.h
    engines/kyra/screen_mr.cpp
    engines/kyra/screen_mr.h
    engines/kyra/screen_v2.cpp
    engines/kyra/screen_v2.h
    engines/kyra/script.cpp
    engines/kyra/script.h
    engines/kyra/script_hof.cpp
    engines/kyra/script_lok.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_mr.cpp
    engines/kyra/script_tim.cpp
    engines/kyra/script_tim.h
    engines/kyra/script_v1.cpp
    engines/kyra/script_v2.cpp
    engines/kyra/seqplayer.cpp
    engines/kyra/seqplayer.h
    engines/kyra/sequences_hof.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sequences_mr.cpp
    engines/kyra/sequences_v2.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound.h
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_adlib.h
    engines/kyra/sound_amiga.cpp
    engines/kyra/sound_digital.cpp
    engines/kyra/sound_intern.h
    engines/kyra/sound_lok.cpp
    engines/kyra/sound_lol.cpp
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_pcspk.cpp
    engines/kyra/sound_towns.cpp
    engines/kyra/sprites.cpp
    engines/kyra/sprites.h
    engines/kyra/sprites_lol.cpp
    engines/kyra/staticres.cpp
    engines/kyra/staticres_lol.cpp
    engines/kyra/text.cpp
    engines/kyra/text.h
    engines/kyra/text_hof.cpp
    engines/kyra/text_hof.h
    engines/kyra/text_lok.cpp
    engines/kyra/text_lol.cpp
    engines/kyra/text_lol.h
    engines/kyra/text_mr.cpp
    engines/kyra/text_mr.h
    engines/kyra/timer.cpp
    engines/kyra/timer.h
    engines/kyra/timer_hof.cpp
    engines/kyra/timer_lok.cpp
    engines/kyra/timer_lol.cpp
    engines/kyra/timer_mr.cpp
    engines/kyra/util.cpp
    engines/kyra/util.h
    engines/kyra/vqa.cpp
    engines/kyra/vqa.h
    engines/kyra/wsamovie.cpp
    engines/kyra/wsamovie.h
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/data/animation.h
    engines/lastexpress/data/archive.cpp
    engines/lastexpress/data/archive.h
    engines/lastexpress/data/background.cpp
    engines/lastexpress/data/background.h
    engines/lastexpress/data/cursor.cpp
    engines/lastexpress/data/cursor.h
    engines/lastexpress/data/font.cpp
    engines/lastexpress/data/font.h
    engines/lastexpress/data/scene.cpp
    engines/lastexpress/data/scene.h
    engines/lastexpress/data/sequence.cpp
    engines/lastexpress/data/sequence.h
    engines/lastexpress/data/snd.cpp
    engines/lastexpress/data/snd.h
    engines/lastexpress/data/subtitle.cpp
    engines/lastexpress/data/subtitle.h
    engines/lastexpress/debug.cpp
    engines/lastexpress/debug.h
    engines/lastexpress/detection.cpp
    engines/lastexpress/drawable.h
    engines/lastexpress/entities/abbot.cpp
    engines/lastexpress/entities/abbot.h
    engines/lastexpress/entities/alexei.cpp
    engines/lastexpress/entities/alexei.h
    engines/lastexpress/entities/alouan.cpp
    engines/lastexpress/entities/alouan.h
    engines/lastexpress/entities/anna.cpp
    engines/lastexpress/entities/anna.h
    engines/lastexpress/entities/august.cpp
    engines/lastexpress/entities/august.h
    engines/lastexpress/entities/boutarel.cpp
    engines/lastexpress/entities/boutarel.h
    engines/lastexpress/entities/chapters.cpp
    engines/lastexpress/entities/chapters.h
    engines/lastexpress/entities/cooks.cpp
    engines/lastexpress/entities/cooks.h
    engines/lastexpress/entities/coudert.cpp
    engines/lastexpress/entities/coudert.h
    engines/lastexpress/entities/entity.cpp
    engines/lastexpress/entities/entity.h
    engines/lastexpress/entities/entity39.cpp
    engines/lastexpress/entities/entity39.h
    engines/lastexpress/entities/entity_intern.h
    engines/lastexpress/entities/francois.cpp
    engines/lastexpress/entities/francois.h
    engines/lastexpress/entities/gendarmes.cpp
    engines/lastexpress/entities/gendarmes.h
    engines/lastexpress/entities/hadija.cpp
    engines/lastexpress/entities/hadija.h
    engines/lastexpress/entities/ivo.cpp
    engines/lastexpress/entities/ivo.h
    engines/lastexpress/entities/kahina.cpp
    engines/lastexpress/entities/kahina.h
    engines/lastexpress/entities/kronos.cpp
    engines/lastexpress/entities/kronos.h
    engines/lastexpress/entities/mahmud.cpp
    engines/lastexpress/entities/mahmud.h
    engines/lastexpress/entities/max.cpp
    engines/lastexpress/entities/max.h
    engines/lastexpress/entities/mertens.cpp
    engines/lastexpress/entities/mertens.h
    engines/lastexpress/entities/milos.cpp
    engines/lastexpress/entities/milos.h
    engines/lastexpress/entities/mmeboutarel.cpp
    engines/lastexpress/entities/mmeboutarel.h
    engines/lastexpress/entities/pascale.cpp
    engines/lastexpress/entities/pascale.h
    engines/lastexpress/entities/rebecca.cpp
    engines/lastexpress/entities/rebecca.h
    engines/lastexpress/entities/salko.cpp
    engines/lastexpress/entities/salko.h
    engines/lastexpress/entities/servers0.cpp
    engines/lastexpress/entities/servers0.h
    engines/lastexpress/entities/servers1.cpp
    engines/lastexpress/entities/servers1.h
    engines/lastexpress/entities/sophie.cpp
    engines/lastexpress/entities/sophie.h
    engines/lastexpress/entities/tables.cpp
    engines/lastexpress/entities/tables.h
    engines/lastexpress/entities/tatiana.cpp
    engines/lastexpress/entities/tatiana.h
    engines/lastexpress/entities/train.cpp
    engines/lastexpress/entities/train.h
    engines/lastexpress/entities/vassili.cpp
    engines/lastexpress/entities/vassili.h
    engines/lastexpress/entities/verges.cpp
    engines/lastexpress/entities/verges.h
    engines/lastexpress/entities/vesna.cpp
    engines/lastexpress/entities/vesna.h
    engines/lastexpress/entities/yasmin.cpp
    engines/lastexpress/entities/yasmin.h
    engines/lastexpress/eventhandler.h
    engines/lastexpress/game/action.cpp
    engines/lastexpress/game/action.h
    engines/lastexpress/game/beetle.cpp
    engines/lastexpress/game/beetle.h
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/game/entities.h
    engines/lastexpress/game/fight.cpp
    engines/lastexpress/game/fight.h
    engines/lastexpress/game/inventory.cpp
    engines/lastexpress/game/inventory.h
    engines/lastexpress/game/logic.cpp
    engines/lastexpress/game/logic.h
    engines/lastexpress/game/menu.cpp
    engines/lastexpress/game/menu.h
    engines/lastexpress/game/object.cpp
    engines/lastexpress/game/object.h
    engines/lastexpress/game/savegame.cpp
    engines/lastexpress/game/savegame.h
    engines/lastexpress/game/savepoint.cpp
    engines/lastexpress/game/savepoint.h
    engines/lastexpress/game/scenes.cpp
    engines/lastexpress/game/scenes.h
    engines/lastexpress/game/sound.cpp
    engines/lastexpress/game/sound.h
    engines/lastexpress/game/state.cpp
    engines/lastexpress/game/state.h
    engines/lastexpress/graphics.cpp
    engines/lastexpress/graphics.h
    engines/lastexpress/helpers.h
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/lastexpress.h
    engines/lastexpress/resource.cpp
    engines/lastexpress/resource.h
    engines/lastexpress/shared.h
    engines/lure/animseq.cpp
    engines/lure/animseq.h
    engines/lure/debugger.cpp
    engines/lure/debugger.h
    engines/lure/decode.cpp
    engines/lure/decode.h
    engines/lure/detection.cpp
    engines/lure/disk.cpp
    engines/lure/disk.h
    engines/lure/events.cpp
    engines/lure/events.h
    engines/lure/fights.cpp
    engines/lure/fights.h
    engines/lure/game.cpp
    engines/lure/game.h
    engines/lure/hotspots.cpp
    engines/lure/hotspots.h
    engines/lure/intro.cpp
    engines/lure/intro.h
    engines/lure/lure.cpp
    engines/lure/lure.h
    engines/lure/luredefs.h
    engines/lure/memory.cpp
    engines/lure/memory.h
    engines/lure/menu.cpp
    engines/lure/menu.h
    engines/lure/palette.cpp
    engines/lure/palette.h
    engines/lure/res.cpp
    engines/lure/res.h
    engines/lure/res_struct.cpp
    engines/lure/res_struct.h
    engines/lure/room.cpp
    engines/lure/room.h
    engines/lure/screen.cpp
    engines/lure/screen.h
    engines/lure/scripts.cpp
    engines/lure/scripts.h
    engines/lure/sound.cpp
    engines/lure/sound.h
    engines/lure/strings.cpp
    engines/lure/strings.h
    engines/lure/surface.cpp
    engines/lure/surface.h
    engines/m4/actor.cpp
    engines/m4/actor.h
    engines/m4/animation.cpp
    engines/m4/animation.h
    engines/m4/assets.cpp
    engines/m4/assets.h
    engines/m4/burger_data.h
    engines/m4/compression.cpp
    engines/m4/compression.h
    engines/m4/console.cpp
    engines/m4/console.h
    engines/m4/converse.cpp
    engines/m4/converse.h
    engines/m4/detection.cpp
    engines/m4/dialogs.cpp
    engines/m4/dialogs.h
    engines/m4/events.cpp
    engines/m4/events.h
    engines/m4/font.cpp
    engines/m4/font.h
    engines/m4/globals.cpp
    engines/m4/globals.h
    engines/m4/graphics.cpp
    engines/m4/graphics.h
    engines/m4/gui.cpp
    engines/m4/gui.h
    engines/m4/hotspot.cpp
    engines/m4/hotspot.h
    engines/m4/m4.cpp
    engines/m4/m4.h
    engines/m4/m4_menus.cpp
    engines/m4/m4_menus.h
    engines/m4/m4_scene.cpp
    engines/m4/m4_scene.h
    engines/m4/m4_views.cpp
    engines/m4/m4_views.h
    engines/m4/mads_anim.cpp
    engines/m4/mads_anim.h
    engines/m4/mads_logic.cpp
    engines/m4/mads_logic.h
    engines/m4/mads_menus.cpp
    engines/m4/mads_menus.h
    engines/m4/mads_player.cpp
    engines/m4/mads_player.h
    engines/m4/mads_scene.cpp
    engines/m4/mads_scene.h
    engines/m4/mads_views.cpp
    engines/m4/mads_views.h
    engines/m4/midi.cpp
    engines/m4/midi.h
    engines/m4/rails.cpp
    engines/m4/rails.h
    engines/m4/resource.cpp
    engines/m4/resource.h
    engines/m4/saveload.cpp
    engines/m4/saveload.h
    engines/m4/scene.cpp
    engines/m4/scene.h
    engines/m4/script.cpp
    engines/m4/script.h
    engines/m4/sound.cpp
    engines/m4/sound.h
    engines/m4/sprite.cpp
    engines/m4/sprite.h
    engines/m4/staticres.cpp
    engines/m4/staticres.h
    engines/m4/viewmgr.cpp
    engines/m4/viewmgr.h
    engines/m4/woodscript.cpp
    engines/m4/woodscript.h
    engines/m4/ws_machine.cpp
    engines/m4/ws_sequence.cpp
    engines/made/console.cpp
    engines/made/console.h
    engines/made/database.cpp
    engines/made/database.h
    engines/made/detection.cpp
    engines/made/graphics.cpp
    engines/made/graphics.h
    engines/made/made.cpp
    engines/made/made.h
    engines/made/music.cpp
    engines/made/music.h
    engines/made/pmvplayer.cpp
    engines/made/pmvplayer.h
    engines/made/redreader.cpp
    engines/made/redreader.h
    engines/made/resource.cpp
    engines/made/resource.h
    engines/made/screen.cpp
    engines/made/screen.h
    engines/made/screenfx.cpp
    engines/made/screenfx.h
    engines/made/script.cpp
    engines/made/script.h
    engines/made/scriptfuncs.cpp
    engines/made/scriptfuncs.h
    engines/made/sound.cpp
    engines/made/sound.h
    engines/metaengine.h
    engines/mohawk/bitmap.cpp
    engines/mohawk/bitmap.h
    engines/mohawk/console.cpp
    engines/mohawk/console.h
    engines/mohawk/cstime.cpp
    engines/mohawk/cstime.h
    engines/mohawk/cstime_cases.cpp
    engines/mohawk/cstime_cases.h
    engines/mohawk/cstime_game.cpp
    engines/mohawk/cstime_game.h
    engines/mohawk/cstime_ui.cpp
    engines/mohawk/cstime_ui.h
    engines/mohawk/cstime_view.cpp
    engines/mohawk/cstime_view.h
    engines/mohawk/cursors.cpp
    engines/mohawk/cursors.h
    engines/mohawk/detection.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/dialogs.cpp
    engines/mohawk/dialogs.h
    engines/mohawk/graphics.cpp
    engines/mohawk/graphics.h
    engines/mohawk/installer_archive.cpp
    engines/mohawk/installer_archive.h
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h
    engines/mohawk/mohawk.cpp
    engines/mohawk/mohawk.h
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_areas.cpp
    engines/mohawk/myst_areas.h
    engines/mohawk/myst_scripts.cpp
    engines/mohawk/myst_scripts.h
    engines/mohawk/myst_stacks/channelwood.cpp
    engines/mohawk/myst_stacks/channelwood.h
    engines/mohawk/myst_stacks/credits.cpp
    engines/mohawk/myst_stacks/credits.h
    engines/mohawk/myst_stacks/demo.cpp
    engines/mohawk/myst_stacks/demo.h
    engines/mohawk/myst_stacks/dni.cpp
    engines/mohawk/myst_stacks/dni.h
    engines/mohawk/myst_stacks/intro.cpp
    engines/mohawk/myst_stacks/intro.h
    engines/mohawk/myst_stacks/makingof.cpp
    engines/mohawk/myst_stacks/makingof.h
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/mechanical.h
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/myst.h
    engines/mohawk/myst_stacks/preview.cpp
    engines/mohawk/myst_stacks/preview.h
    engines/mohawk/myst_stacks/selenitic.cpp
    engines/mohawk/myst_stacks/selenitic.h
    engines/mohawk/myst_stacks/slides.cpp
    engines/mohawk/myst_stacks/slides.h
    engines/mohawk/myst_stacks/stoneship.cpp
    engines/mohawk/myst_stacks/stoneship.h
    engines/mohawk/myst_state.cpp
    engines/mohawk/myst_state.h
    engines/mohawk/resource.cpp
    engines/mohawk/resource.h
    engines/mohawk/resource_cache.cpp
    engines/mohawk/resource_cache.h
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_external.cpp
    engines/mohawk/riven_external.h
    engines/mohawk/riven_saveload.cpp
    engines/mohawk/riven_saveload.h
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/riven_scripts.h
    engines/mohawk/riven_vars.cpp
    engines/mohawk/sound.cpp
    engines/mohawk/sound.h
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/mohawk/view.cpp
    engines/mohawk/view.h
    engines/parallaction/balloons.cpp
    engines/parallaction/callables_br.cpp
    engines/parallaction/callables_ns.cpp
    engines/parallaction/debug.cpp
    engines/parallaction/detection.cpp
    engines/parallaction/dialogue.cpp
    engines/parallaction/disk.cpp
    engines/parallaction/disk.h
    engines/parallaction/disk_br.cpp
    engines/parallaction/disk_ns.cpp
    engines/parallaction/exec.cpp
    engines/parallaction/exec.h
    engines/parallaction/exec_br.cpp
    engines/parallaction/exec_ns.cpp
    engines/parallaction/font.cpp
    engines/parallaction/gfxbase.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/graphics.h
    engines/parallaction/gui.cpp
    engines/parallaction/gui.h
    engines/parallaction/gui_br.cpp
    engines/parallaction/gui_ns.cpp
    engines/parallaction/input.cpp
    engines/parallaction/input.h
    engines/parallaction/inventory.cpp
    engines/parallaction/inventory.h
    engines/parallaction/objects.cpp
    engines/parallaction/objects.h
    engines/parallaction/parallaction.cpp
    engines/parallaction/parallaction.h
    engines/parallaction/parallaction_br.cpp
    engines/parallaction/parallaction_ns.cpp
    engines/parallaction/parser.cpp
    engines/parallaction/parser.h
    engines/parallaction/parser_br.cpp
    engines/parallaction/parser_ns.cpp
    engines/parallaction/saveload.cpp
    engines/parallaction/saveload.h
    engines/parallaction/sound.h
    engines/parallaction/sound_br.cpp
    engines/parallaction/sound_ns.cpp
    engines/parallaction/staticres.cpp
    engines/parallaction/walk.cpp
    engines/parallaction/walk.h
    engines/queen/bankman.cpp
    engines/queen/bankman.h
    engines/queen/command.cpp
    engines/queen/command.h
    engines/queen/credits.cpp
    engines/queen/credits.h
    engines/queen/cutaway.cpp
    engines/queen/cutaway.h
    engines/queen/debug.cpp
    engines/queen/debug.h
    engines/queen/defs.h
    engines/queen/display.cpp
    engines/queen/display.h
    engines/queen/graphics.cpp
    engines/queen/graphics.h
    engines/queen/grid.cpp
    engines/queen/grid.h
    engines/queen/input.cpp
    engines/queen/input.h
    engines/queen/journal.cpp
    engines/queen/journal.h
    engines/queen/logic.cpp
    engines/queen/logic.h
    engines/queen/midiadlib.cpp
    engines/queen/music.cpp
    engines/queen/music.h
    engines/queen/musicdata.cpp
    engines/queen/queen.cpp
    engines/queen/queen.h
    engines/queen/resource.cpp
    engines/queen/resource.h
    engines/queen/restables.cpp
    engines/queen/sound.cpp
    engines/queen/sound.h
    engines/queen/state.cpp
    engines/queen/state.h
    engines/queen/structs.h
    engines/queen/talk.cpp
    engines/queen/talk.h
    engines/queen/walk.cpp
    engines/queen/walk.h
    engines/saga/actor.cpp
    engines/saga/actor.h
    engines/saga/actor_path.cpp
    engines/saga/actor_walk.cpp
    engines/saga/animation.cpp
    engines/saga/animation.h
    engines/saga/console.cpp
    engines/saga/console.h
    engines/saga/detection.cpp
    engines/saga/detection_tables.h
    engines/saga/displayinfo.h
    engines/saga/events.cpp
    engines/saga/events.h
    engines/saga/font.cpp
    engines/saga/font.h
    engines/saga/font_map.cpp
    engines/saga/gfx.cpp
    engines/saga/gfx.h
    engines/saga/image.cpp
    engines/saga/input.cpp
    engines/saga/interface.cpp
    engines/saga/interface.h
    engines/saga/introproc_ihnm.cpp
    engines/saga/introproc_ite.cpp
    engines/saga/introproc_saga2.cpp
    engines/saga/isomap.cpp
    engines/saga/isomap.h
    engines/saga/itedata.cpp
    engines/saga/itedata.h
    engines/saga/music.cpp
    engines/saga/music.h
    engines/saga/objectmap.cpp
    engines/saga/objectmap.h
    engines/saga/palanim.cpp
    engines/saga/palanim.h
    engines/saga/puzzle.cpp
    engines/saga/puzzle.h
    engines/saga/render.cpp
    engines/saga/render.h
    engines/saga/resource.cpp
    engines/saga/resource.h
    engines/saga/resource_hrs.cpp
    engines/saga/resource_res.cpp
    engines/saga/resource_rsc.cpp
    engines/saga/saga.cpp
    engines/saga/saga.h
    engines/saga/saveload.cpp
    engines/saga/scene.cpp
    engines/saga/scene.h
    engines/saga/script.cpp
    engines/saga/script.h
    engines/saga/sfuncs.cpp
    engines/saga/sfuncs_ihnm.cpp
    engines/saga/shorten.cpp
    engines/saga/shorten.h
    engines/saga/sndres.cpp
    engines/saga/sndres.h
    engines/saga/sound.cpp
    engines/saga/sound.h
    engines/saga/sprite.cpp
    engines/saga/sprite.h
    engines/saga/sthread.cpp
    engines/savestate.cpp
    engines/savestate.h
    engines/sci/console.cpp
    engines/sci/console.h
    engines/sci/debug.h
    engines/sci/decompressor.cpp
    engines/sci/decompressor.h
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/features.h
    engines/sci/engine/gc.cpp
    engines/sci/engine/gc.h
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kevent.cpp
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmath.cpp
    engines/sci/engine/kmenu.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/kmovement.cpp
    engines/sci/engine/kparse.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/ksound.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/message.cpp
    engines/sci/engine/message.h
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.cpp
    engines/sci/engine/savegame.h
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/segment.cpp
    engines/sci/engine/segment.h
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/static_selectors.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/vm_types.cpp
    engines/sci/engine/vm_types.h
    engines/sci/engine/workarounds.cpp
    engines/sci/engine/workarounds.h
    engines/sci/event.cpp
    engines/sci/event.h
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/animate.h
    engines/sci/graphics/cache.cpp
    engines/sci/graphics/cache.h
    engines/sci/graphics/compare.cpp
    engines/sci/graphics/compare.h
    engines/sci/graphics/controls.cpp
    engines/sci/graphics/controls.h
    engines/sci/graphics/coordadjuster.cpp
    engines/sci/graphics/coordadjuster.h
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/cursor.h
    engines/sci/graphics/font.cpp
    engines/sci/graphics/font.h
    engines/sci/graphics/fontsjis.cpp
    engines/sci/graphics/fontsjis.h
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/helpers.h
    engines/sci/graphics/maciconbar.cpp
    engines/sci/graphics/maciconbar.h
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/menu.h
    engines/sci/graphics/paint.cpp
    engines/sci/graphics/paint.h
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/paint16.h
    engines/sci/graphics/paint32.cpp
    engines/sci/graphics/paint32.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/picture.h
    engines/sci/graphics/portrait.cpp
    engines/sci/graphics/portrait.h
    engines/sci/graphics/ports.cpp
    engines/sci/graphics/ports.h
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/screen.h
    engines/sci/graphics/text16.cpp
    engines/sci/graphics/text16.h
    engines/sci/graphics/transitions.cpp
    engines/sci/graphics/transitions.h
    engines/sci/graphics/view.cpp
    engines/sci/graphics/view.h
    engines/sci/parser/grammar.cpp
    engines/sci/parser/said.cpp
    engines/sci/parser/vocabulary.cpp
    engines/sci/parser/vocabulary.h
    engines/sci/resource.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp
    engines/sci/resource_intern.h
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/audio.cpp
    engines/sci/sound/audio.h
    engines/sci/sound/drivers/adlib.cpp
    engines/sci/sound/drivers/amigamac.cpp
    engines/sci/sound/drivers/cms.cpp
    engines/sci/sound/drivers/fb01.cpp
    engines/sci/sound/drivers/gm_names.h
    engines/sci/sound/drivers/map-mt32-to-gm.h
    engines/sci/sound/drivers/midi.cpp
    engines/sci/sound/drivers/mididriver.h
    engines/sci/sound/drivers/pcjr.cpp
    engines/sci/sound/midiparser_sci.cpp
    engines/sci/sound/midiparser_sci.h
    engines/sci/sound/music.cpp
    engines/sci/sound/music.h
    engines/sci/sound/soundcmd.cpp
    engines/sci/sound/soundcmd.h
    engines/sci/util.cpp
    engines/sci/util.h
    engines/sci/video/robot_decoder.cpp
    engines/sci/video/robot_decoder.h
    engines/sci/video/seq_decoder.cpp
    engines/sci/video/seq_decoder.h
    engines/scumm/actor.cpp
    engines/scumm/actor.h
    engines/scumm/actor_he.h
    engines/scumm/akos.cpp
    engines/scumm/akos.h
    engines/scumm/base-costume.cpp
    engines/scumm/base-costume.h
    engines/scumm/bomp.cpp
    engines/scumm/bomp.h
    engines/scumm/boxes.cpp
    engines/scumm/boxes.h
    engines/scumm/camera.cpp
    engines/scumm/charset-fontdata.cpp
    engines/scumm/charset.cpp
    engines/scumm/charset.h
    engines/scumm/costume.cpp
    engines/scumm/costume.h
    engines/scumm/cursor.cpp
    engines/scumm/debugger.cpp
    engines/scumm/debugger.h
    engines/scumm/detection.cpp
    engines/scumm/detection.h
    engines/scumm/detection_tables.h
    engines/scumm/dialogs.cpp
    engines/scumm/dialogs.h
    engines/scumm/file.cpp
    engines/scumm/file.h
    engines/scumm/file_nes.cpp
    engines/scumm/file_nes.h
    engines/scumm/gfx.cpp
    engines/scumm/gfx.h
    engines/scumm/gfxARM.s
    engines/scumm/gfx_towns.cpp
    engines/scumm/he/animation_he.cpp
    engines/scumm/he/animation_he.h
    engines/scumm/he/cup_player_he.cpp
    engines/scumm/he/cup_player_he.h
    engines/scumm/he/floodfill_he.cpp
    engines/scumm/he/floodfill_he.h
    engines/scumm/he/intern_he.h
    engines/scumm/he/logic_he.cpp
    engines/scumm/he/logic_he.h
    engines/scumm/he/palette_he.cpp
    engines/scumm/he/resource_he.cpp
    engines/scumm/he/resource_he.h
    engines/scumm/he/script_v100he.cpp
    engines/scumm/he/script_v60he.cpp
    engines/scumm/he/script_v70he.cpp
    engines/scumm/he/script_v71he.cpp
    engines/scumm/he/script_v72he.cpp
    engines/scumm/he/script_v80he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/he/sound_he.cpp
    engines/scumm/he/sound_he.h
    engines/scumm/he/sprite_he.cpp
    engines/scumm/he/sprite_he.h
    engines/scumm/he/wiz_he.cpp
    engines/scumm/he/wiz_he.h
    engines/scumm/help.cpp
    engines/scumm/help.h
    engines/scumm/imuse/imuse.cpp
    engines/scumm/imuse/imuse.h
    engines/scumm/imuse/imuse_internal.h
    engines/scumm/imuse/imuse_part.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/imuse/instrument.cpp
    engines/scumm/imuse/instrument.h
    engines/scumm/imuse/sysex.h
    engines/scumm/imuse/sysex_samnmax.cpp
    engines/scumm/imuse/sysex_scumm.cpp
    engines/scumm/imuse_digi/dimuse.cpp
    engines/scumm/imuse_digi/dimuse.h
    engines/scumm/imuse_digi/dimuse_bndmgr.cpp
    engines/scumm/imuse_digi/dimuse_bndmgr.h
    engines/scumm/imuse_digi/dimuse_codecs.cpp
    engines/scumm/imuse_digi/dimuse_codecs.h
    engines/scumm/imuse_digi/dimuse_music.cpp
    engines/scumm/imuse_digi/dimuse_script.cpp
    engines/scumm/imuse_digi/dimuse_sndmgr.cpp
    engines/scumm/imuse_digi/dimuse_sndmgr.h
    engines/scumm/imuse_digi/dimuse_tables.cpp
    engines/scumm/imuse_digi/dimuse_tables.h
    engines/scumm/imuse_digi/dimuse_track.cpp
    engines/scumm/imuse_digi/dimuse_track.h
    engines/scumm/input.cpp
    engines/scumm/insane/insane.cpp
    engines/scumm/insane/insane.h
    engines/scumm/insane/insane_ben.cpp
    engines/scumm/insane/insane_enemy.cpp
    engines/scumm/insane/insane_iact.cpp
    engines/scumm/insane/insane_scenes.cpp
    engines/scumm/midiparser_ro.cpp
    engines/scumm/music.h
    engines/scumm/nut_renderer.cpp
    engines/scumm/nut_renderer.h
    engines/scumm/object.cpp
    engines/scumm/object.h
    engines/scumm/palette.cpp
    engines/scumm/player_mod.cpp
    engines/scumm/player_mod.h
    engines/scumm/player_nes.cpp
    engines/scumm/player_nes.h
    engines/scumm/player_pce.cpp
    engines/scumm/player_pce.h
    engines/scumm/player_sid.cpp
    engines/scumm/player_sid.h
    engines/scumm/player_towns.cpp
    engines/scumm/player_towns.h
    engines/scumm/player_v1.cpp
    engines/scumm/player_v1.h
    engines/scumm/player_v2.cpp
    engines/scumm/player_v2.h
    engines/scumm/player_v2a.cpp
    engines/scumm/player_v2a.h
    engines/scumm/player_v2base.cpp
    engines/scumm/player_v2base.h
    engines/scumm/player_v2cms.cpp
    engines/scumm/player_v2cms.h
    engines/scumm/player_v3a.cpp
    engines/scumm/player_v3a.h
    engines/scumm/player_v4a.cpp
    engines/scumm/player_v4a.h
    engines/scumm/proc3ARM.s
    engines/scumm/resource.cpp
    engines/scumm/resource.h
    engines/scumm/resource_v2.cpp
    engines/scumm/resource_v3.cpp
    engines/scumm/resource_v4.cpp
    engines/scumm/room.cpp
    engines/scumm/saveload.cpp
    engines/scumm/saveload.h
    engines/scumm/script.cpp
    engines/scumm/script.h
    engines/scumm/script_v0.cpp
    engines/scumm/script_v2.cpp
    engines/scumm/script_v3.cpp
    engines/scumm/script_v4.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/script_v6.cpp
    engines/scumm/script_v8.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/scumm_v0.h
    engines/scumm/scumm_v2.h
    engines/scumm/scumm_v3.h
    engines/scumm/scumm_v4.h
    engines/scumm/scumm_v5.h
    engines/scumm/scumm_v6.h
    engines/scumm/scumm_v7.h
    engines/scumm/scumm_v8.h
    engines/scumm/smush/channel.cpp
    engines/scumm/smush/channel.h
    engines/scumm/smush/codec1.cpp
    engines/scumm/smush/codec37.cpp
    engines/scumm/smush/codec37.h
    engines/scumm/smush/codec47.cpp
    engines/scumm/smush/codec47.h
    engines/scumm/smush/codec47ARM.s
    engines/scumm/smush/imuse_channel.cpp
    engines/scumm/smush/saud_channel.cpp
    engines/scumm/smush/smush_font.cpp
    engines/scumm/smush/smush_font.h
    engines/scumm/smush/smush_mixer.cpp
    engines/scumm/smush/smush_mixer.h
    engines/scumm/smush/smush_player.cpp
    engines/scumm/smush/smush_player.h
    engines/scumm/sound.cpp
    engines/scumm/sound.h
    engines/scumm/string.cpp
    engines/scumm/usage_bits.cpp
    engines/scumm/usage_bits.h
    engines/scumm/util.cpp
    engines/scumm/util.h
    engines/scumm/vars.cpp
    engines/scumm/verbs.cpp
    engines/scumm/verbs.h
    engines/sky/autoroute.cpp
    engines/sky/autoroute.h
    engines/sky/compact.cpp
    engines/sky/compact.h
    engines/sky/control.cpp
    engines/sky/control.h
    engines/sky/debug.cpp
    engines/sky/debug.h
    engines/sky/detection.cpp
    engines/sky/disk.cpp
    engines/sky/disk.h
    engines/sky/grid.cpp
    engines/sky/grid.h
    engines/sky/hufftext.cpp
    engines/sky/intro.cpp
    engines/sky/intro.h
    engines/sky/logic.cpp
    engines/sky/logic.h
    engines/sky/mouse.cpp
    engines/sky/mouse.h
    engines/sky/music/adlibchannel.cpp
    engines/sky/music/adlibchannel.h
    engines/sky/music/adlibmusic.cpp
    engines/sky/music/adlibmusic.h
    engines/sky/music/gmchannel.cpp
    engines/sky/music/gmchannel.h
    engines/sky/music/gmmusic.cpp
    engines/sky/music/gmmusic.h
    engines/sky/music/mt32music.cpp
    engines/sky/music/mt32music.h
    engines/sky/music/musicbase.cpp
    engines/sky/music/musicbase.h
    engines/sky/rnc_deco.cpp
    engines/sky/rnc_deco.h
    engines/sky/screen.cpp
    engines/sky/screen.h
    engines/sky/sky.cpp
    engines/sky/sky.h
    engines/sky/skydefs.h
    engines/sky/sound.cpp
    engines/sky/sound.h
    engines/sky/struc.h
    engines/sky/text.cpp
    engines/sky/text.h
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword1/collision.h
    engines/sword1/console.cpp
    engines/sword1/console.h
    engines/sword1/control.cpp
    engines/sword1/control.h
    engines/sword1/debug.cpp
    engines/sword1/debug.h
    engines/sword1/detection.cpp
    engines/sword1/eventman.cpp
    engines/sword1/eventman.h
    engines/sword1/logic.cpp
    engines/sword1/logic.h
    engines/sword1/memman.cpp
    engines/sword1/memman.h
    engines/sword1/menu.cpp
    engines/sword1/menu.h
    engines/sword1/mouse.cpp
    engines/sword1/mouse.h
    engines/sword1/music.cpp
    engines/sword1/music.h
    engines/sword1/object.h
    engines/sword1/objectman.cpp
    engines/sword1/objectman.h
    engines/sword1/resman.cpp
    engines/sword1/resman.h
    engines/sword1/router.cpp
    engines/sword1/router.h
    engines/sword1/screen.cpp
    engines/sword1/screen.h
    engines/sword1/sound.cpp
    engines/sword1/sound.h
    engines/sword1/staticres.cpp
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h
    engines/sword1/sworddefs.h
    engines/sword1/swordres.h
    engines/sword1/text.cpp
    engines/sword1/text.h
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    engines/sword2/anims.cpp
    engines/sword2/console.cpp
    engines/sword2/console.h
    engines/sword2/controls.cpp
    engines/sword2/controls.h
    engines/sword2/debug.cpp
    engines/sword2/debug.h
    engines/sword2/defs.h
    engines/sword2/events.cpp
    engines/sword2/function.cpp
    engines/sword2/header.cpp
    engines/sword2/header.h
    engines/sword2/icons.cpp
    engines/sword2/interpreter.cpp
    engines/sword2/interpreter.h
    engines/sword2/layers.cpp
    engines/sword2/logic.cpp
    engines/sword2/logic.h
    engines/sword2/maketext.cpp
    engines/sword2/maketext.h
    engines/sword2/memory.cpp
    engines/sword2/memory.h
    engines/sword2/menu.cpp
    engines/sword2/mouse.cpp
    engines/sword2/mouse.h
    engines/sword2/music.cpp
    engines/sword2/object.h
    engines/sword2/palette.cpp
    engines/sword2/protocol.cpp
    engines/sword2/render.cpp
    engines/sword2/resman.cpp
    engines/sword2/resman.h
    engines/sword2/router.cpp
    engines/sword2/router.h
    engines/sword2/saveload.cpp
    engines/sword2/saveload.h
    engines/sword2/screen.cpp
    engines/sword2/screen.h
    engines/sword2/scroll.cpp
    engines/sword2/sound.cpp
    engines/sword2/sound.h
    engines/sword2/speech.cpp
    engines/sword2/sprite.cpp
    engines/sword2/startup.cpp
    engines/sword2/sword2.cpp
    engines/sword2/sword2.h
    engines/sword2/sync.cpp
    engines/sword2/walker.cpp
    engines/sword25/console.cpp
    engines/sword25/console.h
    engines/sword25/detection.cpp
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/fmv/movieplayer.h
    engines/sword25/fmv/movieplayer_script.cpp
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/fmv/theora_decoder.h
    engines/sword25/gfx/animation.cpp
    engines/sword25/gfx/animation.h
    engines/sword25/gfx/animationdescription.cpp
    engines/sword25/gfx/animationdescription.h
    engines/sword25/gfx/animationresource.cpp
    engines/sword25/gfx/animationresource.h
    engines/sword25/gfx/animationtemplate.cpp
    engines/sword25/gfx/animationtemplate.h
    engines/sword25/gfx/animationtemplateregistry.cpp
    engines/sword25/gfx/animationtemplateregistry.h
    engines/sword25/gfx/bitmap.cpp
    engines/sword25/gfx/bitmap.h
    engines/sword25/gfx/bitmapresource.h
    engines/sword25/gfx/dynamicbitmap.cpp
    engines/sword25/gfx/dynamicbitmap.h
    engines/sword25/gfx/fontresource.cpp
    engines/sword25/gfx/fontresource.h
    engines/sword25/gfx/graphicengine.cpp
    engines/sword25/gfx/graphicengine.h
    engines/sword25/gfx/graphicengine_script.cpp
    engines/sword25/gfx/image/art.cpp
    engines/sword25/gfx/image/art.h
    engines/sword25/gfx/image/image.h
    engines/sword25/gfx/image/pngloader.cpp
    engines/sword25/gfx/image/pngloader.h
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/image/renderedimage.h
    engines/sword25/gfx/image/swimage.cpp
    engines/sword25/gfx/image/swimage.h
    engines/sword25/gfx/image/vectorimage.cpp
    engines/sword25/gfx/image/vectorimage.h
    engines/sword25/gfx/image/vectorimagerenderer.cpp
    engines/sword25/gfx/panel.cpp
    engines/sword25/gfx/panel.h
    engines/sword25/gfx/renderobject.cpp
    engines/sword25/gfx/renderobject.h
    engines/sword25/gfx/renderobjectmanager.cpp
    engines/sword25/gfx/renderobjectmanager.h
    engines/sword25/gfx/renderobjectptr.h
    engines/sword25/gfx/renderobjectregistry.h
    engines/sword25/gfx/rootrenderobject.h
    engines/sword25/gfx/screenshot.cpp
    engines/sword25/gfx/screenshot.h
    engines/sword25/gfx/staticbitmap.cpp
    engines/sword25/gfx/staticbitmap.h
    engines/sword25/gfx/text.cpp
    engines/sword25/gfx/text.h
    engines/sword25/gfx/timedrenderobject.cpp
    engines/sword25/gfx/timedrenderobject.h
    engines/sword25/input/inputengine.cpp
    engines/sword25/input/inputengine.h
    engines/sword25/input/inputengine_script.cpp
    engines/sword25/kernel/common.h
    engines/sword25/kernel/filesystemutil.cpp
    engines/sword25/kernel/filesystemutil.h
    engines/sword25/kernel/inputpersistenceblock.cpp
    engines/sword25/kernel/inputpersistenceblock.h
    engines/sword25/kernel/kernel.cpp
    engines/sword25/kernel/kernel.h
    engines/sword25/kernel/kernel_script.cpp
    engines/sword25/kernel/objectregistry.h
    engines/sword25/kernel/outputpersistenceblock.cpp
    engines/sword25/kernel/outputpersistenceblock.h
    engines/sword25/kernel/persistable.h
    engines/sword25/kernel/persistenceblock.h
    engines/sword25/kernel/persistenceservice.cpp
    engines/sword25/kernel/persistenceservice.h
    engines/sword25/kernel/resmanager.cpp
    engines/sword25/kernel/resmanager.h
    engines/sword25/kernel/resource.cpp
    engines/sword25/kernel/resource.h
    engines/sword25/kernel/resservice.h
    engines/sword25/kernel/service.h
    engines/sword25/math/geometry.h
    engines/sword25/math/geometry_script.cpp
    engines/sword25/math/line.h
    engines/sword25/math/polygon.cpp
    engines/sword25/math/polygon.h
    engines/sword25/math/region.cpp
    engines/sword25/math/region.h
    engines/sword25/math/regionregistry.cpp
    engines/sword25/math/regionregistry.h
    engines/sword25/math/vertex.cpp
    engines/sword25/math/vertex.h
    engines/sword25/math/walkregion.cpp
    engines/sword25/math/walkregion.h
    engines/sword25/package/packagemanager.cpp
    engines/sword25/package/packagemanager.h
    engines/sword25/package/packagemanager_script.cpp
    engines/sword25/script/lua_extensions.cpp
    engines/sword25/script/luabindhelper.cpp
    engines/sword25/script/luabindhelper.h
    engines/sword25/script/luacallback.cpp
    engines/sword25/script/luacallback.h
    engines/sword25/script/luascript.cpp
    engines/sword25/script/luascript.h
    engines/sword25/script/script.h
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/sfx/soundengine.h
    engines/sword25/sfx/soundengine_script.cpp
    engines/sword25/sword25.cpp
    engines/sword25/sword25.h
    engines/sword25/util/lua/lauxlib.cpp
    engines/sword25/util/lua/liolib.cpp
    engines/sword25/util/lua/llex.cpp
    engines/sword25/util/lua/loslib.cpp
    engines/sword25/util/lua/luaconf.h
    engines/teenagent/actor.cpp
    engines/teenagent/actor.h
    engines/teenagent/animation.cpp
    engines/teenagent/animation.h
    engines/teenagent/callbacks.cpp
    engines/teenagent/console.cpp
    engines/teenagent/console.h
    engines/teenagent/detection.cpp
    engines/teenagent/dialog.cpp
    engines/teenagent/dialog.h
    engines/teenagent/font.cpp
    engines/teenagent/font.h
    engines/teenagent/inventory.cpp
    engines/teenagent/inventory.h
    engines/teenagent/music.cpp
    engines/teenagent/music.h
    engines/teenagent/objects.cpp
    engines/teenagent/objects.h
    engines/teenagent/pack.cpp
    engines/teenagent/pack.h
    engines/teenagent/resources.cpp
    engines/teenagent/resources.h
    engines/teenagent/scene.cpp
    engines/teenagent/scene.h
    engines/teenagent/segment.cpp
    engines/teenagent/segment.h
    engines/teenagent/surface.cpp
    engines/teenagent/surface.h
    engines/teenagent/surface_list.cpp
    engines/teenagent/surface_list.h
    engines/teenagent/teenagent.cpp
    engines/teenagent/teenagent.h
    engines/testbed/config-params.cpp
    engines/testbed/config-params.h
    engines/testbed/config.cpp
    engines/testbed/config.h
    engines/testbed/detection.cpp
    engines/testbed/events.cpp
    engines/testbed/events.h
    engines/testbed/fs.cpp
    engines/testbed/fs.h
    engines/testbed/graphics.cpp
    engines/testbed/graphics.h
    engines/testbed/midi.cpp
    engines/testbed/midi.h
    engines/testbed/misc.cpp
    engines/testbed/misc.h
    engines/testbed/savegame.cpp
    engines/testbed/savegame.h
    engines/testbed/sound.cpp
    engines/testbed/sound.h
    engines/testbed/template.h
    engines/testbed/testbed.cpp
    engines/testbed/testbed.h
    engines/testbed/testsuite.cpp
    engines/testbed/testsuite.h
    engines/tinsel/actors.cpp
    engines/tinsel/actors.h
    engines/tinsel/adpcm.cpp
    engines/tinsel/adpcm.h
    engines/tinsel/anim.cpp
    engines/tinsel/anim.h
    engines/tinsel/background.cpp
    engines/tinsel/background.h
    engines/tinsel/bg.cpp
    engines/tinsel/bmv.cpp
    engines/tinsel/bmv.h
    engines/tinsel/cliprect.cpp
    engines/tinsel/cliprect.h
    engines/tinsel/config.cpp
    engines/tinsel/config.h
    engines/tinsel/coroutine.cpp
    engines/tinsel/coroutine.h
    engines/tinsel/cursor.cpp
    engines/tinsel/cursor.h
    engines/tinsel/debugger.cpp
    engines/tinsel/debugger.h
    engines/tinsel/detection.cpp
    engines/tinsel/detection_tables.h
    engines/tinsel/dialogs.cpp
    engines/tinsel/dialogs.h
    engines/tinsel/drives.cpp
    engines/tinsel/drives.h
    engines/tinsel/dw.h
    engines/tinsel/effect.cpp
    engines/tinsel/events.cpp
    engines/tinsel/events.h
    engines/tinsel/faders.cpp
    engines/tinsel/faders.h
    engines/tinsel/film.h
    engines/tinsel/font.cpp
    engines/tinsel/font.h
    engines/tinsel/graphics.cpp
    engines/tinsel/graphics.h
    engines/tinsel/handle.cpp
    engines/tinsel/handle.h
    engines/tinsel/heapmem.cpp
    engines/tinsel/heapmem.h
    engines/tinsel/mareels.cpp
    engines/tinsel/mareels.h
    engines/tinsel/move.cpp
    engines/tinsel/move.h
    engines/tinsel/multiobj.cpp
    engines/tinsel/multiobj.h
    engines/tinsel/music.cpp
    engines/tinsel/music.h
    engines/tinsel/object.cpp
    engines/tinsel/object.h
    engines/tinsel/palette.cpp
    engines/tinsel/palette.h
    engines/tinsel/pcode.cpp
    engines/tinsel/pcode.h
    engines/tinsel/pdisplay.cpp
    engines/tinsel/pdisplay.h
    engines/tinsel/pid.h
    engines/tinsel/play.cpp
    engines/tinsel/play.h
    engines/tinsel/polygons.cpp
    engines/tinsel/polygons.h
    engines/tinsel/rince.cpp
    engines/tinsel/rince.h
    engines/tinsel/saveload.cpp
    engines/tinsel/savescn.cpp
    engines/tinsel/savescn.h
    engines/tinsel/scene.cpp
    engines/tinsel/scene.h
    engines/tinsel/sched.cpp
    engines/tinsel/sched.h
    engines/tinsel/scn.cpp
    engines/tinsel/scn.h
    engines/tinsel/scroll.cpp
    engines/tinsel/scroll.h
    engines/tinsel/sound.cpp
    engines/tinsel/sound.h
    engines/tinsel/strres.cpp
    engines/tinsel/strres.h
    engines/tinsel/sysvar.cpp
    engines/tinsel/sysvar.h
    engines/tinsel/text.cpp
    engines/tinsel/text.h
    engines/tinsel/timers.cpp
    engines/tinsel/timers.h
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinlib.h
    engines/tinsel/tinsel.cpp
    engines/tinsel/tinsel.h
    engines/tinsel/token.cpp
    engines/tinsel/token.h
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/audio.cpp
    engines/toon/audio.h
    engines/toon/character.cpp
    engines/toon/character.h
    engines/toon/console.cpp
    engines/toon/console.h
    engines/toon/conversation.cpp
    engines/toon/conversation.h
    engines/toon/detection.cpp
    engines/toon/drew.cpp
    engines/toon/drew.h
    engines/toon/flux.cpp
    engines/toon/flux.h
    engines/toon/font.cpp
    engines/toon/font.h
    engines/toon/hotspot.cpp
    engines/toon/hotspot.h
    engines/toon/movie.cpp
    engines/toon/movie.h
    engines/toon/path.cpp
    engines/toon/path.h
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/resource.cpp
    engines/toon/resource.h
    engines/toon/script.cpp
    engines/toon/script.h
    engines/toon/script_func.cpp
    engines/toon/script_func.h
    engines/toon/state.cpp
    engines/toon/state.h
    engines/toon/text.cpp
    engines/toon/text.h
    engines/toon/tools.cpp
    engines/toon/tools.h
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/console.cpp
    engines/touche/console.h
    engines/touche/detection.cpp
    engines/touche/graphics.cpp
    engines/touche/graphics.h
    engines/touche/menu.cpp
    engines/touche/midi.cpp
    engines/touche/midi.h
    engines/touche/opcodes.cpp
    engines/touche/resource.cpp
    engines/touche/saveload.cpp
    engines/touche/staticres.cpp
    engines/touche/touche.cpp
    engines/touche/touche.h
    engines/tsage/converse.cpp
    engines/tsage/converse.h
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/debugger.h
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/dialogs.h
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/module.mk
    engines/tsage/resources.cpp
    engines/tsage/resources.h
    engines/tsage/ringworld_demo.cpp
    engines/tsage/ringworld_demo.h
    engines/tsage/ringworld_logic.cpp
    engines/tsage/ringworld_logic.h
    engines/tsage/ringworld_scenes1.cpp
    engines/tsage/ringworld_scenes1.h
    engines/tsage/ringworld_scenes10.cpp
    engines/tsage/ringworld_scenes10.h
    engines/tsage/ringworld_scenes2.cpp
    engines/tsage/ringworld_scenes2.h
    engines/tsage/ringworld_scenes3.cpp
    engines/tsage/ringworld_scenes3.h
    engines/tsage/ringworld_scenes4.cpp
    engines/tsage/ringworld_scenes4.h
    engines/tsage/ringworld_scenes5.cpp
    engines/tsage/ringworld_scenes5.h
    engines/tsage/ringworld_scenes6.cpp
    engines/tsage/ringworld_scenes6.h
    engines/tsage/ringworld_scenes8.cpp
    engines/tsage/ringworld_scenes8.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/scenes.h
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    engines/tucker/console.cpp
    engines/tucker/console.h
    engines/tucker/detection.cpp
    engines/tucker/graphics.cpp
    engines/tucker/graphics.h
    engines/tucker/locations.cpp
    engines/tucker/resource.cpp
    engines/tucker/saveload.cpp
    engines/tucker/sequences.cpp
    engines/tucker/staticres.cpp
    engines/tucker/tucker.cpp
    engines/tucker/tucker.h
    engines/util.h
    graphics/VectorRenderer.cpp
    graphics/VectorRenderer.h
    graphics/VectorRendererSpec.cpp
    graphics/VectorRendererSpec.h
    graphics/colormasks.h
    graphics/conversion.cpp
    graphics/conversion.h
    graphics/cursorman.cpp
    graphics/cursorman.h
    graphics/dither.cpp
    graphics/dither.h
    graphics/font.cpp
    graphics/font.h
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/fonts/scummfont.cpp
    graphics/fonts/winfont.cpp
    graphics/fonts/winfont.h
    graphics/iff.cpp
    graphics/iff.h
    graphics/imagedec.cpp
    graphics/imagedec.h
    graphics/jpeg.cpp
    graphics/jpeg.h
    graphics/module.mk
    graphics/palette.h
    graphics/pict.cpp
    graphics/pict.h
    graphics/pixelformat.h
    graphics/png.cpp
    graphics/png.h
    graphics/primitives.cpp
    graphics/primitives.h
    graphics/scaler.cpp
    graphics/scaler.h
    graphics/scaler/2xsai.cpp
    graphics/scaler/Normal2xARM.s
    graphics/scaler/aspect.cpp
    graphics/scaler/aspect.h
    graphics/scaler/downscaler.cpp
    graphics/scaler/downscaler.h
    graphics/scaler/downscalerARM.s
    graphics/scaler/hq2x.cpp
    graphics/scaler/hq3x.cpp
    graphics/scaler/intern.h
    graphics/scaler/scale2xARM.s
    graphics/scaler/thumbnail_intern.cpp
    graphics/sjis.cpp
    graphics/sjis.h
    graphics/surface.cpp
    graphics/surface.h
    graphics/thumbnail.cpp
    graphics/thumbnail.h
    graphics/wincursor.cpp
    graphics/wincursor.h
    gui/Actions.cpp
    gui/Actions.h
    gui/Key.cpp
    gui/Key.h
    gui/KeysDialog.cpp
    gui/KeysDialog.h
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeEval.cpp
    gui/ThemeEval.h
    gui/ThemeLayout.cpp
    gui/ThemeLayout.h
    gui/ThemeParser.cpp
    gui/ThemeParser.h
    gui/Tooltip.cpp
    gui/Tooltip.h
    gui/about.cpp
    gui/about.h
    gui/browser.cpp
    gui/browser.h
    gui/browser_osx.mm
    gui/chooser.cpp
    gui/chooser.h
    gui/console.cpp
    gui/console.h
    gui/credits.h
    gui/debugger.cpp
    gui/debugger.h
    gui/dialog.cpp
    gui/dialog.h
    gui/error.cpp
    gui/error.h
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/launcher.cpp
    gui/launcher.h
    gui/massadd.cpp
    gui/massadd.h
    gui/message.cpp
    gui/message.h
    gui/object.cpp
    gui/object.h
    gui/options.cpp
    gui/options.h
    gui/saveload.cpp
    gui/saveload.h
    gui/themebrowser.cpp
    gui/themebrowser.h
    gui/themes/scummclassic/classic_gfx.stx
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    gui/widgets/editable.cpp
    gui/widgets/editable.h
    gui/widgets/edittext.cpp
    gui/widgets/edittext.h
    gui/widgets/list.cpp
    gui/widgets/list.h
    gui/widgets/popup.cpp
    gui/widgets/popup.h
    gui/widgets/scrollbar.cpp
    gui/widgets/scrollbar.h
    gui/widgets/tab.cpp
    gui/widgets/tab.h
    po/de_DE.po
    po/es_ES.po
    po/pt_BR.po
    po/ru_RU.po
    po/uk_UA.po
    ports.mk
    rules.mk
    test/common/array.h
    test/module.mk
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/codecs/cdtoons.cpp
    video/codecs/cdtoons.h
    video/codecs/cinepak.cpp
    video/codecs/cinepak.h
    video/codecs/codec.h
    video/codecs/indeo3.cpp
    video/codecs/indeo3.h
    video/codecs/mjpeg.cpp
    video/codecs/mjpeg.h
    video/codecs/msrle.cpp
    video/codecs/msrle.h
    video/codecs/msvideo1.cpp
    video/codecs/msvideo1.h
    video/codecs/qdm2.cpp
    video/codecs/qdm2.h
    video/codecs/qdm2data.h
    video/codecs/qtrle.cpp
    video/codecs/qtrle.h
    video/codecs/rpza.cpp
    video/codecs/rpza.h
    video/codecs/smc.cpp
    video/codecs/smc.h
    video/codecs/truemotion1.cpp
    video/codecs/truemotion1.h
    video/codecs/truemotion1data.h
    video/coktel_decoder.cpp
    video/coktel_decoder.h
    video/dxa_decoder.cpp
    video/dxa_decoder.h
    video/flic_decoder.cpp
    video/flic_decoder.h
    video/mpeg_player.cpp
    video/mpeg_player.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp
    video/smk_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h





Commit: 224c71e483e09931ba386555ff3b436b9defe63d
    https://github.com/scummvm/scummvm/commit/224c71e483e09931ba386555ff3b436b9defe63d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-02T22:14:16-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A audio/decoders/aac.cpp
  A audio/decoders/aac.h
  A audio/decoders/qdm2.cpp
  A audio/decoders/qdm2.h
  A audio/decoders/qdm2data.h
  A audio/decoders/quicktime.cpp
  A audio/decoders/quicktime.h
  A audio/decoders/quicktime_intern.h
  A backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp
  A backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h
  A common/quicktime.cpp
  A common/quicktime.h
  A devtools/create_project/xcode.cpp
  A devtools/create_project/xcode.h
  A devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj
  A dists/iphone/readme.txt
  A dists/samsungtv/README-SamsungTV
  A engines/sword25/detection_tables.h
  A engines/sword25/gfx/image/imgloader.cpp
  A engines/sword25/gfx/image/imgloader.h
  A engines/sword25/util/lua/scummvm_file.cpp
  A engines/sword25/util/lua/scummvm_file.h
  R video/codecs/qdm2.cpp
  R video/codecs/qdm2.h
  R video/codecs/qdm2data.h
  R engines/sword25/gfx/image/pngloader.h
  R engines/sword25/gfx/image/pngloader.cpp
  R engines/sword25/util/lua/ldump.cpp
  R engines/sword25/util/lua/lundump.cpp
  R engines/sword25/util/lua/lundump.h
  R engines/sword25/util/lua/print.cpp
  R video/mpeg_player.cpp
  R video/mpeg_player.h
    .gitignore
    AUTHORS
    COPYING
    COPYRIGHT
    NEWS
    README
    audio/audiostream.cpp
    audio/decoders/flac.cpp
    audio/fmopl.h
    audio/mididrv.cpp
    audio/midiparser_xmidi.cpp
    audio/mods/tfmx.cpp
    audio/module.mk
    audio/softsynth/adlib.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.h
    audio/softsynth/fmtowns_pc98/towns_midi.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.h
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
    audio/softsynth/mt32.cpp
    audio/softsynth/mt32/partial.cpp
    audio/softsynth/mt32/synth.cpp
    audio/softsynth/mt32/synth.h
    audio/softsynth/mt32/tables.cpp
    audio/softsynth/mt32/tables.h
    audio/softsynth/opl/mame.cpp
    audio/softsynth/opl/mame.h
    backends/audiocd/audiocd.h
    backends/base-backend.cpp
    backends/events/sdl/sdl-events.cpp
    backends/fs/posix/posix-fs-factory.cpp
    backends/fs/posix/posix-fs.cpp
    backends/graphics/opengl/gltexture.h
    backends/midi/alsa.cpp
    backends/mixer/sdl/sdl-mixer.cpp
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/module.mk
    backends/platform/android/gfx.cpp
    backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
    backends/platform/dc/Makefile
    backends/platform/dc/dc.h
    backends/platform/dc/input.cpp
    backends/platform/dc/selector.cpp
    backends/platform/dingux/module.mk
    backends/platform/ds/arm9/dist/readme_ds.txt
    backends/platform/ds/arm9/makefile
    backends/platform/ds/arm9/source/dsmain.cpp
    backends/platform/ds/arm9/source/fat/gba_nds_fat.c
    backends/platform/ds/arm9/source/portdefs.h
    backends/platform/ds/arm9/source/zipreader.cpp
    backends/platform/gp2x/gp2x.cpp
    backends/platform/gp2x/module.mk
    backends/platform/gph/build/caanoo-config-alleng.sh
    backends/platform/gph/build/caanoo-config.sh
    backends/platform/gph/build/gp2x-config-alleng.sh
    backends/platform/gph/build/gp2x-config.sh
    backends/platform/gph/build/gp2xwiz-config-alleng.sh
    backends/platform/gph/build/gp2xwiz-config.sh
    backends/platform/gph/gph-backend.cpp
    backends/platform/gph/module.mk
    backends/platform/linuxmoto/module.mk
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/portdefs.h
    backends/platform/null/null.cpp
    backends/platform/openpandora/build/config-alleng.sh
    backends/platform/openpandora/build/config.sh
    backends/platform/openpandora/module.mk
    backends/platform/ps2/Makefile.gdb
    backends/platform/ps2/Makefile.ps2
    backends/platform/psp/display_manager.cpp
    backends/platform/samsungtv/main.cpp
    backends/platform/samsungtv/module.mk
    backends/platform/samsungtv/samsungtv.cpp
    backends/platform/samsungtv/samsungtv.h
    backends/platform/sdl/main.cpp
    backends/platform/sdl/module.mk
    backends/platform/sdl/posix/posix-main.cpp
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/sdl.cpp
    backends/platform/symbian/BuildPackageUpload_LocalSettings.pl
    backends/platform/symbian/README
    backends/platform/symbian/src/portdefs.h
    backends/platform/wii/options.cpp
    backends/platform/wince/Makefile
    backends/platform/wince/README-WinCE.txt
    backends/platform/wince/missing/io.h
    backends/platform/wince/portdefs.h
    backends/plugins/posix/posix-provider.cpp
    backends/plugins/posix/posix-provider.h
    backends/plugins/win32/win32-provider.cpp
    backends/saves/posix/posix-saves.cpp
    backends/saves/posix/posix-saves.h
    backends/vkeybd/image-map.h
    backends/vkeybd/polygon.h
    backends/vkeybd/virtual-keyboard-gui.h
    backends/vkeybd/virtual-keyboard-parser.h
    backends/vkeybd/virtual-keyboard.h
    base/commandLine.cpp
    base/commandLine.h
    base/main.cpp
    base/plugins.h
    base/version.cpp
    common/algorithm.h
    common/error.cpp
    common/error.h
    common/events.h
    common/forbidden.h
    common/module.mk
    common/savefile.h
    common/scummsys.h
    common/str.cpp
    common/str.h
    common/system.h
    common/textconsole.cpp
    common/unzip.cpp
    common/util.cpp
    common/util.h
    configure
    devtools/README
    devtools/create_hugo/create_hugo.h
    devtools/create_hugo/enums.h
    devtools/create_kyradat/module.mk
    devtools/create_lure/create_lure_dat.cpp
    devtools/create_mads/parser.cpp
    devtools/create_project/codeblocks/create_project.cbp
    devtools/create_project/create_project.cpp
    devtools/create_project/module.mk
    devtools/create_project/msvc10/create_project.vcxproj
    devtools/create_project/msvc10/create_project.vcxproj.filters
    devtools/create_project/msvc8/create_project.vcproj
    devtools/create_project/msvc9/create_project.vcproj
    devtools/credits.pl
    dists/iphone/scummvm.xcodeproj/project.pbxproj
    dists/redhat/README
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.h
    engines/agi/checks.cpp
    engines/agi/graphics.cpp
    engines/agi/loader_v2.cpp
    engines/agi/op_cmd.cpp
    engines/agi/op_test.cpp
    engines/agi/saveload.cpp
    engines/agi/sound.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agos/midi.cpp
    engines/agos/saveload.cpp
    engines/agos/string_pn.cpp
    engines/cine/cine.h
    engines/cine/detection.cpp
    engines/cine/saveload.cpp
    engines/cine/various.cpp
    engines/cruise/cruise.cpp
    engines/cruise/cruise.h
    engines/cruise/detection.cpp
    engines/cruise/mainDraw.cpp
    engines/cruise/menu.cpp
    engines/dialogs.cpp
    engines/draci/detection.cpp
    engines/draci/draci.cpp
    engines/draci/draci.h
    engines/draci/game.cpp
    engines/draci/music.cpp
    engines/draci/saveload.cpp
    engines/draci/script.h
    engines/draci/sound.cpp
    engines/drascula/drascula.cpp
    engines/drascula/drascula.h
    engines/drascula/saveload.cpp
    engines/engine.cpp
    engines/engine.h
    engines/gob/resources.cpp
    engines/gob/save/saveconverter.cpp
    engines/gob/save/savehandler.cpp
    engines/gob/sound/sound.cpp
    engines/groovie/detection.cpp
    engines/groovie/groovie.cpp
    engines/groovie/groovie.h
    engines/groovie/music.cpp
    engines/groovie/music.h
    engines/groovie/player.cpp
    engines/groovie/player.h
    engines/groovie/resource.cpp
    engines/groovie/resource.h
    engines/groovie/script.cpp
    engines/groovie/script.h
    engines/groovie/vdx.cpp
    engines/hugo/console.cpp
    engines/hugo/console.h
    engines/hugo/display.cpp
    engines/hugo/hugo.cpp
    engines/hugo/hugo.h
    engines/hugo/object_v1d.cpp
    engines/hugo/object_v1w.cpp
    engines/hugo/object_v2d.cpp
    engines/hugo/parser.h
    engines/hugo/schedule.cpp
    engines/hugo/schedule.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound.h
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_intern.h
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_towns.cpp
    engines/lastexpress/detection.cpp
    engines/lastexpress/game/sound.cpp
    engines/lastexpress/game/sound.h
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/lastexpress.h
    engines/lure/debugger.cpp
    engines/lure/decode.cpp
    engines/lure/detection.cpp
    engines/lure/lure.cpp
    engines/lure/lure.h
    engines/lure/res.cpp
    engines/lure/res_struct.cpp
    engines/lure/sound.h
    engines/lure/surface.cpp
    engines/lure/surface.h
    engines/m4/animation.cpp
    engines/m4/animation.h
    engines/m4/compression.cpp
    engines/m4/compression.h
    engines/m4/console.cpp
    engines/m4/globals.cpp
    engines/m4/globals.h
    engines/m4/gui.h
    engines/m4/m4.cpp
    engines/m4/m4.h
    engines/m4/mads_anim.cpp
    engines/m4/mads_logic.cpp
    engines/m4/mads_logic.h
    engines/m4/mads_menus.cpp
    engines/m4/mads_menus.h
    engines/m4/mads_scene.cpp
    engines/m4/mads_scene.h
    engines/m4/mads_views.cpp
    engines/m4/mads_views.h
    engines/m4/rails.cpp
    engines/m4/rails.h
    engines/made/database.cpp
    engines/made/database.h
    engines/made/made.cpp
    engines/made/script.cpp
    engines/made/scriptfuncs.cpp
    engines/mohawk/cstime_ui.cpp
    engines/mohawk/livingbooks.cpp
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/queen/command.cpp
    engines/queen/command.h
    engines/queen/cutaway.cpp
    engines/queen/display.h
    engines/queen/logic.cpp
    engines/queen/musicdata.cpp
    engines/queen/queen.cpp
    engines/queen/queen.h
    engines/queen/structs.h
    engines/queen/walk.cpp
    engines/saga/detection.cpp
    engines/saga/font.cpp
    engines/saga/font.h
    engines/saga/objectmap.cpp
    engines/saga/saga.h
    engines/saga/script.cpp
    engines/saga/sfuncs.cpp
    engines/saga/sfuncs_ihnm.cpp
    engines/savestate.cpp
    engines/savestate.h
    engines/sci/console.cpp
    engines/sci/detection.cpp
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.cpp
    engines/sci/engine/savegame.h
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/segment.h
    engines/sci/engine/selector.h
    engines/sci/engine/workarounds.cpp
    engines/sci/event.cpp
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/text16.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/scumm/actor.cpp
    engines/scumm/boxes.cpp
    engines/scumm/detection.cpp
    engines/scumm/gfx.cpp
    engines/scumm/help.cpp
    engines/scumm/imuse/imuse.cpp
    engines/scumm/imuse/imuse_internal.h
    engines/scumm/imuse/imuse_part.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/imuse/sysex_scumm.cpp
    engines/scumm/input.cpp
    engines/scumm/object.cpp
    engines/scumm/palette.cpp
    engines/scumm/player_towns.cpp
    engines/scumm/player_v4a.h
    engines/scumm/saveload.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/scumm_v0.h
    engines/scumm/string.cpp
    engines/sky/detection.cpp
    engines/sky/logic.cpp
    engines/sky/sky.h
    engines/sky/sound.cpp
    engines/sword1/animation.cpp
    engines/sword1/detection.cpp
    engines/sword1/router.cpp
    engines/sword1/sword1.h
    engines/sword1/sworddefs.h
    engines/sword2/animation.cpp
    engines/sword2/console.cpp
    engines/sword2/controls.cpp
    engines/sword2/icons.cpp
    engines/sword2/interpreter.cpp
    engines/sword2/layers.cpp
    engines/sword2/maketext.cpp
    engines/sword2/maketext.h
    engines/sword2/render.cpp
    engines/sword2/router.cpp
    engines/sword2/router.h
    engines/sword2/saveload.cpp
    engines/sword2/screen.cpp
    engines/sword2/screen.h
    engines/sword2/sword2.cpp
    engines/sword2/sword2.h
    engines/sword25/detection.cpp
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/fmv/theora_decoder.h
    engines/sword25/gfx/graphicengine.h
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/image/swimage.cpp
    engines/sword25/gfx/panel.cpp
    engines/sword25/gfx/screenshot.cpp
    engines/sword25/input/inputengine.h
    engines/sword25/kernel/kernel.cpp
    engines/sword25/kernel/kernel.h
    engines/sword25/kernel/persistenceservice.cpp
    engines/sword25/math/polygon.cpp
    engines/sword25/math/polygon.h
    engines/sword25/math/region.cpp
    engines/sword25/math/region.h
    engines/sword25/math/vertex.h
    engines/sword25/math/walkregion.cpp
    engines/sword25/module.mk
    engines/sword25/script/luascript.cpp
    engines/sword25/script/luascript.h
    engines/sword25/script/script.h
    engines/sword25/sfx/soundengine.h
    engines/sword25/sword25.cpp
    engines/sword25/sword25.h
    engines/sword25/util/lua/lapi.cpp
    engines/sword25/util/lua/lauxlib.cpp
    engines/sword25/util/lua/ldo.cpp
    engines/sword25/util/lua/liolib.cpp
    engines/sword25/util/lua/llex.cpp
    engines/sword25/util/lua/lmathlib.cpp
    engines/sword25/util/lua/loadlib.cpp
    engines/sword25/util/lua/loslib.cpp
    engines/sword25/util/lua/lua.h
    engines/sword25/util/lua/luaconf.h
    engines/sword25/util/lua/lvm.cpp
    engines/teenagent/detection.cpp
    engines/teenagent/inventory.cpp
    engines/teenagent/inventory.h
    engines/teenagent/teenagent.cpp
    engines/teenagent/teenagent.h
    engines/tinsel/actors.cpp
    engines/tinsel/background.cpp
    engines/tinsel/background.h
    engines/tinsel/bg.cpp
    engines/tinsel/bmv.cpp
    engines/tinsel/bmv.h
    engines/tinsel/cliprect.cpp
    engines/tinsel/cursor.cpp
    engines/tinsel/detection.cpp
    engines/tinsel/dialogs.cpp
    engines/tinsel/handle.cpp
    engines/tinsel/heapmem.cpp
    engines/tinsel/heapmem.h
    engines/tinsel/move.cpp
    engines/tinsel/multiobj.cpp
    engines/tinsel/multiobj.h
    engines/tinsel/object.cpp
    engines/tinsel/pcode.cpp
    engines/tinsel/pcode.h
    engines/tinsel/polygons.cpp
    engines/tinsel/savescn.cpp
    engines/tinsel/savescn.h
    engines/tinsel/scene.cpp
    engines/tinsel/scroll.cpp
    engines/tinsel/sysvar.cpp
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinsel.cpp
    engines/tinsel/tinsel.h
    engines/toon/audio.cpp
    engines/toon/script_func.cpp
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/saveload.cpp
    engines/touche/touche.h
    engines/tsage/core.cpp
    engines/tsage/debugger.cpp
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/ringworld_logic.cpp
    engines/tsage/ringworld_scenes1.cpp
    engines/tsage/ringworld_scenes10.cpp
    engines/tsage/ringworld_scenes3.cpp
    engines/tsage/ringworld_scenes3.h
    engines/tsage/ringworld_scenes5.cpp
    engines/tsage/ringworld_scenes6.cpp
    engines/tsage/ringworld_scenes8.cpp
    engines/tsage/saveload.cpp
    engines/tsage/scenes.cpp
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    engines/tucker/detection.cpp
    engines/tucker/resource.cpp
    engines/tucker/saveload.cpp
    engines/tucker/sequences.cpp
    engines/tucker/tucker.h
    graphics/font.cpp
    graphics/font.h
    graphics/iff.h
    graphics/palette.h
    graphics/pict.cpp
    graphics/scaler.cpp
    graphics/surface.cpp
    graphics/yuv_to_rgb.cpp
    gui/credits.h
    gui/debugger.cpp
    gui/debugger.h
    gui/gui-manager.cpp
    gui/launcher.cpp
    gui/massadd.cpp
    gui/options.cpp
    gui/saveload.cpp
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widgets/list.cpp
    ports.mk
    rules.mk
    test/common/str.h
    video/avi_decoder.cpp
    video/codecs/indeo3.cpp
    video/codecs/indeo3.h
    video/coktel_decoder.cpp
    video/module.mk
    video/qt_decoder.cpp
    video/qt_decoder.h





Commit: d355475a0416897ed254fa85f4d63d0f75d9c7ea
    https://github.com/scummvm/scummvm/commit/d355475a0416897ed254fa85f4d63d0f75d9c7ea
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-13T10:12:23-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  R backends/events/gp2xsdl/gp2xsdl-events.cpp
  R backends/events/gp2xsdl/gp2xsdl-events.h
  R backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp
  R backends/graphics/gp2xsdl/gp2xsdl-graphics.h
  R backends/platform/gp2x/build/clean.sh
  R backends/platform/gp2x/gp2x-common.h
  R backends/platform/gp2x/gp2x-hw.cpp
  R backends/platform/gp2x/gp2x-hw.h
  R backends/platform/gp2x/gp2x-main.cpp
  R backends/platform/gp2x/gp2x-mem.cpp
  R backends/platform/gp2x/gp2x-mem.h
  R backends/platform/gp2x/gp2x.cpp
  R backends/platform/gp2x/module.mk
  R graphics/fonts/scummfont.cpp
    .gitignore
    audio/decoders/aac.h
    audio/decoders/quicktime.h
    audio/mididrv.cpp
    audio/mididrv.h
    audio/midiparser_xmidi.cpp
    audio/mixer.cpp
    audio/mixer.h
    audio/mixer_intern.h
    audio/musicplugin.h
    audio/softsynth/fmtowns_pc98/towns_midi.cpp
    audio/softsynth/fmtowns_pc98/towns_midi.h
    audio/softsynth/mt32.cpp
    backends/base-backend.cpp
    backends/base-backend.h
    backends/events/gph/gph-events.cpp
    backends/events/openpandora/op-events.cpp
    backends/events/openpandora/op-events.h
    backends/events/wincesdl/wincesdl-events.cpp
    backends/events/wincesdl/wincesdl-events.h
    backends/fs/ds/ds-fs.cpp
    backends/fs/posix/posix-fs-factory.cpp
    backends/fs/posix/posix-fs.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/gph/gph-graphics.h
    backends/graphics/graphics.h
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openpandora/op-graphics.cpp
    backends/graphics/openpandora/op-graphics.h
    backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.cpp
    backends/graphics/sdl/sdl-graphics.h
    backends/graphics/symbiansdl/symbiansdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/module.mk
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/display.cpp
    backends/platform/dc/input.cpp
    backends/platform/dc/time.cpp
    backends/platform/dc/vmsave.cpp
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/gph/build/gp2x-config.sh
    backends/platform/gph/devices/gp2x/scummvm.gpe
    backends/platform/gph/gph-backend.cpp
    backends/platform/gph/gph-main.cpp
    backends/platform/gph/gph-sdl.h
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.m
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_video.cpp
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/osys_n64_utilities.cpp
    backends/platform/null/null.cpp
    backends/platform/openpandora/op-backend.cpp
    backends/platform/openpandora/op-main.cpp
    backends/platform/openpandora/op-sdl.h
    backends/platform/ps2/fileio.cpp
    backends/platform/ps2/fileio.h
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/cursor.h
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/osys_psp.h
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx.h
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/posix/posix.h
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    backends/platform/sdl/win32/win32.cpp
    backends/platform/sdl/win32/win32.h
    backends/platform/wii/osystem.cpp
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_events.cpp
    backends/platform/wii/osystem_gfx.cpp
    backends/platform/wince/CEActionsPocket.cpp
    backends/platform/wince/CEActionsPocket.h
    backends/platform/wince/CEActionsSmartphone.cpp
    backends/platform/wince/CEActionsSmartphone.h
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince-sdl.h
    backends/vkeybd/virtual-keyboard-parser.cpp
    common/forbidden.h
    common/macresman.cpp
    common/str.cpp
    common/system.cpp
    common/system.h
    common/xmlparser.cpp
    common/xmlparser.h
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/games.cpp
    devtools/create_project/msbuild.cpp
    devtools/create_project/visualstudio.cpp
    dists/engine-data/kyra.dat
    dists/iphone/scummvm.xcodeproj/project.pbxproj
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/detection.cpp
    engines/agi/predictive.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_pcjr.cpp
    engines/agos/detection.cpp
    engines/cine/detection.cpp
    engines/cruise/detection.cpp
    engines/draci/detection.cpp
    engines/drascula/detection.cpp
    engines/gob/detection.cpp
    engines/groovie/detection.cpp
    engines/groovie/groovie.cpp
    engines/groovie/groovie.h
    engines/groovie/music.cpp
    engines/groovie/resource.cpp
    engines/hugo/detection.cpp
    engines/kyra/animator_mr.cpp
    engines/kyra/detection.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_mr.cpp
    engines/kyra/items_lol.cpp
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_mr.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/scene_lol.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_tim.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sound_lok.cpp
    engines/kyra/sound_lol.cpp
    engines/kyra/staticres.cpp
    engines/kyra/text_hof.cpp
    engines/kyra/text_mr.cpp
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/debug.cpp
    engines/lastexpress/detection.cpp
    engines/lastexpress/game/sound.cpp
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/lastexpress.h
    engines/lure/detection.cpp
    engines/m4/detection.cpp
    engines/made/detection.cpp
    engines/mohawk/detection.cpp
    engines/mohawk/detection_tables.h
    engines/parallaction/detection.cpp
    engines/saga/detection.cpp
    engines/sci/console.cpp
    engines/sci/console.h
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/state.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm_types.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/compare.cpp
    engines/sci/graphics/controls.cpp
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/transitions.cpp
    engines/sci/graphics/view.cpp
    engines/sci/sci.h
    engines/sci/sound/drivers/amigamac.cpp
    engines/scumm/gfx_towns.cpp
    engines/scumm/he/resource_he.cpp
    engines/scumm/scumm.cpp
    engines/sword25/detection.cpp
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/gfx/animationresource.cpp
    engines/sword25/gfx/animationresource.h
    engines/sword25/gfx/fontresource.cpp
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/util/lua/ldblib.cpp
    engines/teenagent/detection.cpp
    engines/testbed/config.cpp
    engines/testbed/config.h
    engines/testbed/detection.cpp
    engines/testbed/fs.cpp
    engines/testbed/graphics.cpp
    engines/testbed/graphics.h
    engines/testbed/midi.cpp
    engines/testbed/misc.cpp
    engines/testbed/misc.h
    engines/testbed/savegame.cpp
    engines/testbed/sound.h
    engines/testbed/testbed.cpp
    engines/testbed/testsuite.cpp
    engines/testbed/testsuite.h
    engines/tinsel/detection.cpp
    engines/toon/audio.cpp
    engines/toon/audio.h
    engines/toon/detection.cpp
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/detection.cpp
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/ringworld_demo.cpp
    engines/tsage/ringworld_scenes1.cpp
    engines/tsage/ringworld_scenes1.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/tsage.h
    engines/tucker/detection.cpp
    graphics/cursorman.cpp
    graphics/cursorman.h
    graphics/font.h
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/module.mk
    graphics/scaler/Normal2xARM.s
    graphics/scaler/aspect.cpp
    graphics/scaler/downscaler.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeParser.cpp
    gui/console.h
    gui/debugger.cpp
    gui/debugger.h
    gui/options.cpp
    gui/themes/translations.dat
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    test/common/str.h





Commit: 5e7acc83b7ad363014e2a6681bcba22c9bbd9c07
    https://github.com/scummvm/scummvm/commit/5e7acc83b7ad363014e2a6681bcba22c9bbd9c07
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-13T10:20:15-07:00

Commit Message:
PEGASUS: Update detection

Changed paths:
    engines/pegasus/detection.cpp



diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index 1852429..d0e3fc1 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -83,37 +83,15 @@ static const PegasusGameDescription gameDescriptions[] = {
 
 } // End of namespace Pegasus
 
-static const ADParams detectionParams = {
-	// Pointer to ADGameDescription or its superset structure
-	(const byte *)Pegasus::gameDescriptions,
-	// Size of that superset structure
-	sizeof(Pegasus::PegasusGameDescription),
-	// Number of bytes to compute MD5 sum for
-	5000,
-	// List of all engine targets
-	pegasusGames,
-	// Structure for autoupgrading obsolete targets
-	0,
-	// Name of single gameid (optional)
-	"pegasus",
-	// List of files for file-based fallback detection (optional)
-	0,
-	// Flags
-	0,
-	// Additional GUI options (for every game)
-	Common::GUIO_NONE,
-	// Maximum directory depth
-	1,
-	// List of directory globs
-	0
-};
 
 class PegasusMetaEngine : public AdvancedMetaEngine {
 public:
-	PegasusMetaEngine() : AdvancedMetaEngine(detectionParams) {}
+	PegasusMetaEngine() : AdvancedMetaEngine(Pegasus::gameDescriptions, sizeof(Pegasus::PegasusGameDescription), pegasusGames) {
+		params.singleid = "pegasus";
+	}
 
 	virtual const char *getName() const {
-		return "Pegasus Prime Engine";
+		return "The Journeyman Project: Pegasus Prime";
 	}
 
 	virtual const char *getOriginalCopyright() const {


Commit: 4926c41e01a46735747930b09cc924ecd826a215
    https://github.com/scummvm/scummvm/commit/4926c41e01a46735747930b09cc924ecd826a215
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-14T13:21:39-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A engines/obsolete.cpp
  A engines/obsolete.h
    backends/events/default/default-events.cpp
    backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.h
    backends/mixer/symbiansdl/symbiansdl-mixer.cpp
    backends/platform/iphone/osys_events.cpp
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/detection.cpp
    engines/agos/animation.cpp
    engines/agos/detection.cpp
    engines/cine/detection.cpp
    engines/cruise/detection.cpp
    engines/dialogs.cpp
    engines/draci/detection.cpp
    engines/drascula/detection.cpp
    engines/engine.cpp
    engines/game.cpp
    engines/game.h
    engines/gob/detection.cpp
    engines/gob/detection_tables.h
    engines/gob/inter_playtoons.cpp
    engines/gob/inter_v2.cpp
    engines/gob/inter_v5.cpp
    engines/groovie/detection.cpp
    engines/groovie/script.cpp
    engines/kyra/detection.cpp
    engines/kyra/sound_midi.cpp
    engines/lastexpress/detection.cpp
    engines/lure/detection.cpp
    engines/m4/detection.cpp
    engines/m4/m4_menus.cpp
    engines/made/detection.cpp
    engines/module.mk
    engines/mohawk/detection.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/mohawk.h
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/riven_scripts.h
    engines/mohawk/video.cpp
    engines/parallaction/detection.cpp
    engines/parallaction/saveload.cpp
    engines/pegasus/detection.cpp
    engines/saga/detection.cpp
    engines/sci/detection.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/gfx_towns.cpp
    engines/scumm/resource.h
    engines/scumm/scumm.cpp
    engines/sky/compact.cpp
    engines/sword1/animation.cpp
    engines/sword1/control.cpp
    engines/sword1/detection.cpp
    engines/sword1/logic.cpp
    engines/sword1/music.cpp
    engines/sword1/music.h
    engines/sword2/animation.cpp
    engines/sword25/detection.cpp
    engines/teenagent/detection.cpp
    engines/testbed/detection.cpp
    engines/tinsel/detection.cpp
    engines/tinsel/saveload.cpp
    engines/toon/detection.cpp
    engines/touche/detection.cpp
    engines/touche/touche.h
    engines/tsage/detection.cpp
    engines/tucker/detection.cpp
    gui/themes/translations.dat
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po



diff --cc engines/pegasus/detection.cpp
index d0e3fc1,0000000..9c486f7
mode 100644,000000..100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@@ -1,118 -1,0 +1,118 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "base/plugins.h"
 +
 +#include "engines/advancedDetector.h"
 +#include "common/config-manager.h"
 +#include "common/file.h"
 +
 +#include "pegasus/pegasus.h"
 +
 +namespace Pegasus {
 +
 +struct PegasusGameDescription {
 +	ADGameDescription desc;
 +};
 +
 +bool PegasusEngine::hasFeature(EngineFeature f) const {
 +	return
 +		(f == kSupportsRTL);
 +}
 +
 +bool PegasusEngine::isDemo() const {
 +	return (_gameDescription->desc.flags & ADGF_DEMO) != 0;
 +}
 +
 +} // End of namespace Pegasus
 +
 +static const PlainGameDescriptor pegasusGames[] = {
 +	{"pegasus", "The Journeyman Project: Pegasus Prime"},
 +	{0, 0}
 +};
 +
 +
 +namespace Pegasus {
 +
 +static const PegasusGameDescription gameDescriptions[] = {
 +	{
 +		{
 +			"pegasus",
 +			"",
 +			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 2009943),
 +			Common::EN_ANY,
 +			Common::kPlatformMacintosh,
 +			ADGF_MACRESFORK,
 +			Common::GUIO_NONE
 +		},
 +	},
 +
 +	{
 +		{
 +			"pegasus",
 +			"",
 +			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 360129),
 +			Common::EN_ANY,
 +			Common::kPlatformMacintosh,
 +			ADGF_MACRESFORK|ADGF_DEMO,
 +			Common::GUIO_NONE
 +		},
 +	},
 +
 +	{ AD_TABLE_END_MARKER }
 +};
 +
 +} // End of namespace Pegasus
 +
 +
 +class PegasusMetaEngine : public AdvancedMetaEngine {
 +public:
 +	PegasusMetaEngine() : AdvancedMetaEngine(Pegasus::gameDescriptions, sizeof(Pegasus::PegasusGameDescription), pegasusGames) {
- 		params.singleid = "pegasus";
++		_singleid = "pegasus";
 +	}
 +
 +	virtual const char *getName() const {
 +		return "The Journeyman Project: Pegasus Prime";
 +	}
 +
 +	virtual const char *getOriginalCopyright() const {
 +		return "The Journeyman Project: Pegasus Prime (C) Presto Studios";
 +	}
 +
 +	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
 +};
 +
 +bool PegasusMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 +	const Pegasus::PegasusGameDescription *gd = (const Pegasus::PegasusGameDescription *)desc;
 +
 +	if (gd)
 +		*engine = new Pegasus::PegasusEngine(syst, gd);
 +
 +	return (gd != 0);
 +}
 +
 +#if PLUGIN_ENABLED_DYNAMIC(PEGASUS)
 +	REGISTER_PLUGIN_DYNAMIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
 +#else
 +	REGISTER_PLUGIN_STATIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
 +#endif
 +


Commit: a93a7717533045b1dfc7e81eeb5b54b947b3f9ed
    https://github.com/scummvm/scummvm/commit/a93a7717533045b1dfc7e81eeb5b54b947b3f9ed
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T09:50:36-07:00

Commit Message:
PEGASUS: Begin porting over base MMShell classes

Changed paths:
  A engines/pegasus/MMShell/MMConstants.h
  A engines/pegasus/MMShell/MMTypes.h
  A engines/pegasus/MMShell/Utilities/MMIDObject.h



diff --git a/engines/pegasus/MMShell/MMConstants.h b/engines/pegasus/MMShell/MMConstants.h
new file mode 100755
index 0000000..e96eb15
--- /dev/null
+++ b/engines/pegasus/MMShell/MMConstants.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_MMTYPES_H
+#define PEGASUS_MMSHELL_MMTYPES_H
+
+#include "pegasus/MMShell/MMTypes.h"
+
+namespace Pegasus {
+
+const tDisplayElementID kNoDisplayElement = -1;
+const tDisplayElementID kHighestReservedElementID = -2;
+
+const tDisplayElementID kCursorID = kHighestReservedElementID;
+const tDisplayElementID kLoadScreenID = kCursorID - 1;
+
+const tDisplayOrder kMinAvailableOrder = 0;
+const tDisplayOrder kMaxAvailableOrder = 999998;
+const tDisplayOrder kLoadScreenOrder = 900000;
+const tDisplayOrder kCursorOrder = 1000000;
+
+const tHotSpotID kNoHotSpotID = -1;
+const tHotSpotFlags kNoHotSpotFlags = 0;
+const tHotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
+
+const tNotificationFlags kNoNotificationFlags = 0;
+
+const tDisplayElementID kCurrentDragSpriteID = 1000;
+
+// TODO
+//const Fixed kFixed1 = 1 << 16;
+//const Fixed kFixedMinus1 = -1 << 16;
+
+// Originally "TimeScale" instead of int
+const int kDefaultTimeScale = 600;
+
+// TODO
+//const RGBColor kWhiteRGB = {0xFFFF, 0xFFFF, 0xFFFF};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/MMShell/MMTypes.h b/engines/pegasus/MMShell/MMTypes.h
new file mode 100755
index 0000000..ae5f0d0
--- /dev/null
+++ b/engines/pegasus/MMShell/MMTypes.h
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_MMTYPES_H
+#define PEGASUS_MMSHELL_MMTYPES_H
+
+#include "common/scummsys.h"
+
+namespace Pegasus {
+
+// TODO: All of the "tMM"-prefixed defines should be replaced eventually
+// TODO: Probably all of these don't really need to be typedef'd...
+typedef int8 tMM8BitS;
+typedef uint8 tMM8BitU;
+
+typedef int16 tMM16BitS;
+typedef uint16 tMM16BitU;
+
+typedef int32 tMM32BitS;
+typedef uint32 tMM32BitU;
+
+typedef tMM8BitS tMM8BitID;
+typedef tMM16BitS tMM16BitID;
+typedef tMM32BitS tMM32BitID;
+
+typedef tMM8BitU tMM8BitFlags;
+typedef tMM16BitU tMM16BitFlags;
+typedef tMM32BitU tMM32BitFlags;
+
+typedef tMM32BitID tDisplayElementID;
+typedef tMM32BitS tDisplayOrder;
+
+typedef tMM16BitID tHotSpotID;
+typedef tMM32BitFlags tHotSpotFlags;
+
+typedef tMM8BitFlags tButtonState;
+typedef tMM32BitFlags tInputBits;
+
+typedef tMM8BitU tKeyMapType[16];
+typedef tMM8BitU tKeyType;
+typedef tMM8BitU tKeyMapIndexType;
+typedef tMM8BitU tKeyMapBitType;
+
+typedef tMM32BitID tNotificationID;
+typedef tMM32BitFlags tNotificationFlags;
+
+//	Mac types.
+typedef tMM16BitS tResIDType;
+typedef tMM16BitS tCoordType;
+typedef tMM16BitS tQDCopyMode;
+typedef tMM16BitS tResItemCountType;
+
+enum tCopyMode {
+	kNoMask,
+	kUseClipArea,
+	kUseTransparency
+};
+
+enum tSlideDirection {
+	kSlideLeftMask = 1,
+	kSlideRightMask = kSlideLeftMask << 1,
+	kSlideUpMask = kSlideRightMask << 1 << 1,
+	kSlideDownMask = kSlideUpMask << 1,
+	
+	kSlideHorizMask = kSlideLeftMask | kSlideRightMask,
+	kSlideVertMask = kSlideUpMask | kSlideDownMask,
+
+	kSlideUpLeftMask = kSlideLeftMask | kSlideUpMask,
+	kSlideUpRightMask = kSlideRightMask | kSlideUpMask,
+	kSlideDownLeftMask = kSlideLeftMask | kSlideDownMask,
+	kSlideDownRightMask = kSlideRightMask | kSlideDownMask
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/MMShell/Utilities/MMIDObject.h
new file mode 100755
index 0000000..e0ca29b
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMIDObject.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_MMIDOBJECT_H
+#define PEGASUS_MMSHELL_MMIDOBJECT_H
+
+#include "pegasus/MMShell/MMTypes.h"
+
+namespace Pegasus {
+
+class MMIDObject {
+friend inline int operator==(const MMIDObject &arg1, const MMIDObject &arg1);
+friend inline int operator!=(const MMIDObject &arg2, const MMIDObject &arg2);
+
+public:
+	MMIDObject(const tMM32BitID id);
+	~MMIDObject();
+	
+	tMM32BitID GetObjectID() const;
+
+private:
+	tMM32BitID fObjectID;
+};
+
+inline MMIDObject::MMIDObject(const tMM32BitID id) {
+	fObjectID = id;
+}
+
+inline MMIDObject::~MMIDObject() {
+}
+
+inline tMM32BitID MMIDObject::GetObjectID() const {
+	return fObjectID;
+}
+
+inline int operator==(const MMIDObject &arg1, const MMIDObject &arg2) {
+	return arg1.fObjectID == arg2.fObjectID;
+}
+
+inline int operator!=(const MMIDObject &arg1, const MMIDObject &arg2) {
+	return arg1.fObjectID != arg2.fObjectID;
+}
+
+} // End of namespace Pegasus
+
+#endif


Commit: 0e78eb00197ae00cabefa02f4df74ce5a5de1e89
    https://github.com/scummvm/scummvm/commit/0e78eb00197ae00cabefa02f4df74ce5a5de1e89
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T09:54:17-07:00

Commit Message:
PEGASUS: Add the Game Shell CItem class

Changed paths:
  A engines/pegasus/Game_Shell/CItem.cpp
  A engines/pegasus/Game_Shell/CItem.h
  A engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
  A engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp
new file mode 100755
index 0000000..0816e59
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CItem.cpp
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "pegasus/Game_Shell/CItem.h"
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Pegasus {
+
+CItem::CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) {
+	fItemNeighborhood = neighborhood;
+	fItemRoom = room;
+	fItemDirection = direction;
+	fItemWeight = 1;
+	fItemOwnerID = kNoActorID;
+	fItemState = 0;
+
+	// TODO: This line would append this item to the list of all items
+	//gAllItems.Append(this);
+}
+
+CItem::~CItem() {
+}
+
+Common::Error CItem::WriteToStream(Common::WriteStream *stream) {
+	stream->writeUint16BE(fItemNeighborhood);
+	stream->writeUint16BE(fItemRoom);
+	stream->writeByte(fItemDirection);
+	stream->writeUint16BE(fItemOwnerID);
+	stream->writeUint16BE(fItemState);
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error CItem::ReadFromStream(Common::ReadStream *stream) {
+	fItemNeighborhood = stream->readUint16BE();
+	fItemRoom = stream->readUint16BE();
+	fItemDirection = stream->readByte();
+	fItemOwnerID = stream->readUint16BE();
+	fItemState = stream->readUint16BE();
+	
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+tActorID CItem::GetItemOwner() const {
+	return fItemOwnerID;
+}
+
+void CItem::SetItemOwner(const tActorID owner) {
+	fItemOwnerID = owner;
+}
+
+tWeightType CItem::GetItemWeight() {
+	return fItemWeight;
+}
+
+tItemState CItem::GetItemState() const {
+	return fItemState;
+}
+
+void CItem::SetItemState(const tItemState state) {
+	fItemState = state;
+}
+
+void CItem::GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
+	neighborhood = fItemNeighborhood;
+	room = fItemRoom;
+	direction = fItemDirection;
+}
+
+void CItem::SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	fItemNeighborhood = neighborhood;
+	fItemRoom = room;
+	fItemDirection = direction;
+}
+
+tNeighborhoodID CItem::GetItemNeighborhood() const {
+	return fItemNeighborhood;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CItem.h b/engines/pegasus/Game_Shell/CItem.h
new file mode 100755
index 0000000..2bef735
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CItem.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_GAMESHELL_CITEM_H
+#define PEGASUS_GAMESHELL_CITEM_H
+
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
+#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+
+namespace Common {
+	class Error;
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+/*
+
+	CItem is an object which can be picked up and carried around.
+	CItems have
+		a location
+		an ID.
+		weight
+		an owner (kNoActorID if no one is carrying the CItem)
+
+*/
+
+class CItem : public MMIDObject {
+public:
+	CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	virtual ~CItem();
+	
+	// WriteToStream writes everything EXCEPT the item's ID.
+	// It is assumed that the calling function will write and read the ID.
+	virtual Common::Error WriteToStream(Common::WriteStream *stream);
+	virtual Common::Error ReadFromStream(Common::ReadStream *stream);
+	
+	virtual tActorID GetItemOwner() const;
+	virtual void SetItemOwner(const tActorID owner);
+	
+	void GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const;
+	void SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	tNeighborhoodID GetItemNeighborhood() const;
+	
+	virtual tWeightType GetItemWeight();
+	
+	virtual void SetItemState(const tItemState state);
+	virtual tItemState GetItemState() const;
+
+protected:
+	tNeighborhoodID fItemNeighborhood;
+	tRoomID	fItemRoom;
+	tDirectionConstant fItemDirection;
+	tActorID fItemOwnerID;
+	tWeightType fItemWeight;
+	tItemState fItemState;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
new file mode 100755
index 0000000..919c059
--- /dev/null
+++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS
+#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS
+
+#include "engines/pegasus/MMShell/MMConstants.h"
+#include "engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+
+namespace Pegasus {
+
+const tGameID kGameIDNothing = -1;
+
+const tActorID kNoActorID = kGameIDNothing;
+const tActorID kPlayerID = 0;
+const tItemID kNoItemID = kGameIDNothing;
+const tRoomID kNoRoomID = kGameIDNothing;
+const tExtraID kNoExtraID = 0xFFFFFFFF;
+const tNeighborhoodID kNoNeighborhoodID = kGameIDNothing;
+const tAlternateID kNoAlternateID = 0;
+const tGameMenuCommand kMenuCmdNoCommand = 0;
+
+const tHotSpotActivationID kActivateHotSpotAlways = 0;
+const tHotSpotActivationID kActivateHotSpotNever = -1;
+
+const tItemState kNoItemState = -1;
+
+const tDirectionConstant kNoDirection = 0xFF;
+
+const tTurnDirection kNoTurn = 0xFF;
+const tTurnDirection kTurnLeft = 0;
+const tTurnDirection kTurnRight = 1;
+const tTurnDirection kTurnUp = 2;
+const tTurnDirection kTurnDown = 3;
+const tTurnDirection kMaxTurns = 4;
+
+const tGameMode kNoMode = -1;
+const tGameMode kModeNavigation = 0;
+const tGameMode kLastGameShellMode = kModeNavigation;
+
+const tCanMoveForwardReason kCanMoveForward = 0;
+const tCanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
+const tCanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
+const tCanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
+const tCanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
+
+const tCanTurnReason kCanTurn = 0;
+const tCanTurnReason kCantTurnNoTurn = kCanTurn + 1;
+const tCanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
+
+const tCanOpenDoorReason kCanOpenDoor = 0;
+const tCanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
+const tCanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
+const tCanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
+const tCanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
new file mode 100755
index 0000000..1c3b0f3
--- /dev/null
+++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
@@ -0,0 +1,80 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES
+#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES
+
+#include "pegasus/MMShell/MMTypes.h"
+
+namespace Pegasus {
+
+typedef tMM16BitID tGameID;
+
+typedef tGameID tItemID;
+typedef tGameID tActorID;
+typedef tGameID tRoomID;
+typedef tGameID tNeighborhoodID;
+typedef tMM8BitU tAlternateID;
+typedef tMM8BitS tHotSpotActivationID;
+
+typedef tMM16BitS tWeightType;
+
+typedef tMM8BitU tDirectionConstant;
+typedef tMM8BitU tTurnDirection;
+
+// Meant to be room in low 16 bits and direction in high 16 bits.
+typedef tMM32BitU tRoomViewID;
+
+#define MakeRoomView(room, direction) (((tRoomViewID) (room)) | (((tRoomViewID) (direction)) << 16))
+
+typedef tMM32BitU tExtraID;
+
+typedef tMM16BitS tGameMode;
+
+typedef tMM16BitS tWeightType;
+
+typedef tMM16BitS tItemState;
+
+typedef tMM8BitS tDeathReason;
+
+typedef tMM32BitS tGameMenuCommand;
+
+typedef tMM32BitS tGameScoreType;
+
+typedef long tCanMoveForwardReason;
+
+typedef long tCanTurnReason;
+
+typedef long tCanOpenDoorReason;
+
+enum tInventoryResult {
+	kInventoryOK,
+	kTooMuchWeight,
+	kItemNotInInventory
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 5855750..923d96a 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -9,7 +9,8 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	sound.o \
-	video.o
+	video.o \
+	Game_Shell/CItem.o
 
 
 # This module can be built as a plugin


Commit: ea05bc5687456aab1318fb06f73f484a7e5310bc
    https://github.com/scummvm/scummvm/commit/ea05bc5687456aab1318fb06f73f484a7e5310bc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T09:56:49-07:00

Commit Message:
PEGASUS: Import the MMResourceFile class

Changed paths:
  A engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
  A engines/pegasus/MMShell/Utilities/MMResourceFile.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp b/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
new file mode 100755
index 0000000..dda9a58
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/endian.h"
+#include "common/error.h"
+#include "common/macresman.h"
+#include "common/stream.h"
+
+#include "pegasus/MMShell/Utilities/MMResourceFile.h"
+
+namespace Pegasus {
+
+MMResourceFile::MMResourceFile() {
+	_resFork = 0;
+}
+
+MMResourceFile::~MMResourceFile() {
+	if (IsFileOpen())
+		CloseResourceFile();
+}
+
+Common::Error MMResourceFile::UsePathname(const Common::String &str) {
+	if (IsFileOpen())
+		return Common::kUnknownError;
+
+	_fileName = str;
+	return Common::kNoError;
+}
+
+Common::Error MMResourceFile::OpenResourceFile() {
+	if (IsFileOpen() || _fileName.empty())
+		return Common::kUnknownError;
+
+	_resFork = new Common::MacResManager();
+
+	if (!_resFork->open(_fileName)) {
+		delete _resFork; _resFork = 0;
+		return Common::kReadingFailed;
+	}
+
+	return Common::kNoError;
+}
+
+Common::Error MMResourceFile::CloseResourceFile() {
+	if (!IsFileOpen())
+		return Common::kUnknownError;
+
+	delete _resFork;
+	_resFork = 0;
+	return Common::kNoError;
+}
+
+Common::Error MMResourceFile::GetResource(const uint32 type, const tResIDType id, Common::SeekableReadStream *&h) {
+	if (!IsFileOpen())
+		return Common::kUnknownError;
+
+	// Look how well our API fits in!
+	h = _resFork->getResource(type, id);
+	return Common::kNoError;
+}
+
+Common::Error MMResourceFile::GetResource(const uint32 type, const Common::String &name, Common::SeekableReadStream *&h) {
+	if (!IsFileOpen())
+		return Common::kUnknownError;
+
+	// Look how well our API fits in!
+	h = _resFork->getResource(type, name);
+	return Common::kNoError;
+}
+
+Common::Error MMResourceFile::GetCIcon(const tResIDType id, Common::SeekableReadStream *&icon) {
+	Common::Error err = GetResource(MKTAG('c', 'i', 'c', 'n'), id, icon);
+
+	if (err.getCode() != Common::kNoError)
+		return err;
+
+	return (icon == 0) ? Common::kUnknownError : Common::kNoError;
+}
+
+bool MMResourceFile::IsFileOpen() const {
+	return _resFork != 0;
+}
+
+} // End of namespace Pegasus
\ No newline at end of file
diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.h b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
new file mode 100755
index 0000000..6dc70f9
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
@@ -0,0 +1,75 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_UTILITIES_MMRESOURCEFILE
+#define PEGASUS_MMSHELL_UTILITIES_MMRESOURCEFILE
+
+#include "common/str.h"
+
+#include "pegasus/MMShell/MMTypes.h"
+
+namespace Common {
+	class Error;
+	class MacResManager;
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class MMResourceFile {
+public:
+	MMResourceFile();
+	virtual ~MMResourceFile();
+
+	Common::Error UsePathname(const Common::String &str);
+
+	// For ScummVM, we don't need this function
+	//OSErr MMResourceFile::UseFSSpec(const FSSpec&);
+	
+	virtual Common::Error OpenResourceFile();
+	virtual Common::Error CloseResourceFile();
+	bool IsFileOpen() const;
+	
+	virtual Common::Error GetResource(const uint32 type, const tResIDType id, Common::SeekableReadStream *&h);
+	virtual Common::Error GetResource(const uint32 type, const Common::String &name, Common::SeekableReadStream *&h);
+
+	// This function is unused!
+	//virtual OSErr PutResource(const ResType, const tResIDType, const Common::String &, Handle);
+
+	// For ScummVM, we will be hardcoding the file names so these two functions
+	// do nothing for us
+	//virtual OSErr GetIndString(const tResIDType, const short, Str255&);
+	//virtual OSErr GetIndString(const Str255, const short, Str255&);
+
+	virtual Common::Error GetCIcon(const tResIDType id, Common::SeekableReadStream *&icon);
+
+protected:
+	Common::MacResManager *_resFork;
+	Common::String _fileName;
+};
+
+} // End of namespace Pegasus
+
+#endif
\ No newline at end of file
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 923d96a..62a2fe9 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -10,7 +10,8 @@ MODULE_OBJS = \
 	pegasus.o \
 	sound.o \
 	video.o \
-	Game_Shell/CItem.o
+	Game_Shell/CItem.o \
+	MMShell/Utilities/MMResourceFile.o
 
 
 # This module can be built as a plugin


Commit: ae1a9323917b7d1d45929d675a14ffd314bf95da
    https://github.com/scummvm/scummvm/commit/ae1a9323917b7d1d45929d675a14ffd314bf95da
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T09:58:01-07:00

Commit Message:
PEGASUS: Import the MMSound class

Changed paths:
  A engines/pegasus/MMShell/Sounds/MMSound.cpp
  A engines/pegasus/MMShell/Sounds/MMSound.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Sounds/MMSound.cpp b/engines/pegasus/MMShell/Sounds/MMSound.cpp
new file mode 100755
index 0000000..f536463
--- /dev/null
+++ b/engines/pegasus/MMShell/Sounds/MMSound.cpp
@@ -0,0 +1,126 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "audio/audiostream.h"
+#include "audio/decoders/aiff.h"
+#include "common/file.h"
+#include "common/system.h"
+
+#include "engines/pegasus/MMShell/Sounds/MMSound.h"
+
+namespace Pegasus {
+
+MMSound::MMSound() {
+	_aiffStream = 0;
+	_volume = 0xFF;
+}
+
+MMSound::~MMSound() {
+	DisposeSound();
+}
+
+void MMSound::DisposeSound() {
+	StopSound();
+	delete _aiffStream; _aiffStream = 0;
+}
+
+void MMSound::InitFromAIFFFile(const Common::String &fileName) {
+	Common::File *file = new Common::File();
+	if (!file->open(fileName)) {
+		delete file;
+		return;
+	}
+
+	_aiffStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
+}
+
+#if 0
+// TODO!
+void MMSound::AttachFader(MMSoundFader *theFader) {
+	if (fTheFader)
+		fTheFader->AttachSound(NULL);
+
+	fTheFader = theFader;
+
+	if (fTheFader)
+		fTheFader->AttachSound(this);
+}
+#endif
+
+void MMSound::PlaySound() {
+	if (!SoundLoaded())
+		return;
+
+	StopSound();
+
+#if 0
+	// TODO!
+	if (fTheFader)
+		this->SetVolume(fTheFader->GetFaderValue());
+#endif
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _aiffStream, -1, _volume, 0, DisposeAfterUse::NO);
+}
+
+void MMSound::LoopSound() {
+	if (!SoundLoaded())
+		return;
+
+	StopSound();
+
+	// Create a looping stream
+	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_aiffStream, 0, DisposeAfterUse::NO);
+
+#if 0
+	// TODO!
+	// Assume that if there is a fader, we're going to fade the sound in.
+	if (fTheFader)
+		this->SetVolume(0);
+#endif
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
+}
+
+void MMSound::StopSound(void) {
+	g_system->getMixer()->stopHandle(_handle);
+}
+
+void MMSound::SetVolume(const uint16 volume) {
+	// Clipping the volume to [0x00, 0xFF] instead of Apple's [0, 0x100]
+	// We store the volume in case SetVolume is called before the sound starts
+
+	_volume = (volume == 0x100) ? 0xFF : volume;
+	g_system->getMixer()->setChannelVolume(_handle, _volume);
+}
+
+bool MMSound::IsPlaying() {
+	return SoundLoaded() && g_system->getMixer()->isSoundHandleActive(_handle);
+}
+
+bool MMSound::SoundLoaded() const {
+	return _aiffStream != 0;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Sounds/MMSound.h b/engines/pegasus/MMShell/Sounds/MMSound.h
new file mode 100755
index 0000000..8bcf410
--- /dev/null
+++ b/engines/pegasus/MMShell/Sounds/MMSound.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_SOUNDS_MMSOUND_H
+#define PEGASUS_MMSHELL_SOUNDS_MMSOUND_H
+
+#include "audio/mixer.h"
+#include "common/str.h"
+
+namespace Audio {
+	class AudioStream;
+	class RewindableAudioStream;
+}
+
+namespace Pegasus {
+
+// TODO!
+//class MMSoundFader;
+
+//	Things you might want to do with sound:
+//		Start it
+//		Stop it
+//		Loop it
+//		Pause it
+//		Set the volume
+//		Set the pitch (rate)
+//		Pan the sound
+//		Change these settings dynamically over time
+
+class MMSound {
+public:
+	MMSound();
+	~MMSound();
+
+	// We only have one access point here because we should
+	// only be opening an AIFF file from a file name. We're
+	// not using the resource fork string resources.
+	void InitFromAIFFFile(const Common::String &fileName);
+
+	void DisposeSound();
+	bool SoundLoaded() const;
+	void PlaySound();
+	void LoopSound();
+	void StopSound();
+	void SetVolume(const uint16 volume);
+	bool IsPlaying();
+
+	// TODO!
+	//void AttachFader(MMSoundFader*);
+
+protected:
+	Audio::RewindableAudioStream *_aiffStream;
+	Audio::SoundHandle _handle;
+	byte _volume;
+
+	// TODO!
+	//MMSoundFader *fTheFader;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 62a2fe9..1f5e6f5 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS = \
 	sound.o \
 	video.o \
 	Game_Shell/CItem.o \
+	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o
 
 


Commit: 9aa9e6afcb160d0aee233aeaeb80390a23a616a4
    https://github.com/scummvm/scummvm/commit/9aa9e6afcb160d0aee233aeaeb80390a23a616a4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T10:00:17-07:00

Commit Message:
PEGASUS: Switch sound playback to using the MMSound class

Changed paths:
  R engines/pegasus/sound.cpp
  R engines/pegasus/sound.h
    engines/pegasus/menu.cpp
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 33e8df3..577d96a 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -26,6 +26,8 @@
 #include "pegasus/console.h"
 #include "pegasus/pegasus.h"
 
+#include "pegasus/MMShell/Sounds/MMSound.h"
+
 namespace Pegasus {
 
 enum {
@@ -44,7 +46,9 @@ enum {
 };	
 
 void PegasusEngine::runMainMenu() {
-	_sound->playSound("Sounds/Main Menu.aiff", true);
+	MMSound sound;
+	sound.InitFromAIFFFile("Sounds/Main Menu.aiff");
+	sound.LoopSound();
 
 	// Note down how long since the last click
 	uint32 lastClickTime = _system->getMillis();
@@ -82,14 +86,14 @@ void PegasusEngine::runMainMenu() {
 				case Common::KEYCODE_RETURN:
 					if (buttonSelected != kDifficultyButton) {
 						drawMenuButtonSelected(buttonSelected);
+						sound.StopSound();
 						setGameMode(buttonSelected);
 
-						if (_gameMode != kMainMenuMode) {
-							_sound->stopSound();
+						if (_gameMode != kMainMenuMode)
 							return;
-						}
-
+						
 						drawMenu(buttonSelected);
+						sound.LoopSound();
 					}
 					break;
 				case Common::KEYCODE_d:
@@ -118,7 +122,7 @@ void PegasusEngine::runMainMenu() {
 		return;
 
 	// Too slow! Go back and show the intro again.
-	_sound->stopSound();
+	sound.StopSound();
 	_video->playMovie(_introDirectory + "/LilMovie.movie");
 	_gameMode = kIntroMode;
 }
@@ -173,9 +177,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 			_gameMode = kMainGameMode;
 			break;
 		case kDemoCreditsButton:
-			_sound->stopSound();
 			runDemoCredits();
-			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kDemoQuitButton:
 			_gameMode = kQuitMode;
@@ -184,9 +186,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 	} else {
 		switch (buttonSelected) {
 		case kInterfaceOverviewButton:
-			_sound->stopSound();
 			runInterfaceOverview();
-			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kStartButton:
 			_gameMode = kMainGameMode;
@@ -195,9 +195,7 @@ void PegasusEngine::setGameMode(int buttonSelected) {
 			showLoadDialog();
 			break;
 		case kCreditsButton:
-			_sound->stopSound();
 			runCredits();
-			_sound->playSound("Sounds/Main Menu.aiff", true);
 			break;
 		case kQuitButton:
 			_gameMode = kQuitMode;
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 1f5e6f5..cb1f237 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -8,7 +8,6 @@ MODULE_OBJS = \
 	menu.o \
 	overview.o \
 	pegasus.o \
-	sound.o \
 	video.o \
 	Game_Shell/CItem.o \
 	MMShell/Sounds/MMSound.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index cf79900..4e68007 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -37,6 +37,10 @@
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
 
+#ifdef RUN_INTERFACE_TEST
+#include "pegasus/MMShell/Sounds/MMSound.h"
+#endif
+
 namespace Pegasus {
 
 PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
@@ -44,7 +48,6 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 
 PegasusEngine::~PegasusEngine() {
 	delete _video;
-	delete _sound;
 	delete _gfx;
 	delete _resFork;
 	delete _inventoryLid;
@@ -56,7 +59,6 @@ Common::Error PegasusEngine::run() {
 	_console = new PegasusConsole(this);
 	_gfx = new GraphicsManager(this);
 	_video = new VideoManager(this);
-	_sound = new SoundManager(this);
 	_resFork = new Common::MacResManager();
 	_inventoryLid = new Common::MacResManager();
 	_biochipLid = new Common::MacResManager();
@@ -112,7 +114,9 @@ Common::Error PegasusEngine::run() {
 #elif defined(RUN_INTERFACE_TEST)
 	drawInterface();
 	_gfx->setCursor(kMainCursor);
-	_sound->playSound("Sounds/Caldoria/Apartment Music.aiff", true);
+	MMSound sound;
+	sound.InitFromAIFFFile("Sounds/Caldoria/Apartment Music.aiff");
+	sound.LoopSound();
 
 	while (!shouldQuit()) {
 		Common::Event event;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index ee5dc76..9f54633 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -31,7 +31,6 @@
 
 #include "engines/engine.h"
 
-#include "pegasus/sound.h"
 #include "pegasus/graphics.h"
 #include "pegasus/video.h"
 
@@ -204,7 +203,6 @@ public:
 	GUI::Debugger *getDebugger();
 	
 	VideoManager *_video;
-	SoundManager *_sound;
 	GraphicsManager *_gfx;
 	Common::MacResManager *_resFork, *_inventoryLid, *_biochipLid;
 
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
deleted file mode 100644
index b87bff4..0000000
--- a/engines/pegasus/sound.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/sound.h"
-
-#include "common/file.h"
-#include "common/textconsole.h"
-#include "audio/decoders/aiff.h"
-
-namespace Pegasus {
-
-SoundManager::SoundManager(PegasusEngine *vm) : _vm(vm) {
-}
-        
-void SoundManager::playSound(Common::String filename, bool loop) {
-	SndHandle *handle = getHandle();
-	handle->type = kUsedHandle;
-
-	Common::File *file = new Common::File();
-	if (!file->open(filename.c_str()))
-		error("Could not open file \'%s\'", filename.c_str());
-
-	Audio::AudioStream* audStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
-
-	if (loop)
-		audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream*)audStream, 0);
-	
-	if (audStream)
-		_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle->handle, audStream);
-}
-
-SndHandle *SoundManager::getHandle() {
-	for (int i = 0; i < SOUND_HANDLES; i++) {
-		if (_handles[i].type == kFreeHandle)
-			return &_handles[i];
-
-		if (!_vm->_mixer->isSoundHandleActive(_handles[i].handle)) {
-			_handles[i].type = kFreeHandle;
-			return &_handles[i];
-		}
-	}
-
-	error("SoundManager::getHandle(): Too many sound handles");
-	return NULL;
-}
-
-bool SoundManager::isPlaying() {
-	for (int i = 0; i < SOUND_HANDLES; i++)
-		if (_handles[i].type == kUsedHandle)
-			if (_vm->_mixer->isSoundHandleActive(_handles[i].handle))
-				return true;
-	return false;
-}
-
-void SoundManager::stopSound() {
-	_vm->_mixer->stopAll();
-}
-
-void SoundManager::pauseSound() {
-	_vm->_mixer->pauseAll(true);
-}
-
-void SoundManager::resumeSound() {
-	_vm->_mixer->pauseAll(false);
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
deleted file mode 100644
index ebe6f79..0000000
--- a/engines/pegasus/sound.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_SOUND_H
-#define PEGASUS_SOUND_H
-
-#include "common/scummsys.h"
-#include "common/str.h"
-
-#include "audio/audiostream.h"
-#include "audio/mixer.h"
-
-#include "pegasus/pegasus.h"
-
-namespace Pegasus {
-
-#define SOUND_HANDLES 10
-
-enum sndHandleType {
-	kFreeHandle,
-	kUsedHandle
-};
-
-struct SndHandle {
-	Audio::SoundHandle handle;
-	sndHandleType type;
-};
-
-class PegasusEngine;
-
-class SoundManager {
-public:
-	SoundManager(PegasusEngine *vm);
-
-	void playSound(Common::String filename, bool loop = false);
-	void stopSound();
-	void pauseSound();
-	void resumeSound();
-	bool isPlaying();
-	
-private:
-	PegasusEngine *_vm;
-
-	SndHandle _handles[SOUND_HANDLES];
-	SndHandle *getHandle();
-};
-
-} // End of namespace Pegasus
-
-#endif


Commit: 8d4e60d432c621d88a03c73607739b7e79823f15
    https://github.com/scummvm/scummvm/commit/8d4e60d432c621d88a03c73607739b7e79823f15
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T11:01:51-07:00

Commit Message:
PEGASUS: Import MMUtilities functions

Changed paths:
  A engines/pegasus/MMShell/Utilities/MMUtilities.cpp
  A engines/pegasus/MMShell/Utilities/MMUtilities.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp b/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
new file mode 100755
index 0000000..a64b7db
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/random.h"
+#include "common/util.h"
+
+#include "pegasus/MMShell/Utilities/MMUtilities.h"
+
+namespace Pegasus {
+
+inline int32 Round(const int32 a, const int32 b) {
+	if (b < 0)
+		if (a < 0)
+			return -((a - (-b >> 1)) / -b);
+		else
+			return -((a + (-b >> 1)) / -b);
+	else
+		if (a < 0)
+			return (a - (b >> 1)) / b;
+		else
+			return (a + (b >> 1)) / b;
+}
+
+int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2) {
+	if (start2 == stop2)
+		return start2;
+	else
+		return start2 + Round((current1 - start1) * (stop2 - start2), (stop1 - start1));
+}
+
+void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random) {	
+	if (count > 1) {
+		for (int32 i = 1; i < count; ++i) {
+			int32 j = random.getRandomNumber(i);
+			if (j != i)
+				SWAP(arr[i], arr[j]);
+		}
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.h b/engines/pegasus/MMShell/Utilities/MMUtilities.h
new file mode 100755
index 0000000..4c504b1
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMUtilities.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H
+#define PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H
+
+#include "common/scummsys.h"
+
+namespace Common {
+	class RandomSource;
+}
+
+namespace Pegasus {
+
+int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2);
+
+void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random);
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index cb1f237..050285f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -11,7 +11,8 @@ MODULE_OBJS = \
 	video.o \
 	Game_Shell/CItem.o \
 	MMShell/Sounds/MMSound.o \
-	MMShell/Utilities/MMResourceFile.o
+	MMShell/Utilities/MMResourceFile.o \
+	MMShell/Utilities/MMUtilities.o
 
 
 # This module can be built as a plugin


Commit: 2211a4d713fffa88a822182db2bdb64ad41d0981
    https://github.com/scummvm/scummvm/commit/2211a4d713fffa88a822182db2bdb64ad41d0981
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T11:06:55-07:00

Commit Message:
PEGASUS: Import MMFunctionPtr class

Changed paths:
  A engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
  A engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
new file mode 100755
index 0000000..c0e616c
--- /dev/null
+++ b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/MMShell/Base_Classes/MMFunctionPtr.h"
+
+namespace Pegasus {
+
+MMFunctionPtr::MMFunctionPtr() {
+	fTheFunction = 0;
+	fFunctionArg = 0;
+}
+
+MMFunctionPtr::~MMFunctionPtr() {
+}
+
+void MMFunctionPtr::SetFunctionPtr(tFunctionPtr theFunction, void *functionArg) {
+	fTheFunction = theFunction;
+	fFunctionArg = functionArg;
+}
+
+void MMFunctionPtr::CallFunction() {
+	if (fTheFunction != 0)
+		(*fTheFunction)(this, fFunctionArg);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
new file mode 100755
index 0000000..e9c2126
--- /dev/null
+++ b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H
+#define PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H
+
+namespace Pegasus {
+
+class MMFunctionPtr;
+
+typedef void (*tFunctionPtr)(MMFunctionPtr *theFunction, void *functionArg);
+
+class MMFunctionPtr {
+public:
+	MMFunctionPtr();
+	virtual ~MMFunctionPtr();
+	
+	void SetFunctionPtr(tFunctionPtr theFunction, void *functionArg);
+
+protected:
+	void CallFunction();
+	
+	tFunctionPtr fTheFunction;
+	void *fFunctionArg;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 050285f..2c07c38 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS = \
 	pegasus.o \
 	video.o \
 	Game_Shell/CItem.o \
+	MMShell/Base_Classes/MMFunctionPtr.o \
 	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMUtilities.o


Commit: e2e224176d0dd727eb05ab7eb02236b1d18aa0a7
    https://github.com/scummvm/scummvm/commit/e2e224176d0dd727eb05ab7eb02236b1d18aa0a7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T21:54:47-07:00

Commit Message:
PEGASUS: Import the CItemList class

Changed paths:
  A engines/pegasus/Game_Shell/CItemList.cpp
  A engines/pegasus/Game_Shell/CItemList.h
    engines/pegasus/Game_Shell/CItem.cpp
    engines/pegasus/module.mk



diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp
index 0816e59..90a7a04 100755
--- a/engines/pegasus/Game_Shell/CItem.cpp
+++ b/engines/pegasus/Game_Shell/CItem.cpp
@@ -27,6 +27,7 @@
 #include "common/stream.h"
 
 #include "pegasus/Game_Shell/CItem.h"
+#include "pegasus/Game_Shell/CItemList.h"
 #include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
 
 namespace Pegasus {
@@ -39,8 +40,7 @@ CItem::CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID
 	fItemOwnerID = kNoActorID;
 	fItemState = 0;
 
-	// TODO: This line would append this item to the list of all items
-	//gAllItems.Append(this);
+	gAllItems.push_back(this);
 }
 
 CItem::~CItem() {
diff --git a/engines/pegasus/Game_Shell/CItemList.cpp b/engines/pegasus/Game_Shell/CItemList.cpp
new file mode 100755
index 0000000..eb7cf9a
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CItemList.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "engines/pegasus/Game_Shell/CItem.h"
+#include "engines/pegasus/Game_Shell/CItemList.h"
+
+namespace Pegasus {
+
+// TODO: Don't use global construction!
+CItemList gAllItems;
+
+CItemList::CItemList() {
+}
+
+CItemList::~CItemList() {
+}
+
+Common::Error CItemList::WriteToStream(Common::WriteStream *stream) {
+	stream->writeUint32BE(size());
+
+	for (CItemIterator it = begin(); it != end(); it++) {
+		stream->writeUint16BE((*it)->GetObjectID());
+		(*it)->WriteToStream(stream);
+	}
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error CItemList::ReadFromStream(Common::ReadStream *stream) {
+	uint32 itemCount = stream->readUint32BE();
+
+	for (uint32 i = 0; i < itemCount; i++) {
+		tItemID itemID = stream->readUint16BE();
+		gAllItems.FindItemByID(itemID)->ReadFromStream(stream);
+	}
+
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+CItem *CItemList::FindItemByID(const tItemID id) {
+	for (CItemIterator it = begin(); it != end(); it++)
+		if ((*it)->GetObjectID() == id)
+			return *it;
+
+	return 0;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CItemList.h b/engines/pegasus/Game_Shell/CItemList.h
new file mode 100755
index 0000000..e2caa09
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CItemList.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_GAMESHELL_CITEMLIST_H
+#define PEGASUS_GAMESHELL_CITEMLIST_H
+
+#include "common/list.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class CItem;
+
+class CItemList : public Common::List<CItem *> {
+public:
+	CItemList();
+	virtual ~CItemList();
+	
+	virtual Common::Error WriteToStream(Common::WriteStream *stream);
+	virtual Common::Error ReadFromStream(Common::ReadStream *stream);
+	
+	CItem *FindItemByID(const tItemID id);
+};
+
+typedef CItemList::iterator CItemIterator;
+
+// TODO: Don't use global construction!
+extern CItemList gAllItems;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2c07c38..ff49b1f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS = \
 	pegasus.o \
 	video.o \
 	Game_Shell/CItem.o \
+	Game_Shell/CItemList.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
 	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \


Commit: 9f3c68983966597aa7f946d5d2e485c7379152fd
    https://github.com/scummvm/scummvm/commit/9f3c68983966597aa7f946d5d2e485c7379152fd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-15T22:21:25-07:00

Commit Message:
PEGASUS: Import the CInventory class

Changed paths:
  A engines/pegasus/Game_Shell/CInventory.cpp
  A engines/pegasus/Game_Shell/CInventory.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/Game_Shell/CInventory.cpp b/engines/pegasus/Game_Shell/CInventory.cpp
new file mode 100755
index 0000000..96ff3b5
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CInventory.cpp
@@ -0,0 +1,175 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/Game_Shell/CItem.h"
+#include "pegasus/Game_Shell/CInventory.h"
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Pegasus {
+
+CInventory::CInventory() {
+	fWeightLimit = 100;
+	fOwnerID = kNoActorID;
+	fReferenceCount = 0;
+}
+
+CInventory::~CInventory() {
+}
+
+void CInventory::SetWeightLimit(tWeightType limit) {
+	fWeightLimit = limit;
+	//	*** What to do if the new weight limit is greater than the current weight?
+}
+
+tWeightType CInventory::GetWeight() {
+	tWeightType	result = 0;
+
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++)
+		result += (*it)->GetItemWeight();
+
+	return result;
+}
+
+//	If the item already belongs, just return kInventoryOK.
+tInventoryResult CInventory::AddItem(CItem *item) {
+	if (ItemInInventory(item))
+		return kInventoryOK;
+
+	if (GetWeight() + item->GetItemWeight() > fWeightLimit)
+		return kTooMuchWeight;
+
+	fInventoryList.push_back(item);
+	item->SetItemOwner(fOwnerID);
+
+	++fReferenceCount;
+	return kInventoryOK;
+}
+
+tInventoryResult CInventory::RemoveItem(CItem *item) {
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++) {
+		if (*it == item) {
+			fInventoryList.erase(it);
+			item->SetItemOwner(kNoActorID);
+
+			++fReferenceCount;
+			return kInventoryOK;
+		}
+	}
+
+	return kItemNotInInventory;
+}
+
+tInventoryResult CInventory::RemoveItem(tItemID id) {
+	CItem *item = FindItemByID(id);
+	
+	if (item) {
+		fInventoryList.remove(item);
+		item->SetItemOwner(kNoActorID);
+
+		++fReferenceCount;
+		return kInventoryOK;
+	}
+
+	return kItemNotInInventory;
+}
+
+void CInventory::RemoveAllItems() {
+	fInventoryList.clear();
+	++fReferenceCount;
+}
+
+bool CInventory::ItemInInventory(CItem *item) {
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++)
+		if (*it == item)
+			return true;
+
+	return false;
+}
+
+bool CInventory::ItemInInventory(tItemID id) {
+	return FindItemByID(id) != NULL;
+}
+
+CItem *CInventory::GetItemAt(int32 index) {
+	int32 i = 0;
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
+		if (i == index)
+			return *it;
+
+	return 0;
+}
+
+tItemID CInventory::GetItemIDAt(int32 index) {
+	CItem *item = GetItemAt(index);
+
+	if (item)
+		return item->GetObjectID();
+
+	return kNoItemID;
+}
+
+CItem *CInventory::FindItemByID(tItemID id) {
+	return fInventoryList.FindItemByID(id);
+}
+
+//	Return -1 if not found.
+
+int32 CInventory::FindIndexOf(CItem *item) {
+	uint32 i = 0;
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
+		if (*it == item)
+			return i;
+
+	return -1;
+}
+
+//	Return -1 if not found.
+
+int32 CInventory::FindIndexOf(tItemID id) {
+	uint32 i = 0;
+	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
+		if ((*it)->GetObjectID() == id)
+			return i;
+
+	return -1;
+}
+
+tWeightType CInventory::GetWeightLimit() {
+	return fWeightLimit;
+}
+
+int32 CInventory::GetNumItems() {
+	return fInventoryList.size();
+}
+
+void CInventory::SetOwnerID(const tActorID id) {
+	fOwnerID = id;
+}
+
+tActorID CInventory::GetOwnerID() const {
+	return fOwnerID;
+}
+
+} // End of namespae Pegasus
diff --git a/engines/pegasus/Game_Shell/CInventory.h b/engines/pegasus/Game_Shell/CInventory.h
new file mode 100755
index 0000000..4a18610
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CInventory.h
@@ -0,0 +1,80 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_GAMESHELL_CINVENTORY_H
+#define PEGASUS_GAMESHELL_CINVENTORY_H
+
+#include "pegasus/Game_Shell/CItemList.h"
+#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+
+namespace Pegasus {
+
+class CItem;
+
+//	Inventories have a "current item". This item is the default item the player can
+//	use. In a text adventure system, the current item would be "it", as in
+//	"Hit the troll with it," where "it" would refer to some weapon which is the current
+//	item. In a graphic adventure, the current item would be the item the user selects
+//	to use with the mouse or other pointing device.
+
+class CInventory {
+public:
+	CInventory();
+	virtual ~CInventory();
+	
+	tWeightType GetWeightLimit();
+	void SetWeightLimit(tWeightType limit);
+	tWeightType GetWeight();
+	
+	virtual tInventoryResult AddItem(CItem *item);
+	virtual tInventoryResult RemoveItem(CItem *item);
+	virtual tInventoryResult RemoveItem(tItemID id);
+	virtual bool ItemInInventory(CItem *item);
+	virtual bool ItemInInventory(tItemID id);
+	virtual CItem *GetItemAt(int32 index);
+	virtual tItemID GetItemIDAt(int32 index);
+	virtual CItem *FindItemByID(tItemID id);
+	virtual int32 FindIndexOf(CItem *item);
+	virtual int32 FindIndexOf(tItemID id);
+	int32 GetNumItems();
+	virtual void RemoveAllItems();
+	
+	void SetOwnerID(const tActorID id);
+	tActorID GetOwnerID() const;
+	
+	uint32 GetReferenceCount() { return fReferenceCount; }
+
+protected:
+	tWeightType fWeightLimit;
+	tActorID fOwnerID;
+	CItemList fInventoryList;
+
+private:
+	uint32 fReferenceCount;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index ff49b1f..420b21d 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	video.o \
+	Game_Shell/CInventory.o \
 	Game_Shell/CItem.o \
 	Game_Shell/CItemList.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \


Commit: 752e7561357073ecdbe218f53ba5ba8047cd1afb
    https://github.com/scummvm/scummvm/commit/752e7561357073ecdbe218f53ba5ba8047cd1afb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T08:31:25-07:00

Commit Message:
PEGASUS: Import the MMAction class

Changed paths:
  A engines/pegasus/MMShell/Base_Classes/MMAction.h



diff --git a/engines/pegasus/MMShell/Base_Classes/MMAction.h b/engines/pegasus/MMShell/Base_Classes/MMAction.h
new file mode 100755
index 0000000..78c0bb8
--- /dev/null
+++ b/engines/pegasus/MMShell/Base_Classes/MMAction.h
@@ -0,0 +1,40 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_BASECLASSES_MMACTION_H
+#define PEGASUS_MMSHELL_BASECLASSES_MMACTION_H
+
+namespace Pegasus {
+
+class MMAction {
+public:
+	virtual	~MMAction() {}
+	
+	virtual void InvokeAction() {}
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 0fc10033b5dbbeeac34cf9a256e356091dd5231a
    https://github.com/scummvm/scummvm/commit/0fc10033b5dbbeeac34cf9a256e356091dd5231a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T08:57:10-07:00

Commit Message:
PEGASUS: Import the CGameState class

Changed paths:
  A engines/pegasus/Game_Shell/CGameState.cpp
  A engines/pegasus/Game_Shell/CGameState.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/Game_Shell/CGameState.cpp b/engines/pegasus/Game_Shell/CGameState.cpp
new file mode 100755
index 0000000..16c6009
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CGameState.cpp
@@ -0,0 +1,252 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "pegasus/Game_Shell/CGameState.h"
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Pegasus {
+
+tNeighborhoodID CGameState::gCurrentNeighborhood = kNoNeighborhoodID;
+tRoomID CGameState::gCurrentRoom = kNoRoomID;
+tDirectionConstant CGameState::gCurrentDirection = kNoDirection;
+tNeighborhoodID CGameState::gNextNeighborhoodID = kNoNeighborhoodID;
+tRoomID CGameState::gNextRoomID = kNoRoomID;
+tDirectionConstant CGameState::gNextDirection = kNoDirection;
+tNeighborhoodID CGameState::gLastNeighborhood = kNoNeighborhoodID;
+tRoomID CGameState::gLastRoom = kNoRoomID;
+tDirectionConstant CGameState::gLastDirection = kNoDirection;
+tRoomID CGameState::gOpenDoorRoom = kNoRoomID;
+tDirectionConstant CGameState::gOpenDoorDirection = kNoDirection;
+
+Common::Error CGameState::WriteGameState(Common::WriteStream *stream) {
+	stream->writeUint16BE(gCurrentNeighborhood);
+	stream->writeUint16BE(gCurrentRoom);
+	stream->writeByte(gCurrentDirection);
+	stream->writeUint16BE(gNextNeighborhoodID);
+	stream->writeUint16BE(gNextRoomID);
+	stream->writeByte(gNextDirection);
+	stream->writeUint16BE(gLastNeighborhood);
+	stream->writeUint16BE(gLastRoom);
+	stream->writeUint16BE(gOpenDoorRoom);
+	stream->writeByte(gOpenDoorDirection);
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error CGameState::ReadGameState(Common::ReadStream *stream) {
+	gCurrentNeighborhood = stream->readUint16BE();
+	gCurrentRoom = stream->readUint16BE();
+	gCurrentDirection = stream->readByte();
+	gNextNeighborhoodID = stream->readUint16BE();
+	gNextRoomID = stream->readUint16BE();
+	gNextDirection = stream->readByte();
+	gLastNeighborhood = stream->readUint16BE();
+	gLastRoom = stream->readUint16BE();
+	gOpenDoorRoom = stream->readUint16BE();
+	gOpenDoorDirection = stream->readByte();
+
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+void CGameState::ResetGameState() {
+	gCurrentNeighborhood = kNoNeighborhoodID;
+	gCurrentRoom = kNoRoomID;
+	gCurrentDirection = kNoDirection;
+	gNextNeighborhoodID = kNoNeighborhoodID;
+	gNextRoomID = kNoRoomID;
+	gNextDirection = kNoDirection;
+	gLastNeighborhood = kNoNeighborhoodID;
+	gLastRoom = kNoRoomID;
+	gLastDirection = kNoDirection;
+	gOpenDoorRoom = kNoRoomID;
+	gOpenDoorDirection = kNoDirection;
+}
+
+void CGameState::GetCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = gCurrentNeighborhood;
+	room = gCurrentRoom;
+	direction = gCurrentDirection;
+}
+
+void CGameState::SetCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	gLastNeighborhood = gCurrentNeighborhood;
+	gLastRoom = gCurrentRoom;
+	gLastDirection = gCurrentDirection;
+	gCurrentNeighborhood = neighborhood;
+	gCurrentRoom = room;
+	gCurrentDirection = direction;
+}
+
+tNeighborhoodID CGameState::GetCurrentNeighborhood() {
+	return gCurrentNeighborhood;
+}
+
+void CGameState::SetCurrentNeighborhood(const tNeighborhoodID neighborhood) {
+	gLastNeighborhood = gCurrentNeighborhood;
+	gCurrentNeighborhood = neighborhood;
+}
+
+tRoomID CGameState::GetCurrentRoom() {
+	return gCurrentRoom;
+}
+
+void CGameState::SetCurrentRoom(const tRoomID room) {
+	gLastRoom = gCurrentRoom;
+	gCurrentRoom = room;
+}
+
+tDirectionConstant CGameState::GetCurrentDirection() {
+	return gCurrentDirection;
+}
+
+void CGameState::SetCurrentDirection(const tDirectionConstant direction) {
+	gLastDirection = gCurrentDirection;
+	gCurrentDirection = direction;
+}
+
+tRoomViewID CGameState::GetCurrentRoomAndView() {
+	return MakeRoomView(gCurrentRoom, gCurrentDirection);
+}
+
+void CGameState::GetNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = gNextNeighborhoodID;
+	room = gNextRoomID;
+	direction = gNextDirection;
+}
+
+void CGameState::SetNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	gNextNeighborhoodID = neighborhood;
+	gNextRoomID = room;
+	gNextDirection = direction;
+}
+
+tNeighborhoodID CGameState::GetNextNeighborhood() {
+	return gNextNeighborhoodID;
+}
+
+void CGameState::SetNextNeighborhood(const tNeighborhoodID neighborhood) {
+	gNextNeighborhoodID = neighborhood;
+}
+
+tRoomID CGameState::GetNextRoom() {
+	return gNextRoomID;
+}
+
+void CGameState::SetNextRoom(const tRoomID room) {
+	gNextRoomID = room;
+}
+
+tDirectionConstant CGameState::GetNextDirection() {
+	return gNextDirection;
+}
+
+void CGameState::SetNextDirection(const tDirectionConstant direction) {
+	gNextDirection = direction;
+}
+
+void CGameState::GetLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = gCurrentNeighborhood;
+	room = gCurrentRoom;
+	direction = gCurrentDirection;
+}
+
+void CGameState::SetLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	gCurrentNeighborhood = neighborhood;
+	gCurrentRoom = room;
+	gCurrentDirection = direction;
+}
+
+tNeighborhoodID CGameState::GetLastNeighborhood() {
+	return gLastNeighborhood;
+}
+
+void CGameState::SetLastNeighborhood(const tNeighborhoodID neighborhood) {
+	gLastNeighborhood = neighborhood;
+}
+
+tRoomID CGameState::GetLastRoom() {
+	return gLastRoom;
+}
+
+void CGameState::SetLastRoom(const tRoomID room) {
+	gLastRoom = room;
+}
+
+tDirectionConstant CGameState::GetLastDirection() {
+	return gLastDirection;
+}
+
+void CGameState::SetLastDirection(const tDirectionConstant direction) {
+	gLastDirection = direction;
+}
+
+tRoomViewID CGameState::GetLastRoomAndView() {
+	return MakeRoomView(gLastRoom, gLastDirection);
+}
+
+void CGameState::GetOpenDoorLocation(tRoomID &room, tDirectionConstant &direction) {
+	room = gOpenDoorRoom;
+	direction = gOpenDoorDirection;
+}
+
+void CGameState::SetOpenDoorLocation(const tRoomID room, const tDirectionConstant direction) {
+	gOpenDoorRoom = room;
+	gOpenDoorDirection = direction;
+}
+
+tRoomID CGameState::GetOpenDoorRoom() {
+	return gOpenDoorRoom;
+}
+
+void CGameState::SetOpenDoorRoom(const tRoomID room) {
+	gOpenDoorRoom = room;
+}
+
+tDirectionConstant CGameState::GetOpenDoorDirection() {
+	return gOpenDoorDirection;
+}
+
+void CGameState::SetOpenDoorDirection(const tDirectionConstant direction) {
+	gOpenDoorDirection = direction;
+}
+
+tRoomViewID CGameState::GetDoorOpenRoomAndView() {
+	return MakeRoomView(gOpenDoorRoom, gOpenDoorDirection);
+}
+
+bool CGameState::IsCurrentDoorOpen() {
+	return gOpenDoorRoom == gCurrentRoom && gOpenDoorDirection == gCurrentDirection;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CGameState.h b/engines/pegasus/Game_Shell/CGameState.h
new file mode 100755
index 0000000..74ec603
--- /dev/null
+++ b/engines/pegasus/Game_Shell/CGameState.h
@@ -0,0 +1,107 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_GAMESHELL_CGAMESTATE_H
+#define PEGASUS_GAMESHELL_CGAMESTATE_H
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+
+namespace Common {
+	class Error;
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class CGameState {
+public:
+	static Common::Error WriteGameState(Common::WriteStream *stream);
+	static Common::Error ReadGameState(Common::ReadStream *stream);
+	
+	static void ResetGameState();
+	
+	static void GetCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	static void SetCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	
+	static tNeighborhoodID GetCurrentNeighborhood();
+	static void SetCurrentNeighborhood(const tNeighborhoodID neighborhood);
+	static tRoomID GetCurrentRoom();
+	static void SetCurrentRoom(const tRoomID room);
+	static tDirectionConstant GetCurrentDirection();
+	static void SetCurrentDirection(const tDirectionConstant direction);
+	
+	static tRoomViewID GetCurrentRoomAndView();
+	
+	static void GetNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	static void	SetNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	
+	static tNeighborhoodID GetNextNeighborhood();
+	static void SetNextNeighborhood(const tNeighborhoodID neighborhood);
+	static tRoomID GetNextRoom();
+	static void SetNextRoom(const tRoomID room);
+	static tDirectionConstant GetNextDirection();
+	static void SetNextDirection(const tDirectionConstant direction);
+	
+	static void GetLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	static void SetLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	
+	static tNeighborhoodID GetLastNeighborhood();
+	static void SetLastNeighborhood(const tNeighborhoodID neighborhood);
+	static tRoomID GetLastRoom();
+	static void SetLastRoom(const tRoomID room);
+	static tDirectionConstant GetLastDirection();
+	static void SetLastDirection(const tDirectionConstant direction);
+	
+	static tRoomViewID GetLastRoomAndView();
+	
+	static void GetOpenDoorLocation(tRoomID &room, tDirectionConstant &direction);
+	static void SetOpenDoorLocation(const tRoomID room, const tDirectionConstant direction);
+	static tRoomID GetOpenDoorRoom();
+	static void SetOpenDoorRoom(const tRoomID room);
+	static tDirectionConstant GetOpenDoorDirection();
+	static void SetOpenDoorDirection(const tDirectionConstant direction);
+	
+	static tRoomViewID GetDoorOpenRoomAndView();
+	
+	static bool IsCurrentDoorOpen();
+
+protected:
+	static tNeighborhoodID gCurrentNeighborhood;
+	static tRoomID gCurrentRoom;
+	static tDirectionConstant gCurrentDirection;
+	static tNeighborhoodID gNextNeighborhoodID;
+	static tRoomID gNextRoomID;
+	static tDirectionConstant gNextDirection;
+	static tNeighborhoodID gLastNeighborhood;
+	static tRoomID gLastRoom;
+	static tDirectionConstant gLastDirection;
+	static tRoomID gOpenDoorRoom;
+	static tDirectionConstant gOpenDoorDirection;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 420b21d..1fdd471 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -9,6 +9,7 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	video.o \
+	Game_Shell/CGameState.o \
 	Game_Shell/CInventory.o \
 	Game_Shell/CItem.o \
 	Game_Shell/CItemList.o \


Commit: fd8eaba47a3a3bdbac56f2d21d100b3b953ed2f5
    https://github.com/scummvm/scummvm/commit/fd8eaba47a3a3bdbac56f2d21d100b3b953ed2f5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T11:10:59-07:00

Commit Message:
PEGASUS: Fix typo in MMConstants.h

Changed paths:
    engines/pegasus/MMShell/MMConstants.h



diff --git a/engines/pegasus/MMShell/MMConstants.h b/engines/pegasus/MMShell/MMConstants.h
index e96eb15..21852a9 100755
--- a/engines/pegasus/MMShell/MMConstants.h
+++ b/engines/pegasus/MMShell/MMConstants.h
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef PEGASUS_MMSHELL_MMTYPES_H
-#define PEGASUS_MMSHELL_MMTYPES_H
+#ifndef PEGASUS_MMSHELL_MMCONSTANTS_H
+#define PEGASUS_MMSHELL_MMCONSTANTS_H
 
 #include "pegasus/MMShell/MMTypes.h"
 


Commit: e789ab0d3b21c1c0cf76700b40f2e3c440a825a0
    https://github.com/scummvm/scummvm/commit/e789ab0d3b21c1c0cf76700b40f2e3c440a825a0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T11:12:18-07:00

Commit Message:
PEGASUS: Import the MMNotification classes

Changed paths:
  A engines/pegasus/MMShell/Notification/MMNotification.cpp
  A engines/pegasus/MMShell/Notification/MMNotification.h
  A engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
  A engines/pegasus/MMShell/Notification/MMNotificationManager.h
  A engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
  A engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Notification/MMNotification.cpp b/engines/pegasus/MMShell/Notification/MMNotification.cpp
new file mode 100755
index 0000000..5bc0820
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotification.cpp
@@ -0,0 +1,99 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/MMShell/Notification/MMNotification.h"
+#include "pegasus/MMShell/Notification/MMNotificationManager.h"
+#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
+
+namespace Pegasus {
+
+typedef tReceiverList::iterator tReceiverIterator;
+
+MMNotification::MMNotification(const tNotificationID id, MMNotificationManager *owner) : MMIDObject(id) {
+	fOwner = owner;
+	fCurrentFlags = kNoNotificationFlags;
+	if (fOwner)
+		fOwner->AddNotification(this);
+}
+
+MMNotification::~MMNotification() {
+	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
+		it->fReceiver->NewNotification(NULL);
+
+	if (fOwner)
+		fOwner->RemoveNotification(this);
+}
+
+//	Selectively set or clear notificiation bits.
+//	Wherever mask is 0, leave existing bits untouched.
+//	Wherever mask is 1, set bit equivalent to flags.
+void MMNotification::NotifyMe(MMNotificationReceiver* receiver, tNotificationFlags flags, tNotificationFlags mask) {
+	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++) {
+		if (it->fReceiver == receiver) {
+			it->fMask = (it->fMask & ~mask) | (flags & mask);
+			receiver->NewNotification(this);
+			return;
+		}
+	}
+
+	tReceiverEntry newEntry;
+	newEntry.fReceiver = receiver;
+	newEntry.fMask = flags;
+	fReceivers.push_back(newEntry);
+
+	receiver->NewNotification(this);
+}
+
+void MMNotification::CancelNotification(MMNotificationReceiver *receiver) {
+	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
+		if (it->fReceiver == receiver)
+			fReceivers.erase(it);
+}
+
+void MMNotification::SetNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
+	fCurrentFlags = (fCurrentFlags & ~mask) | flags;
+}
+
+void MMNotification::CheckReceivers() {	
+	tNotificationFlags currentFlags = fCurrentFlags;
+	fCurrentFlags = kNoNotificationFlags;
+
+	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
+		if (it->fMask & currentFlags)
+			it->fReceiver->ReceiveNotification(this, currentFlags);
+}
+
+//	Receiver entries are equal if their receivers are equal.
+
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+	return	entry1.fReceiver == entry2.fReceiver;
+}
+
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+	return	entry1.fReceiver != entry2.fReceiver;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.h b/engines/pegasus/MMShell/Notification/MMNotification.h
new file mode 100755
index 0000000..a475633
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotification.h
@@ -0,0 +1,85 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
+#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
+
+#include "common/list.h"
+
+#include "pegasus/MMShell/MMTypes.h"
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
+
+namespace Pegasus {
+
+class MMNotificationManager;
+class MMNotificationReceiver;
+
+struct tReceiverEntry {
+	MMNotificationReceiver *fReceiver;
+	tNotificationFlags fMask;
+};
+
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
+
+typedef Common::List<tReceiverEntry> tReceiverList;
+
+/*
+	A notification can have 32 flags associated with it, which can be user-defined.
+*/
+
+class MMNotification : public MMIDObject {
+friend class MMNotificationManager;
+
+public:
+	MMNotification(const tNotificationID id, MMNotificationManager *owner);
+	virtual ~MMNotification();
+
+	//	NotifyMe will have this receiver notified when any of the specified notification
+	//	flags are set.
+	//	If there is already a notification set for this receiver, NotifyMe does a bitwise
+	//	OR with the receiver's current notification flags.
+
+	//	Can selectively set or clear notification bits by using the flags and mask argument.
+
+	void NotifyMe(MMNotificationReceiver*, tNotificationFlags flags, tNotificationFlags mask);
+	void CancelNotification(MMNotificationReceiver *receiver);
+	
+	void SetNotificationFlags(tNotificationFlags flags,	tNotificationFlags mask);
+	tNotificationFlags GetNotificationFlags() { return fCurrentFlags; }
+	
+	void ClearNotificationFlags() { SetNotificationFlags(0, ~(tNotificationFlags)0); }
+
+protected:
+	void CheckReceivers();
+	
+	MMNotificationManager *fOwner;
+	tReceiverList fReceivers;
+	tNotificationFlags fCurrentFlags;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
new file mode 100755
index 0000000..806f5c4
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/MMShell/Notification/MMNotificationManager.h"
+
+namespace Pegasus {
+
+typedef tNotificationList::iterator tNotificationIterator;
+
+MMNotificationManager::MMNotificationManager() {
+}
+
+MMNotificationManager::~MMNotificationManager() {
+	DetachNotifications();
+}
+
+void MMNotificationManager::AddNotification(MMNotification *notification) {
+	fNotifications.push_back(notification);
+}
+
+void MMNotificationManager::RemoveNotification(MMNotification *notification) {
+	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
+		if ((*it) == notification)
+			fNotifications.erase(it);
+}
+
+void MMNotificationManager::DetachNotifications() {
+	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
+		(*it)->fOwner = 0;
+}
+
+void MMNotificationManager::CheckNotifications() {
+	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
+		if ((*it)->fCurrentFlags != kNoNotificationFlags)
+			(*it)->CheckReceivers();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.h b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
new file mode 100755
index 0000000..50af894
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
+#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
+
+#include "common/list.h"
+
+#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
+
+namespace Pegasus {
+
+class MMNotification;
+
+typedef Common::List<MMNotification *> tNotificationList;
+
+class MMNotificationManager : public MMNotificationReceiver {
+friend class MMNotification;
+
+public:
+	MMNotificationManager();
+	virtual ~MMNotificationManager();
+	
+	void CheckNotifications();
+
+protected:
+	void AddNotification(MMNotification *notification);
+	void RemoveNotification(MMNotification *notification);
+	void DetachNotifications();
+	
+	tNotificationList fNotifications;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
new file mode 100755
index 0000000..41191b1
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
+
+namespace Pegasus {
+
+MMNotificationReceiver::MMNotificationReceiver() {
+	fNotification = NULL;
+}
+
+MMNotificationReceiver::~MMNotificationReceiver() {
+	if (fNotification)
+		fNotification->CancelNotification(this);
+}
+
+void MMNotificationReceiver::ReceiveNotification(MMNotification *, const tNotificationFlags) {
+}
+
+void MMNotificationReceiver::NewNotification(MMNotification *notification) {
+	fNotification = notification;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
new file mode 100755
index 0000000..649d0cb
--- /dev/null
+++ b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
+#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
+
+#include "pegasus/MMShell/Notification/MMNotification.h"
+
+namespace Pegasus {
+
+class MMNotificationReceiver {
+friend class MMNotification;
+
+public:
+	MMNotificationReceiver();
+	virtual ~MMNotificationReceiver();
+	
+protected:
+	//	ReceiveNotification is called automatically whenever a notification that this
+	//	receiver depends on has its flags set
+	
+	virtual void ReceiveNotification(MMNotification *, const tNotificationFlags);
+	virtual void NewNotification(MMNotification *notification);
+
+private:
+	MMNotification *fNotification;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 1fdd471..647ad55 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -14,6 +14,9 @@ MODULE_OBJS = \
 	Game_Shell/CItem.o \
 	Game_Shell/CItemList.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
+	MMShell/Notification/MMNotification.o \
+	MMShell/Notification/MMNotificationManager.o \
+	MMShell/Notification/MMNotificationReceiver.o \
 	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMUtilities.o


Commit: e5953a879bf45b8707b1d50ddbe4c2520b062866
    https://github.com/scummvm/scummvm/commit/e5953a879bf45b8707b1d50ddbe4c2520b062866
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T12:18:18-07:00

Commit Message:
PEGASUS: Update the MMTypes with a TimeValue/TimeScale replacement

Changed paths:
    engines/pegasus/MMShell/MMConstants.h
    engines/pegasus/MMShell/MMTypes.h



diff --git a/engines/pegasus/MMShell/MMConstants.h b/engines/pegasus/MMShell/MMConstants.h
index 21852a9..036caad 100755
--- a/engines/pegasus/MMShell/MMConstants.h
+++ b/engines/pegasus/MMShell/MMConstants.h
@@ -53,8 +53,7 @@ const tDisplayElementID kCurrentDragSpriteID = 1000;
 //const Fixed kFixed1 = 1 << 16;
 //const Fixed kFixedMinus1 = -1 << 16;
 
-// Originally "TimeScale" instead of int
-const int kDefaultTimeScale = 600;
+const TimeScale kDefaultTimeScale = 600;
 
 // TODO
 //const RGBColor kWhiteRGB = {0xFFFF, 0xFFFF, 0xFFFF};
diff --git a/engines/pegasus/MMShell/MMTypes.h b/engines/pegasus/MMShell/MMTypes.h
index ae5f0d0..93eac4e 100755
--- a/engines/pegasus/MMShell/MMTypes.h
+++ b/engines/pegasus/MMShell/MMTypes.h
@@ -93,6 +93,11 @@ enum tSlideDirection {
 	kSlideDownRightMask = kSlideRightMask | kSlideDownMask
 };
 
+// ScummVM QuickTime/QuickDraw replacement types
+typedef uint TimeValue;
+typedef uint TimeScale;
+// TODO: Fixed and RGBColor
+
 } // End of namespace Pegasus
 
 #endif


Commit: 9dd9012ed8104a6756e06e26f0149bd9d2c967f5
    https://github.com/scummvm/scummvm/commit/9dd9012ed8104a6756e06e26f0149bd9d2c967f5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-06-16T12:20:33-07:00

Commit Message:
PEGASUS: Import the MMTimeValue class

Changed paths:
  A engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
  A engines/pegasus/MMShell/Utilities/MMTimeValue.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
new file mode 100755
index 0000000..8807743
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/MMShell/Utilities/MMTimeValue.h"
+
+namespace Pegasus {
+
+MMTimeValue::MMTimeValue() {
+	fTheTime = 0;
+	fTheScale = kDefaultTimeScale;
+}
+
+TimeValue MMTimeValue::GetTime() const {
+	return fTheTime;
+}
+
+void MMTimeValue::GetTime(TimeValue &time, const TimeScale scale) const {
+	time = fTheTime * fTheScale / scale;
+}
+
+void MMTimeValue::SetTime(const TimeValue time) {
+	fTheTime = time;
+}
+
+void MMTimeValue::SetTime(const TimeValue time, const TimeScale scale) {
+	fTheTime = time * scale / fTheScale;
+}
+
+TimeScale MMTimeValue::GetScale() const {
+	return fTheScale;
+}
+
+void MMTimeValue::SetScale(const TimeScale scale) {
+	fTheScale = scale;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.h b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
new file mode 100755
index 0000000..5b75841
--- /dev/null
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_MMTIMEVALUE_H
+#define PEGASUS_MMSHELL_MMTIMEVALUE_H
+
+#include "pegasus/MMShell/MMTypes.h"
+
+namespace Pegasus {
+
+class MMTimeValue {
+public:
+	MMTimeValue();
+	
+	TimeValue GetTime() const;
+	void GetTime(TimeValue &time, const TimeScale scale) const;
+	void SetTime(const TimeValue time);
+	void SetTime(const TimeValue time, const TimeScale scale);
+	
+	TimeScale GetScale() const;
+	void SetScale(const TimeScale scale);
+
+protected:
+	TimeValue fTheTime;
+	TimeScale fTheScale;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 647ad55..ca5017b 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS = \
 	MMShell/Notification/MMNotificationReceiver.o \
 	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \
+	MMShell/Utilities/MMTimeValue.o \
 	MMShell/Utilities/MMUtilities.o
 
 


Commit: d7411acc2b1c7702280dbff1c3e1bafee528184b
    https://github.com/scummvm/scummvm/commit/d7411acc2b1c7702280dbff1c3e1bafee528184b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-07-20T06:27:11-07:00

Commit Message:
PEGASUS: Update copyright with full Presto name

Changed paths:
    engines/pegasus/Game_Shell/CGameState.cpp
    engines/pegasus/Game_Shell/CGameState.h
    engines/pegasus/Game_Shell/CInventory.cpp
    engines/pegasus/Game_Shell/CInventory.h
    engines/pegasus/Game_Shell/CItem.cpp
    engines/pegasus/Game_Shell/CItem.h
    engines/pegasus/Game_Shell/CItemList.cpp
    engines/pegasus/Game_Shell/CItemList.h
    engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
    engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
    engines/pegasus/MMShell/Base_Classes/MMAction.h
    engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
    engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
    engines/pegasus/MMShell/MMConstants.h
    engines/pegasus/MMShell/MMTypes.h
    engines/pegasus/MMShell/Notification/MMNotification.cpp
    engines/pegasus/MMShell/Notification/MMNotification.h
    engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
    engines/pegasus/MMShell/Notification/MMNotificationManager.h
    engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
    engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
    engines/pegasus/MMShell/Sounds/MMSound.cpp
    engines/pegasus/MMShell/Sounds/MMSound.h
    engines/pegasus/MMShell/Utilities/MMIDObject.h
    engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
    engines/pegasus/MMShell/Utilities/MMResourceFile.h
    engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
    engines/pegasus/MMShell/Utilities/MMTimeValue.h
    engines/pegasus/MMShell/Utilities/MMUtilities.cpp
    engines/pegasus/MMShell/Utilities/MMUtilities.h



diff --git a/engines/pegasus/Game_Shell/CGameState.cpp b/engines/pegasus/Game_Shell/CGameState.cpp
index 16c6009..70a5545 100755
--- a/engines/pegasus/Game_Shell/CGameState.cpp
+++ b/engines/pegasus/Game_Shell/CGameState.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CGameState.h b/engines/pegasus/Game_Shell/CGameState.h
index 74ec603..b7ad71b 100755
--- a/engines/pegasus/Game_Shell/CGameState.h
+++ b/engines/pegasus/Game_Shell/CGameState.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CInventory.cpp b/engines/pegasus/Game_Shell/CInventory.cpp
index 96ff3b5..3747bed 100755
--- a/engines/pegasus/Game_Shell/CInventory.cpp
+++ b/engines/pegasus/Game_Shell/CInventory.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CInventory.h b/engines/pegasus/Game_Shell/CInventory.h
index 4a18610..57ea1c9 100755
--- a/engines/pegasus/Game_Shell/CInventory.h
+++ b/engines/pegasus/Game_Shell/CInventory.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp
index 90a7a04..af0bff4 100755
--- a/engines/pegasus/Game_Shell/CItem.cpp
+++ b/engines/pegasus/Game_Shell/CItem.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CItem.h b/engines/pegasus/Game_Shell/CItem.h
index 2bef735..cb0931c 100755
--- a/engines/pegasus/Game_Shell/CItem.h
+++ b/engines/pegasus/Game_Shell/CItem.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CItemList.cpp b/engines/pegasus/Game_Shell/CItemList.cpp
index eb7cf9a..256a895 100755
--- a/engines/pegasus/Game_Shell/CItemList.cpp
+++ b/engines/pegasus/Game_Shell/CItemList.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/CItemList.h b/engines/pegasus/Game_Shell/CItemList.h
index e2caa09..75a34a0 100755
--- a/engines/pegasus/Game_Shell/CItemList.h
+++ b/engines/pegasus/Game_Shell/CItemList.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
index 919c059..5d64629 100755
--- a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
+++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
index 1c3b0f3..923f7a7 100755
--- a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
+++ b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Base_Classes/MMAction.h b/engines/pegasus/MMShell/Base_Classes/MMAction.h
index 78c0bb8..8ad34a8 100755
--- a/engines/pegasus/MMShell/Base_Classes/MMAction.h
+++ b/engines/pegasus/MMShell/Base_Classes/MMAction.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
index c0e616c..9a2543d 100755
--- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
+++ b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
index e9c2126..4aa18ca 100755
--- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
+++ b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/MMConstants.h b/engines/pegasus/MMShell/MMConstants.h
index 036caad..1b36c81 100755
--- a/engines/pegasus/MMShell/MMConstants.h
+++ b/engines/pegasus/MMShell/MMConstants.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/MMTypes.h b/engines/pegasus/MMShell/MMTypes.h
index 93eac4e..a4bc547 100755
--- a/engines/pegasus/MMShell/MMTypes.h
+++ b/engines/pegasus/MMShell/MMTypes.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.cpp b/engines/pegasus/MMShell/Notification/MMNotification.cpp
index 5bc0820..8b8d694 100755
--- a/engines/pegasus/MMShell/Notification/MMNotification.cpp
+++ b/engines/pegasus/MMShell/Notification/MMNotification.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.h b/engines/pegasus/MMShell/Notification/MMNotification.h
index a475633..8ad7f73 100755
--- a/engines/pegasus/MMShell/Notification/MMNotification.h
+++ b/engines/pegasus/MMShell/Notification/MMNotification.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
index 806f5c4..2a1f1be 100755
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
+++ b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.h b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
index 50af894..3df455f 100755
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.h
+++ b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
index 41191b1..037cf18 100755
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
+++ b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
index 649d0cb..cb72047 100755
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
+++ b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Sounds/MMSound.cpp b/engines/pegasus/MMShell/Sounds/MMSound.cpp
index f536463..23ac60b 100755
--- a/engines/pegasus/MMShell/Sounds/MMSound.cpp
+++ b/engines/pegasus/MMShell/Sounds/MMSound.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Sounds/MMSound.h b/engines/pegasus/MMShell/Sounds/MMSound.h
index 8bcf410..bb55782 100755
--- a/engines/pegasus/MMShell/Sounds/MMSound.h
+++ b/engines/pegasus/MMShell/Sounds/MMSound.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/MMShell/Utilities/MMIDObject.h
index e0ca29b..4cca1c0 100755
--- a/engines/pegasus/MMShell/Utilities/MMIDObject.h
+++ b/engines/pegasus/MMShell/Utilities/MMIDObject.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp b/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
index dda9a58..6743a8b 100755
--- a/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
+++ b/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.h b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
index 6dc70f9..47c82fd 100755
--- a/engines/pegasus/MMShell/Utilities/MMResourceFile.h
+++ b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
index 8807743..c3bf85b 100755
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.h b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
index 5b75841..4060322 100755
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.h
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp b/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
index a64b7db..e6bd146 100755
--- a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
+++ b/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.h b/engines/pegasus/MMShell/Utilities/MMUtilities.h
index 4c504b1..d5f7e54 100755
--- a/engines/pegasus/MMShell/Utilities/MMUtilities.h
+++ b/engines/pegasus/MMShell/Utilities/MMUtilities.h
@@ -5,7 +5,7 @@
  * file distributed with this source distribution.
  *
  * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License


Commit: ad293b249e74dd1cfbdbd721d02145efbdaf9eca
    https://github.com/scummvm/scummvm/commit/ad293b249e74dd1cfbdbd721d02145efbdaf9eca
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-07-20T06:27:39-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A audio/decoders/codec.h
  A backends/events/ps3sdl/ps3sdl-events.cpp
  A backends/events/ps3sdl/ps3sdl-events.h
  A backends/fs/ps3/ps3-fs-factory.cpp
  A backends/fs/ps3/ps3-fs-factory.h
  A backends/graphics/surfacesdl/surfacesdl-graphics.cpp
  A backends/graphics/surfacesdl/surfacesdl-graphics.h
  A backends/mixer/sdl13/sdl13-mixer.cpp
  A backends/mixer/sdl13/sdl13-mixer.h
  A backends/platform/gph/devices/gp2x/mmuhack/README
  A backends/platform/openpandora/build/PXML_schema.xsd
  A backends/platform/sdl/macosx/appmenu_osx.h
  A backends/platform/sdl/macosx/appmenu_osx.mm
  A backends/platform/sdl/ps3/ps3-main.cpp
  A backends/platform/sdl/ps3/ps3.cpp
  A backends/platform/sdl/ps3/ps3.h
  A backends/taskbar/unity/unity-taskbar.cpp
  A backends/taskbar/unity/unity-taskbar.h
  A backends/taskbar/win32/mingw-compat.h
  A backends/taskbar/win32/win32-taskbar.cpp
  A backends/taskbar/win32/win32-taskbar.h
  A common/bitstream.cpp
  A common/bitstream.h
  A common/cosinetables.cpp
  A common/cosinetables.h
  A common/dct.cpp
  A common/dct.h
  A common/fft.cpp
  A common/fft.h
  A common/huffman.cpp
  A common/huffman.h
  A common/math.h
  A common/rdft.cpp
  A common/rdft.h
  A common/sinetables.cpp
  A common/sinetables.h
  A common/taskbar.h
  A devtools/tasmrecover/.gitignore
  A devtools/tasmrecover/dreamweb/LICENSE
  A devtools/tasmrecover/dreamweb/backdrop.asm
  A devtools/tasmrecover/dreamweb/debug.asm
  A devtools/tasmrecover/dreamweb/dreamweb.asm
  A devtools/tasmrecover/dreamweb/keypad.asm
  A devtools/tasmrecover/dreamweb/look.asm
  A devtools/tasmrecover/dreamweb/monitor.asm
  A devtools/tasmrecover/dreamweb/newplace.asm
  A devtools/tasmrecover/dreamweb/object.asm
  A devtools/tasmrecover/dreamweb/print.asm
  A devtools/tasmrecover/dreamweb/saveload.asm
  A devtools/tasmrecover/dreamweb/sblaster.asm
  A devtools/tasmrecover/dreamweb/sprite.asm
  A devtools/tasmrecover/dreamweb/talk.asm
  A devtools/tasmrecover/dreamweb/titles.asm
  A devtools/tasmrecover/dreamweb/use.asm
  A devtools/tasmrecover/dreamweb/vars.asm
  A devtools/tasmrecover/dreamweb/vgafades.asm
  A devtools/tasmrecover/dreamweb/vgagrafx.asm
  A devtools/tasmrecover/tasm-recover
  A devtools/tasmrecover/tasm/__init__.py
  A devtools/tasmrecover/tasm/cpp.py
  A devtools/tasmrecover/tasm/lex.py
  A devtools/tasmrecover/tasm/op.py
  A devtools/tasmrecover/tasm/parser.py
  A devtools/tasmrecover/tasm/proc.py
  A dists/ps3/ICON0.PNG
  A dists/ps3/PIC1.PNG
  A dists/ps3/readme-ps3.md
  A dists/ps3/sfo.xml
  A dists/win32/graphics/left.bmp
  A dists/win32/graphics/scummvm-install.ico
  A dists/win32/plugins/Games.dll
  A dists/win32/scummvm.gdf.xml
  A dists/win32/scummvm.nsi
  A dists/win32/scummvm.nsi.in
  A doc/QuickStart
  A doc/de/Liesmich
  A doc/de/Schnellstart
  A doc/fr/QuickStart_fr
  A engines/dreamweb/README
  A engines/dreamweb/console.cpp
  A engines/dreamweb/console.h
  A engines/dreamweb/detection.cpp
  A engines/dreamweb/detection_tables.h
  A engines/dreamweb/dreamgen.cpp
  A engines/dreamweb/dreamgen.h
  A engines/dreamweb/dreamweb.cpp
  A engines/dreamweb/dreamweb.h
  A engines/dreamweb/module.mk
  A engines/dreamweb/runtime.h
  A engines/dreamweb/structs.h
  A engines/dreamweb/stubs.cpp
  A engines/dreamweb/stubs.h
  A engines/lastexpress/fight/fight.cpp
  A engines/lastexpress/fight/fight.h
  A engines/lastexpress/fight/fighter.cpp
  A engines/lastexpress/fight/fighter.h
  A engines/lastexpress/fight/fighter_anna.cpp
  A engines/lastexpress/fight/fighter_anna.h
  A engines/lastexpress/fight/fighter_ivo.cpp
  A engines/lastexpress/fight/fighter_ivo.h
  A engines/lastexpress/fight/fighter_milos.cpp
  A engines/lastexpress/fight/fighter_milos.h
  A engines/lastexpress/fight/fighter_salko.cpp
  A engines/lastexpress/fight/fighter_salko.h
  A engines/lastexpress/fight/fighter_vesna.cpp
  A engines/lastexpress/fight/fighter_vesna.h
  A engines/lastexpress/menu/clock.cpp
  A engines/lastexpress/menu/clock.h
  A engines/lastexpress/menu/menu.cpp
  A engines/lastexpress/menu/menu.h
  A engines/lastexpress/menu/trainline.cpp
  A engines/lastexpress/menu/trainline.h
  A engines/lastexpress/sound/entry.cpp
  A engines/lastexpress/sound/entry.h
  A engines/lastexpress/sound/queue.cpp
  A engines/lastexpress/sound/queue.h
  A engines/lastexpress/sound/sound.cpp
  A engines/lastexpress/sound/sound.h
  A engines/scumm/imuse/pcspk.cpp
  A engines/scumm/imuse/pcspk.h
  A graphics/fonts/bdf.cpp
  A graphics/fonts/bdf.h
  A icons/count.ico
  A video/bink_decoder.cpp
  A video/bink_decoder.h
  A video/binkdata.h
  R backends/graphics/sdl/sdl-graphics.cpp
  R backends/graphics/sdl/sdl-graphics.h
  R backends/platform/gph/devices/gp2x/mmuhack/readme.txt
  R dists/nsis/graphics/scummvm-install.ico
  R dists/nsis/graphics/left.bmp
  R dists/nsis/scummvm.nsi
  R dists/nsis/scummvm.nsi.in
  R doc/translations/README-translation_template.txt
  R doc/translations/README-fr.txt
  R doc/he/bink-md5s.txt
  R doc/he/md5s.txt
  R doc/he/smacker-md5s.txt
  R doc/he/u32.txt
  R doc/he/versions.html
  R doc/translations/README-de.txt
  R engines/lastexpress/game/fight.cpp
  R engines/lastexpress/game/fight.h
  R engines/lastexpress/game/sound.h
  R engines/lastexpress/game/menu.cpp
  R engines/lastexpress/game/menu.h
  R engines/lastexpress/game/sound.cpp
    .gitignore
    AUTHORS
    NEWS
    README
    audio/decoders/aac.cpp
    audio/decoders/aac.h
    audio/decoders/adpcm.cpp
    audio/decoders/qdm2.cpp
    audio/decoders/qdm2.h
    audio/decoders/quicktime.cpp
    audio/decoders/quicktime.h
    audio/decoders/quicktime_intern.h
    audio/decoders/voc.cpp
    audio/mididrv.cpp
    audio/mpu401.cpp
    audio/rate.cpp
    audio/softsynth/fmtowns_pc98/towns_audio.cpp
    audio/softsynth/fmtowns_pc98/towns_midi.cpp
    audio/softsynth/fmtowns_pc98/towns_midi.h
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
    audio/softsynth/mt32.cpp
    audio/softsynth/opl/mame.cpp
    backends/audiocd/audiocd.h
    backends/events/sdl/sdl-events.cpp
    backends/events/sdl/sdl-events.h
    backends/events/webossdl/webossdl-events.cpp
    backends/events/wincesdl/wincesdl-events.cpp
    backends/fs/ds/ds-fs-factory.cpp
    backends/fs/posix/posix-fs-factory.cpp
    backends/fs/posix/posix-fs-factory.h
    backends/fs/posix/posix-fs.cpp
    backends/fs/ps2/ps2-fs-factory.cpp
    backends/fs/psp/psp-fs-factory.cpp
    backends/fs/wii/wii-fs-factory.cpp
    backends/fs/windows/windows-fs.cpp
    backends/fs/windows/windows-fs.h
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.h
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/gph/gph-graphics.h
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
    backends/graphics/opengl/gltexture.cpp
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openpandora/op-graphics.cpp
    backends/graphics/openpandora/op-graphics.h
    backends/graphics/samsungtvsdl/samsungtvsdl-graphics.cpp
    backends/graphics/samsungtvsdl/samsungtvsdl-graphics.h
    backends/graphics/symbiansdl/symbiansdl-graphics.cpp
    backends/graphics/symbiansdl/symbiansdl-graphics.h
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.h
    backends/mixer/wincesdl/wincesdl-mixer.cpp
    backends/modular-backend.h
    backends/module.mk
    backends/platform/android/android.cpp
    backends/platform/android/jni.cpp
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/plugins.cpp
    backends/platform/dc/selector.cpp
    backends/platform/dingux/dingux.cpp
    backends/platform/ds/arm9/source/gbampsave.cpp
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/osys_n64_events.cpp
    backends/platform/null/null.cpp
    backends/platform/openpandora/build/PXML.xml
    backends/platform/openpandora/build/pnd_make.sh
    backends/platform/openpandora/build/runscummvm.sh
    backends/platform/openpandora/op-bundle.mk
    backends/platform/ps2/systemps2.cpp
    backends/platform/psp/cursor.cpp
    backends/platform/psp/display_client.cpp
    backends/platform/psp/display_client.h
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/display_manager.h
    backends/platform/psp/dummy.cpp
    backends/platform/psp/image_viewer.cpp
    backends/platform/psp/image_viewer.h
    backends/platform/psp/input.cpp
    backends/platform/psp/input.h
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/png_loader.cpp
    backends/platform/psp/png_loader.h
    backends/platform/psp/powerman.cpp
    backends/platform/psp/rtc.cpp
    backends/platform/psp/trace.cpp
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/main.cpp
    backends/platform/sdl/module.mk
    backends/platform/sdl/posix/posix-main.cpp
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/sdl-sys.h
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    backends/platform/sdl/win32/win32.cpp
    backends/platform/sdl/win32/win32.h
    backends/platform/symbian/src/SymbianOS.cpp
    backends/platform/wii/osystem.cpp
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_gfx.cpp
    backends/platform/wince/CEActionsPocket.cpp
    backends/platform/wince/CEActionsSmartphone.cpp
    backends/platform/wince/CELauncherDialog.cpp
    backends/platform/wince/README-WinCE.txt
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince-sdl.h
    backends/plugins/elf/elf-loader.cpp
    backends/plugins/elf/elf-provider.cpp
    backends/plugins/elf/memory-manager.cpp
    backends/plugins/elf/memory-manager.h
    backends/plugins/elf/mips-loader.cpp
    backends/plugins/elf/shorts-segment-manager.cpp
    backends/vkeybd/virtual-keyboard-parser.cpp
    base/commandLine.cpp
    base/main.cpp
    base/plugins.cpp
    base/plugins.h
    base/version.cpp
    common/EventRecorder.cpp
    common/archive.cpp
    common/archive.h
    common/array.h
    common/config-file.cpp
    common/config-manager.cpp
    common/config-manager.h
    common/debug.cpp
    common/error.cpp
    common/error.h
    common/forbidden.h
    common/hashmap.h
    common/module.mk
    common/ptr.h
    common/quicktime.cpp
    common/scummsys.h
    common/singleton.h
    common/str.cpp
    common/str.h
    common/system.cpp
    common/system.h
    common/textconsole.cpp
    common/translation.cpp
    common/util.h
    common/winexe_ne.cpp
    common/winexe_pe.h
    common/xmlparser.cpp
    common/xmlparser.h
    configure
    devtools/convbdf.c
    devtools/create_hugo/create_hugo.cpp
    devtools/create_hugo/staticdisplay.h
    devtools/create_kyradat/extract.cpp
    devtools/create_mads/main.cpp
    devtools/create_mads/parser.cpp
    devtools/create_project/create_project.cpp
    devtools/create_project/msvc10/create_project.vcxproj
    devtools/create_project/scripts/installer.vbs
    devtools/create_project/scripts/postbuild.cmd
    devtools/create_toon/create_toon.cpp
    devtools/create_toon/create_toon.h
    devtools/credits.pl
    devtools/skycpt/cptcompiler.cpp
    devtools/update-version.pl
    dists/redhat/scummvm.spec
    dists/redhat/scummvm.spec.in
    dists/scummvm.rc
    dists/scummvm.rc.in
    dists/win32/ScummVM.iss
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/detection.cpp
    engines/agi/preagi_winnie.cpp
    engines/agi/sound.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agi/sound_midi.cpp
    engines/agi/sound_pcjr.h
    engines/agi/sound_sarien.cpp
    engines/agi/text.cpp
    engines/agi/wagparser.cpp
    engines/agos/script_pn.cpp
    engines/agos/string.cpp
    engines/cine/detection.cpp
    engines/cine/prc.cpp
    engines/cine/various.cpp
    engines/cruise/background.cpp
    engines/cruise/cruise_main.cpp
    engines/cruise/mainDraw.cpp
    engines/cruise/script.cpp
    engines/dialogs.cpp
    engines/draci/script.cpp
    engines/draci/sound.cpp
    engines/drascula/detection.cpp
    engines/drascula/graphics.cpp
    engines/drascula/interface.cpp
    engines/drascula/resource.cpp
    engines/drascula/rooms.cpp
    engines/engine.cpp
    engines/engine.h
    engines/engines.mk
    engines/game.cpp
    engines/game.h
    engines/gob/inter_fascin.cpp
    engines/gob/video_v6.cpp
    engines/groovie/detection.cpp
    engines/groovie/music.cpp
    engines/groovie/player.h
    engines/groovie/saveload.cpp
    engines/groovie/script.cpp
    engines/hugo/console.cpp
    engines/hugo/dialogs.cpp
    engines/hugo/display.cpp
    engines/hugo/file_v1d.cpp
    engines/hugo/file_v1w.cpp
    engines/hugo/file_v2d.cpp
    engines/hugo/file_v3d.cpp
    engines/hugo/hugo.cpp
    engines/hugo/hugo.h
    engines/hugo/inventory.h
    engines/hugo/object.cpp
    engines/hugo/parser.cpp
    engines/hugo/parser.h
    engines/hugo/schedule.cpp
    engines/hugo/schedule.h
    engines/hugo/sound.cpp
    engines/hugo/util.cpp
    engines/kyra/debugger.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui.cpp
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_v2.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/saveload_hof.cpp
    engines/kyra/saveload_lok.cpp
    engines/kyra/saveload_lol.cpp
    engines/kyra/saveload_mr.cpp
    engines/kyra/screen.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound.h
    engines/kyra/sound_intern.h
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_towns.cpp
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/data/background.cpp
    engines/lastexpress/data/font.cpp
    engines/lastexpress/data/scene.cpp
    engines/lastexpress/data/sequence.cpp
    engines/lastexpress/data/snd.cpp
    engines/lastexpress/data/snd.h
    engines/lastexpress/data/subtitle.cpp
    engines/lastexpress/debug.cpp
    engines/lastexpress/detection.cpp
    engines/lastexpress/entities/abbot.cpp
    engines/lastexpress/entities/alexei.cpp
    engines/lastexpress/entities/alouan.cpp
    engines/lastexpress/entities/anna.cpp
    engines/lastexpress/entities/august.cpp
    engines/lastexpress/entities/boutarel.cpp
    engines/lastexpress/entities/chapters.cpp
    engines/lastexpress/entities/cooks.cpp
    engines/lastexpress/entities/coudert.cpp
    engines/lastexpress/entities/entity.cpp
    engines/lastexpress/entities/entity.h
    engines/lastexpress/entities/entity_intern.h
    engines/lastexpress/entities/francois.cpp
    engines/lastexpress/entities/gendarmes.cpp
    engines/lastexpress/entities/gendarmes.h
    engines/lastexpress/entities/hadija.cpp
    engines/lastexpress/entities/ivo.cpp
    engines/lastexpress/entities/kahina.cpp
    engines/lastexpress/entities/kronos.cpp
    engines/lastexpress/entities/mahmud.cpp
    engines/lastexpress/entities/max.cpp
    engines/lastexpress/entities/mertens.cpp
    engines/lastexpress/entities/milos.cpp
    engines/lastexpress/entities/mmeboutarel.cpp
    engines/lastexpress/entities/pascale.cpp
    engines/lastexpress/entities/rebecca.cpp
    engines/lastexpress/entities/salko.cpp
    engines/lastexpress/entities/servers0.cpp
    engines/lastexpress/entities/servers1.cpp
    engines/lastexpress/entities/sophie.cpp
    engines/lastexpress/entities/tables.cpp
    engines/lastexpress/entities/tatiana.cpp
    engines/lastexpress/entities/train.cpp
    engines/lastexpress/entities/vassili.cpp
    engines/lastexpress/entities/verges.cpp
    engines/lastexpress/entities/vesna.cpp
    engines/lastexpress/entities/yasmin.cpp
    engines/lastexpress/game/action.cpp
    engines/lastexpress/game/beetle.cpp
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/game/inventory.cpp
    engines/lastexpress/game/logic.cpp
    engines/lastexpress/game/object.cpp
    engines/lastexpress/game/savegame.cpp
    engines/lastexpress/game/savepoint.cpp
    engines/lastexpress/game/scenes.cpp
    engines/lastexpress/game/state.cpp
    engines/lastexpress/game/state.h
    engines/lastexpress/graphics.cpp
    engines/lastexpress/helpers.h
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/module.mk
    engines/lastexpress/resource.cpp
    engines/lastexpress/resource.h
    engines/lastexpress/shared.h
    engines/lure/debugger.cpp
    engines/lure/disk.cpp
    engines/lure/hotspots.cpp
    engines/lure/memory.cpp
    engines/lure/res_struct.h
    engines/lure/sound.cpp
    engines/m4/animation.cpp
    engines/m4/assets.cpp
    engines/m4/assets.h
    engines/m4/detection.cpp
    engines/m4/dialogs.cpp
    engines/m4/events.cpp
    engines/m4/font.h
    engines/m4/globals.cpp
    engines/m4/graphics.cpp
    engines/m4/graphics.h
    engines/m4/m4.cpp
    engines/m4/m4.h
    engines/m4/m4_views.cpp
    engines/m4/mads_anim.cpp
    engines/m4/mads_logic.cpp
    engines/m4/mads_logic.h
    engines/m4/mads_menus.cpp
    engines/m4/mads_player.cpp
    engines/m4/mads_scene.cpp
    engines/m4/mads_views.cpp
    engines/m4/mads_views.h
    engines/m4/resource.cpp
    engines/m4/resource.h
    engines/m4/scene.cpp
    engines/m4/sound.cpp
    engines/m4/sprite.cpp
    engines/made/database.cpp
    engines/made/detection.cpp
    engines/mohawk/bitmap.cpp
    engines/mohawk/console.cpp
    engines/mohawk/cstime.cpp
    engines/mohawk/cursors.cpp
    engines/mohawk/cursors.h
    engines/mohawk/detection_tables.h
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h
    engines/mohawk/mohawk.h
    engines/mohawk/myst.cpp
    engines/mohawk/myst_scripts.cpp
    engines/mohawk/myst_stacks/demo.cpp
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/resource.cpp
    engines/mohawk/resource.h
    engines/mohawk/riven.cpp
    engines/mohawk/riven_external.cpp
    engines/mohawk/riven_saveload.cpp
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/sound.cpp
    engines/mohawk/video.cpp
    engines/parallaction/dialogue.cpp
    engines/parallaction/exec_br.cpp
    engines/parallaction/gfxbase.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/graphics.h
    engines/parallaction/gui_br.cpp
    engines/parallaction/gui_ns.cpp
    engines/parallaction/objects.cpp
    engines/parallaction/parallaction.cpp
    engines/parallaction/parallaction_ns.cpp
    engines/parallaction/parser_br.cpp
    engines/parallaction/parser_ns.cpp
    engines/parallaction/sound.h
    engines/parallaction/sound_ns.cpp
    engines/parallaction/walk.cpp
    engines/queen/talk.cpp
    engines/saga/actor.cpp
    engines/saga/actor.h
    engines/saga/actor_walk.cpp
    engines/saga/animation.cpp
    engines/saga/detection.cpp
    engines/saga/detection_tables.h
    engines/saga/events.cpp
    engines/saga/introproc_ite.cpp
    engines/saga/introproc_saga2.cpp
    engines/saga/isomap.cpp
    engines/saga/music.cpp
    engines/saga/palanim.cpp
    engines/saga/resource.cpp
    engines/saga/saga.cpp
    engines/saga/saga.h
    engines/saga/scene.cpp
    engines/saga/scene.h
    engines/saga/sndres.cpp
    engines/saga/sprite.cpp
    engines/savestate.cpp
    engines/savestate.h
    engines/sci/console.cpp
    engines/sci/decompressor.cpp
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/features.h
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kevent.cpp
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/kmovement.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.h
    engines/sci/engine/script.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/segment.cpp
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h
    engines/sci/engine/state.cpp
    engines/sci/engine/static_selectors.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm_types.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/event.cpp
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/compare.h
    engines/sci/graphics/coordadjuster.h
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/ports.cpp
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/text16.cpp
    engines/sci/graphics/view.cpp
    engines/sci/parser/said.cpp
    engines/sci/resource.cpp
    engines/sci/resource_audio.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/audio.cpp
    engines/sci/sound/drivers/amigamac.cpp
    engines/sci/sound/music.cpp
    engines/sci/video/robot_decoder.cpp
    engines/sci/video/seq_decoder.h
    engines/scumm/actor.cpp
    engines/scumm/charset.cpp
    engines/scumm/charset.h
    engines/scumm/costume.cpp
    engines/scumm/cursor.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/gfx.cpp
    engines/scumm/gfx.h
    engines/scumm/gfx_towns.cpp
    engines/scumm/he/animation_he.cpp
    engines/scumm/he/animation_he.h
    engines/scumm/he/logic_he.cpp
    engines/scumm/he/resource_he.cpp
    engines/scumm/he/resource_he.h
    engines/scumm/he/script_v100he.cpp
    engines/scumm/he/script_v60he.cpp
    engines/scumm/he/script_v72he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/imuse/imuse.cpp
    engines/scumm/imuse/imuse.h
    engines/scumm/imuse/imuse_internal.h
    engines/scumm/imuse/imuse_part.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/imuse/instrument.cpp
    engines/scumm/imuse/instrument.h
    engines/scumm/imuse/sysex_samnmax.cpp
    engines/scumm/imuse/sysex_scumm.cpp
    engines/scumm/imuse_digi/dimuse_codecs.cpp
    engines/scumm/input.cpp
    engines/scumm/module.mk
    engines/scumm/palette.cpp
    engines/scumm/player_towns.cpp
    engines/scumm/player_towns.h
    engines/scumm/resource.cpp
    engines/scumm/saveload.cpp
    engines/scumm/script_v4.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/smush/smush_player.cpp
    engines/scumm/sound.cpp
    engines/scumm/string.cpp
    engines/scumm/vars.cpp
    engines/scumm/verbs.cpp
    engines/sky/detection.cpp
    engines/sword1/animation.cpp
    engines/sword2/animation.cpp
    engines/sword2/controls.cpp
    engines/sword2/render.cpp
    engines/sword25/detection_tables.h
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/gfx/animation.h
    engines/sword25/gfx/animationresource.cpp
    engines/sword25/gfx/animationtemplateregistry.cpp
    engines/sword25/gfx/fontresource.cpp
    engines/sword25/gfx/graphicengine.cpp
    engines/sword25/gfx/image/art.cpp
    engines/sword25/gfx/image/art.h
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/image/vectorimage.cpp
    engines/sword25/gfx/image/vectorimagerenderer.cpp
    engines/sword25/gfx/screenshot.cpp
    engines/sword25/gfx/staticbitmap.cpp
    engines/sword25/gfx/text.cpp
    engines/sword25/kernel/inputpersistenceblock.cpp
    engines/sword25/kernel/inputpersistenceblock.h
    engines/sword25/kernel/outputpersistenceblock.cpp
    engines/sword25/kernel/persistenceblock.h
    engines/sword25/kernel/persistenceservice.cpp
    engines/sword25/kernel/persistenceservice.h
    engines/sword25/math/regionregistry.cpp
    engines/sword25/package/packagemanager.cpp
    engines/sword25/package/packagemanager.h
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/sfx/soundengine.h
    engines/sword25/sword25.cpp
    engines/sword25/util/lua/lapi.cpp
    engines/sword25/util/lua/lauxlib.cpp
    engines/sword25/util/lua/ldblib.cpp
    engines/sword25/util/lua/ldebug.cpp
    engines/sword25/util/lua/ldo.cpp
    engines/sword25/util/lua/lgc.cpp
    engines/sword25/util/lua/liolib.cpp
    engines/sword25/util/lua/llex.cpp
    engines/sword25/util/lua/llimits.h
    engines/sword25/util/lua/loadlib.cpp
    engines/sword25/util/lua/lobject.h
    engines/sword25/util/lua/lopcodes.h
    engines/sword25/util/lua/lstate.cpp
    engines/sword25/util/lua/lstrlib.cpp
    engines/sword25/util/lua/ltable.cpp
    engines/sword25/util/lua/lua.h
    engines/sword25/util/lua/lualib.h
    engines/sword25/util/lua/lvm.cpp
    engines/sword25/util/lua/scummvm_file.cpp
    engines/sword25/util/lua/scummvm_file.h
    engines/teenagent/animation.cpp
    engines/teenagent/inventory.cpp
    engines/teenagent/inventory.h
    engines/teenagent/resources.cpp
    engines/teenagent/resources.h
    engines/teenagent/scene.cpp
    engines/teenagent/teenagent.cpp
    engines/testbed/config-params.cpp
    engines/testbed/config-params.h
    engines/tinsel/coroutine.h
    engines/tinsel/detection_tables.h
    engines/tinsel/pcode.cpp
    engines/tinsel/saveload.cpp
    engines/tinsel/sched.cpp
    engines/tinsel/tinlib.cpp
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/character.cpp
    engines/toon/font.cpp
    engines/toon/movie.cpp
    engines/toon/path.cpp
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/tools.cpp
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/menu.cpp
    engines/touche/resource.cpp
    engines/tsage/blueforce_logic.cpp
    engines/tsage/converse.cpp
    engines/tsage/converse.h
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/resources.cpp
    engines/tsage/ringworld_demo.cpp
    engines/tsage/ringworld_demo.h
    engines/tsage/ringworld_logic.cpp
    engines/tsage/ringworld_scenes1.cpp
    engines/tsage/ringworld_scenes1.h
    engines/tsage/ringworld_scenes10.cpp
    engines/tsage/ringworld_scenes10.h
    engines/tsage/ringworld_scenes2.cpp
    engines/tsage/ringworld_scenes2.h
    engines/tsage/ringworld_scenes3.cpp
    engines/tsage/ringworld_scenes3.h
    engines/tsage/ringworld_scenes4.cpp
    engines/tsage/ringworld_scenes4.h
    engines/tsage/ringworld_scenes5.cpp
    engines/tsage/ringworld_scenes5.h
    engines/tsage/ringworld_scenes6.cpp
    engines/tsage/ringworld_scenes6.h
    engines/tsage/ringworld_scenes8.cpp
    engines/tsage/ringworld_scenes8.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/scenes.h
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    graphics/cursorman.cpp
    graphics/font.cpp
    graphics/font.h
    graphics/fontman.cpp
    graphics/fonts/consolefont.cpp
    graphics/fonts/newfont.cpp
    graphics/fonts/newfont_big.cpp
    graphics/fonts/winfont.cpp
    graphics/fonts/winfont.h
    graphics/jpeg.h
    graphics/module.mk
    graphics/png.cpp
    graphics/scaler.cpp
    graphics/scaler/aspect.cpp
    graphics/sjis.cpp
    graphics/sjis.h
    graphics/surface.cpp
    graphics/surface.h
    graphics/yuv_to_rgb.cpp
    graphics/yuv_to_rgb.h
    gui/ThemeEngine.cpp
    gui/ThemeParser.cpp
    gui/credits.h
    gui/debugger.h
    gui/gui-manager.cpp
    gui/massadd.cpp
    gui/massadd.h
    gui/options.cpp
    gui/saveload.cpp
    gui/themes/translations.dat
    icons/scummvm.ico
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    video/codecs/cdtoons.cpp
    video/codecs/truemotion1.cpp
    video/codecs/truemotion1.h
    video/module.mk
    video/qt_decoder.cpp
    video/smk_decoder.cpp





Commit: 4a69dc13d92e82fff85dc5a3a923b74ced259ffa
    https://github.com/scummvm/scummvm/commit/4a69dc13d92e82fff85dc5a3a923b74ced259ffa
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-08-26T19:44:17-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A audio/decoders/xa.cpp
  A audio/decoders/xa.h
  A backends/graphics/sdl/sdl-graphics.cpp
  A backends/graphics/sdl/sdl-graphics.h
  A backends/platform/bada/README.TXT
  A backends/platform/bada/application.cpp
  A backends/platform/bada/application.h
  A backends/platform/bada/audio.cpp
  A backends/platform/bada/audio.h
  A backends/platform/bada/bada.mk
  A backends/platform/bada/form.cpp
  A backends/platform/bada/form.h
  A backends/platform/bada/fs.cpp
  A backends/platform/bada/fs.h
  A backends/platform/bada/graphics.cpp
  A backends/platform/bada/graphics.h
  A backends/platform/bada/main.cpp
  A backends/platform/bada/missing.cpp
  A backends/platform/bada/portdefs.h
  A backends/platform/bada/sscanf.cpp
  A backends/platform/bada/system.cpp
  A backends/platform/bada/system.h
  A backends/timer/bada/timer.cpp
  A backends/timer/bada/timer.h
  A backends/updates/macosx/macosx-updates.h
  A backends/updates/macosx/macosx-updates.mm
  A common/localization.cpp
  A common/localization.h
  A common/updates.h
  A dists/bada/Icons/mainMenu1.png
  A dists/bada/Icons/mainMenu2.png
  A dists/bada/Icons/splash1.png
  A dists/bada/Icons/splash2.png
  A dists/bada/Res/scummmobile/THEMERC
  A dists/bada/Res/scummmobile/checkbox.bmp
  A dists/bada/Res/scummmobile/checkbox_empty.bmp
  A dists/bada/Res/scummmobile/clR6x12-iso-8859-2.fcc
  A dists/bada/Res/scummmobile/clR6x12-iso-8859-5.fcc
  A dists/bada/Res/scummmobile/cursor.bmp
  A dists/bada/Res/scummmobile/cursor_small.bmp
  A dists/bada/Res/scummmobile/fixed5x8-iso-8859-2.fcc
  A dists/bada/Res/scummmobile/fixed5x8-iso-8859-5.fcc
  A dists/bada/Res/scummmobile/helvB14-ASCII.fcc
  A dists/bada/Res/scummmobile/helvB14.bdf
  A dists/bada/Res/scummmobile/helvB18-ASCII.fcc
  A dists/bada/Res/scummmobile/helvB18.bdf
  A dists/bada/Res/scummmobile/helvB24-ASCII.fcc
  A dists/bada/Res/scummmobile/helvB24.bdf
  A dists/bada/Res/scummmobile/helvb12-iso-8859-1.fcc
  A dists/bada/Res/scummmobile/helvb12-iso-8859-2.fcc
  A dists/bada/Res/scummmobile/helvb12-iso-8859-5.fcc
  A dists/bada/Res/scummmobile/logo.bmp
  A dists/bada/Res/scummmobile/logo_small.bmp
  A dists/bada/Res/scummmobile/radiobutton.bmp
  A dists/bada/Res/scummmobile/radiobutton_empty.bmp
  A dists/bada/Res/scummmobile/scummmobile_gfx.stx
  A dists/bada/Res/scummmobile/scummmobile_layout.stx
  A dists/bada/Res/scummmobile/search.bmp
  A dists/bada/Res/vkeybd_bada/lowercase-symbols800x399.bmp
  A dists/bada/Res/vkeybd_bada/lowercase800x399.bmp
  A dists/bada/Res/vkeybd_bada/uppercase-symbols800x399.bmp
  A dists/bada/Res/vkeybd_bada/uppercase800x399.bmp
  A dists/bada/Res/vkeybd_bada/vkeybd_bada.xml
  A dists/macosx/scummvm_osx_appcast.xml
  A engines/agi/loader_v1.cpp
  A engines/agi/opcodes.cpp
  A engines/composer/composer.cpp
  A engines/composer/composer.h
  A engines/composer/detection.cpp
  A engines/composer/graphics.cpp
  A engines/composer/graphics.h
  A engines/composer/module.mk
  A engines/composer/resource.cpp
  A engines/composer/resource.h
  A engines/composer/scripting.cpp
  A engines/dreamweb/backdrop.cpp
  A engines/dreamweb/pathfind.cpp
  A engines/dreamweb/print.cpp
  A engines/dreamweb/saveload.cpp
  A engines/dreamweb/sprite.cpp
  A engines/dreamweb/vgagrafx.cpp
  A engines/gob/init_geisha.cpp
  A engines/gob/inter_geisha.cpp
  A engines/scumm/he/logic/baseball2001.cpp
  A engines/scumm/he/logic/basketball.cpp
  A engines/scumm/he/logic/football.cpp
  A engines/scumm/he/logic/funshop.cpp
  A engines/scumm/he/logic/moonbase.cpp
  A engines/scumm/he/logic/puttrace.cpp
  A engines/scumm/he/logic/soccer.cpp
  A engines/tsage/blue_force/blueforce_logic.cpp
  A engines/tsage/blue_force/blueforce_logic.h
  A engines/tsage/blue_force/blueforce_scenes0.cpp
  A engines/tsage/blue_force/blueforce_scenes0.h
  A engines/tsage/blue_force/blueforce_scenes1.cpp
  A engines/tsage/blue_force/blueforce_scenes1.h
  A engines/tsage/blue_force/blueforce_scenes3.cpp
  A engines/tsage/blue_force/blueforce_scenes3.h
  A engines/tsage/blue_force/blueforce_ui.cpp
  A engines/tsage/blue_force/blueforce_ui.h
  A engines/tsage/ringworld/ringworld_demo.cpp
  A engines/tsage/ringworld/ringworld_demo.h
  A engines/tsage/ringworld/ringworld_logic.cpp
  A engines/tsage/ringworld/ringworld_logic.h
  A engines/tsage/ringworld/ringworld_scenes1.cpp
  A engines/tsage/ringworld/ringworld_scenes1.h
  A engines/tsage/ringworld/ringworld_scenes10.cpp
  A engines/tsage/ringworld/ringworld_scenes10.h
  A engines/tsage/ringworld/ringworld_scenes2.cpp
  A engines/tsage/ringworld/ringworld_scenes2.h
  A engines/tsage/ringworld/ringworld_scenes3.cpp
  A engines/tsage/ringworld/ringworld_scenes3.h
  A engines/tsage/ringworld/ringworld_scenes4.cpp
  A engines/tsage/ringworld/ringworld_scenes4.h
  A engines/tsage/ringworld/ringworld_scenes5.cpp
  A engines/tsage/ringworld/ringworld_scenes5.h
  A engines/tsage/ringworld/ringworld_scenes6.cpp
  A engines/tsage/ringworld/ringworld_scenes6.h
  A engines/tsage/ringworld/ringworld_scenes8.cpp
  A engines/tsage/ringworld/ringworld_scenes8.h
  A graphics/cursor.h
  A test/common/math.h
  R audio/decoders/vag.cpp
  R audio/decoders/vag.h
  R engines/agi/preagi_common.h
  R engines/agi/preagi_common.cpp
  R engines/tsage/blueforce_logic.h
  R engines/tsage/blueforce_logic.cpp
  R engines/tsage/ringworld_demo.cpp
  R engines/tsage/ringworld_demo.h
  R engines/tsage/ringworld_logic.cpp
  R engines/tsage/ringworld_logic.h
  R engines/tsage/ringworld_scenes1.cpp
  R engines/tsage/ringworld_scenes1.h
  R engines/tsage/ringworld_scenes10.cpp
  R engines/tsage/ringworld_scenes10.h
  R engines/tsage/ringworld_scenes2.cpp
  R engines/tsage/ringworld_scenes2.h
  R engines/tsage/ringworld_scenes3.cpp
  R engines/tsage/ringworld_scenes3.h
  R engines/tsage/ringworld_scenes4.cpp
  R engines/tsage/ringworld_scenes4.h
  R engines/tsage/ringworld_scenes5.cpp
  R engines/tsage/ringworld_scenes5.h
  R engines/tsage/ringworld_scenes6.cpp
  R engines/tsage/ringworld_scenes6.h
  R engines/tsage/ringworld_scenes8.cpp
  R engines/tsage/ringworld_scenes8.h
    AUTHORS
    COPYING
    COPYING.LGPL
    Makefile
    NEWS
    README
    audio/audiostream.cpp
    audio/audiostream.h
    audio/decoders/aac.cpp
    audio/decoders/aac.h
    audio/decoders/adpcm.cpp
    audio/decoders/adpcm_intern.h
    audio/decoders/mp3.cpp
    audio/decoders/quicktime.cpp
    audio/decoders/quicktime.h
    audio/decoders/quicktime_intern.h
    audio/decoders/raw.cpp
    audio/decoders/vorbis.cpp
    audio/fmopl.cpp
    audio/fmopl.h
    audio/mididrv.cpp
    audio/mixer.cpp
    audio/mods/maxtrax.cpp
    audio/module.mk
    audio/mpu401.cpp
    audio/rate_arm.cpp
    audio/softsynth/appleiigs.cpp
    audio/softsynth/cms.cpp
    audio/softsynth/eas.cpp
    audio/softsynth/emumidi.h
    audio/softsynth/fmtowns_pc98/towns_audio.h
    audio/softsynth/fmtowns_pc98/towns_euphony.h
    audio/softsynth/fmtowns_pc98/towns_midi.h
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.h
    audio/softsynth/fmtowns_pc98/towns_pc98_fmsynth.h
    audio/softsynth/mt32.cpp
    audio/softsynth/mt32/mt32_file.cpp
    audio/softsynth/opl/dosbox.h
    audio/softsynth/opl/mame.cpp
    backends/base-backend.cpp
    backends/events/dinguxsdl/dinguxsdl-events.cpp
    backends/events/gph/gph-events.cpp
    backends/events/linuxmotosdl/linuxmotosdl-events.cpp
    backends/events/openpandora/op-events.cpp
    backends/events/ps3sdl/ps3sdl-events.cpp
    backends/events/sdl/sdl-events.cpp
    backends/events/sdl/sdl-events.h
    backends/events/symbiansdl/symbiansdl-events.cpp
    backends/events/symbiansdl/symbiansdl-events.h
    backends/events/webossdl/webossdl-events.cpp
    backends/events/wincesdl/wincesdl-events.cpp
    backends/events/wincesdl/wincesdl-events.h
    backends/fs/n64/n64-fs-factory.cpp
    backends/fs/n64/n64-fs.cpp
    backends/fs/n64/romfsstream.cpp
    backends/fs/stdiostream.cpp
    backends/fs/symbian/symbian-fs.cpp
    backends/fs/symbian/symbianstream.cpp
    backends/fs/wii/wii-fs-factory.cpp
    backends/fs/wii/wii-fs-factory.h
    backends/fs/wii/wii-fs.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.h
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/gph/gph-graphics.h
    backends/graphics/graphics.h
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
    backends/graphics/opengl/gltexture.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/openglsdl/openglsdl-graphics.h
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.h
    backends/graphics/symbiansdl/symbiansdl-graphics.cpp
    backends/graphics/symbiansdl/symbiansdl-graphics.h
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/log/log.cpp
    backends/log/log.h
    backends/mixer/symbiansdl/symbiansdl-mixer.cpp
    backends/mixer/symbiansdl/symbiansdl-mixer.h
    backends/mixer/wincesdl/wincesdl-mixer.cpp
    backends/mixer/wincesdl/wincesdl-mixer.h
    backends/module.mk
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/android.mk
    backends/platform/android/asset-archive.h
    backends/platform/android/events.cpp
    backends/platform/android/gfx.cpp
    backends/platform/android/jni.cpp
    backends/platform/android/jni.h
    backends/platform/android/module.mk
    backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
    backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
    backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
    backends/platform/android/org/inodes/gus/scummvm/Unpacker.java
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h
    backends/platform/dc/DCLauncherDialog.h
    backends/platform/dc/README
    backends/platform/dc/audio.cpp
    backends/platform/dc/cache.S
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/display.cpp
    backends/platform/dc/input.cpp
    backends/platform/dc/label.cpp
    backends/platform/dc/plugin_head.S
    backends/platform/dingux/README.DINGUX
    backends/platform/dingux/scummvm.gpe
    backends/platform/ds/arm7/source/libcartreset/cartreset.c
    backends/platform/ds/arm7/source/libcartreset/cartreset_nolibfat.h
    backends/platform/ds/arm7/source/main.cpp
    backends/platform/ds/arm9/dist/readme_ds.txt
    backends/platform/ds/arm9/source/dsoptions.cpp
    backends/platform/ds/arm9/source/fat/disc_io.h
    backends/platform/ds/arm9/source/fat/io_m3_common.c
    backends/platform/ds/arm9/source/fat/io_m3_common.h
    backends/platform/ds/arm9/source/fat/io_m3sd_asm.s
    backends/platform/ds/arm9/source/fat/io_njsd.c
    backends/platform/ds/arm9/source/fat/io_scsd.c
    backends/platform/ds/arm9/source/fat/io_scsd_asm.s
    backends/platform/ds/arm9/source/fat/io_sd_common.c
    backends/platform/ds/arm9/source/fat/m3sd.s
    backends/platform/ds/arm9/source/keys.cpp
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/scummhelp.cpp
    backends/platform/ds/ds.mk
    backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h
    backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s
    backends/platform/iphone/iphone_main.m
    backends/platform/iphone/iphone_video.m
    backends/platform/n64/Makefile
    backends/platform/n64/README.N64
    backends/platform/n64/framfs_save_manager.cpp
    backends/platform/n64/framfs_save_manager.h
    backends/platform/n64/n64.mk
    backends/platform/n64/nintendo64.cpp
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/n64/osys_n64_events.cpp
    backends/platform/n64/osys_n64_utilities.cpp
    backends/platform/n64/pad_rom.sh
    backends/platform/n64/pakfs_save_manager.cpp
    backends/platform/n64/pakfs_save_manager.h
    backends/platform/n64/portdefs.h
    backends/platform/openpandora/build/PXML_schema.xsd
    backends/platform/openpandora/build/runscummvm.sh
    backends/platform/ps2/DmaPipe.h
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Makefile.gdb
    backends/platform/ps2/Makefile.ps2
    backends/platform/ps2/asyncfio.cpp
    backends/platform/ps2/asyncfio.h
    backends/platform/ps2/eecodyvdfs.c
    backends/platform/ps2/eecodyvdfs.h
    backends/platform/ps2/iop/CoDyVDfs/iop/cdtypes.h
    backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.c
    backends/platform/ps2/iop/CoDyVDfs/iop/codyvdfs.h
    backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.c
    backends/platform/ps2/iop/CoDyVDfs/iop/fiofs.h
    backends/platform/ps2/iop/CoDyVDfs/iop/imports.lst
    backends/platform/ps2/iop/CoDyVDfs/iop/rpcfs.c
    backends/platform/ps2/iop/rpckbd/src/imports.lst
    backends/platform/ps2/irxboot.cpp
    backends/platform/ps2/irxboot.h
    backends/platform/ps2/ps2debug.cpp
    backends/platform/ps2/ps2debug.h
    backends/platform/ps2/ps2input.cpp
    backends/platform/ps2/ps2input.h
    backends/platform/ps2/ps2mutex.cpp
    backends/platform/ps2/ps2pad.cpp
    backends/platform/ps2/ps2pad.h
    backends/platform/ps2/rpckbd.c
    backends/platform/ps2/rpckbd.h
    backends/platform/ps2/sdlkeys.h
    backends/platform/psp/Makefile
    backends/platform/psp/README.PSP
    backends/platform/psp/README.PSP.in
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/dummy.cpp
    backends/platform/psp/image_viewer.cpp
    backends/platform/psp/image_viewer.h
    backends/platform/psp/input.cpp
    backends/platform/psp/memory.h
    backends/platform/psp/mp3.cpp
    backends/platform/psp/mp3.h
    backends/platform/psp/png_loader.cpp
    backends/platform/psp/png_loader.h
    backends/platform/psp/portdefs.h
    backends/platform/psp/pspkeyboard.cpp
    backends/platform/psp/rtc.cpp
    backends/platform/psp/thread.cpp
    backends/platform/psp/thread.h
    backends/platform/psp/trace.cpp
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/sdl.cpp
    backends/platform/sdl/sdl.h
    backends/platform/symbian/.placeholder
    backends/platform/symbian/BuildPackageUpload_AllVersions.pl
    backends/platform/symbian/README
    backends/platform/symbian/S60/scummvm-CVS-SymbianS60v2.pkg
    backends/platform/symbian/S60v3/ScummVM_Loc.rss
    backends/platform/symbian/S60v3/scummvm_A0000658_loc.rss
    backends/platform/symbian/S60v3/scummvm_A0000658_reg.rss
    backends/platform/symbian/S60v3/scummvm_reg.rss
    backends/platform/symbian/S80/ScummVM_S80.mmp.in
    backends/platform/symbian/S90/Scummvm_S90.mmp.in
    backends/platform/symbian/UIQ2/ScummVM.rss
    backends/platform/symbian/UIQ2/ScummVM_UIQ2.mmp.in
    backends/platform/symbian/UIQ2/scummvm-CVS-SymbianUIQ2_SE.pkg
    backends/platform/symbian/UIQ3/ScummVM.rss
    backends/platform/symbian/UIQ3/ScummVM_A0000658.rss
    backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss
    backends/platform/symbian/UIQ3/scummvm_A0000658_reg.rss
    backends/platform/symbian/UIQ3/scummvm_loc.rss
    backends/platform/symbian/UIQ3/scummvm_reg.rss
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/res/ScummVmAif.rss
    backends/platform/symbian/src/ScummApp.cpp
    backends/platform/symbian/src/ScummApp.h
    backends/platform/wii/gdb.txt
    backends/platform/wii/main.cpp
    backends/platform/wii/module.mk
    backends/platform/wii/options.cpp
    backends/platform/wii/options.h
    backends/platform/wii/osystem_events.cpp
    backends/platform/wii/osystem_gfx.cpp
    backends/platform/wii/osystem_sfx.cpp
    backends/platform/wii/wii.mk
    backends/platform/wince/CEScaler.cpp
    backends/platform/wince/CEgui/CEGUI.h
    backends/platform/wince/CEgui/PanelKeyboard.cpp
    backends/platform/wince/CEkeys/CEKeys.h
    backends/platform/wince/CEkeys/EventsBuffer.cpp
    backends/platform/wince/missing/assert.h
    backends/platform/wince/missing/io.h
    backends/plugins/ds/ds-provider.cpp
    backends/plugins/ds/ds-provider.h
    backends/plugins/elf/arm-loader.cpp
    backends/plugins/elf/arm-loader.h
    backends/plugins/elf/elf-loader.cpp
    backends/plugins/elf/elf-loader.h
    backends/plugins/elf/elf-provider.cpp
    backends/plugins/elf/elf-provider.h
    backends/plugins/elf/elf32.h
    backends/plugins/elf/memory-manager.cpp
    backends/plugins/elf/mips-loader.cpp
    backends/plugins/elf/mips-loader.h
    backends/plugins/elf/ppc-loader.cpp
    backends/plugins/elf/ppc-loader.h
    backends/plugins/elf/shorts-segment-manager.cpp
    backends/plugins/elf/shorts-segment-manager.h
    backends/plugins/elf/version.cpp
    backends/plugins/elf/version.h
    backends/plugins/ps2/ps2-provider.cpp
    backends/plugins/ps2/ps2-provider.h
    backends/plugins/psp/psp-provider.cpp
    backends/plugins/psp/psp-provider.h
    backends/plugins/wii/wii-provider.cpp
    backends/plugins/wii/wii-provider.h
    backends/saves/psp/psp-saves.cpp
    backends/taskbar/unity/unity-taskbar.cpp
    backends/taskbar/unity/unity-taskbar.h
    backends/taskbar/win32/mingw-compat.h
    backends/taskbar/win32/win32-taskbar.cpp
    backends/taskbar/win32/win32-taskbar.h
    backends/timer/default/default-timer.cpp
    backends/timer/default/default-timer.h
    backends/vkeybd/virtual-keyboard.cpp
    base/main.cpp
    base/plugins.cpp
    base/version.cpp
    common/EventDispatcher.cpp
    common/EventRecorder.cpp
    common/EventRecorder.h
    common/algorithm.h
    common/archive.cpp
    common/archive.h
    common/array.h
    common/config-file.cpp
    common/config-file.h
    common/config-manager.cpp
    common/config-manager.h
    common/dcl.cpp
    common/dcl.h
    common/events.h
    common/file.cpp
    common/file.h
    common/fs.cpp
    common/func.h
    common/huffman.h
    common/iff_container.cpp
    common/iff_container.h
    common/keyboard.h
    common/math.h
    common/memorypool.cpp
    common/module.mk
    common/ptr.h
    common/quicktime.cpp
    common/quicktime.h
    common/rational.cpp
    common/serializer.h
    common/str.h
    common/stream.cpp
    common/substream.h
    common/system.cpp
    common/system.h
    common/taskbar.h
    common/timer.h
    common/tokenizer.cpp
    common/translation.cpp
    common/unarj.cpp
    common/unzip.cpp
    common/util.cpp
    common/util.h
    common/winexe_pe.cpp
    common/xmlparser.cpp
    common/xmlparser.h
    common/zlib.cpp
    configure
    devtools/create_hugo/README
    devtools/create_hugo/dists/msvc10/create_hugo.vcxproj
    devtools/create_hugo/staticdata.h
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/create_kyradat.h
    devtools/create_kyradat/extract.cpp
    devtools/create_kyradat/extract.h
    devtools/create_kyradat/games.cpp
    devtools/create_kyradat/search.cpp
    devtools/create_kyradat/search.h
    devtools/create_kyradat/tables.cpp
    devtools/create_kyradat/tables.h
    devtools/create_kyradat/util.cpp
    devtools/create_mads/main.cpp
    devtools/create_mads/scripts/rex_nebular.txt
    devtools/create_project/msvc10/create_project.vcxproj.filters
    devtools/create_toon/create_toon.cpp
    devtools/create_toon/staticdata.h
    devtools/credits.pl
    devtools/sci/musicplayer.cpp
    devtools/sci/scitrace.asm
    devtools/scumm-md5.txt
    devtools/skycpt/KmpSearch.h
    devtools/skycpt/skycpt-engine.patch
    devtools/tasmrecover/.gitignore
    devtools/tasmrecover/dreamweb/backdrop.asm
    devtools/tasmrecover/dreamweb/dreamweb.asm
    devtools/tasmrecover/dreamweb/keypad.asm
    devtools/tasmrecover/dreamweb/look.asm
    devtools/tasmrecover/dreamweb/monitor.asm
    devtools/tasmrecover/dreamweb/newplace.asm
    devtools/tasmrecover/dreamweb/object.asm
    devtools/tasmrecover/dreamweb/saveload.asm
    devtools/tasmrecover/dreamweb/sblaster.asm
    devtools/tasmrecover/dreamweb/sprite.asm
    devtools/tasmrecover/dreamweb/talk.asm
    devtools/tasmrecover/dreamweb/titles.asm
    devtools/tasmrecover/dreamweb/use.asm
    devtools/tasmrecover/dreamweb/vars.asm
    devtools/tasmrecover/dreamweb/vgafades.asm
    devtools/tasmrecover/dreamweb/vgagrafx.asm
    devtools/tasmrecover/tasm-recover
    devtools/tasmrecover/tasm/cpp.py
    devtools/tasmrecover/tasm/op.py
    devtools/themeparser.py
    dists/android/AndroidManifest.xml
    dists/android/AndroidManifest.xml.in
    dists/android/README.Android
    dists/android/mkplugin.sh
    dists/android/plugin-manifest.xml
    dists/android/plugin-manifest.xml.in
    dists/android/plugin-strings.xml
    dists/android/res/layout/main.xml
    dists/engine-data/README
    dists/engine-data/kyra.dat
    dists/macosx/Info.plist
    dists/macosx/Info.plist.in
    dists/maemo/scummvm.servicewrapper
    dists/motomagx/mgx/readme-motomagx-mgx.txt
    dists/motomagx/mgx/scummvm.cfg
    dists/motomagx/pep/description.ini
    dists/os2/readme.os2
    dists/redhat/scummvm.spec
    dists/redhat/scummvm.spec.in
    dists/wii/READMII
    dists/wii/meta.xml
    dists/wii/meta.xml.in
    dists/win32/ScummVM.iss
    dists/win32/scummvm.gdf.xml
    doc/QuickStart
    doc/de/Liesmich
    doc/de/Schnellstart
    doc/fr/QuickStart_fr
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/checks.cpp
    engines/agi/console.cpp
    engines/agi/console.h
    engines/agi/cycle.cpp
    engines/agi/detection.cpp
    engines/agi/detection_tables.h
    engines/agi/id.cpp
    engines/agi/keyboard.cpp
    engines/agi/module.mk
    engines/agi/motion.cpp
    engines/agi/objects.cpp
    engines/agi/op_cmd.cpp
    engines/agi/op_dbg.cpp
    engines/agi/op_test.cpp
    engines/agi/opcodes.h
    engines/agi/preagi.cpp
    engines/agi/preagi.h
    engines/agi/preagi_mickey.cpp
    engines/agi/preagi_mickey.h
    engines/agi/preagi_troll.cpp
    engines/agi/preagi_troll.h
    engines/agi/preagi_winnie.cpp
    engines/agi/preagi_winnie.h
    engines/agi/saveload.cpp
    engines/agi/sound.cpp
    engines/agi/sound.h
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agi/sound_coco3.cpp
    engines/agi/sound_coco3.h
    engines/agi/sound_midi.cpp
    engines/agi/sound_midi.h
    engines/agi/sound_pcjr.cpp
    engines/agi/sound_pcjr.h
    engines/agi/sound_sarien.cpp
    engines/agi/sound_sarien.h
    engines/agi/sprite.cpp
    engines/agi/view.cpp
    engines/agi/view.h
    engines/agi/words.cpp
    engines/agos/agos.cpp
    engines/agos/agos.h
    engines/agos/charset-fontdata.cpp
    engines/agos/charset.cpp
    engines/agos/contain.cpp
    engines/agos/cursor.cpp
    engines/agos/debug.cpp
    engines/agos/debug.h
    engines/agos/debugger.cpp
    engines/agos/detection_tables.h
    engines/agos/draw.cpp
    engines/agos/event.cpp
    engines/agos/gfx.cpp
    engines/agos/icons.cpp
    engines/agos/input.cpp
    engines/agos/input_pn.cpp
    engines/agos/items.cpp
    engines/agos/menus.cpp
    engines/agos/midi.cpp
    engines/agos/midiparser_s1d.cpp
    engines/agos/oracle.cpp
    engines/agos/res_ami.cpp
    engines/agos/res_snd.cpp
    engines/agos/rooms.cpp
    engines/agos/saveload.cpp
    engines/agos/script.cpp
    engines/agos/script_dp.cpp
    engines/agos/script_pn.cpp
    engines/agos/script_s1.cpp
    engines/agos/script_s2.cpp
    engines/agos/script_ww.cpp
    engines/agos/sound.cpp
    engines/agos/sound.h
    engines/agos/verb.cpp
    engines/agos/vga.cpp
    engines/agos/vga_e2.cpp
    engines/agos/vga_s2.cpp
    engines/agos/window.cpp
    engines/agos/zones.cpp
    engines/cruise/cruise.h
    engines/cruise/cruise_main.cpp
    engines/cruise/module.mk
    engines/cruise/saveload.cpp
    engines/cruise/sound.cpp
    engines/cruise/sound.h
    engines/dialogs.cpp
    engines/draci/saveload.cpp
    engines/drascula/drascula.h
    engines/drascula/resource.cpp
    engines/drascula/saveload.cpp
    engines/dreamweb/detection.cpp
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/module.mk
    engines/dreamweb/runtime.h
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp
    engines/dreamweb/stubs.h
    engines/engine.cpp
    engines/engines.mk
    engines/gob/console.cpp
    engines/gob/console.h
    engines/gob/dataio.cpp
    engines/gob/dataio.h
    engines/gob/detection_tables.h
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/game.cpp
    engines/gob/gob.cpp
    engines/gob/init.h
    engines/gob/init_v1.cpp
    engines/gob/init_v2.cpp
    engines/gob/inter.h
    engines/gob/inter_v1.cpp
    engines/gob/inter_v3.cpp
    engines/gob/module.mk
    engines/gob/palanim.cpp
    engines/gob/scenery.cpp
    engines/groovie/groovie.cpp
    engines/groovie/music.cpp
    engines/groovie/music.h
    engines/groovie/script.cpp
    engines/hugo/detection.cpp
    engines/hugo/display.cpp
    engines/hugo/file.cpp
    engines/hugo/file_v1d.cpp
    engines/hugo/file_v1w.cpp
    engines/hugo/file_v2d.cpp
    engines/hugo/file_v2w.cpp
    engines/hugo/file_v3d.cpp
    engines/hugo/intro.cpp
    engines/hugo/schedule.cpp
    engines/hugo/sound.cpp
    engines/hugo/sound.h
    engines/kyra/animator_hof.cpp
    engines/kyra/animator_lok.cpp
    engines/kyra/animator_lok.h
    engines/kyra/animator_mr.cpp
    engines/kyra/animator_v2.cpp
    engines/kyra/debugger.cpp
    engines/kyra/debugger.h
    engines/kyra/detection.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui.cpp
    engines/kyra/gui.h
    engines/kyra/gui_hof.cpp
    engines/kyra/gui_hof.h
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_lok.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_lol.h
    engines/kyra/gui_mr.cpp
    engines/kyra/gui_mr.h
    engines/kyra/gui_v2.cpp
    engines/kyra/gui_v2.h
    engines/kyra/item.h
    engines/kyra/items_hof.cpp
    engines/kyra/items_lok.cpp
    engines/kyra/items_lol.cpp
    engines/kyra/items_mr.cpp
    engines/kyra/items_v2.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_hof.h
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_lok.h
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_mr.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/kyra_v2.cpp
    engines/kyra/kyra_v2.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/resource.cpp
    engines/kyra/resource.h
    engines/kyra/saveload.cpp
    engines/kyra/saveload_hof.cpp
    engines/kyra/saveload_lok.cpp
    engines/kyra/saveload_lol.cpp
    engines/kyra/saveload_mr.cpp
    engines/kyra/scene_hof.cpp
    engines/kyra/scene_lok.cpp
    engines/kyra/scene_lol.cpp
    engines/kyra/scene_mr.cpp
    engines/kyra/scene_v2.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen.h
    engines/kyra/screen_hof.cpp
    engines/kyra/screen_hof.h
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_lol.h
    engines/kyra/screen_v2.cpp
    engines/kyra/screen_v2.h
    engines/kyra/script.cpp
    engines/kyra/script.h
    engines/kyra/script_hof.cpp
    engines/kyra/script_lok.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_tim.cpp
    engines/kyra/script_tim.h
    engines/kyra/script_v1.cpp
    engines/kyra/script_v2.cpp
    engines/kyra/seqplayer.cpp
    engines/kyra/seqplayer.h
    engines/kyra/sequences_hof.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sequences_mr.cpp
    engines/kyra/sequences_v2.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_adlib.h
    engines/kyra/sound_amiga.cpp
    engines/kyra/sound_digital.cpp
    engines/kyra/sound_lol.cpp
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_pcspk.cpp
    engines/kyra/sound_towns.cpp
    engines/kyra/sprites.cpp
    engines/kyra/sprites.h
    engines/kyra/sprites_lol.cpp
    engines/kyra/staticres.cpp
    engines/kyra/staticres_lol.cpp
    engines/kyra/text.h
    engines/kyra/text_hof.h
    engines/kyra/text_lol.cpp
    engines/kyra/text_lol.h
    engines/kyra/text_mr.cpp
    engines/kyra/timer.h
    engines/kyra/timer_lok.cpp
    engines/kyra/timer_lol.cpp
    engines/kyra/util.cpp
    engines/kyra/util.h
    engines/kyra/wsamovie.cpp
    engines/kyra/wsamovie.h
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/lastexpress.h
    engines/lastexpress/module.mk
    engines/lure/module.mk
    engines/lure/sound.h
    engines/m4/converse.cpp
    engines/m4/globals.cpp
    engines/m4/globals.h
    engines/m4/m4.h
    engines/m4/mads_logic.cpp
    engines/m4/midi.h
    engines/m4/saveload.cpp
    engines/m4/scripttab.h
    engines/made/detection.cpp
    engines/mohawk/console.cpp
    engines/mohawk/cstime.h
    engines/mohawk/cursors.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/dialogs.cpp
    engines/mohawk/dialogs.h
    engines/mohawk/graphics.cpp
    engines/mohawk/graphics.h
    engines/mohawk/livingbooks.h
    engines/mohawk/mohawk.cpp
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_scripts.cpp
    engines/mohawk/myst_stacks/demo.cpp
    engines/mohawk/myst_stacks/demo.h
    engines/mohawk/myst_stacks/myst.h
    engines/mohawk/myst_stacks/preview.cpp
    engines/mohawk/myst_stacks/preview.h
    engines/mohawk/myst_stacks/slides.cpp
    engines/mohawk/myst_stacks/slides.h
    engines/mohawk/myst_state.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_external.cpp
    engines/mohawk/riven_vars.cpp
    engines/mohawk/sound.cpp
    engines/mohawk/sound.h
    engines/parallaction/graphics.h
    engines/parallaction/gui_br.cpp
    engines/parallaction/sound.h
    engines/parallaction/walk.cpp
    engines/queen/command.h
    engines/queen/credits.cpp
    engines/saga/detection.cpp
    engines/saga/detection_tables.h
    engines/saga/input.cpp
    engines/saga/interface.cpp
    engines/saga/music.cpp
    engines/saga/palanim.h
    engines/saga/puzzle.cpp
    engines/saga/render.cpp
    engines/saga/saga.h
    engines/saga/saveload.cpp
    engines/saga/shorten.cpp
    engines/saga/shorten.h
    engines/saga/sthread.cpp
    engines/savestate.cpp
    engines/sci/decompressor.h
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/kstring.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/screen.cpp
    engines/sci/parser/said.cpp
    engines/sci/resource.cpp
    engines/sci/sound/drivers/cms.cpp
    engines/sci/sound/midiparser_sci.cpp
    engines/sci/sound/soundcmd.cpp
    engines/sci/sound/soundcmd.h
    engines/scumm/cursor.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/dialogs.cpp
    engines/scumm/gfx.cpp
    engines/scumm/he/intern_he.h
    engines/scumm/he/logic_he.cpp
    engines/scumm/he/logic_he.h
    engines/scumm/he/script_v100he.cpp
    engines/scumm/he/script_v72he.cpp
    engines/scumm/he/script_v80he.cpp
    engines/scumm/he/sprite_he.cpp
    engines/scumm/he/sprite_he.h
    engines/scumm/he/wiz_he.cpp
    engines/scumm/help.cpp
    engines/scumm/help.h
    engines/scumm/imuse/pcspk.cpp
    engines/scumm/imuse/pcspk.h
    engines/scumm/imuse/sysex.h
    engines/scumm/imuse_digi/dimuse.cpp
    engines/scumm/input.cpp
    engines/scumm/insane/insane_enemy.cpp
    engines/scumm/insane/insane_iact.cpp
    engines/scumm/insane/insane_scenes.cpp
    engines/scumm/module.mk
    engines/scumm/palette.cpp
    engines/scumm/player_v2.h
    engines/scumm/player_v2base.h
    engines/scumm/player_v2cms.cpp
    engines/scumm/player_v2cms.h
    engines/scumm/saveload.cpp
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/smush/channel.cpp
    engines/scumm/smush/codec37.cpp
    engines/scumm/smush/smush_font.cpp
    engines/scumm/sound.cpp
    engines/scumm/sound.h
    engines/scumm/string.cpp
    engines/scumm/vars.cpp
    engines/sky/autoroute.h
    engines/sword1/control.h
    engines/sword1/debug.h
    engines/sword1/detection.cpp
    engines/sword1/music.cpp
    engines/sword1/music.h
    engines/sword1/object.h
    engines/sword1/screen.h
    engines/sword1/sound.cpp
    engines/sword2/music.cpp
    engines/sword2/sound.cpp
    engines/sword25/detection.cpp
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/util/lua/lapi.cpp
    engines/sword25/util/lua/lauxlib.cpp
    engines/sword25/util/lua/lauxlib.h
    engines/sword25/util/lua/lbaselib.cpp
    engines/sword25/util/lua/lcode.cpp
    engines/sword25/util/lua/ldblib.cpp
    engines/sword25/util/lua/ldebug.cpp
    engines/sword25/util/lua/ldo.cpp
    engines/sword25/util/lua/ldo.h
    engines/sword25/util/lua/lfunc.cpp
    engines/sword25/util/lua/lgc.cpp
    engines/sword25/util/lua/linit.cpp
    engines/sword25/util/lua/liolib.cpp
    engines/sword25/util/lua/llex.cpp
    engines/sword25/util/lua/lmathlib.cpp
    engines/sword25/util/lua/lmem.cpp
    engines/sword25/util/lua/lmem.h
    engines/sword25/util/lua/loadlib.cpp
    engines/sword25/util/lua/lobject.h
    engines/sword25/util/lua/lopcodes.cpp
    engines/sword25/util/lua/loslib.cpp
    engines/sword25/util/lua/lstate.cpp
    engines/sword25/util/lua/lstate.h
    engines/sword25/util/lua/lstring.cpp
    engines/sword25/util/lua/lstrlib.cpp
    engines/sword25/util/lua/ltablib.cpp
    engines/sword25/util/lua/ltm.cpp
    engines/sword25/util/lua/luaconf.h
    engines/sword25/util/lua/lvm.cpp
    engines/sword25/util/lua/lzio.cpp
    engines/sword25/util/pluto/CHANGELOG
    engines/sword25/util/pluto/FILEFORMAT
    engines/sword25/util/pluto/THANKS
    engines/sword25/util/pluto/plzio.cpp
    engines/teenagent/animation.cpp
    engines/teenagent/animation.h
    engines/teenagent/detection.cpp
    engines/teenagent/font.h
    engines/teenagent/inventory.cpp
    engines/teenagent/scene.cpp
    engines/teenagent/surface.cpp
    engines/teenagent/surface.h
    engines/teenagent/surface_list.cpp
    engines/teenagent/surface_list.h
    engines/teenagent/teenagent.cpp
    engines/testbed/misc.cpp
    engines/tinsel/adpcm.cpp
    engines/tinsel/coroutine.cpp
    engines/tinsel/detection.cpp
    engines/tinsel/detection_tables.h
    engines/tinsel/saveload.cpp
    engines/tinsel/sound.cpp
    engines/tinsel/strres.h
    engines/tinsel/tinsel.h
    engines/toon/audio.cpp
    engines/toon/character.cpp
    engines/toon/detection.cpp
    engines/toon/drew.cpp
    engines/toon/hotspot.cpp
    engines/toon/path.cpp
    engines/toon/path.h
    engines/toon/script.cpp
    engines/toon/script.h
    engines/tsage/converse.cpp
    engines/tsage/converse.h
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/debugger.h
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/dialogs.h
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/module.mk
    engines/tsage/resources.cpp
    engines/tsage/resources.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/scenes.h
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/fonts/bdf.cpp
    graphics/fonts/bdf.h
    graphics/imagedec.h
    graphics/maccursor.h
    graphics/primitives.h
    graphics/scaler/aspect.cpp
    graphics/scaler/hq2x_i386.asm
    graphics/scaler/hq3x_i386.asm
    graphics/scaler/scale2x.cpp
    graphics/scaler/scale2x.h
    graphics/scaler/scale3x.cpp
    graphics/scaler/scale3x.h
    graphics/scaler/scalebit.cpp
    graphics/scaler/scalebit.h
    graphics/scaler/thumbnail_intern.cpp
    graphics/sjis.cpp
    graphics/sjis.h
    graphics/surface.cpp
    graphics/thumbnail.cpp
    graphics/thumbnail.h
    graphics/wincursor.cpp
    graphics/wincursor.h
    graphics/yuv_to_rgb.cpp
    graphics/yuv_to_rgb.h
    gui/credits.h
    gui/launcher.cpp
    gui/themebrowser.cpp
    gui/themebrowser.h
    gui/themes/fonts/topaz/README.ScummVM
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    gui/widgets/scrollbar.cpp
    icons/scummvm.svg
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/module.mk
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    test/README
    test/audio/audiostream.h
    test/audio/helper.h
    test/common/algorithm.h
    test/common/fixedstack.h
    test/common/queue.h
    test/common/stack.h
    test/common/tokenizer.h
    test/cxxtest/COPYING
    test/cxxtest/TODO
    test/cxxtest/cxxtest.spec
    test/cxxtest/cxxtest/Descriptions.h
    test/cxxtest/cxxtest/DummyDescriptions.cpp
    test/cxxtest/cxxtest/DummyDescriptions.h
    test/cxxtest/cxxtest/GlobalFixture.cpp
    test/cxxtest/cxxtest/GlobalFixture.h
    test/cxxtest/cxxtest/LinkedList.h
    test/cxxtest/cxxtest/RealDescriptions.cpp
    test/cxxtest/cxxtest/RealDescriptions.h
    test/cxxtest/docs/guide.html
    test/cxxtest/sample/Construct
    test/cxxtest/sample/aborter.tpl
    test/cxxtest/sample/file_printer.tpl
    test/cxxtest/sample/mock/Dice.cpp
    test/cxxtest/sample/mock/Dice.h
    test/cxxtest/sample/msvc/CxxTest_Workspace.dsw
    test/cxxtest/sample/only.tpl
    test/cxxtest/sample/winddk/SOURCES
    video/bink_decoder.cpp





Commit: 8263f5a7b576718a3f4e04980fe5a08fb02d4788
    https://github.com/scummvm/scummvm/commit/8263f5a7b576718a3f4e04980fe5a08fb02d4788
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-01T08:44:20-07:00

Commit Message:
PEGASUS: Implement basic neighborhood resource parsing

Changed paths:
  A engines/pegasus/neighborhood/door.cpp
  A engines/pegasus/neighborhood/door.h
  A engines/pegasus/neighborhood/exit.cpp
  A engines/pegasus/neighborhood/exit.h
  A engines/pegasus/neighborhood/extra.cpp
  A engines/pegasus/neighborhood/extra.h
  A engines/pegasus/neighborhood/hotspot.cpp
  A engines/pegasus/neighborhood/hotspot.h
  A engines/pegasus/neighborhood/neighborhood.cpp
  A engines/pegasus/neighborhood/neighborhood.h
  A engines/pegasus/neighborhood/spot.cpp
  A engines/pegasus/neighborhood/spot.h
  A engines/pegasus/neighborhood/turn.cpp
  A engines/pegasus/neighborhood/turn.h
  A engines/pegasus/neighborhood/view.cpp
  A engines/pegasus/neighborhood/view.h
  A engines/pegasus/neighborhood/zoom.cpp
  A engines/pegasus/neighborhood/zoom.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index ca5017b..af79e7c 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -20,7 +20,16 @@ MODULE_OBJS = \
 	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMTimeValue.o \
-	MMShell/Utilities/MMUtilities.o
+	MMShell/Utilities/MMUtilities.o \
+	neighborhood/door.o \
+	neighborhood/exit.o \
+	neighborhood/extra.o \
+	neighborhood/hotspot.o \
+	neighborhood/neighborhood.o \
+	neighborhood/spot.o \
+	neighborhood/turn.o \
+	neighborhood/view.o \
+	neighborhood/zoom.o
 
 
 # This module can be built as a plugin
diff --git a/engines/pegasus/neighborhood/door.cpp b/engines/pegasus/neighborhood/door.cpp
new file mode 100755
index 0000000..82c83f1
--- /dev/null
+++ b/engines/pegasus/neighborhood/door.cpp
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/door.h"
+
+namespace Pegasus {
+
+void DoorTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		_entries[i].altCode = stream->readByte();
+		_entries[i].movieStart = stream->readUint32BE();
+		_entries[i].movieEnd = stream->readUint32BE();
+		_entries[i].flags = stream->readByte();
+		stream->readByte(); // alignment
+		debug(0, "Door[%d]: %d %d %d %d %d %d", i, _entries[i].room, _entries[i].direction,
+				_entries[i].altCode, _entries[i].movieStart, _entries[i].movieEnd,
+				_entries[i].flags);
+	}
+}
+
+void DoorTable::clear() {
+	_entries.clear();
+}
+
+DoorTable::Entry DoorTable::findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
new file mode 100755
index 0000000..3aa8db6
--- /dev/null
+++ b/engines/pegasus/neighborhood/door.h
@@ -0,0 +1,82 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_DOOR_H
+#define PEGASUS_NEIGHBORHOOD_DOOR_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+typedef tMM8BitFlags tDoorFlags;
+
+enum {
+	kDoorPresentBit,				//	Bit set if there is a door here.
+	kDoorLockedBit					//	Bit set if door is locked, clear if unlocked.
+};
+
+const tDoorFlags kNoDoorFlags = 0;
+const tDoorFlags kDoorPresentMask = 1 << kDoorPresentBit;
+const tDoorFlags kDoorLockedMask = 1 << kDoorLockedBit;
+
+class DoorTable {
+public:
+	DoorTable() {}
+	~DoorTable() {}
+
+	static const uint32 getResTag() { return MKTAG('D', 'o', 'o', 'r'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { movieStart = 0xffffffff; }
+		bool isEmpty() { return movieStart == 0xffffffff; }
+
+		tRoomID room;
+		tDirectionConstant direction;
+		tAlternateID altCode;
+		TimeValue movieStart;
+		TimeValue movieEnd;
+		tDoorFlags flags;
+	};
+
+	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
+
diff --git a/engines/pegasus/neighborhood/exit.cpp b/engines/pegasus/neighborhood/exit.cpp
new file mode 100755
index 0000000..ce3fe9d
--- /dev/null
+++ b/engines/pegasus/neighborhood/exit.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/exit.h"
+
+namespace Pegasus {
+
+void ExitTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		_entries[i].altCode = stream->readByte();
+		_entries[i].movieStart = stream->readUint32BE();
+		_entries[i].movieEnd = stream->readUint32BE();
+		_entries[i].exitEnd = stream->readUint32BE();
+		_entries[i].exitLoop = stream->readUint32BE();
+		_entries[i].exitRoom = stream->readUint32BE();
+		_entries[i].exitDirection = stream->readByte();
+		stream->readByte(); // alignment
+
+		_entries[i].originalEnd = _entries[i].exitEnd;
+
+		debug(0, "Exit[%d]: %d %d %d %d %d %d %d %d %d", i, _entries[i].room, _entries[i].direction,
+				_entries[i].altCode, _entries[i].movieStart, _entries[i].movieEnd, _entries[i].exitEnd,
+				_entries[i].exitLoop, _entries[i].exitRoom, _entries[i].exitDirection);
+	}
+}
+
+void ExitTable::clear() {
+	_entries.clear();
+}
+
+ExitTable::Entry ExitTable::findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
new file mode 100755
index 0000000..03bf52d
--- /dev/null
+++ b/engines/pegasus/neighborhood/exit.h
@@ -0,0 +1,77 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_EXIT_H
+#define PEGASUS_NEIGHBORHOOD_EXIT_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class ExitTable {
+public:
+	ExitTable() {}
+	~ExitTable() {}
+
+	static const uint32 getResTag() { return MKTAG('E', 'x', 'i', 't'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { movieStart = 0xffffffff; }
+		bool isEmpty() { return movieStart == 0xffffffff; }
+
+		tRoomID room;
+		tDirectionConstant direction;
+		tAlternateID altCode;
+		TimeValue movieStart;
+		TimeValue movieEnd;
+		//	fExitEnd is the end of the optimized run of walks.
+		TimeValue exitEnd;
+		TimeValue originalEnd;
+		//	fExitLoop is the loop start time of the optimized run of walks if the run
+		//	loops back on itself (so far, only in TSA).
+		TimeValue exitLoop;
+		tRoomID exitRoom;
+		tDirectionConstant exitDirection;
+	};
+
+	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/extra.cpp b/engines/pegasus/neighborhood/extra.cpp
new file mode 100755
index 0000000..44235ff
--- /dev/null
+++ b/engines/pegasus/neighborhood/extra.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/extra.h"
+
+namespace Pegasus {
+
+void ExtraTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].extra = stream->readUint32BE();
+		_entries[i].movieStart = stream->readUint32BE();
+		_entries[i].movieEnd = stream->readUint32BE();
+		debug(0, "Extra[%d]: %d %d %d", i, _entries[i].extra, _entries[i].movieStart, _entries[i].movieEnd);
+	}
+}
+
+void ExtraTable::clear() {
+	_entries.clear();
+}
+
+ExtraTable::Entry ExtraTable::findEntry(tExtraID extra) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].extra == extra)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/extra.h b/engines/pegasus/neighborhood/extra.h
new file mode 100755
index 0000000..3658fbd
--- /dev/null
+++ b/engines/pegasus/neighborhood/extra.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_EXTRA_H
+#define PEGASUS_NEIGHBORHOOD_EXTRA_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class ExtraTable {
+public:
+	ExtraTable() {}
+	~ExtraTable() {}
+
+	static const uint32 getResTag() { return MKTAG('X', 't', 'r', 'a'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { movieStart = 0xffffffff; }
+		bool isEmpty() { return movieStart == 0xffffffff; }
+
+		tExtraID extra;
+		TimeValue movieStart;
+		TimeValue movieEnd;
+	};
+
+	Entry findEntry(tExtraID extra);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/hotspot.cpp b/engines/pegasus/neighborhood/hotspot.cpp
new file mode 100755
index 0000000..16af1a6
--- /dev/null
+++ b/engines/pegasus/neighborhood/hotspot.cpp
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/hotspot.h"
+
+namespace Pegasus {
+
+void HotspotTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].hotspot = stream->readUint16BE();
+		_entries[i].hotspotActivation = stream->readSByte();
+		stream->readByte(); // alignment
+		_entries[i].hotspotRoom = stream->readUint16BE();
+		_entries[i].hotspotDirection = stream->readByte();
+		stream->readByte(); // alignment
+		_entries[i].hotspotExtra = stream->readUint32BE();
+		_entries[i].hotspotItem = stream->readUint16BE();
+		debug(0, "Hotspot[%d]: %d %d %d %d %d %d", i, _entries[i].hotspot, _entries[i].hotspotActivation,
+				_entries[i].hotspotRoom, _entries[i].hotspotDirection, _entries[i].hotspotExtra,
+				_entries[i].hotspotItem);
+	}
+}
+
+void HotspotTable::clear() {
+	_entries.clear();
+}
+
+HotspotTable::Entry HotspotTable::findEntry(tHotSpotID hotspot) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].hotspot == hotspot)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/hotspot.h b/engines/pegasus/neighborhood/hotspot.h
new file mode 100755
index 0000000..ea7f3bb
--- /dev/null
+++ b/engines/pegasus/neighborhood/hotspot.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_HOTSPOT_H
+#define PEGASUS_NEIGHBORHOOD_HOTSPOT_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class HotspotTable {
+public:
+	HotspotTable() {}
+	~HotspotTable() {}
+
+	static const uint32 getResTag() { return MKTAG('H', 'S', 'I', 'n'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { hotspotRoom = kNoRoomID; }
+		bool isEmpty() { return hotspotRoom == kNoRoomID; }
+
+		tHotSpotID hotspot;
+		tHotSpotActivationID hotspotActivation;
+		//	Location hot spot lives in:
+		tRoomID hotspotRoom;
+		tDirectionConstant hotspotDirection;
+		//	Extra to play if this is a "play extra" hot spot.
+		tExtraID hotspotExtra;
+		//	Item corresponding to this hot spot if it is an item-related hot spot.
+		tItemID hotspotItem;
+	};
+
+	Entry findEntry(tHotSpotID hotspot);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
new file mode 100644
index 0000000..291c0a9
--- /dev/null
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName) : _vm(vm), _resName(resName) {
+}
+
+Neighborhood::~Neighborhood() {
+}
+
+void Neighborhood::init() {
+	debug(0, "Loading '%s' neighborhood resources", _resName.c_str());
+
+	Common::SeekableReadStream *stream = _vm->_resFork->getResource(_doorTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load doors");
+	_doorTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_exitTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load exits");
+	_exitTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_extraTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load extras");
+	_extraTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_hotspotTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load hotspots");
+	_hotspotTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_spotTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load spots");
+	_spotTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_turnTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load turns");
+	_turnTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_viewTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load views");
+	_viewTable.loadFromStream(stream);
+	delete stream;
+
+	stream = _vm->_resFork->getResource(_zoomTable.getResTag(), _resName);
+	if (!stream)
+		error("Failed to load zooms");
+	_zoomTable.loadFromStream(stream);
+	delete stream;
+
+	// TODO: AI, movies, notifications, buncha other stuff
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
new file mode 100644
index 0000000..d70628e
--- /dev/null
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_H
+#define PEGASUS_NEIGHBORHOOD_H
+
+#include "common/str.h"
+
+#include "pegasus/neighborhood/door.h"
+#include "pegasus/neighborhood/exit.h"
+#include "pegasus/neighborhood/extra.h"
+#include "pegasus/neighborhood/hotspot.h"
+#include "pegasus/neighborhood/spot.h"
+#include "pegasus/neighborhood/turn.h"
+#include "pegasus/neighborhood/view.h"
+#include "pegasus/neighborhood/zoom.h"
+
+namespace Pegasus {
+
+class PegasusEngine;
+
+class Neighborhood {
+public:
+	Neighborhood(PegasusEngine *vm, const Common::String &resName);
+	virtual ~Neighborhood();
+
+	virtual void init();
+
+private:
+	PegasusEngine *_vm;
+	Common::String _resName;
+
+	DoorTable _doorTable;
+	ExitTable _exitTable;
+	ExtraTable _extraTable;
+	HotspotTable _hotspotTable;
+	SpotTable _spotTable;
+	TurnTable _turnTable;
+	ViewTable _viewTable;
+	ZoomTable _zoomTable;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/spot.cpp b/engines/pegasus/neighborhood/spot.cpp
new file mode 100755
index 0000000..9ccdfd2
--- /dev/null
+++ b/engines/pegasus/neighborhood/spot.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/spot.h"
+
+namespace Pegasus {
+
+void SpotTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		_entries[i].srcFlags = stream->readByte();
+		_entries[i].altCode = stream->readByte();
+		stream->readByte(); // alignment
+		_entries[i].movieStart = stream->readUint32BE();
+		_entries[i].movieEnd = stream->readUint32BE();
+		_entries[i].dstFlags = stream->readByte();
+		stream->readByte(); // alignment
+		debug(0, "Spot[%d]: %d %d %d %d %d %d %d", i, _entries[i].room, _entries[i].direction,
+				_entries[i].srcFlags, _entries[i].altCode, _entries[i].movieStart,
+				_entries[i].movieEnd, _entries[i].dstFlags);
+	}
+}
+
+void SpotTable::clear() {
+	_entries.clear();
+}
+
+//	Two CSpotIndices are equal if
+//		In addition to having their rooms, directions and alt codes identical...
+//		They are both either loops or once only animations AND
+//		They overlap in at least one of the on arrival, on turn and on door open bits.
+SpotTable::Entry SpotTable::findEntry(tRoomID room, tDirectionConstant direction, tSpotFlags srcFlags, tAlternateID altCode) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode && (_entries[i].srcFlags & kSpotLoopsMask) == (srcFlags & kSpotLoopsMask) && ((_entries[i].srcFlags & srcFlags) & kSpotTriggers) != 0)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
new file mode 100755
index 0000000..1bfa589
--- /dev/null
+++ b/engines/pegasus/neighborhood/spot.h
@@ -0,0 +1,88 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_SPOT_H
+#define PEGASUS_NEIGHBORHOOD_SPOT_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+typedef tMM8BitFlags tSpotFlags;
+
+enum {
+	kSpotLoopsBit,			//	Loop or once only?
+	kSpotOnArrivalBit,
+	kSpotOnTurnBit,
+	kSpotOnDoorOpenBit
+};
+
+static const tSpotFlags kNoSpotFlags = 0;
+static const tSpotFlags kSpotLoopsMask = 1 << kSpotLoopsBit;
+static const tSpotFlags kSpotOnArrivalMask = 1 << kSpotOnArrivalBit;
+static const tSpotFlags kSpotOnTurnMask = 1 << kSpotOnTurnBit;
+static const tSpotFlags kSpotOnDoorOpenMask = 1 << kSpotOnDoorOpenBit;
+
+static const tSpotFlags kSpotTriggers = kSpotOnArrivalMask | kSpotOnTurnMask | kSpotOnDoorOpenMask;
+
+class SpotTable {
+public:
+	SpotTable() {}
+	~SpotTable() {}
+
+	static const uint32 getResTag() { return MKTAG('S', 'p', 'o', 't'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { movieStart = 0xffffffff; }
+		bool isEmpty() { return movieStart == 0xffffffff; }
+
+		tRoomID room;
+		tDirectionConstant direction;
+		tSpotFlags srcFlags;
+		tAlternateID altCode;
+		TimeValue movieStart;
+		TimeValue movieEnd;
+		tSpotFlags dstFlags;
+	};
+
+	Entry findEntry(tRoomID room, tDirectionConstant direction, tSpotFlags srcFlags, tAlternateID altCode);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/turn.cpp b/engines/pegasus/neighborhood/turn.cpp
new file mode 100755
index 0000000..6b66b32
--- /dev/null
+++ b/engines/pegasus/neighborhood/turn.cpp
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/turn.h"
+
+namespace Pegasus {
+
+void TurnTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		_entries[i].turnDirection = stream->readByte();
+		_entries[i].altCode = stream->readByte();
+		stream->readByte(); // alignment
+		_entries[i].endDirection = stream->readByte();
+		stream->readByte(); // alignment
+		debug(0, "Turn[%d]: %d %d %d %d %d", i, _entries[i].room, _entries[i].direction,
+				_entries[i].turnDirection, _entries[i].altCode, _entries[i].endDirection);
+	}
+}
+
+void TurnTable::clear() {
+	_entries.clear();
+}
+
+TurnTable::Entry TurnTable::findEntry(tRoomID room, tDirectionConstant direction, tTurnDirection turnDirection, tAlternateID altCode) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].turnDirection == turnDirection && _entries[i].altCode == altCode)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/turn.h b/engines/pegasus/neighborhood/turn.h
new file mode 100755
index 0000000..daeaf2f
--- /dev/null
+++ b/engines/pegasus/neighborhood/turn.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_TURN_H
+#define PEGASUS_NEIGHBORHOOD_TURN_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class TurnTable {
+public:
+	TurnTable() {}
+	~TurnTable() {}
+
+	static const uint32 getResTag() { return MKTAG('T', 'u', 'r', 'n'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { endDirection = kNoDirection; }
+		bool isEmpty() { return endDirection == kNoDirection; }
+
+		tRoomID room;
+		tDirectionConstant direction;
+		tTurnDirection turnDirection;
+		tAlternateID altCode;
+		tDirectionConstant endDirection;
+	};
+
+	Entry findEntry(tRoomID room, tDirectionConstant direction, tTurnDirection turnDirection, tAlternateID altCode);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/view.cpp b/engines/pegasus/neighborhood/view.cpp
new file mode 100755
index 0000000..e57fc88
--- /dev/null
+++ b/engines/pegasus/neighborhood/view.cpp
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/view.h"
+
+namespace Pegasus {
+
+void ViewTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		_entries[i].altCode = stream->readByte();
+		_entries[i].time = stream->readUint32BE();
+		debug(0, "View[%d]: %d %d %d %d", i, _entries[i].room, _entries[i].direction,
+				_entries[i].altCode, _entries[i].time);
+	}
+}
+
+void ViewTable::clear() {
+	_entries.clear();
+}
+
+ViewTable::Entry ViewTable::findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace pegasus
diff --git a/engines/pegasus/neighborhood/view.h b/engines/pegasus/neighborhood/view.h
new file mode 100755
index 0000000..f1efb2b
--- /dev/null
+++ b/engines/pegasus/neighborhood/view.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_VIEW_H
+#define PEGASUS_NEIGHBORHOOD_VIEW_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class ViewTable {
+public:
+	ViewTable() {}
+	~ViewTable() {}
+
+	static const uint32 getResTag() { return MKTAG('V', 'i', 'e', 'w'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { time = 0xffffffff; }
+		bool isEmpty() { return time == 0xffffffff; }
+
+		tRoomID	room;
+		tDirectionConstant direction;
+		tAlternateID altCode;
+		TimeValue time;
+	};
+
+	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/zoom.cpp b/engines/pegasus/neighborhood/zoom.cpp
new file mode 100755
index 0000000..9422890
--- /dev/null
+++ b/engines/pegasus/neighborhood/zoom.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/zoom.h"
+
+namespace Pegasus {
+
+void ZoomTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].hotspot = stream->readUint16BE();
+		_entries[i].movieStart = stream->readUint32BE();
+		_entries[i].movieEnd = stream->readUint32BE();
+		_entries[i].room = stream->readUint16BE();
+		_entries[i].direction = stream->readByte();
+		debug(0, "Zoom[%d]: %d %d %d %d %d", i, _entries[i].hotspot, _entries[i].movieStart,
+				_entries[i].movieEnd, _entries[i].room, _entries[i].direction);
+		stream->readByte(); // alignment
+	}
+}
+
+void ZoomTable::clear() {
+	_entries.clear();
+}
+
+ZoomTable::Entry::Entry() {
+	hotspot = kNoHotSpotID;
+	movieStart = 0xffffffff;
+	movieEnd = 0xffffffff;
+	room = kNoRoomID;
+	direction = kNoDirection;
+}
+
+ZoomTable::Entry ZoomTable::findEntry(tHotSpotID hotspot) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].hotspot == hotspot)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
\ No newline at end of file
diff --git a/engines/pegasus/neighborhood/zoom.h b/engines/pegasus/neighborhood/zoom.h
new file mode 100755
index 0000000..e659b11
--- /dev/null
+++ b/engines/pegasus/neighborhood/zoom.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_ZOOM_H
+#define PEGASUS_NEIGHBORHOOD_ZOOM_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class ZoomTable {
+public:
+	ZoomTable() {}
+	~ZoomTable() {}
+
+	static const uint32 getResTag() { return MKTAG('Z', 'o', 'o', 'm'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry();
+		bool isEmpty() { return movieStart == 0xffffffff; }
+
+		tHotSpotID hotspot;
+		TimeValue movieStart;
+		TimeValue movieEnd;
+		tRoomID	room;
+		tDirectionConstant direction;
+	};
+
+	Entry findEntry(tHotSpotID hotspot);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 4e68007..d318497 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -33,6 +33,7 @@
 
 #include "pegasus/console.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/neighborhood.h"
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
@@ -240,118 +241,11 @@ void PegasusEngine::mainGameLoop() {
 
 void PegasusEngine::changeLocation(TimeZone timeZone) {
 	_timeZone = timeZone;
-	loadViews(_timeZone);
-	//loadExits(_timeZone);
-	loadDoors(_timeZone);
-	//loadHSLs(_timeZone);
-	//loadHSIn(_timeZone);
-	loadSoundSpots(_timeZone);
-	//loadTurns(_timeZone);
-	loadZooms(_timeZone);
-	loadExtras(_timeZone);
-}
-
-void PegasusEngine::loadViews(TimeZone timeZone) {
-	_currentViews.clear();
-
-	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('V', 'i', 'e', 'w'), getTimeZoneDesc(timeZone));
-
-	uint32 entryCount = res->readUint32BE();
-
-	for (uint32 i = 0; i < entryCount; i++) {
-		View view;
-		view.u0 = res->readUint16BE(); // Compass reading?
-		view.u1 = res->readByte(); // Always 0-3, direction?
-		view.u2 = res->readByte(); // Usually 0, rarely 3
-		view.frameTime = res->readUint32BE();
-		debug(1, "View[%d]: u0 = %d, u1 = %d, u2 = %d, time = %d", i, view.u0, view.u1, view.u2, view.frameTime);
-		_currentViews.push_back(view);
-	}
-
-	delete res;
-}
-
-void PegasusEngine::loadDoors(TimeZone timeZone) {
-	_currentDoors.clear();
-
-	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('D', 'o', 'o', 'r'), getTimeZoneDesc(timeZone));
-
-	uint32 entryCount = res->readUint32BE();
-
-	for (uint32 i = 0; i < entryCount; i++) {
-		Door door;
-		door.u0 = res->readUint16BE();
-		door.u1 = res->readUint16BE(); // Always divisible by 256?
-		door.startTime = res->readUint32BE();
-		door.endTime = res->readUint32BE();
-		door.u2 = res->readUint16BE();
-		debug(1, "Door[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, door.u0, door.u1, door.startTime, door.endTime, door.u2);
-		_currentDoors.push_back(door);
-	}
-
-	delete res;
-}
-
-void PegasusEngine::loadSoundSpots(TimeZone timeZone) {
-	_currentSoundSpots.clear();
-
-	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('S', 'p', 'o', 't'), getTimeZoneDesc(timeZone));
-
-	uint32 entryCount = res->readUint32BE();
 
-	for (uint32 i = 0; i < entryCount; i++) {
-		SoundSpot spot;
-		spot.u0 = res->readUint16BE();
-		spot.u1 = res->readUint16BE();
-		spot.u2 = res->readUint16BE(); // 0/1 or 768/769
-		spot.startTime = res->readUint32BE();
-		spot.endTime = res->readUint32BE();
-		spot.u3 = res->readUint16BE();
-		debug(1, "Sound Spot[%d]: u0 = %d, u1 = %d, u2 = %d, startTime = %d, endTime = %d, u3 = %d", i, spot.u0, spot.u1, spot.u2, spot.startTime, spot.endTime, spot.u3);
-		_currentSoundSpots.push_back(spot);
-	}
-
-	delete res;
-}
-
-void PegasusEngine::loadZooms(TimeZone timeZone) {
-	_currentZooms.clear();
-
-	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('Z', 'o', 'o', 'm'), getTimeZoneDesc(timeZone));
-
-	uint32 entryCount = res->readUint32BE();
-
-	for (uint32 i = 0; i < entryCount; i++) {
-		Zoom zoom;
-		zoom.u0 = res->readUint16BE();
-		zoom.u1 = res->readUint16BE();
-		zoom.startTime = res->readUint32BE();
-		zoom.endTime = res->readUint32BE();
-		zoom.u2 = res->readUint16BE();
-		debug(1, "Zoom[%d]: u0 = %d, u1 = %d, startTime = %d, endTime = %d, u2 = %d", i, zoom.u0, zoom.u1, zoom.startTime, zoom.endTime, zoom.u2);
-		_currentZooms.push_back(zoom);
-	}
-
-	delete res;
-}
-
-void PegasusEngine::loadExtras(TimeZone timeZone) {
-	_currentExtras.clear();
-
-	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('X', 't', 'r', 'a'), getTimeZoneDesc(timeZone));
-
-	uint32 entryCount = res->readUint32BE();
-
-	for (uint32 i = 0; i < entryCount; i++) {
-		Extra extra;
-		extra.u0 = res->readUint32BE();
-		extra.startTime = res->readUint32BE();
-		extra.endTime = res->readUint32BE();
-		debug(1, "Extra[%d]: u0 = %d, startTime = %d, endTime = %d", i, extra.u0, extra.startTime, extra.endTime);
-		_currentExtras.push_back(extra);
-	}
-
-	delete res;
+	// Just a test...
+	Neighborhood *neighborhood = new Neighborhood(this, getTimeZoneDesc(_timeZone));
+	neighborhood->init();
+	delete neighborhood;
 }
 
 void PegasusEngine::showLoadDialog() {
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 9f54633..d049f58 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -65,44 +65,6 @@ struct ItemLocationData {
 	byte u1;
 };
 
-struct View {
-	uint16 u0;
-	byte u1;
-	byte u2;
-	uint32 frameTime;
-};
-
-struct Door {
-	uint16 u0;
-	uint16 u1;
-	uint32 startTime;
-	uint32 endTime;
-	uint16 u2;
-};
-
-struct SoundSpot {
-	uint16 u0;
-	uint16 u1;
-	uint16 u2;
-	uint32 startTime;
-	uint32 endTime;
-	uint16 u3;
-};
-
-struct Zoom {
-	uint16 u0;
-	uint32 startTime;
-	uint32 endTime;
-	uint16 u1;
-	uint16 u2;
-};
-
-struct Extra {
-	uint32 u0;
-	uint32 startTime;
-	uint32 endTime;
-};
-
 struct InventoryPanelEntry {
 	uint32 startTime;
 	uint32 endTime;
@@ -237,11 +199,6 @@ private:
 	void mainGameLoop();
 	void loadItemLocationData();
 	void changeLocation(TimeZone timeZone);
-	void loadViews(TimeZone timeZone);
-	void loadDoors(TimeZone timeZone);
-	void loadSoundSpots(TimeZone timeZone);
-	void loadZooms(TimeZone timeZone);
-	void loadExtras(TimeZone timeZone);
 
 	// Misc Functions
 	static Common::String getTimeZoneFolder(TimeZone timeZone);
@@ -252,11 +209,6 @@ private:
 	GameMode _gameMode;
 	TimeZone _timeZone;
 	Common::Array<ItemLocationData> _itemLocationData;
-	Common::Array<View> _currentViews;
-	Common::Array<Door> _currentDoors;
-	Common::Array<SoundSpot> _currentSoundSpots;
-	Common::Array<Zoom> _currentZooms;
-	Common::Array<Extra> _currentExtras;
 
 	// Console
 	PegasusConsole *_console;


Commit: 3239002dae193fa92cceb973d0cae1ffe9fef8a4
    https://github.com/scummvm/scummvm/commit/3239002dae193fa92cceb973d0cae1ffe9fef8a4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-01T09:54:00-07:00

Commit Message:
PEGASUS: Implement some more neighborhood code

Changed paths:
  A engines/pegasus/neighborhood/hotspotinfo.cpp
  A engines/pegasus/neighborhood/hotspotinfo.h
  R engines/pegasus/neighborhood/hotspot.cpp
  R engines/pegasus/neighborhood/hotspot.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index af79e7c..56a9589 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -24,7 +24,7 @@ MODULE_OBJS = \
 	neighborhood/door.o \
 	neighborhood/exit.o \
 	neighborhood/extra.o \
-	neighborhood/hotspot.o \
+	neighborhood/hotspotinfo.o \
 	neighborhood/neighborhood.o \
 	neighborhood/spot.o \
 	neighborhood/turn.o \
diff --git a/engines/pegasus/neighborhood/hotspot.cpp b/engines/pegasus/neighborhood/hotspot.cpp
deleted file mode 100755
index 16af1a6..0000000
--- a/engines/pegasus/neighborhood/hotspot.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/debug.h"
-#include "common/stream.h"
-#include "common/textconsole.h"
-
-#include "pegasus/neighborhood/hotspot.h"
-
-namespace Pegasus {
-
-void HotspotTable::loadFromStream(Common::SeekableReadStream *stream) {
-	uint32 count = stream->readUint32BE();
-	_entries.resize(count);
-
-	for (uint32 i = 0; i < count; i++) {
-		_entries[i].hotspot = stream->readUint16BE();
-		_entries[i].hotspotActivation = stream->readSByte();
-		stream->readByte(); // alignment
-		_entries[i].hotspotRoom = stream->readUint16BE();
-		_entries[i].hotspotDirection = stream->readByte();
-		stream->readByte(); // alignment
-		_entries[i].hotspotExtra = stream->readUint32BE();
-		_entries[i].hotspotItem = stream->readUint16BE();
-		debug(0, "Hotspot[%d]: %d %d %d %d %d %d", i, _entries[i].hotspot, _entries[i].hotspotActivation,
-				_entries[i].hotspotRoom, _entries[i].hotspotDirection, _entries[i].hotspotExtra,
-				_entries[i].hotspotItem);
-	}
-}
-
-void HotspotTable::clear() {
-	_entries.clear();
-}
-
-HotspotTable::Entry HotspotTable::findEntry(tHotSpotID hotspot) {
-	for (uint32 i = 0; i < _entries.size(); i++)
-		if (_entries[i].hotspot == hotspot)
-			return _entries[i];
-
-	return Entry();
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/hotspot.h b/engines/pegasus/neighborhood/hotspot.h
deleted file mode 100755
index ea7f3bb..0000000
--- a/engines/pegasus/neighborhood/hotspot.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_NEIGHBORHOOD_HOTSPOT_H
-#define PEGASUS_NEIGHBORHOOD_HOTSPOT_H
-
-#include "common/array.h"
-#include "common/endian.h"
-
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
-
-namespace Common {
-	class SeekableReadStream;
-}
-
-namespace Pegasus {
-
-class HotspotTable {
-public:
-	HotspotTable() {}
-	~HotspotTable() {}
-
-	static const uint32 getResTag() { return MKTAG('H', 'S', 'I', 'n'); }
-
-	void loadFromStream(Common::SeekableReadStream *stream);
-	void clear();
-
-	struct Entry {
-		Entry() { hotspotRoom = kNoRoomID; }
-		bool isEmpty() { return hotspotRoom == kNoRoomID; }
-
-		tHotSpotID hotspot;
-		tHotSpotActivationID hotspotActivation;
-		//	Location hot spot lives in:
-		tRoomID hotspotRoom;
-		tDirectionConstant hotspotDirection;
-		//	Extra to play if this is a "play extra" hot spot.
-		tExtraID hotspotExtra;
-		//	Item corresponding to this hot spot if it is an item-related hot spot.
-		tItemID hotspotItem;
-	};
-
-	Entry findEntry(tHotSpotID hotspot);
-
-private:
-	Common::Array<Entry> _entries;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/neighborhood/hotspotinfo.cpp b/engines/pegasus/neighborhood/hotspotinfo.cpp
new file mode 100755
index 0000000..1cd2416
--- /dev/null
+++ b/engines/pegasus/neighborhood/hotspotinfo.cpp
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/debug.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+
+#include "pegasus/neighborhood/hotspotinfo.h"
+
+namespace Pegasus {
+
+void HotspotInfoTable::loadFromStream(Common::SeekableReadStream *stream) {
+	uint32 count = stream->readUint32BE();
+	_entries.resize(count);
+
+	for (uint32 i = 0; i < count; i++) {
+		_entries[i].hotspot = stream->readUint16BE();
+		_entries[i].hotspotActivation = stream->readSByte();
+		stream->readByte(); // alignment
+		_entries[i].hotspotRoom = stream->readUint16BE();
+		_entries[i].hotspotDirection = stream->readByte();
+		stream->readByte(); // alignment
+		_entries[i].hotspotExtra = stream->readUint32BE();
+		_entries[i].hotspotItem = stream->readUint16BE();
+		debug(0, "Hotspot[%d]: %d %d %d %d %d %d", i, _entries[i].hotspot, _entries[i].hotspotActivation,
+				_entries[i].hotspotRoom, _entries[i].hotspotDirection, _entries[i].hotspotExtra,
+				_entries[i].hotspotItem);
+	}
+}
+
+void HotspotInfoTable::clear() {
+	_entries.clear();
+}
+
+HotspotInfoTable::Entry HotspotInfoTable::findEntry(tHotSpotID hotspot) {
+	for (uint32 i = 0; i < _entries.size(); i++)
+		if (_entries[i].hotspot == hotspot)
+			return _entries[i];
+
+	return Entry();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
new file mode 100755
index 0000000..3199a51
--- /dev/null
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_HOTSPOTINFO_H
+#define PEGASUS_NEIGHBORHOOD_HOTSPOTINFO_H
+
+#include "common/array.h"
+#include "common/endian.h"
+
+#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+
+namespace Common {
+	class SeekableReadStream;
+}
+
+namespace Pegasus {
+
+class HotspotInfoTable {
+public:
+	HotspotInfoTable() {}
+	~HotspotInfoTable() {}
+
+	static const uint32 getResTag() { return MKTAG('H', 'S', 'I', 'n'); }
+
+	void loadFromStream(Common::SeekableReadStream *stream);
+	void clear();
+
+	struct Entry {
+		Entry() { hotspotRoom = kNoRoomID; }
+		bool isEmpty() { return hotspotRoom == kNoRoomID; }
+
+		tHotSpotID hotspot;
+		tHotSpotActivationID hotspotActivation;
+		//	Location hot spot lives in:
+		tRoomID hotspotRoom;
+		tDirectionConstant hotspotDirection;
+		//	Extra to play if this is a "play extra" hot spot.
+		tExtraID hotspotExtra;
+		//	Item corresponding to this hot spot if it is an item-related hot spot.
+		tItemID hotspotItem;
+	};
+
+	Entry findEntry(tHotSpotID hotspot);
+
+private:
+	Common::Array<Entry> _entries;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 291c0a9..1197c65 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -27,11 +27,14 @@
 #include "common/stream.h"
 
 #include "pegasus/pegasus.h"
+#include "pegasus/game_shell/CGameState.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
 
-Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName) : _vm(vm), _resName(resName) {
+Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : _vm(vm), _resName(resName) {
+	CGameState::SetOpenDoorLocation(kNoRoomID, kNoDirection);
+	_currentAlternate = 0;
 }
 
 Neighborhood::~Neighborhood() {
@@ -58,10 +61,10 @@ void Neighborhood::init() {
 	_extraTable.loadFromStream(stream);
 	delete stream;
 
-	stream = _vm->_resFork->getResource(_hotspotTable.getResTag(), _resName);
+	stream = _vm->_resFork->getResource(_hotspotInfoTable.getResTag(), _resName);
 	if (!stream)
-		error("Failed to load hotspots");
-	_hotspotTable.loadFromStream(stream);
+		error("Failed to load hotspot info");
+	_hotspotInfoTable.loadFromStream(stream);
 	delete stream;
 
 	stream = _vm->_resFork->getResource(_spotTable.getResTag(), _resName);
@@ -91,4 +94,133 @@ void Neighborhood::init() {
 	// TODO: AI, movies, notifications, buncha other stuff
 }
 
+void Neighborhood::start() {
+	CGameState::SetCurrentRoom(CGameState::GetLastRoom());
+	CGameState::SetCurrentDirection(CGameState::GetLastDirection());
+	arriveAt(CGameState::GetNextRoom(), CGameState::GetNextDirection());
+}
+
+void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
+	// TODO
+}
+
+//	These functions can be overridden to tweak the exact frames used.
+
+void Neighborhood::getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry) {
+	entry = _exitTable.findEntry(room, direction, _currentAlternate);
+
+	if (entry.isEmpty())
+		entry = _exitTable.findEntry(room, direction, kNoAlternateID);
+}
+
+TimeValue Neighborhood::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	if (CGameState::GetOpenDoorRoom() == room && CGameState::GetOpenDoorDirection() == direction) {
+		// If we get here, the door entry for this location must exist.
+		DoorTable::Entry doorEntry = _doorTable.findEntry(room, direction, _currentAlternate);
+
+		if (doorEntry.isEmpty())
+			doorEntry = _doorTable.findEntry(room, direction, kNoAlternateID);
+
+		return doorEntry.movieEnd - 1;
+	}
+
+	ViewTable::Entry viewEntry = _viewTable.findEntry(room, direction, _currentAlternate);
+
+	if (viewEntry.isEmpty())
+		viewEntry = _viewTable.findEntry(room, direction, kNoAlternateID);
+
+	return viewEntry.time;
+}
+
+void Neighborhood::getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry) {
+	doorEntry = _doorTable.findEntry(room, direction, _currentAlternate);
+
+	if (doorEntry.isEmpty())
+		doorEntry = _doorTable.findEntry(room, direction, kNoAlternateID);
+}
+
+tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn) {
+	TurnTable::Entry turnEntry = _turnTable.findEntry(room, direction, turn, _currentAlternate);
+
+	if (turnEntry.isEmpty())
+		turnEntry = _turnTable.findEntry(room, direction, turn, kNoAlternateID);
+
+	return turnEntry.turnDirection;
+}
+
+void Neighborhood::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {
+	spotEntry = _spotTable.findEntry(room, direction, flags, _currentAlternate);
+
+	if (spotEntry.isEmpty())
+		spotEntry = _spotTable.findEntry(room, direction, flags, kNoAlternateID);
+}
+
+void Neighborhood::getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry) {
+	zoomEntry = _zoomTable.findEntry(id);
+}
+
+void Neighborhood::getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry) {
+	hotspotEntry = _hotspotInfoTable.findEntry(id);
+}
+
+void Neighborhood::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry) {
+	extraEntry = _extraTable.findEntry(id);
+}
+
+/////////////////////////////////////////////
+//
+//	"Can" functions: Called to see whether or not a user is allowed to do something
+
+tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
+	DoorTable::Entry door;
+	
+	getExitEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), entry);
+	getDoorEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), door);
+
+	//	Fixed this so that doors that don't lead anywhere can be opened, but not walked
+	//	through.
+	if (door.flags & kDoorPresentMask) {
+		if (CGameState::IsCurrentDoorOpen()) {
+			if (entry.exitRoom == kNoRoomID)
+				return kCantMoveBlocked;
+			else
+				return kCanMoveForward;
+		} else if (door.flags & kDoorLockedMask) {
+			return kCantMoveDoorLocked;
+		} else {
+			return kCantMoveDoorClosed;
+		}
+	} else if (entry.exitRoom == kNoRoomID) {
+		return kCantMoveBlocked;
+	}
+
+	return kCanMoveForward;
+}
+
+tCanTurnReason Neighborhood::canTurn(tTurnDirection turn, tDirectionConstant &nextDir) {
+	nextDir = getTurnEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), turn);
+
+	if (nextDir == kNoDirection)
+		return kCantTurnNoTurn;
+
+	return kCanTurn;
+}
+
+tCanOpenDoorReason Neighborhood::canOpenDoor(DoorTable::Entry &entry) {
+	getDoorEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), entry);
+
+	if (entry.flags & kDoorPresentMask) {
+		if (CGameState::IsCurrentDoorOpen())
+			return kCantOpenAlreadyOpen;
+
+		if (entry.flags & kDoorLockedMask)
+			return kCantOpenLocked;
+
+		return kCanOpenDoor;
+	}
+
+	return kCantOpenNoDoor;
+}
+
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index d70628e..0b8be86 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -31,7 +31,7 @@
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
 #include "pegasus/neighborhood/extra.h"
-#include "pegasus/neighborhood/hotspot.h"
+#include "pegasus/neighborhood/hotspotinfo.h"
 #include "pegasus/neighborhood/spot.h"
 #include "pegasus/neighborhood/turn.h"
 #include "pegasus/neighborhood/view.h"
@@ -41,25 +41,58 @@ namespace Pegasus {
 
 class PegasusEngine;
 
+// Pegasus Prime neighborhood id's
+const tNeighborhoodID kCaldoriaID = 0;
+const tNeighborhoodID kFullTSAID = 1;
+const tNeighborhoodID kFinalTSAID = 2;
+const tNeighborhoodID kTinyTSAID = 3;
+const tNeighborhoodID kPrehistoricID = 4;
+const tNeighborhoodID kMarsID = 5;
+const tNeighborhoodID kWSCID = 6;
+const tNeighborhoodID kNoradAlphaID = 7;
+const tNeighborhoodID kNoradDeltaID = 8;
+//	The sub chase is not really a neighborhood, but we define a constant that is used
+//	to allow an easy transition out of Norad Alpha.
+const tNeighborhoodID kNoradSubChaseID = 1000;
+
 class Neighborhood {
 public:
-	Neighborhood(PegasusEngine *vm, const Common::String &resName);
+	Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
 
 	virtual void init();
+	void start();
+
+	void arriveAt(tRoomID room, tDirectionConstant direction);
+
+	virtual void getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry);
+	virtual TimeValue getViewTime(const tRoomID room, const tDirectionConstant direction);
+	virtual void getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry);
+	virtual tDirectionConstant getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn);
+	virtual void findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry);
+	virtual void getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry);
+	virtual void getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
+	virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
 
-private:
+	tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
+	tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
+
+protected:
 	PegasusEngine *_vm;
 	Common::String _resName;
+	tNeighborhoodID _neighborhoodID;
 
 	DoorTable _doorTable;
 	ExitTable _exitTable;
 	ExtraTable _extraTable;
-	HotspotTable _hotspotTable;
+	HotspotInfoTable _hotspotInfoTable;
 	SpotTable _spotTable;
 	TurnTable _turnTable;
 	ViewTable _viewTable;
 	ZoomTable _zoomTable;
+
+	tAlternateID _currentAlternate;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d318497..598c97c 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -141,10 +141,8 @@ Common::Error PegasusEngine::run() {
 			runMainMenu();
 			break;
 		case kMainGameMode:
-			if (isDemo())
-				changeLocation(kLocPrehistoric);
-			else
-				changeLocation(kLocCaldoria);
+			// NOTE: Prehistoric will be our testing location
+			changeLocation(kPrehistoricID);
 			mainGameLoop();
 			break;
 		case kQuitMode:
@@ -233,19 +231,19 @@ void PegasusEngine::mainGameLoop() {
 	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
 	drawInterface();
 
-	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(_timeZone).c_str(), getTimeZoneDesc(_timeZone).c_str());
+	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(_neighborhood).c_str(), getTimeZoneDesc(_neighborhood).c_str());
 	_video->playMovie(navMovie, kViewScreenOffset, kViewScreenOffset);
 
 	_gameMode = kQuitMode;
 }
 
-void PegasusEngine::changeLocation(TimeZone timeZone) {
-	_timeZone = timeZone;
+void PegasusEngine::changeLocation(tNeighborhoodID neighborhood) {
+	_neighborhood = neighborhood;
 
 	// Just a test...
-	Neighborhood *neighborhood = new Neighborhood(this, getTimeZoneDesc(_timeZone));
-	neighborhood->init();
-	delete neighborhood;
+	Neighborhood *neighborhoodPtr = new Neighborhood(this, getTimeZoneDesc(_neighborhood), _neighborhood);
+	neighborhoodPtr->init();
+	delete neighborhoodPtr;
 }
 
 void PegasusEngine::showLoadDialog() {
@@ -267,16 +265,16 @@ void PegasusEngine::showLoadDialog() {
 	slc.close();
 }
 
-Common::String PegasusEngine::getTimeZoneDesc(TimeZone timeZone) {
-	static const char *names[] = { "Prehistoric", "Mars", "WSC", "Tiny TSA", "Full TSA", "Norad Alpha", "Caldoria", "Norad Delta" };
-	return names[timeZone];
+Common::String PegasusEngine::getTimeZoneDesc(tNeighborhoodID neighborhood) {
+	static const char *names[] = { "Caldoria", "Full TSA", "Full TSA", "Tiny TSA", "Prehistoric", "Mars", "WSC", "Norad Alpha", "Norad Delta" };
+	return names[neighborhood];
 }
 
-Common::String PegasusEngine::getTimeZoneFolder(TimeZone timeZone) {
-	if (timeZone == kLocFullTSA || timeZone == kLocTinyTSA)
+Common::String PegasusEngine::getTimeZoneFolder(tNeighborhoodID neighborhood) {
+	if (neighborhood == kFullTSAID || neighborhood == kTinyTSAID || neighborhood == kFinalTSAID)
 		return "TSA";
 
-	return getTimeZoneDesc(timeZone);
+	return getTimeZoneDesc(neighborhood);
 }
 
 GUI::Debugger *PegasusEngine::getDebugger() {
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index d049f58..d6e312c 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -33,6 +33,7 @@
 
 #include "pegasus/graphics.h"
 #include "pegasus/video.h"
+#include "pegasus/neighborhood/neighborhood.h"
 
 namespace Video {
 	class Video::QuickTimeDecoder;
@@ -105,17 +106,6 @@ struct OverviewHotspot {
 	uint32 time;
 };
 
-enum TimeZone {
-	kLocPrehistoric = 0,
-	kLocMars = 1,
-	kLocWSC = 2,
-	kLocTinyTSA = 3,
-	kLocFullTSA = 4,
-	kLocNoradAlpha = 5,
-	kLocCaldoria = 6,
-	kLocNoradDelta = 7
-};
-
 // Taken from JMP PP Resources
 enum Item {
 	kAIBiochip = 128,
@@ -198,16 +188,16 @@ private:
 	// Main Game Functions
 	void mainGameLoop();
 	void loadItemLocationData();
-	void changeLocation(TimeZone timeZone);
+	void changeLocation(tNeighborhoodID neighborhood);
 
 	// Misc Functions
-	static Common::String getTimeZoneFolder(TimeZone timeZone);
-	static Common::String getTimeZoneDesc(TimeZone timeZone);
+	static Common::String getTimeZoneFolder(tNeighborhoodID neighborhood);
+	static Common::String getTimeZoneDesc(tNeighborhoodID neighborhood);
 
 	// Game Variables
 	bool _adventureMode;
 	GameMode _gameMode;
-	TimeZone _timeZone;
+	tNeighborhoodID _neighborhood;
 	Common::Array<ItemLocationData> _itemLocationData;
 
 	// Console


Commit: e642906cdda1d943bcbc875c752bb7ba69c2b81e
    https://github.com/scummvm/scummvm/commit/e642906cdda1d943bcbc875c752bb7ba69c2b81e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-01T21:27:13-07:00

Commit Message:
PEGASUS: Begin restructuring the game state classes

The entire game state should now be functional

Changed paths:
  A engines/pegasus/constants.h
  A engines/pegasus/gamestate.cpp
  A engines/pegasus/gamestate.h
  A engines/pegasus/scoring.h
  A engines/pegasus/types.h
  R engines/pegasus/Game_Shell/CGameState.cpp
  R engines/pegasus/Game_Shell/CGameState.h
  R engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
  R engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
  R engines/pegasus/MMShell/MMConstants.h
  R engines/pegasus/MMShell/MMTypes.h
    engines/pegasus/Game_Shell/CInventory.cpp
    engines/pegasus/Game_Shell/CInventory.h
    engines/pegasus/Game_Shell/CItem.cpp
    engines/pegasus/Game_Shell/CItem.h
    engines/pegasus/Game_Shell/CItemList.h
    engines/pegasus/MMShell/Notification/MMNotification.cpp
    engines/pegasus/MMShell/Notification/MMNotification.h
    engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
    engines/pegasus/MMShell/Utilities/MMIDObject.h
    engines/pegasus/MMShell/Utilities/MMResourceFile.h
    engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
    engines/pegasus/MMShell/Utilities/MMTimeValue.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/exit.h
    engines/pegasus/neighborhood/extra.h
    engines/pegasus/neighborhood/hotspotinfo.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/neighborhood/turn.h
    engines/pegasus/neighborhood/view.h
    engines/pegasus/neighborhood/zoom.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/Game_Shell/CGameState.cpp b/engines/pegasus/Game_Shell/CGameState.cpp
deleted file mode 100755
index 70a5545..0000000
--- a/engines/pegasus/Game_Shell/CGameState.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/error.h"
-#include "common/stream.h"
-
-#include "pegasus/Game_Shell/CGameState.h"
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
-
-namespace Pegasus {
-
-tNeighborhoodID CGameState::gCurrentNeighborhood = kNoNeighborhoodID;
-tRoomID CGameState::gCurrentRoom = kNoRoomID;
-tDirectionConstant CGameState::gCurrentDirection = kNoDirection;
-tNeighborhoodID CGameState::gNextNeighborhoodID = kNoNeighborhoodID;
-tRoomID CGameState::gNextRoomID = kNoRoomID;
-tDirectionConstant CGameState::gNextDirection = kNoDirection;
-tNeighborhoodID CGameState::gLastNeighborhood = kNoNeighborhoodID;
-tRoomID CGameState::gLastRoom = kNoRoomID;
-tDirectionConstant CGameState::gLastDirection = kNoDirection;
-tRoomID CGameState::gOpenDoorRoom = kNoRoomID;
-tDirectionConstant CGameState::gOpenDoorDirection = kNoDirection;
-
-Common::Error CGameState::WriteGameState(Common::WriteStream *stream) {
-	stream->writeUint16BE(gCurrentNeighborhood);
-	stream->writeUint16BE(gCurrentRoom);
-	stream->writeByte(gCurrentDirection);
-	stream->writeUint16BE(gNextNeighborhoodID);
-	stream->writeUint16BE(gNextRoomID);
-	stream->writeByte(gNextDirection);
-	stream->writeUint16BE(gLastNeighborhood);
-	stream->writeUint16BE(gLastRoom);
-	stream->writeUint16BE(gOpenDoorRoom);
-	stream->writeByte(gOpenDoorDirection);
-
-	if (stream->err())
-		return Common::kWritingFailed;
-	
-	return Common::kNoError;
-}
-
-Common::Error CGameState::ReadGameState(Common::ReadStream *stream) {
-	gCurrentNeighborhood = stream->readUint16BE();
-	gCurrentRoom = stream->readUint16BE();
-	gCurrentDirection = stream->readByte();
-	gNextNeighborhoodID = stream->readUint16BE();
-	gNextRoomID = stream->readUint16BE();
-	gNextDirection = stream->readByte();
-	gLastNeighborhood = stream->readUint16BE();
-	gLastRoom = stream->readUint16BE();
-	gOpenDoorRoom = stream->readUint16BE();
-	gOpenDoorDirection = stream->readByte();
-
-	if (stream->err())
-		return Common::kReadingFailed;
-	
-	return Common::kNoError;
-}
-
-void CGameState::ResetGameState() {
-	gCurrentNeighborhood = kNoNeighborhoodID;
-	gCurrentRoom = kNoRoomID;
-	gCurrentDirection = kNoDirection;
-	gNextNeighborhoodID = kNoNeighborhoodID;
-	gNextRoomID = kNoRoomID;
-	gNextDirection = kNoDirection;
-	gLastNeighborhood = kNoNeighborhoodID;
-	gLastRoom = kNoRoomID;
-	gLastDirection = kNoDirection;
-	gOpenDoorRoom = kNoRoomID;
-	gOpenDoorDirection = kNoDirection;
-}
-
-void CGameState::GetCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
-	neighborhood = gCurrentNeighborhood;
-	room = gCurrentRoom;
-	direction = gCurrentDirection;
-}
-
-void CGameState::SetCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
-	gLastNeighborhood = gCurrentNeighborhood;
-	gLastRoom = gCurrentRoom;
-	gLastDirection = gCurrentDirection;
-	gCurrentNeighborhood = neighborhood;
-	gCurrentRoom = room;
-	gCurrentDirection = direction;
-}
-
-tNeighborhoodID CGameState::GetCurrentNeighborhood() {
-	return gCurrentNeighborhood;
-}
-
-void CGameState::SetCurrentNeighborhood(const tNeighborhoodID neighborhood) {
-	gLastNeighborhood = gCurrentNeighborhood;
-	gCurrentNeighborhood = neighborhood;
-}
-
-tRoomID CGameState::GetCurrentRoom() {
-	return gCurrentRoom;
-}
-
-void CGameState::SetCurrentRoom(const tRoomID room) {
-	gLastRoom = gCurrentRoom;
-	gCurrentRoom = room;
-}
-
-tDirectionConstant CGameState::GetCurrentDirection() {
-	return gCurrentDirection;
-}
-
-void CGameState::SetCurrentDirection(const tDirectionConstant direction) {
-	gLastDirection = gCurrentDirection;
-	gCurrentDirection = direction;
-}
-
-tRoomViewID CGameState::GetCurrentRoomAndView() {
-	return MakeRoomView(gCurrentRoom, gCurrentDirection);
-}
-
-void CGameState::GetNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
-	neighborhood = gNextNeighborhoodID;
-	room = gNextRoomID;
-	direction = gNextDirection;
-}
-
-void CGameState::SetNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
-	gNextNeighborhoodID = neighborhood;
-	gNextRoomID = room;
-	gNextDirection = direction;
-}
-
-tNeighborhoodID CGameState::GetNextNeighborhood() {
-	return gNextNeighborhoodID;
-}
-
-void CGameState::SetNextNeighborhood(const tNeighborhoodID neighborhood) {
-	gNextNeighborhoodID = neighborhood;
-}
-
-tRoomID CGameState::GetNextRoom() {
-	return gNextRoomID;
-}
-
-void CGameState::SetNextRoom(const tRoomID room) {
-	gNextRoomID = room;
-}
-
-tDirectionConstant CGameState::GetNextDirection() {
-	return gNextDirection;
-}
-
-void CGameState::SetNextDirection(const tDirectionConstant direction) {
-	gNextDirection = direction;
-}
-
-void CGameState::GetLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
-	neighborhood = gCurrentNeighborhood;
-	room = gCurrentRoom;
-	direction = gCurrentDirection;
-}
-
-void CGameState::SetLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
-	gCurrentNeighborhood = neighborhood;
-	gCurrentRoom = room;
-	gCurrentDirection = direction;
-}
-
-tNeighborhoodID CGameState::GetLastNeighborhood() {
-	return gLastNeighborhood;
-}
-
-void CGameState::SetLastNeighborhood(const tNeighborhoodID neighborhood) {
-	gLastNeighborhood = neighborhood;
-}
-
-tRoomID CGameState::GetLastRoom() {
-	return gLastRoom;
-}
-
-void CGameState::SetLastRoom(const tRoomID room) {
-	gLastRoom = room;
-}
-
-tDirectionConstant CGameState::GetLastDirection() {
-	return gLastDirection;
-}
-
-void CGameState::SetLastDirection(const tDirectionConstant direction) {
-	gLastDirection = direction;
-}
-
-tRoomViewID CGameState::GetLastRoomAndView() {
-	return MakeRoomView(gLastRoom, gLastDirection);
-}
-
-void CGameState::GetOpenDoorLocation(tRoomID &room, tDirectionConstant &direction) {
-	room = gOpenDoorRoom;
-	direction = gOpenDoorDirection;
-}
-
-void CGameState::SetOpenDoorLocation(const tRoomID room, const tDirectionConstant direction) {
-	gOpenDoorRoom = room;
-	gOpenDoorDirection = direction;
-}
-
-tRoomID CGameState::GetOpenDoorRoom() {
-	return gOpenDoorRoom;
-}
-
-void CGameState::SetOpenDoorRoom(const tRoomID room) {
-	gOpenDoorRoom = room;
-}
-
-tDirectionConstant CGameState::GetOpenDoorDirection() {
-	return gOpenDoorDirection;
-}
-
-void CGameState::SetOpenDoorDirection(const tDirectionConstant direction) {
-	gOpenDoorDirection = direction;
-}
-
-tRoomViewID CGameState::GetDoorOpenRoomAndView() {
-	return MakeRoomView(gOpenDoorRoom, gOpenDoorDirection);
-}
-
-bool CGameState::IsCurrentDoorOpen() {
-	return gOpenDoorRoom == gCurrentRoom && gOpenDoorDirection == gCurrentDirection;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CGameState.h b/engines/pegasus/Game_Shell/CGameState.h
deleted file mode 100755
index b7ad71b..0000000
--- a/engines/pegasus/Game_Shell/CGameState.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_GAMESHELL_CGAMESTATE_H
-#define PEGASUS_GAMESHELL_CGAMESTATE_H
-
-#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
-
-namespace Common {
-	class Error;
-	class ReadStream;
-	class WriteStream;
-}
-
-namespace Pegasus {
-
-class CGameState {
-public:
-	static Common::Error WriteGameState(Common::WriteStream *stream);
-	static Common::Error ReadGameState(Common::ReadStream *stream);
-	
-	static void ResetGameState();
-	
-	static void GetCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	static void SetCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	
-	static tNeighborhoodID GetCurrentNeighborhood();
-	static void SetCurrentNeighborhood(const tNeighborhoodID neighborhood);
-	static tRoomID GetCurrentRoom();
-	static void SetCurrentRoom(const tRoomID room);
-	static tDirectionConstant GetCurrentDirection();
-	static void SetCurrentDirection(const tDirectionConstant direction);
-	
-	static tRoomViewID GetCurrentRoomAndView();
-	
-	static void GetNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	static void	SetNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	
-	static tNeighborhoodID GetNextNeighborhood();
-	static void SetNextNeighborhood(const tNeighborhoodID neighborhood);
-	static tRoomID GetNextRoom();
-	static void SetNextRoom(const tRoomID room);
-	static tDirectionConstant GetNextDirection();
-	static void SetNextDirection(const tDirectionConstant direction);
-	
-	static void GetLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	static void SetLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	
-	static tNeighborhoodID GetLastNeighborhood();
-	static void SetLastNeighborhood(const tNeighborhoodID neighborhood);
-	static tRoomID GetLastRoom();
-	static void SetLastRoom(const tRoomID room);
-	static tDirectionConstant GetLastDirection();
-	static void SetLastDirection(const tDirectionConstant direction);
-	
-	static tRoomViewID GetLastRoomAndView();
-	
-	static void GetOpenDoorLocation(tRoomID &room, tDirectionConstant &direction);
-	static void SetOpenDoorLocation(const tRoomID room, const tDirectionConstant direction);
-	static tRoomID GetOpenDoorRoom();
-	static void SetOpenDoorRoom(const tRoomID room);
-	static tDirectionConstant GetOpenDoorDirection();
-	static void SetOpenDoorDirection(const tDirectionConstant direction);
-	
-	static tRoomViewID GetDoorOpenRoomAndView();
-	
-	static bool IsCurrentDoorOpen();
-
-protected:
-	static tNeighborhoodID gCurrentNeighborhood;
-	static tRoomID gCurrentRoom;
-	static tDirectionConstant gCurrentDirection;
-	static tNeighborhoodID gNextNeighborhoodID;
-	static tRoomID gNextRoomID;
-	static tDirectionConstant gNextDirection;
-	static tNeighborhoodID gLastNeighborhood;
-	static tRoomID gLastRoom;
-	static tDirectionConstant gLastDirection;
-	static tRoomID gOpenDoorRoom;
-	static tDirectionConstant gOpenDoorDirection;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/Game_Shell/CInventory.cpp b/engines/pegasus/Game_Shell/CInventory.cpp
index 3747bed..64e62b4 100755
--- a/engines/pegasus/Game_Shell/CInventory.cpp
+++ b/engines/pegasus/Game_Shell/CInventory.cpp
@@ -23,9 +23,9 @@
  *
  */
 
+#include "pegasus/constants.h"
 #include "pegasus/Game_Shell/CItem.h"
 #include "pegasus/Game_Shell/CInventory.h"
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/Game_Shell/CInventory.h b/engines/pegasus/Game_Shell/CInventory.h
index 57ea1c9..45af5c3 100755
--- a/engines/pegasus/Game_Shell/CInventory.h
+++ b/engines/pegasus/Game_Shell/CInventory.h
@@ -26,8 +26,8 @@
 #ifndef PEGASUS_GAMESHELL_CINVENTORY_H
 #define PEGASUS_GAMESHELL_CINVENTORY_H
 
+#include "pegasus/types.h"
 #include "pegasus/Game_Shell/CItemList.h"
-#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp
index af0bff4..b96c24c 100755
--- a/engines/pegasus/Game_Shell/CItem.cpp
+++ b/engines/pegasus/Game_Shell/CItem.cpp
@@ -26,9 +26,9 @@
 #include "common/error.h"
 #include "common/stream.h"
 
+#include "pegasus/constants.h"
 #include "pegasus/Game_Shell/CItem.h"
 #include "pegasus/Game_Shell/CItemList.h"
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/Game_Shell/CItem.h b/engines/pegasus/Game_Shell/CItem.h
index cb0931c..c923e1c 100755
--- a/engines/pegasus/Game_Shell/CItem.h
+++ b/engines/pegasus/Game_Shell/CItem.h
@@ -27,7 +27,7 @@
 #define PEGASUS_GAMESHELL_CITEM_H
 
 #include "pegasus/MMShell/Utilities/MMIDObject.h"
-#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+#include "pegasus/types.h"
 
 namespace Common {
 	class Error;
@@ -48,6 +48,177 @@ namespace Pegasus {
 
 */
 
+//	Item IDs.
+
+const tItemID kAirMask = 7;
+const tItemID kAntidote = 8;
+const tItemID kArgonCanister = 9;
+const tItemID kCardBomb = 10;
+const tItemID kCrowbar = 11;
+const tItemID kGasCanister = 12;
+const tItemID kHistoricalLog = 13;
+const tItemID kJourneymanKey = 14;
+const tItemID kKeyCard = 15;
+const tItemID kMachineGun = 16;
+const tItemID kMarsCard = 17;
+const tItemID kNitrogenCanister = 18;
+const tItemID kOrangeJuiceGlassFull = 19;
+const tItemID kOrangeJuiceGlassEmpty = 20;
+const tItemID kPoisonDart = 21;
+const tItemID kSinclairKey = 22;
+const tItemID kStunGun = 23;
+const tItemID kArgonPickup = 24;
+
+//	Biochips.
+
+const tItemID kAIBiochip = 0;
+const tItemID kInterfaceBiochip = 1;
+const tItemID kMapBiochip = 2;
+const tItemID kOpticalBiochip = 3;
+const tItemID kPegasusBiochip = 4;
+const tItemID kRetinalScanBiochip = 5;
+const tItemID kShieldBiochip = 6;
+
+const tItemID kNumItems = 25;
+
+//	Item States.
+
+const tItemState kAI000 = 0;
+const tItemState kAI005 = 1;
+const tItemState kAI006 = 2;
+const tItemState kAI010 = 3;
+const tItemState kAI015 = 4;
+const tItemState kAI016 = 5;
+const tItemState kAI020 = 6;
+const tItemState kAI024 = 7;
+const tItemState kAI100 = 8;
+const tItemState kAI101 = 9;
+const tItemState kAI105 = 10;
+const tItemState kAI106 = 11;
+const tItemState kAI110 = 12;
+const tItemState kAI111 = 13;
+const tItemState kAI115 = 14;
+const tItemState kAI116 = 15;
+const tItemState kAI120 = 16;
+const tItemState kAI121 = 17;
+const tItemState kAI124 = 18;
+const tItemState kAI125 = 19;
+const tItemState kAI126 = 20;
+const tItemState kAI200 = 21;
+const tItemState kAI201 = 22;
+const tItemState kAI202 = 23;
+const tItemState kAI205 = 24;
+const tItemState kAI206 = 25;
+const tItemState kAI210 = 26;
+const tItemState kAI211 = 27;
+const tItemState kAI212 = 28;
+const tItemState kAI215 = 29;
+const tItemState kAI216 = 30;
+const tItemState kAI220 = 31;
+const tItemState kAI221 = 32;
+const tItemState kAI222 = 33;
+const tItemState kAI224 = 34;
+const tItemState kAI225 = 35;
+const tItemState kAI226 = 36;
+const tItemState kAI300 = 37;
+const tItemState kAI301 = 38;
+const tItemState kAI302 = 39;
+const tItemState kAI303 = 40;
+const tItemState kAI305 = 41;
+const tItemState kAI306 = 42;
+const tItemState kAI310 = 43;
+const tItemState kAI311 = 44;
+const tItemState kAI312 = 45;
+const tItemState kAI313 = 46;
+const tItemState kAI315 = 47;
+const tItemState kAI316 = 48;
+const tItemState kAI320 = 49;
+const tItemState kAI321 = 50;
+const tItemState kAI322 = 51;
+const tItemState kAI323 = 52;
+const tItemState kAI324 = 53;
+const tItemState kAI325 = 54;
+const tItemState kAI326 = 55;
+const tItemState kNormalItem = 56;
+const tItemState kMapUnavailable = 57;
+const tItemState kMapEngaged = 58;
+const tItemState kOptical000 = 59;
+const tItemState kOptical001 = 60;
+const tItemState kOptical002 = 61;
+const tItemState kOptical010 = 62;
+const tItemState kOptical011 = 63;
+const tItemState kOptical012 = 64;
+const tItemState kOptical020 = 65;
+const tItemState kOptical021 = 66;
+const tItemState kOptical100 = 67;
+const tItemState kOptical101 = 68;
+const tItemState kOptical102 = 69;
+const tItemState kOptical110 = 70;
+const tItemState kOptical111 = 71;
+const tItemState kOptical112 = 72;
+const tItemState kOptical120 = 73;
+const tItemState kOptical121 = 74;
+const tItemState kOptical200 = 75;
+const tItemState kOptical201 = 76;
+const tItemState kOptical210 = 77;
+const tItemState kOptical211 = 78;
+const tItemState kPegasusTSA00 = 79;
+const tItemState kPegasusTSA10 = 80;
+const tItemState kPegasusPrehistoric00 = 81;
+const tItemState kPegasusPrehistoric01 = 82;
+const tItemState kPegasusPrehistoric10 = 83;
+const tItemState kPegasusPrehistoric11 = 84;
+const tItemState kPegasusMars00 = 85;
+const tItemState kPegasusMars01 = 86;
+const tItemState kPegasusMars10 = 87;
+const tItemState kPegasusMars11 = 88;
+const tItemState kPegasusNorad00 = 89;
+const tItemState kPegasusNorad01 = 90;
+const tItemState kPegasusNorad10 = 91;
+const tItemState kPegasusNorad11 = 92;
+const tItemState kPegasusWSC00 = 93;
+const tItemState kPegasusWSC01 = 94;
+const tItemState kPegasusWSC10 = 95;
+const tItemState kPegasusWSC11 = 96;
+const tItemState kPegasusCaldoria = 97;
+const tItemState kRetinalSimulating = 98;
+const tItemState kShieldNormal = 99;
+const tItemState kShieldRadiation = 100;
+const tItemState kShieldPlasma = 101;
+const tItemState kShieldCardBomb = 102;
+const tItemState kShieldDraining = 103;
+const tItemState kAirMaskEmptyOff = 104;
+const tItemState kAirMaskEmptyFilter = 105;
+const tItemState kAirMaskLowOff = 106;
+const tItemState kAirMaskLowFilter = 107;
+const tItemState kAirMaskLowOn = 108;
+const tItemState kAirMaskFullOff = 109;
+const tItemState kAirMaskFullFilter = 110;
+const tItemState kAirMaskFullOn = 111;
+const tItemState kArgonEmpty = 112;
+const tItemState kArgonFull = 113;
+const tItemState kFlashlightOff = 114;
+const tItemState kFlashlightOn = 115;
+const tItemState kNitrogenEmpty = 116;
+const tItemState kNitrogenFull = 117;
+const tItemState kFullGlass = 118;
+
+//	Extra IDs.
+
+const uint32 kRetinalScanSearching = 0;
+const uint32 kRetinalScanActivated = 1;
+const uint32 kShieldIntro = 2;
+const uint32 kRemoveAirMask = 3;
+const uint32 kRemoveArgon = 4;
+const uint32 kRemoveCrowbar = 5;
+const uint32 kGasCanLoop = 6;
+const uint32 kRemoveJourneymanKey = 7;
+const uint32 kRemoveMarsCard = 8;
+const uint32 kRemoveNitrogen = 9;
+const uint32 kRemoveGlass = 10;
+const uint32 kRemoveDart = 11;
+const uint32 kRemoveSinclairKey = 12;
+
 class CItem : public MMIDObject {
 public:
 	CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
diff --git a/engines/pegasus/Game_Shell/CItemList.h b/engines/pegasus/Game_Shell/CItemList.h
index 75a34a0..d4c0d56 100755
--- a/engines/pegasus/Game_Shell/CItemList.h
+++ b/engines/pegasus/Game_Shell/CItemList.h
@@ -28,7 +28,7 @@
 
 #include "common/list.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Types.h"
+#include "pegasus/types.h"
 
 namespace Common {
 	class ReadStream;
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
deleted file mode 100755
index 5d64629..0000000
--- a/engines/pegasus/Game_Shell/Headers/Game_Shell_Constants.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
- 
-#ifndef PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS
-#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLCONSTANTS
-
-#include "engines/pegasus/MMShell/MMConstants.h"
-#include "engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h"
-
-namespace Pegasus {
-
-const tGameID kGameIDNothing = -1;
-
-const tActorID kNoActorID = kGameIDNothing;
-const tActorID kPlayerID = 0;
-const tItemID kNoItemID = kGameIDNothing;
-const tRoomID kNoRoomID = kGameIDNothing;
-const tExtraID kNoExtraID = 0xFFFFFFFF;
-const tNeighborhoodID kNoNeighborhoodID = kGameIDNothing;
-const tAlternateID kNoAlternateID = 0;
-const tGameMenuCommand kMenuCmdNoCommand = 0;
-
-const tHotSpotActivationID kActivateHotSpotAlways = 0;
-const tHotSpotActivationID kActivateHotSpotNever = -1;
-
-const tItemState kNoItemState = -1;
-
-const tDirectionConstant kNoDirection = 0xFF;
-
-const tTurnDirection kNoTurn = 0xFF;
-const tTurnDirection kTurnLeft = 0;
-const tTurnDirection kTurnRight = 1;
-const tTurnDirection kTurnUp = 2;
-const tTurnDirection kTurnDown = 3;
-const tTurnDirection kMaxTurns = 4;
-
-const tGameMode kNoMode = -1;
-const tGameMode kModeNavigation = 0;
-const tGameMode kLastGameShellMode = kModeNavigation;
-
-const tCanMoveForwardReason kCanMoveForward = 0;
-const tCanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
-const tCanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
-const tCanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
-const tCanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
-
-const tCanTurnReason kCanTurn = 0;
-const tCanTurnReason kCantTurnNoTurn = kCanTurn + 1;
-const tCanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
-
-const tCanOpenDoorReason kCanOpenDoor = 0;
-const tCanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
-const tCanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
-const tCanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
-const tCanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h b/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
deleted file mode 100755
index 923f7a7..0000000
--- a/engines/pegasus/Game_Shell/Headers/Game_Shell_Types.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
- 
-#ifndef PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES
-#define PEGASUS_GAMESHELL_HEADERS_GAMESHELLTYPES
-
-#include "pegasus/MMShell/MMTypes.h"
-
-namespace Pegasus {
-
-typedef tMM16BitID tGameID;
-
-typedef tGameID tItemID;
-typedef tGameID tActorID;
-typedef tGameID tRoomID;
-typedef tGameID tNeighborhoodID;
-typedef tMM8BitU tAlternateID;
-typedef tMM8BitS tHotSpotActivationID;
-
-typedef tMM16BitS tWeightType;
-
-typedef tMM8BitU tDirectionConstant;
-typedef tMM8BitU tTurnDirection;
-
-// Meant to be room in low 16 bits and direction in high 16 bits.
-typedef tMM32BitU tRoomViewID;
-
-#define MakeRoomView(room, direction) (((tRoomViewID) (room)) | (((tRoomViewID) (direction)) << 16))
-
-typedef tMM32BitU tExtraID;
-
-typedef tMM16BitS tGameMode;
-
-typedef tMM16BitS tWeightType;
-
-typedef tMM16BitS tItemState;
-
-typedef tMM8BitS tDeathReason;
-
-typedef tMM32BitS tGameMenuCommand;
-
-typedef tMM32BitS tGameScoreType;
-
-typedef long tCanMoveForwardReason;
-
-typedef long tCanTurnReason;
-
-typedef long tCanOpenDoorReason;
-
-enum tInventoryResult {
-	kInventoryOK,
-	kTooMuchWeight,
-	kItemNotInInventory
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/MMConstants.h b/engines/pegasus/MMShell/MMConstants.h
deleted file mode 100755
index 1b36c81..0000000
--- a/engines/pegasus/MMShell/MMConstants.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_MMCONSTANTS_H
-#define PEGASUS_MMSHELL_MMCONSTANTS_H
-
-#include "pegasus/MMShell/MMTypes.h"
-
-namespace Pegasus {
-
-const tDisplayElementID kNoDisplayElement = -1;
-const tDisplayElementID kHighestReservedElementID = -2;
-
-const tDisplayElementID kCursorID = kHighestReservedElementID;
-const tDisplayElementID kLoadScreenID = kCursorID - 1;
-
-const tDisplayOrder kMinAvailableOrder = 0;
-const tDisplayOrder kMaxAvailableOrder = 999998;
-const tDisplayOrder kLoadScreenOrder = 900000;
-const tDisplayOrder kCursorOrder = 1000000;
-
-const tHotSpotID kNoHotSpotID = -1;
-const tHotSpotFlags kNoHotSpotFlags = 0;
-const tHotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
-
-const tNotificationFlags kNoNotificationFlags = 0;
-
-const tDisplayElementID kCurrentDragSpriteID = 1000;
-
-// TODO
-//const Fixed kFixed1 = 1 << 16;
-//const Fixed kFixedMinus1 = -1 << 16;
-
-const TimeScale kDefaultTimeScale = 600;
-
-// TODO
-//const RGBColor kWhiteRGB = {0xFFFF, 0xFFFF, 0xFFFF};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/MMTypes.h b/engines/pegasus/MMShell/MMTypes.h
deleted file mode 100755
index a4bc547..0000000
--- a/engines/pegasus/MMShell/MMTypes.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_MMTYPES_H
-#define PEGASUS_MMSHELL_MMTYPES_H
-
-#include "common/scummsys.h"
-
-namespace Pegasus {
-
-// TODO: All of the "tMM"-prefixed defines should be replaced eventually
-// TODO: Probably all of these don't really need to be typedef'd...
-typedef int8 tMM8BitS;
-typedef uint8 tMM8BitU;
-
-typedef int16 tMM16BitS;
-typedef uint16 tMM16BitU;
-
-typedef int32 tMM32BitS;
-typedef uint32 tMM32BitU;
-
-typedef tMM8BitS tMM8BitID;
-typedef tMM16BitS tMM16BitID;
-typedef tMM32BitS tMM32BitID;
-
-typedef tMM8BitU tMM8BitFlags;
-typedef tMM16BitU tMM16BitFlags;
-typedef tMM32BitU tMM32BitFlags;
-
-typedef tMM32BitID tDisplayElementID;
-typedef tMM32BitS tDisplayOrder;
-
-typedef tMM16BitID tHotSpotID;
-typedef tMM32BitFlags tHotSpotFlags;
-
-typedef tMM8BitFlags tButtonState;
-typedef tMM32BitFlags tInputBits;
-
-typedef tMM8BitU tKeyMapType[16];
-typedef tMM8BitU tKeyType;
-typedef tMM8BitU tKeyMapIndexType;
-typedef tMM8BitU tKeyMapBitType;
-
-typedef tMM32BitID tNotificationID;
-typedef tMM32BitFlags tNotificationFlags;
-
-//	Mac types.
-typedef tMM16BitS tResIDType;
-typedef tMM16BitS tCoordType;
-typedef tMM16BitS tQDCopyMode;
-typedef tMM16BitS tResItemCountType;
-
-enum tCopyMode {
-	kNoMask,
-	kUseClipArea,
-	kUseTransparency
-};
-
-enum tSlideDirection {
-	kSlideLeftMask = 1,
-	kSlideRightMask = kSlideLeftMask << 1,
-	kSlideUpMask = kSlideRightMask << 1 << 1,
-	kSlideDownMask = kSlideUpMask << 1,
-	
-	kSlideHorizMask = kSlideLeftMask | kSlideRightMask,
-	kSlideVertMask = kSlideUpMask | kSlideDownMask,
-
-	kSlideUpLeftMask = kSlideLeftMask | kSlideUpMask,
-	kSlideUpRightMask = kSlideRightMask | kSlideUpMask,
-	kSlideDownLeftMask = kSlideLeftMask | kSlideDownMask,
-	kSlideDownRightMask = kSlideRightMask | kSlideDownMask
-};
-
-// ScummVM QuickTime/QuickDraw replacement types
-typedef uint TimeValue;
-typedef uint TimeScale;
-// TODO: Fixed and RGBColor
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.cpp b/engines/pegasus/MMShell/Notification/MMNotification.cpp
index 8b8d694..e91417a 100755
--- a/engines/pegasus/MMShell/Notification/MMNotification.cpp
+++ b/engines/pegasus/MMShell/Notification/MMNotification.cpp
@@ -23,7 +23,7 @@
  *
  */
 
-#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/constants.h"
 #include "pegasus/MMShell/Notification/MMNotification.h"
 #include "pegasus/MMShell/Notification/MMNotificationManager.h"
 #include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.h b/engines/pegasus/MMShell/Notification/MMNotification.h
index 8ad7f73..2c6dddd 100755
--- a/engines/pegasus/MMShell/Notification/MMNotification.h
+++ b/engines/pegasus/MMShell/Notification/MMNotification.h
@@ -28,7 +28,7 @@
 
 #include "common/list.h"
 
-#include "pegasus/MMShell/MMTypes.h"
+#include "pegasus/types.h"
 #include "pegasus/MMShell/Utilities/MMIDObject.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
index 2a1f1be..4bcaa79 100755
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
+++ b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
@@ -23,7 +23,7 @@
  *
  */
 
-#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/constants.h"
 #include "pegasus/MMShell/Notification/MMNotificationManager.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/MMShell/Utilities/MMIDObject.h
index 4cca1c0..b45c754 100755
--- a/engines/pegasus/MMShell/Utilities/MMIDObject.h
+++ b/engines/pegasus/MMShell/Utilities/MMIDObject.h
@@ -26,7 +26,7 @@
 #ifndef PEGASUS_MMSHELL_MMIDOBJECT_H
 #define PEGASUS_MMSHELL_MMIDOBJECT_H
 
-#include "pegasus/MMShell/MMTypes.h"
+#include "pegasus/types.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.h b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
index 47c82fd..9bd0cd9 100755
--- a/engines/pegasus/MMShell/Utilities/MMResourceFile.h
+++ b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
@@ -28,7 +28,7 @@
 
 #include "common/str.h"
 
-#include "pegasus/MMShell/MMTypes.h"
+#include "pegasus/types.h"
 
 namespace Common {
 	class Error;
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
index c3bf85b..92971a6 100755
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
@@ -23,7 +23,7 @@
  *
  */
 
-#include "pegasus/MMShell/MMConstants.h"
+#include "pegasus/constants.h"
 #include "pegasus/MMShell/Utilities/MMTimeValue.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.h b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
index 4060322..a112f9c 100755
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.h
+++ b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
@@ -26,7 +26,7 @@
 #ifndef PEGASUS_MMSHELL_MMTIMEVALUE_H
 #define PEGASUS_MMSHELL_MMTIMEVALUE_H
 
-#include "pegasus/MMShell/MMTypes.h"
+#include "pegasus/types.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
new file mode 100755
index 0000000..7a63cfc
--- /dev/null
+++ b/engines/pegasus/constants.h
@@ -0,0 +1,226 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_CONSTANTS_H
+#define PEGASUS_CONSTANTS_H
+
+#include "pegasus/types.h"
+
+namespace Pegasus {
+
+const tGameID kGameIDNothing = -1;
+
+const tActorID kNoActorID = kGameIDNothing;
+const tActorID kPlayerID = 0;
+const tItemID kNoItemID = kGameIDNothing;
+const tRoomID kNoRoomID = kGameIDNothing;
+const tExtraID kNoExtraID = 0xFFFFFFFF;
+const tNeighborhoodID kNoNeighborhoodID = kGameIDNothing;
+const tAlternateID kNoAlternateID = 0;
+const tGameMenuCommand kMenuCmdNoCommand = 0;
+
+const tHotSpotActivationID kActivateHotSpotAlways = 0;
+const tHotSpotActivationID kActivateHotSpotNever = -1;
+
+const tItemState kNoItemState = -1;
+
+const tDirectionConstant kNoDirection = 0xFF;
+
+const tTurnDirection kNoTurn = 0xFF;
+const tTurnDirection kTurnLeft = 0;
+const tTurnDirection kTurnRight = 1;
+const tTurnDirection kTurnUp = 2;
+const tTurnDirection kTurnDown = 3;
+const tTurnDirection kMaxTurns = 4;
+
+const tGameMode kNoMode = -1;
+const tGameMode kModeNavigation = 0;
+const tGameMode kLastGameShellMode = kModeNavigation;
+
+const tCanMoveForwardReason kCanMoveForward = 0;
+const tCanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
+const tCanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
+const tCanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
+const tCanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
+
+const tCanTurnReason kCanTurn = 0;
+const tCanTurnReason kCantTurnNoTurn = kCanTurn + 1;
+const tCanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
+
+const tCanOpenDoorReason kCanOpenDoor = 0;
+const tCanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
+const tCanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
+const tCanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
+const tCanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
+
+const tDisplayElementID kNoDisplayElement = -1;
+const tDisplayElementID kHighestReservedElementID = -2;
+
+const tDisplayElementID kCursorID = kHighestReservedElementID;
+const tDisplayElementID kLoadScreenID = kCursorID - 1;
+
+const tDisplayOrder kMinAvailableOrder = 0;
+const tDisplayOrder kMaxAvailableOrder = 999998;
+const tDisplayOrder kLoadScreenOrder = 900000;
+const tDisplayOrder kCursorOrder = 1000000;
+
+const tHotSpotID kNoHotSpotID = -1;
+const tHotSpotFlags kNoHotSpotFlags = 0;
+const tHotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
+
+const tNotificationFlags kNoNotificationFlags = 0;
+
+const tDisplayElementID kCurrentDragSpriteID = 1000;
+
+// TODO
+//const Fixed kFixed1 = 1 << 16;
+//const Fixed kFixedMinus1 = -1 << 16;
+
+const TimeScale kDefaultTimeScale = 600;
+
+// TODO
+//const RGBColor kWhiteRGB = {0xFFFF, 0xFFFF, 0xFFFF};
+
+//	Ticks per second.
+
+const TimeScale kOneTickPerSecond = 1;
+const TimeScale kTwoTicksPerSecond = 2;
+const TimeScale kFifteenTicksPerSecond = 15;
+const TimeScale kThirtyTicksPerSecond = 30;
+const TimeScale kSixtyTicksPerSecond = 60;
+const TimeScale kMovieTicksPerSecond = 600;
+
+//	These times are in seconds.
+
+const TimeValue kOneSecond = 1;
+const TimeValue kTwoSeconds = 2;
+const TimeValue kThreeSeconds = 3;
+const TimeValue kFourSeconds = 4;
+const TimeValue kFiveSeconds = 5;
+const TimeValue kSixSeconds = 6;
+const TimeValue kSevenSeconds = 7;
+const TimeValue kEightSeconds = 8;
+const TimeValue kNineSeconds = 9;
+const TimeValue kTenSeconds = 10;
+const TimeValue kElevenSeconds = 11;
+const TimeValue kTwelveSeconds = 12;
+const TimeValue kThirteenSeconds = 13;
+const TimeValue kFourteenSeconds = 14;
+const TimeValue kFifteenSeconds = 15;
+const TimeValue kSixteenSeconds = 16;
+const TimeValue kSeventeenSeconds = 17;
+const TimeValue kEighteenSeconds = 18;
+const TimeValue kNineteenSeconds = 19;
+const TimeValue kTwentySeconds = 20;
+const TimeValue kThirtySeconds = 30;
+const TimeValue kFortySeconds = 40;
+const TimeValue kFiftySeconds = 50;
+const TimeValue kSixtySeconds = 60;
+const TimeValue kOneMinute = 60;
+const TimeValue kTwoMinutes = kOneMinute * 2;
+const TimeValue kThreeMinutes = kOneMinute * 3;
+const TimeValue kFourMinutes = kOneMinute * 4;
+const TimeValue kFiveMinutes = kOneMinute * 5;
+const TimeValue kSixMinutes = kOneMinute * 6;
+const TimeValue kSevenMinutes = kOneMinute * 7;
+const TimeValue kEightMinutes = kOneMinute * 8;
+const TimeValue kNineMinutes = kOneMinute * 9;
+const TimeValue kTenMinutes = kOneMinute * 10;
+const TimeValue kElevenMinutes = kOneMinute * 11;
+const TimeValue kTwelveMinutes = kOneMinute * 12;
+const TimeValue kThirteenMinutes = kOneMinute * 13;
+const TimeValue kFourteenMinutes = kOneMinute * 14;
+const TimeValue kFifteenMinutes = kOneMinute * 15;
+const TimeValue kSixteenMinutes = kOneMinute * 16;
+const TimeValue kSeventeenMinutes = kOneMinute * 17;
+const TimeValue kEighteenMinutes = kOneMinute * 18;
+const TimeValue kNineteenMinutes = kOneMinute * 19;
+const TimeValue kTwentyMinutes = kOneMinute * 20;
+const TimeValue kThirtyMinutes = kOneMinute * 30;
+const TimeValue kFortyMinutes = kOneMinute * 40;
+const TimeValue kFiftyMinutes = kOneMinute * 50;
+const TimeValue kOneHour = kOneMinute * 60;
+const TimeValue kTwoHours = kOneHour * 2;
+
+//	Common times.
+
+const TimeValue kHalfSecondPerTwoTicks = kTwoTicksPerSecond / 2;
+const TimeValue kHalfSecondPerThirtyTicks = kThirtyTicksPerSecond / 2;
+const TimeValue kHalfSecondPerSixtyTicks = kSixtyTicksPerSecond / 2;
+
+const TimeValue kOneSecondPerTwoTicks = kTwoTicksPerSecond;
+const TimeValue kOneSecondPerThirtyTicks = kThirtyTicksPerSecond;
+const TimeValue kOneSecondPerSixtyTicks = kSixtyTicksPerSecond;
+
+const TimeValue kOneMinutePerFifteenTicks = kOneMinute * kFifteenTicksPerSecond;
+const TimeValue kFiveMinutesPerFifteenTicks = kFiveMinutes * kFifteenTicksPerSecond;
+const TimeValue kTenMinutesPerFifteenTicks = kTenMinutes * kFifteenTicksPerSecond;
+
+const TimeValue kOneMinutePerThirtyTicks = kOneMinute * kThirtyTicksPerSecond;
+const TimeValue kFiveMinutesPerThirtyTicks = kFiveMinutes * kThirtyTicksPerSecond;
+const TimeValue kTenMinutesPerThirtyTicks = kTenMinutes * kThirtyTicksPerSecond;
+
+const TimeValue kOneMinutePerSixtyTicks = kOneMinute * kSixtyTicksPerSecond;
+const TimeValue kFiveMinutesPerSixtyTicks = kFiveMinutes * kSixtyTicksPerSecond;
+const TimeValue kTenMinutesPerSixtyTicks = kTenMinutes * kSixtyTicksPerSecond;
+
+//	Time in seconds you can hang around Caldoria without going to work...
+//const TimeValue kCaldoriaUncreatedTimeLimit = kFifteenMinutes;
+//const TimeValue kCaldoriaUncreatedTimeLimit = kTwentyMinutes;
+const TimeValue kLateWarning2TimeLimit = kFiveMinutes;
+const TimeValue kLateWarning3TimeLimit = kTenMinutes;
+
+const TimeValue kSinclairShootsTimeLimit = kThreeMinutes;
+const TimeValue kCardBombCountDownTime = kTwelveSeconds;
+
+const TimeValue kOxyMaskFullTime = kThirtyMinutes;
+
+const TimeValue kTSAUncreatedTimeLimit = kFiveMinutes;
+const TimeValue kRipTimeLimit = kTenMinutesPerFifteenTicks;
+const TimeScale kRipTimeScale = kFifteenTicksPerSecond;
+
+const TimeValue kIntroTimeOut = kThirtySeconds;
+
+const TimeValue kMarsRobotPatienceLimit = kFifteenSeconds;
+const TimeValue kLockFreezeTimeLmit = kFifteenSeconds;
+const TimeValue kSpaceChaseTimeLimit = kTenMinutes;
+const TimeValue kVacuumSurvivalTimeLimit = kThirtySeconds;
+const TimeValue kColorMatchingTimeLimit = kFourMinutes;
+const TimeScale kJunkTimeScale = kFifteenTicksPerSecond;
+const TimeValue kJunkDropBaseTime = kFiveSeconds;
+const TimeValue kJunkDropSlopTime = kThreeSeconds;
+const TimeValue kJunkTravelTime = kTenSeconds * kJunkTimeScale;
+const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
+const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
+
+const TimeValue kGawkAtRobotTime = kTenSeconds;
+const TimeValue kGawkAtRobotTime2 = kThirteenSeconds;
+const TimeValue kPlasmaImpactTime = kTwoSeconds;
+
+const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
new file mode 100755
index 0000000..2f4aed6
--- /dev/null
+++ b/engines/pegasus/gamestate.cpp
@@ -0,0 +1,2357 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "pegasus/constants.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/scoring.h"
+
+namespace Common {
+DECLARE_SINGLETON(Pegasus::GameStateManager);
+}
+
+namespace Pegasus {
+
+Common::Error GameStateManager::writeGameState(Common::WriteStream *stream) {
+	stream->writeUint16BE(_currentNeighborhood);
+	stream->writeUint16BE(_currentRoom);
+	stream->writeByte(_currentDirection);
+	stream->writeUint16BE(_nextNeighborhoodID);
+	stream->writeUint16BE(_nextRoomID);
+	stream->writeByte(_nextDirection);
+	stream->writeUint16BE(_lastNeighborhood);
+	stream->writeUint16BE(_lastRoom);
+	stream->writeUint16BE(_openDoorRoom);
+	stream->writeByte(_openDoorDirection);
+
+	_globalFlags.writeToStream(stream);
+	_scoringFlags.writeToStream(stream);
+	_itemTakenFlags.writeToStream(stream);
+
+	writeCaldoriaState(stream);
+	writeTSAState(stream);
+	writePrehistoricState(stream);
+	writeNoradState(stream);
+	writeMarsState(stream);
+	writeWSCState(stream);
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error GameStateManager::readGameState(Common::ReadStream *stream) {
+	_currentNeighborhood = stream->readUint16BE();
+	_currentRoom = stream->readUint16BE();
+	_currentDirection = stream->readByte();
+	_nextNeighborhoodID = stream->readUint16BE();
+	_nextRoomID = stream->readUint16BE();
+	_nextDirection = stream->readByte();
+	_lastNeighborhood = stream->readUint16BE();
+	_lastRoom = stream->readUint16BE();
+	_openDoorRoom = stream->readUint16BE();
+	_openDoorDirection = stream->readByte();	
+
+	_globalFlags.readFromStream(stream);
+	_scoringFlags.readFromStream(stream);
+	_itemTakenFlags.readFromStream(stream);
+	
+	readCaldoriaState(stream);
+	readTSAState(stream);
+	readPrehistoricState(stream);
+	readNoradState(stream);
+	readMarsState(stream);
+	readWSCState(stream);
+
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+void GameStateManager::resetGameState() {
+	_currentNeighborhood = kNoNeighborhoodID;
+	_currentRoom = kNoRoomID;
+	_currentDirection = kNoDirection;
+	_nextNeighborhoodID = kNoNeighborhoodID;
+	_nextRoomID = kNoRoomID;
+	_nextDirection = kNoDirection;
+	_lastNeighborhood = kNoNeighborhoodID;
+	_lastRoom = kNoRoomID;
+	_lastDirection = kNoDirection;
+	_openDoorRoom = kNoRoomID;
+	_openDoorDirection = kNoDirection;
+
+	_globalFlags.clearAllFlags();
+	_scoringFlags.clearAllFlags();
+	_itemTakenFlags.clearAllFlags();
+
+	resetCaldoriaState();
+	resetTSAState();
+	resetPrehistoricState();
+	resetNoradState();
+	resetMarsState();
+	resetWSCState();
+}
+
+void GameStateManager::getCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = _currentNeighborhood;
+	room = _currentRoom;
+	direction = _currentDirection;
+}
+
+void GameStateManager::setCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	_lastNeighborhood = _currentNeighborhood;
+	_lastRoom = _currentRoom;
+	_lastDirection = _currentDirection;
+	_currentNeighborhood = neighborhood;
+	_currentRoom = room;
+	_currentDirection = direction;
+}
+
+tNeighborhoodID GameStateManager::getCurrentNeighborhood() {
+	return _currentNeighborhood;
+}
+
+void GameStateManager::setCurrentNeighborhood(const tNeighborhoodID neighborhood) {
+	_lastNeighborhood = _currentNeighborhood;
+	_currentNeighborhood = neighborhood;
+}
+
+tRoomID GameStateManager::getCurrentRoom() {
+	return _currentRoom;
+}
+
+void GameStateManager::setCurrentRoom(const tRoomID room) {
+	_lastRoom = _currentRoom;
+	_currentRoom = room;
+}
+
+tDirectionConstant GameStateManager::getCurrentDirection() {
+	return _currentDirection;
+}
+
+void GameStateManager::setCurrentDirection(const tDirectionConstant direction) {
+	_lastDirection = _currentDirection;
+	_currentDirection = direction;
+}
+
+tRoomViewID GameStateManager::getCurrentRoomAndView() {
+	return MakeRoomView(_currentRoom, _currentDirection);
+}
+
+void GameStateManager::getNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = _nextNeighborhoodID;
+	room = _nextRoomID;
+	direction = _nextDirection;
+}
+
+void GameStateManager::setNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	_nextNeighborhoodID = neighborhood;
+	_nextRoomID = room;
+	_nextDirection = direction;
+}
+
+tNeighborhoodID GameStateManager::getNextNeighborhood() {
+	return _nextNeighborhoodID;
+}
+
+void GameStateManager::setNextNeighborhood(const tNeighborhoodID neighborhood) {
+	_nextNeighborhoodID = neighborhood;
+}
+
+tRoomID GameStateManager::getNextRoom() {
+	return _nextRoomID;
+}
+
+void GameStateManager::setNextRoom(const tRoomID room) {
+	_nextRoomID = room;
+}
+
+tDirectionConstant GameStateManager::getNextDirection() {
+	return _nextDirection;
+}
+
+void GameStateManager::setNextDirection(const tDirectionConstant direction) {
+	_nextDirection = direction;
+}
+
+void GameStateManager::getLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+	neighborhood = _currentNeighborhood;
+	room = _currentRoom;
+	direction = _currentDirection;
+}
+
+void GameStateManager::setLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	_currentNeighborhood = neighborhood;
+	_currentRoom = room;
+	_currentDirection = direction;
+}
+
+tNeighborhoodID GameStateManager::getLastNeighborhood() {
+	return _lastNeighborhood;
+}
+
+void GameStateManager::setLastNeighborhood(const tNeighborhoodID neighborhood) {
+	_lastNeighborhood = neighborhood;
+}
+
+tRoomID GameStateManager::getLastRoom() {
+	return _lastRoom;
+}
+
+void GameStateManager::setLastRoom(const tRoomID room) {
+	_lastRoom = room;
+}
+
+tDirectionConstant GameStateManager::getLastDirection() {
+	return _lastDirection;
+}
+
+void GameStateManager::setLastDirection(const tDirectionConstant direction) {
+	_lastDirection = direction;
+}
+
+tRoomViewID GameStateManager::getLastRoomAndView() {
+	return MakeRoomView(_lastRoom, _lastDirection);
+}
+
+void GameStateManager::getOpenDoorLocation(tRoomID &room, tDirectionConstant &direction) {
+	room = _openDoorRoom;
+	direction = _openDoorDirection;
+}
+
+void GameStateManager::setOpenDoorLocation(const tRoomID room, const tDirectionConstant direction) {
+	_openDoorRoom = room;
+	_openDoorDirection = direction;
+}
+
+tRoomID GameStateManager::getOpenDoorRoom() {
+	return _openDoorRoom;
+}
+
+void GameStateManager::setOpenDoorRoom(const tRoomID room) {
+	_openDoorRoom = room;
+}
+
+tDirectionConstant GameStateManager::getOpenDoorDirection() {
+	return _openDoorDirection;
+}
+
+void GameStateManager::setOpenDoorDirection(const tDirectionConstant direction) {
+	_openDoorDirection = direction;
+}
+
+tRoomViewID GameStateManager::getDoorOpenRoomAndView() {
+	return MakeRoomView(_openDoorRoom, _openDoorDirection);
+}
+
+bool GameStateManager::isCurrentDoorOpen() {
+	return _openDoorRoom == _currentRoom && _openDoorDirection == _currentDirection;
+}
+
+tGameScoreType GameStateManager::getCaldoriaTSAScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringSawINNFlag))
+		result += kSawINNScore;
+	if (_scoringFlags.getFlag(kScoringTookShowerFlag))
+		result += kTookShowerScore;
+	if (_scoringFlags.getFlag(kScoringFixedHairFlag))
+		result += kFixedHairScore;
+	if (_scoringFlags.getFlag(kScoringGotKeyCardFlag))
+		result += kGotKeyCardScore;
+	if (_scoringFlags.getFlag(kScoringReadPaperFlag))
+		result += kReadPaperScore;
+	if (_scoringFlags.getFlag(kScoringLookThroughTelescopeFlag))
+		result += kLookThroughTelescopeScore;
+	if (_scoringFlags.getFlag(kScoringSawCaldoriaKioskFlag))
+		result += kSawCaldoriaKioskScore;
+	if (_scoringFlags.getFlag(kScoringGoToTSAFlag))
+		result += kGoToTSAScore;
+	if (_scoringFlags.getFlag(kScoringEnterTSAFlag))
+		result += kEnterTSAScore;
+	if (_scoringFlags.getFlag(kScoringSawBust1Flag))
+		result += kSawBust1Score;
+	if (_scoringFlags.getFlag(kScoringSawBust2Flag))
+		result += kSawBust2Score;
+	if (_scoringFlags.getFlag(kScoringSawBust3Flag))
+		result += kSawBust3Score;
+	if (_scoringFlags.getFlag(kScoringSawBust4Flag))
+		result += kSawBust4Score;
+	if (_scoringFlags.getFlag(kScoringSawBust5Flag))
+		result += kSawBust5Score;
+	if (_scoringFlags.getFlag(kScoringSawBust6Flag))
+		result += kSawBust6Score;
+	if (_scoringFlags.getFlag(kScoringSawTheoryFlag))
+		result += kSawTheoryScore;
+	if (_scoringFlags.getFlag(kScoringSawBackgroundFlag))
+		result += kSawBackgroundScore;
+	if (_scoringFlags.getFlag(kScoringSawProcedureFlag))
+		result += kSawProcedureScore;
+	if (_scoringFlags.getFlag(kScoringGotJourneymanKeyFlag))
+		result += kGotJourneymanKeyScore;
+	if (_scoringFlags.getFlag(kScoringGotPegasusBiochipFlag))
+		result += kGotPegasusBiochipScore;
+	if (_scoringFlags.getFlag(kScoringGotBiosuitFlag))
+		result += kGotBiosuitScore;
+	if (_scoringFlags.getFlag(kScoringGoToPrehistoricFlag))
+		result += kGoToPrehistoricScore;
+	if (_scoringFlags.getFlag(kScoringPutLogInReaderFlag))
+		result += kPutLogInReaderScore;
+	if (_scoringFlags.getFlag(kScoringSawCaldoriaNormalFlag))
+		result += kSawCaldoriaNormalScore;
+	if (_scoringFlags.getFlag(kScoringSawCaldoriaAlteredFlag))
+		result += kSawCaldoriaAlteredScore;
+	if (_scoringFlags.getFlag(kScoringSawNoradNormalFlag))
+		result += kSawNoradNormalScore;
+	if (_scoringFlags.getFlag(kScoringSawNoradAlteredFlag))
+		result += kSawNoradAlteredScore;
+	if (_scoringFlags.getFlag(kScoringSawMarsNormalFlag))
+		result += kSawMarsNormalScore;
+	if (_scoringFlags.getFlag(kScoringSawMarsAlteredFlag))
+		result += kSawMarsAlteredScore;
+	if (_scoringFlags.getFlag(kScoringSawWSCNormalFlag))
+		result += kSawWSCNormalScore;
+	if (_scoringFlags.getFlag(kScoringSawWSCAlteredFlag))
+		result += kSawWSCAlteredScore;
+	if (_scoringFlags.getFlag(kScoringWentToReadyRoom2Flag))
+		result += kWentToReadyRoom2Score;
+	if (_scoringFlags.getFlag(kScoringWentAfterSinclairFlag))
+		result += kWentAfterSinclairScore;
+	if (_scoringFlags.getFlag(kScoringUsedCardBombFlag))
+		result += kUsedCardBombScore;
+	if (_scoringFlags.getFlag(kScoringShieldedCardBombFlag))
+		result += kShieldedCardBombScore;
+	if (_scoringFlags.getFlag(kScoringStunnedSinclairFlag))
+		result += kStunnedSinclairScore;
+	if (_scoringFlags.getFlag(kScoringDisarmedNukeFlag))
+		result += kDisarmedNukeScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getPrehistoricScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringThrewBreakerFlag))
+		result += kThrewBreakerScore;
+	if (_scoringFlags.getFlag(kScoringExtendedBridgeFlag))
+		result += kExtendedBridgeScore;
+	if (_scoringFlags.getFlag(kScoringGotHistoricalLogFlag))
+		result += kGotHistoricalLogScore;
+	if (_scoringFlags.getFlag(kScoringFinishedPrehistoricFlag))
+		result += kFinishedPrehistoricScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getMarsScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringThrownByRobotFlag))
+		result += kThrownByRobotScore;
+	if (_scoringFlags.getFlag(kScoringGotMarsCardFlag))
+		result += kGotMarsCardScore;
+	if (_scoringFlags.getFlag(kScoringSawMarsKioskFlag))
+		result += kSawMarsKioskScore;
+	if (_scoringFlags.getFlag(kScoringSawTransportMapFlag))
+		result += kSawTransportMapScore;
+	if (_scoringFlags.getFlag(kScoringGotCrowBarFlag))
+		result += kGotCrowBarScore;
+	if (_scoringFlags.getFlag(kScoringTurnedOnTransportFlag))
+		result += kTurnedOnTransportScore;
+	if (_scoringFlags.getFlag(kScoringGotOxygenMaskFlag))
+		result += kGotOxygenMaskScore;
+	if (_scoringFlags.getFlag(kScoringAvoidedRobotFlag))
+		result += kAvoidedRobotScore;
+	if (_scoringFlags.getFlag(kScoringActivatedPlatformFlag))
+		result += kActivatedPlatformScore;
+	if (_scoringFlags.getFlag(kScoringUsedLiquidNitrogenFlag))
+		result += kUsedLiquidNitrogenScore;
+	if (_scoringFlags.getFlag(kScoringUsedCrowBarFlag))
+		result += kUsedCrowBarScore;
+	if (_scoringFlags.getFlag(kScoringFoundCardBombFlag))
+		result += kFoundCardBombScore;
+	if (_scoringFlags.getFlag(kScoringDisarmedCardBombFlag))
+		result += kDisarmedCardBombScore;
+	if (_scoringFlags.getFlag(kScoringGotCardBombFlag))
+		result += kGotCardBombScore;
+	if (_scoringFlags.getFlag(kScoringThreadedMazeFlag))
+		result += kThreadedMazeScore;
+	if (_scoringFlags.getFlag(kScoringThreadedGearRoomFlag))
+		result += kThreadedGearRoomScore;
+	if (_scoringFlags.getFlag(kScoringEnteredShuttleFlag))
+		result += kEnteredShuttleScore;
+	if (_scoringFlags.getFlag(kScoringEnteredLaunchTubeFlag))
+		result += kEnteredLaunchTubeScore;
+	if (_scoringFlags.getFlag(kScoringStoppedRobotsShuttleFlag))
+		result += kStoppedRobotsShuttleScore;
+	if (_scoringFlags.getFlag(kScoringGotMarsOpMemChipFlag))
+		result += kGotMarsOpMemChipScore;
+	if (_scoringFlags.getFlag(kScoringFinishedMarsFlag))
+		result += kFinishedMarsScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getNoradScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringSawSecurityMonitorFlag))
+		result += kSawSecurityMonitorScore;
+	if (_scoringFlags.getFlag(kScoringFilledOxygenCanisterFlag))
+		result += kFilledOxygenCanisterScore;
+	if (_scoringFlags.getFlag(kScoringFilledArgonCanisterFlag))
+		result += kFilledArgonCanisterScore;
+	if (_scoringFlags.getFlag(kScoringSawUnconsciousOperatorFlag))
+		result += kSawUnconsciousOperatorScore;
+	if (_scoringFlags.getFlag(kScoringWentThroughPressureDoorFlag))
+		result += kWentThroughPressureDoorScore;
+	if (_scoringFlags.getFlag(kScoringPreppedSubFlag))
+		result += kPreppedSubScore;
+	if (_scoringFlags.getFlag(kScoringEnteredSubFlag))
+		result += kEnteredSubScore;
+	if (_scoringFlags.getFlag(kScoringExitedSubFlag))
+		result += kExitedSubScore;
+	if (_scoringFlags.getFlag(kScoringSawRobotAt54NorthFlag))
+		result += kSawRobotAt54NorthScore;
+	if (_scoringFlags.getFlag(kScoringPlayedWithClawFlag))
+		result += kPlayedWithClawScore;
+	if (_scoringFlags.getFlag(kScoringUsedRetinalChipFlag))
+		result += kUsedRetinalChipScore;
+	if (_scoringFlags.getFlag(kScoringFinishedGlobeGameFlag))
+		result += kFinishedGlobeGameScore;
+	if (_scoringFlags.getFlag(kScoringStoppedNoradRobotFlag))
+		result += kStoppedNoradRobotScore;
+	if (_scoringFlags.getFlag(kScoringGotNoradOpMemChipFlag))
+		result += kGotNoradOpMemChipScore;
+	if (_scoringFlags.getFlag(kScoringFinishedNoradFlag))
+		result += kFinishedNoradScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getWSCScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringRemovedDartFlag))
+		result += kRemovedDartScore;
+	if (_scoringFlags.getFlag(kScoringAnalyzedDartFlag))
+		result += kAnalyzedDartScore;
+	if (_scoringFlags.getFlag(kScoringBuiltAntidoteFlag))
+		result += kBuiltAntidoteScore;
+	if (_scoringFlags.getFlag(kScoringGotSinclairKeyFlag))
+		result += kGotSinclairKeyScore;
+	if (_scoringFlags.getFlag(kScoringGotArgonCanisterFlag))
+		result += kGotArgonCanisterScore;
+	if (_scoringFlags.getFlag(kScoringGotNitrogenCanisterFlag))
+		result += kGotNitrogenCanisterScore;
+	if (_scoringFlags.getFlag(kScoringPlayedWithMessagesFlag))
+		result += kPlayedWithMessagesScore;
+	if (_scoringFlags.getFlag(kScoringSawMorphExperimentFlag))
+		result += kSawMorphExperimentScore;
+	if (_scoringFlags.getFlag(kScoringEnteredSinclairOfficeFlag))
+		result += kEnteredSinclairOfficeScore;
+	if (_scoringFlags.getFlag(kScoringSawBrochureFlag))
+		result += kSawBrochureScore;
+	if (_scoringFlags.getFlag(kScoringSawSinclairEntry1Flag))
+		result += kSawSinclairEntry1Score;
+	if (_scoringFlags.getFlag(kScoringSawSinclairEntry2Flag))
+		result += kSawSinclairEntry2Score;
+	if (_scoringFlags.getFlag(kScoringSawSinclairEntry3Flag))
+		result += kSawSinclairEntry3Score;
+	if (_scoringFlags.getFlag(kScoringSawWSCDirectoryFlag))
+		result += kSawWSCDirectoryScore;
+	if (_scoringFlags.getFlag(kScoringUsedCrowBarInWSCFlag))
+		result += kUsedCrowBarInWSCScore;
+	if (_scoringFlags.getFlag(kScoringFinishedPlasmaDodgeFlag))
+		result += kFinishedPlasmaDodgeScore;
+	if (_scoringFlags.getFlag(kScoringOpenedCatwalkFlag))
+		result += kOpenedCatwalkScore;
+	if (_scoringFlags.getFlag(kScoringStoppedWSCRobotFlag))
+		result += kStoppedWSCRobotScore;
+	if (_scoringFlags.getFlag(kScoringGotWSCOpMemChipFlag))
+		result += kGotWSCOpMemChipScore;
+	if (_scoringFlags.getFlag(kScoringFinishedWSCFlag))
+		result += kFinishedWSCScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getGandhiScore() {
+	tGameScoreType result = 0;
+
+	if (_scoringFlags.getFlag(kScoringMarsGandhiFlag))
+		result += kMarsGandhiScore;
+	if (_scoringFlags.getFlag(kScoringNoradGandhiFlag))
+		result += kNoradGandhiScore;
+	if (_scoringFlags.getFlag(kScoringWSCGandhiFlag))
+		result += kWSCGandhiScore;
+
+	return result;
+}
+
+tGameScoreType GameStateManager::getTotalScore() {
+	return	getCaldoriaTSAScore() +
+			getPrehistoricScore() +
+			getMarsScore() +
+			getNoradScore() +
+			getWSCScore() +
+			getGandhiScore();
+}
+
+/////////////////////////////////////////////
+//
+//	Caldoria data
+	
+void GameStateManager::writeCaldoriaState(Common::WriteStream *stream) {
+	_caldoriaFlags.writeToStream(stream);
+	stream->writeUint32BE(_caldoriaFuseTimeLimit);
+}
+
+void GameStateManager::readCaldoriaState(Common::ReadStream *stream) {
+	_caldoriaFlags.readFromStream(stream);
+	_caldoriaFuseTimeLimit = stream->readUint32BE();
+}
+
+void GameStateManager::resetCaldoriaState() {
+	_caldoriaFlags.clearAllFlags();
+	_caldoriaFuseTimeLimit = 0;
+}
+
+/////////////////////////////////////////////
+//
+//	TSA data
+
+void GameStateManager::writeTSAState(Common::WriteStream *stream) {
+	_TSAFlags.writeToStream(stream);
+	stream->writeUint32BE(_TSARipTimerTime);
+	stream->writeUint32BE(_TSAFuseTimeLimit);
+	stream->writeByte(_TSAState);
+	stream->writeByte(_T0BMonitorMode);
+	stream->writeUint32BE(_T0BMonitorStart);
+}
+
+void GameStateManager::readTSAState(Common::ReadStream *stream) {
+	_TSAFlags.readFromStream(stream);
+	_TSARipTimerTime = stream->readUint32BE();
+	_TSAFuseTimeLimit = stream->readUint32BE();
+	_TSAState = stream->readByte();
+	_T0BMonitorMode = stream->readByte();
+	_T0BMonitorStart = stream->readUint32BE();
+}
+
+void GameStateManager::resetTSAState() {
+	_TSAFlags.clearAllFlags();
+	_TSAState = 0;
+	_T0BMonitorMode = 0;
+	_T0BMonitorStart = 0;
+	_TSARipTimerTime = 0;
+	_TSAFuseTimeLimit = kTSAUncreatedTimeLimit;
+}
+
+/////////////////////////////////////////////
+//
+//	Prehistoric data
+
+void GameStateManager::writePrehistoricState(Common::WriteStream *stream) {
+	_prehistoricFlags.writeToStream(stream);
+}
+
+void GameStateManager::readPrehistoricState(Common::ReadStream *stream) {
+	_prehistoricFlags.readFromStream(stream);
+}
+
+void GameStateManager::resetPrehistoricState() {
+	_prehistoricFlags.clearAllFlags();
+}
+
+/////////////////////////////////////////////
+//
+//	Norad data
+
+void GameStateManager::writeNoradState(Common::WriteStream *stream) {
+	_noradFlags.writeToStream(stream);
+	stream->writeUint16BE(_noradSubRoomPressure);
+	stream->writeUint32BE(_noradSubPrepState); // FIXME: sizeof(enum)!
+}
+
+void GameStateManager::readNoradState(Common::ReadStream *stream) {
+	_noradFlags.readFromStream(stream);
+	_noradSubRoomPressure = stream->readUint16BE();
+	_noradSubPrepState = (tNoradSubPrepState)stream->readUint32BE(); // FIXME: sizeof(enum)!
+}
+
+void GameStateManager::resetNoradState() {
+	_noradFlags.clearAllFlags();
+	_noradSubRoomPressure = 9;
+	_noradSubPrepState = kSubNotPrepped;
+}
+
+/////////////////////////////////////////////
+//
+//	Mars data
+
+void GameStateManager::writeMarsState(Common::WriteStream *stream) {
+	_marsFlags.writeToStream(stream);
+}
+
+void GameStateManager::readMarsState(Common::ReadStream *stream) {
+	_marsFlags.readFromStream(stream);
+}
+
+void GameStateManager::resetMarsState() {
+	_marsFlags.clearAllFlags();
+}
+
+/////////////////////////////////////////////
+//
+//	WSC data
+
+void GameStateManager::writeWSCState(Common::WriteStream *stream) {
+	_WSCFlags.writeToStream(stream);
+}
+
+void GameStateManager::readWSCState(Common::ReadStream *stream) {
+	_WSCFlags.readFromStream(stream);
+}
+
+void GameStateManager::resetWSCState() {
+	_WSCFlags.clearAllFlags();
+}
+
+void GameStateManager::setScoringSawINN(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawINNFlag, flag);
+}
+
+void GameStateManager::setScoringTookShower(const bool flag) {
+	_scoringFlags.setFlag(kScoringTookShowerFlag, flag);
+}
+
+void GameStateManager::setScoringFixedHair(const bool flag) {
+	_scoringFlags.setFlag(kScoringFixedHairFlag, flag);
+}
+
+void GameStateManager::setScoringGotKeyCard(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotKeyCardFlag, flag);
+}
+
+void GameStateManager::setScoringReadPaper(const bool flag) {
+	_scoringFlags.setFlag(kScoringReadPaperFlag, flag);
+}
+
+void GameStateManager::setScoringLookThroughTelescope(const bool flag) {
+	_scoringFlags.setFlag(kScoringLookThroughTelescopeFlag, flag);
+}
+
+void GameStateManager::setScoringSawCaldoriaKiosk(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawCaldoriaKioskFlag, flag);
+}
+
+void GameStateManager::setScoringGoToTSA(const bool flag) {
+	_scoringFlags.setFlag(kScoringGoToTSAFlag, flag);
+}
+
+void GameStateManager::setScoringEnterTSA(const bool flag) {
+	_scoringFlags.setFlag(kScoringEnterTSAFlag, flag);
+}
+
+void GameStateManager::setScoringSawBust1(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust1Flag, flag);
+}
+
+void GameStateManager::setScoringSawBust2(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust2Flag, flag);
+}
+
+void GameStateManager::setScoringSawBust3(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust3Flag, flag);
+}
+
+void GameStateManager::setScoringSawBust4(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust4Flag, flag);
+}
+
+void GameStateManager::setScoringSawBust5(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust5Flag, flag);
+}
+
+void GameStateManager::setScoringSawBust6(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBust6Flag, flag);
+}
+
+void GameStateManager::setScoringSawTheory(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawTheoryFlag, flag);
+}
+
+void GameStateManager::setScoringSawBackground(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBackgroundFlag, flag);
+}
+
+void GameStateManager::setScoringSawProcedure(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawProcedureFlag, flag);
+}
+
+void GameStateManager::setScoringGotJourneymanKey(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotJourneymanKeyFlag, flag);
+}
+
+void GameStateManager::setScoringGotPegasusBiochip(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotPegasusBiochipFlag, flag);
+}
+
+void GameStateManager::setScoringGotBiosuit(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotBiosuitFlag, flag);
+}
+
+void GameStateManager::setScoringGoToPrehistoric(const bool flag) {
+	_scoringFlags.setFlag(kScoringGoToPrehistoricFlag, flag);
+}
+
+void GameStateManager::setScoringPutLogInReader(const bool flag) {
+	_scoringFlags.setFlag(kScoringPutLogInReaderFlag, flag);
+}
+
+void GameStateManager::setScoringSawCaldoriaNormal(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawCaldoriaNormalFlag, flag);
+}
+
+void GameStateManager::setScoringSawCaldoriaAltered(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawCaldoriaAlteredFlag, flag);
+}
+
+void GameStateManager::setScoringSawNoradNormal(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawNoradNormalFlag, flag);
+}
+
+void GameStateManager::setScoringSawNoradAltered(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawNoradAlteredFlag, flag);
+}
+
+void GameStateManager::setScoringSawMarsNormal(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawMarsNormalFlag, flag);
+}
+
+void GameStateManager::setScoringSawMarsAltered(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawMarsAlteredFlag, flag);
+}
+
+void GameStateManager::setScoringSawWSCNormal(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawWSCNormalFlag, flag);
+}
+
+void GameStateManager::setScoringSawWSCAltered(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawWSCAlteredFlag, flag);
+}
+
+void GameStateManager::setScoringWentToReadyRoom2(const bool flag) {
+	_scoringFlags.setFlag(kScoringWentToReadyRoom2Flag, flag);
+}
+
+void GameStateManager::setScoringWentAfterSinclair(const bool flag) {
+	_scoringFlags.setFlag(kScoringWentAfterSinclairFlag, flag);
+}
+
+void GameStateManager::setScoringUsedCardBomb(const bool flag) {
+	_scoringFlags.setFlag(kScoringUsedCardBombFlag, flag);
+}
+
+void GameStateManager::setScoringShieldedCardBomb(const bool flag) {
+	_scoringFlags.setFlag(kScoringShieldedCardBombFlag, flag);
+}
+
+void GameStateManager::setScoringStunnedSinclair(const bool flag) {
+	_scoringFlags.setFlag(kScoringStunnedSinclairFlag, flag);
+}
+
+void GameStateManager::setScoringDisarmedNuke(const bool flag) {
+	_scoringFlags.setFlag(kScoringDisarmedNukeFlag, flag);
+}
+
+void GameStateManager::setScoringThrewBreaker(const bool flag) {
+	_scoringFlags.setFlag(kScoringThrewBreakerFlag, flag);
+}
+
+void GameStateManager::setScoringExtendedBridge(const bool flag) {
+	_scoringFlags.setFlag(kScoringExtendedBridgeFlag, flag);
+}
+
+void GameStateManager::setScoringGotHistoricalLog(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotHistoricalLogFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedPrehistoric(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedPrehistoricFlag, flag);
+}
+
+void GameStateManager::setScoringThrownByRobot(const bool flag) {
+	_scoringFlags.setFlag(kScoringThrownByRobotFlag, flag);
+}
+
+void GameStateManager::setScoringGotMarsCard(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotMarsCardFlag, flag);
+}
+
+void GameStateManager::setScoringSawMarsKiosk(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawMarsKioskFlag, flag);
+}
+
+void GameStateManager::setScoringSawTransportMap(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawTransportMapFlag, flag);
+}
+
+void GameStateManager::setScoringGotCrowBar(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotCrowBarFlag, flag);
+}
+
+void GameStateManager::setScoringTurnedOnTransport(const bool flag) {
+	_scoringFlags.setFlag(kScoringTurnedOnTransportFlag, flag);
+}
+
+void GameStateManager::setScoringGotOxygenMask(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotOxygenMaskFlag, flag);
+}
+
+void GameStateManager::setScoringAvoidedRobot(const bool flag) {
+	_scoringFlags.setFlag(kScoringAvoidedRobotFlag, flag);
+}
+
+void GameStateManager::setScoringActivatedPlatform(const bool flag) {
+	_scoringFlags.setFlag(kScoringActivatedPlatformFlag, flag);
+}
+
+void GameStateManager::setScoringUsedLiquidNitrogen(const bool flag) {
+	_scoringFlags.setFlag(kScoringUsedLiquidNitrogenFlag, flag);
+}
+
+void GameStateManager::setScoringUsedCrowBar(const bool flag) {
+	_scoringFlags.setFlag(kScoringUsedCrowBarFlag, flag);
+}
+
+void GameStateManager::setScoringFoundCardBomb(const bool flag) {
+	_scoringFlags.setFlag(kScoringFoundCardBombFlag, flag);
+}
+
+void GameStateManager::setScoringDisarmedCardBomb(const bool flag) {
+	_scoringFlags.setFlag(kScoringDisarmedCardBombFlag, flag);
+}
+
+void GameStateManager::setScoringGotCardBomb(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotCardBombFlag, flag);
+}
+
+void GameStateManager::setScoringThreadedMaze(const bool flag) {
+	_scoringFlags.setFlag(kScoringThreadedMazeFlag, flag);
+}
+
+void GameStateManager::setScoringThreadedGearRoom(const bool flag) {
+	_scoringFlags.setFlag(kScoringThreadedGearRoomFlag, flag);
+}
+
+void GameStateManager::setScoringEnteredShuttle(const bool flag) {
+	_scoringFlags.setFlag(kScoringEnteredShuttleFlag, flag);
+}
+
+void GameStateManager::setScoringEnteredLaunchTube(const bool flag) {
+	_scoringFlags.setFlag(kScoringEnteredLaunchTubeFlag, flag);
+}
+
+void GameStateManager::setScoringStoppedRobotsShuttle(const bool flag) {
+	_scoringFlags.setFlag(kScoringStoppedRobotsShuttleFlag, flag);
+}
+
+void GameStateManager::setScoringGotMarsOpMemChip(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotMarsOpMemChipFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedMars(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedMarsFlag, flag);
+}
+
+void GameStateManager::setScoringSawSecurityMonitor(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawSecurityMonitorFlag, flag);
+}
+
+void GameStateManager::setScoringFilledOxygenCanister(const bool flag) {
+	_scoringFlags.setFlag(kScoringFilledOxygenCanisterFlag, flag);
+}
+
+void GameStateManager::setScoringFilledArgonCanister(const bool flag) {
+	_scoringFlags.setFlag(kScoringFilledArgonCanisterFlag, flag);
+}
+
+void GameStateManager::setScoringSawUnconsciousOperator(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawUnconsciousOperatorFlag, flag);
+}
+
+void GameStateManager::setScoringWentThroughPressureDoor(const bool flag) {
+	_scoringFlags.setFlag(kScoringWentThroughPressureDoorFlag, flag);
+}
+
+void GameStateManager::setScoringPreppedSub(const bool flag) {
+	_scoringFlags.setFlag(kScoringPreppedSubFlag, flag);
+}
+
+void GameStateManager::setScoringEnteredSub(const bool flag) {
+	_scoringFlags.setFlag(kScoringEnteredSubFlag, flag);
+}
+
+void GameStateManager::setScoringExitedSub(const bool flag) {
+	_scoringFlags.setFlag(kScoringExitedSubFlag, flag);
+}
+
+void GameStateManager::setScoringSawRobotAt54North(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawRobotAt54NorthFlag, flag);
+}
+
+void GameStateManager::setScoringPlayedWithClaw(const bool flag) {
+	_scoringFlags.setFlag(kScoringPlayedWithClawFlag, flag);
+}
+
+void GameStateManager::setScoringUsedRetinalChip(const bool flag) {
+	_scoringFlags.setFlag(kScoringUsedRetinalChipFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedGlobeGame(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedGlobeGameFlag, flag);
+}
+
+void GameStateManager::setScoringStoppedNoradRobot(const bool flag) {
+	_scoringFlags.setFlag(kScoringStoppedNoradRobotFlag, flag);
+}
+
+void GameStateManager::setScoringGotNoradOpMemChip(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotNoradOpMemChipFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedNorad(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedNoradFlag, flag);
+}
+
+void GameStateManager::setScoringRemovedDart(const bool flag) {
+	_scoringFlags.setFlag(kScoringRemovedDartFlag, flag);
+}
+
+void GameStateManager::setScoringAnalyzedDart(const bool flag) {
+	_scoringFlags.setFlag(kScoringAnalyzedDartFlag, flag);
+}
+
+void GameStateManager::setScoringBuiltAntidote(const bool flag) {
+	_scoringFlags.setFlag(kScoringBuiltAntidoteFlag, flag);
+}
+
+void GameStateManager::setScoringGotSinclairKey(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotSinclairKeyFlag, flag);
+}
+
+void GameStateManager::setScoringGotArgonCanister(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotArgonCanisterFlag, flag);
+}
+
+void GameStateManager::setScoringGotNitrogenCanister(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotNitrogenCanisterFlag, flag);
+}
+
+void GameStateManager::setScoringPlayedWithMessages(const bool flag) {
+	_scoringFlags.setFlag(kScoringPlayedWithMessagesFlag, flag);
+}
+
+void GameStateManager::setScoringSawMorphExperiment(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawMorphExperimentFlag, flag);
+}
+
+void GameStateManager::setScoringEnteredSinclairOffice(const bool flag) {
+	_scoringFlags.setFlag(kScoringEnteredSinclairOfficeFlag, flag);
+}
+
+void GameStateManager::setScoringSawBrochure(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawBrochureFlag, flag);
+}
+
+void GameStateManager::setScoringSawSinclairEntry1(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawSinclairEntry1Flag, flag);
+}
+
+void GameStateManager::setScoringSawSinclairEntry2(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawSinclairEntry2Flag, flag);
+}
+
+void GameStateManager::setScoringSawSinclairEntry3(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawSinclairEntry3Flag, flag);
+}
+
+void GameStateManager::setScoringSawWSCDirectory(const bool flag) {
+	_scoringFlags.setFlag(kScoringSawWSCDirectoryFlag, flag);
+}
+
+void GameStateManager::setScoringUsedCrowBarInWSC(const bool flag) {
+	_scoringFlags.setFlag(kScoringUsedCrowBarInWSCFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedPlasmaDodge(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedPlasmaDodgeFlag, flag);
+}
+
+void GameStateManager::setScoringOpenedCatwalk(const bool flag) {
+	_scoringFlags.setFlag(kScoringOpenedCatwalkFlag, flag);
+}
+
+void GameStateManager::setScoringStoppedWSCRobot(const bool flag) {
+	_scoringFlags.setFlag(kScoringStoppedWSCRobotFlag, flag);
+}
+
+void GameStateManager::setScoringGotWSCOpMemChip(const bool flag) {
+	_scoringFlags.setFlag(kScoringGotWSCOpMemChipFlag, flag);
+}
+
+void GameStateManager::setScoringFinishedWSC(const bool flag) {
+	_scoringFlags.setFlag(kScoringFinishedWSCFlag, flag);
+}
+
+void GameStateManager::setScoringMarsGandhi(const bool flag) {
+	_scoringFlags.setFlag(kScoringMarsGandhiFlag, flag);
+}
+
+void GameStateManager::setScoringNoradGandhi(const bool flag) {
+	_scoringFlags.setFlag(kScoringNoradGandhiFlag, flag);
+}
+
+void GameStateManager::setScoringWSCGandhi(const bool flag) {
+	_scoringFlags.setFlag(kScoringWSCGandhiFlag, flag);
+}
+
+bool GameStateManager::getScoringSawINN() {
+	return _scoringFlags.getFlag(kScoringSawINNFlag);
+}
+
+bool GameStateManager::getScoringTookShower() {
+	return _scoringFlags.getFlag(kScoringTookShowerFlag);
+}
+
+bool GameStateManager::getScoringFixedHair() {
+	return _scoringFlags.getFlag(kScoringFixedHairFlag);
+}
+
+bool GameStateManager::getScoringGotKeyCard() {
+	return _scoringFlags.getFlag(kScoringGotKeyCardFlag);
+}
+
+bool GameStateManager::getScoringReadPaper() {
+	return _scoringFlags.getFlag(kScoringReadPaperFlag);
+}
+
+bool GameStateManager::getScoringLookThroughTelescope() {
+	return _scoringFlags.getFlag(kScoringLookThroughTelescopeFlag);
+}
+
+bool GameStateManager::getScoringSawCaldoriaKiosk() {
+	return _scoringFlags.getFlag(kScoringSawCaldoriaKioskFlag);
+}
+
+bool GameStateManager::getScoringGoToTSA() {
+	return _scoringFlags.getFlag(kScoringGoToTSAFlag);
+}
+
+bool GameStateManager::getScoringEnterTSA() {
+	return _scoringFlags.getFlag(kScoringEnterTSAFlag);
+}
+
+bool GameStateManager::getScoringSawBust1() {
+	return _scoringFlags.getFlag(kScoringSawBust1Flag);
+}
+
+bool GameStateManager::getScoringSawBust2() {
+	return _scoringFlags.getFlag(kScoringSawBust2Flag);
+}
+
+bool GameStateManager::getScoringSawBust3() {
+	return _scoringFlags.getFlag(kScoringSawBust3Flag);
+}
+
+bool GameStateManager::getScoringSawBust4() {
+	return _scoringFlags.getFlag(kScoringSawBust4Flag);
+}
+
+bool GameStateManager::getScoringSawBust5() {
+	return _scoringFlags.getFlag(kScoringSawBust5Flag);
+}
+
+bool GameStateManager::getScoringSawBust6() {
+	return _scoringFlags.getFlag(kScoringSawBust6Flag);
+}
+
+bool GameStateManager::getScoringSawTheory() {
+	return _scoringFlags.getFlag(kScoringSawTheoryFlag);
+}
+
+bool GameStateManager::getScoringSawBackground() {
+	return _scoringFlags.getFlag(kScoringSawBackgroundFlag);
+}
+
+bool GameStateManager::getScoringSawProcedure() {
+	return _scoringFlags.getFlag(kScoringSawProcedureFlag);
+}
+
+bool GameStateManager::getScoringGotJourneymanKey() {
+	return _scoringFlags.getFlag(kScoringGotJourneymanKeyFlag);
+}
+
+bool GameStateManager::getScoringGotPegasusBiochip() {
+	return _scoringFlags.getFlag(kScoringGotPegasusBiochipFlag);
+}
+
+bool GameStateManager::getScoringGotBiosuit() {
+	return _scoringFlags.getFlag(kScoringGotBiosuitFlag);
+}
+
+bool GameStateManager::getScoringGoToPrehistoric() {
+	return _scoringFlags.getFlag(kScoringGoToPrehistoricFlag);
+}
+
+bool GameStateManager::getScoringPutLogInReader() {
+	return _scoringFlags.getFlag(kScoringPutLogInReaderFlag);
+}
+
+bool GameStateManager::getScoringSawCaldoriaNormal() {
+	return _scoringFlags.getFlag(kScoringSawCaldoriaNormalFlag);
+}
+
+bool GameStateManager::getScoringSawCaldoriaAltered() {
+	return _scoringFlags.getFlag(kScoringSawCaldoriaAlteredFlag);
+}
+
+bool GameStateManager::getScoringSawNoradNormal() {
+	return _scoringFlags.getFlag(kScoringSawNoradNormalFlag);
+}
+
+bool GameStateManager::getScoringSawNoradAltered() {
+	return _scoringFlags.getFlag(kScoringSawNoradAlteredFlag);
+}
+
+bool GameStateManager::getScoringSawMarsNormal() {
+	return _scoringFlags.getFlag(kScoringSawMarsNormalFlag);
+}
+
+bool GameStateManager::getScoringSawMarsAltered() {
+	return _scoringFlags.getFlag(kScoringSawMarsAlteredFlag);
+}
+
+bool GameStateManager::getScoringSawWSCNormal() {
+	return _scoringFlags.getFlag(kScoringSawWSCNormalFlag);
+}
+
+bool GameStateManager::getScoringSawWSCAltered() {
+	return _scoringFlags.getFlag(kScoringSawWSCAlteredFlag);
+}
+
+bool GameStateManager::getScoringWentToReadyRoom2() {
+	return _scoringFlags.getFlag(kScoringWentToReadyRoom2Flag);
+}
+
+bool GameStateManager::getScoringWentAfterSinclair() {
+	return _scoringFlags.getFlag(kScoringWentAfterSinclairFlag);
+}
+
+bool GameStateManager::getScoringUsedCardBomb() {
+	return _scoringFlags.getFlag(kScoringUsedCardBombFlag);
+}
+
+bool GameStateManager::getScoringShieldedCardBomb() {
+	return _scoringFlags.getFlag(kScoringShieldedCardBombFlag);
+}
+
+bool GameStateManager::getScoringStunnedSinclair() {
+	return _scoringFlags.getFlag(kScoringStunnedSinclairFlag);
+}
+
+bool GameStateManager::getScoringDisarmedNuke() {
+	return _scoringFlags.getFlag(kScoringDisarmedNukeFlag);
+}
+
+bool GameStateManager::getScoringThrewBreaker() {
+	return _scoringFlags.getFlag(kScoringThrewBreakerFlag);
+}
+
+bool GameStateManager::getScoringExtendedBridge() {
+	return _scoringFlags.getFlag(kScoringExtendedBridgeFlag);
+}
+
+bool GameStateManager::getScoringGotHistoricalLog() {
+	return _scoringFlags.getFlag(kScoringGotHistoricalLogFlag);
+}
+
+bool GameStateManager::getScoringFinishedPrehistoric() {
+	return _scoringFlags.getFlag(kScoringFinishedPrehistoricFlag);
+}
+
+bool GameStateManager::getScoringThrownByRobot() {
+	return _scoringFlags.getFlag(kScoringThrownByRobotFlag);
+}
+
+bool GameStateManager::getScoringGotMarsCard() {
+	return _scoringFlags.getFlag(kScoringGotMarsCardFlag);
+}
+
+bool GameStateManager::getScoringSawMarsKiosk() {
+	return _scoringFlags.getFlag(kScoringSawMarsKioskFlag);
+}
+
+bool GameStateManager::getScoringSawTransportMap() {
+	return _scoringFlags.getFlag(kScoringSawTransportMapFlag);
+}
+
+bool GameStateManager::getScoringGotCrowBar() {
+	return _scoringFlags.getFlag(kScoringGotCrowBarFlag);
+}
+
+bool GameStateManager::getScoringTurnedOnTransport() {
+	return _scoringFlags.getFlag(kScoringTurnedOnTransportFlag);
+}
+
+bool GameStateManager::getScoringGotOxygenMask() {
+	return _scoringFlags.getFlag(kScoringGotOxygenMaskFlag);
+}
+
+bool GameStateManager::getScoringAvoidedRobot() {
+	return _scoringFlags.getFlag(kScoringAvoidedRobotFlag);
+}
+
+bool GameStateManager::getScoringActivatedPlatform() {
+	return _scoringFlags.getFlag(kScoringActivatedPlatformFlag);
+}
+
+bool GameStateManager::getScoringUsedLiquidNitrogen() {
+	return _scoringFlags.getFlag(kScoringUsedLiquidNitrogenFlag);
+}
+
+bool GameStateManager::getScoringUsedCrowBar() {
+	return _scoringFlags.getFlag(kScoringUsedCrowBarFlag);
+}
+
+bool GameStateManager::getScoringFoundCardBomb() {
+	return _scoringFlags.getFlag(kScoringFoundCardBombFlag);
+}
+
+bool GameStateManager::getScoringDisarmedCardBomb() {
+	return _scoringFlags.getFlag(kScoringDisarmedCardBombFlag);
+}
+
+bool GameStateManager::getScoringGotCardBomb() {
+	return _scoringFlags.getFlag(kScoringGotCardBombFlag);
+}
+
+bool GameStateManager::getScoringThreadedMaze() {
+	return _scoringFlags.getFlag(kScoringThreadedMazeFlag);
+}
+
+bool GameStateManager::getScoringThreadedGearRoom() {
+	return _scoringFlags.getFlag(kScoringThreadedGearRoomFlag);
+}
+
+bool GameStateManager::getScoringEnteredShuttle() {
+	return _scoringFlags.getFlag(kScoringEnteredShuttleFlag);
+}
+
+bool GameStateManager::getScoringEnteredLaunchTube() {
+	return _scoringFlags.getFlag(kScoringEnteredLaunchTubeFlag);
+}
+
+bool GameStateManager::getScoringStoppedRobotsShuttle() {
+	return _scoringFlags.getFlag(kScoringStoppedRobotsShuttleFlag);
+}
+
+bool GameStateManager::getScoringGotMarsOpMemChip() {
+	return _scoringFlags.getFlag(kScoringGotMarsOpMemChipFlag);
+}
+
+bool GameStateManager::getScoringFinishedMars() {
+	return _scoringFlags.getFlag(kScoringFinishedMarsFlag);
+}
+
+bool GameStateManager::getScoringSawSecurityMonitor() {
+	return _scoringFlags.getFlag(kScoringSawSecurityMonitorFlag);
+}
+
+bool GameStateManager::getScoringFilledOxygenCanister() {
+	return _scoringFlags.getFlag(kScoringFilledOxygenCanisterFlag);
+}
+
+bool GameStateManager::getScoringFilledArgonCanister() {
+	return _scoringFlags.getFlag(kScoringFilledArgonCanisterFlag);
+}
+
+bool GameStateManager::getScoringSawUnconsciousOperator() {
+	return _scoringFlags.getFlag(kScoringSawUnconsciousOperatorFlag);
+}
+
+bool GameStateManager::getScoringWentThroughPressureDoor() {
+	return _scoringFlags.getFlag(kScoringWentThroughPressureDoorFlag);
+}
+
+bool GameStateManager::getScoringPreppedSub() {
+	return _scoringFlags.getFlag(kScoringPreppedSubFlag);
+}
+
+bool GameStateManager::getScoringEnteredSub() {
+	return _scoringFlags.getFlag(kScoringEnteredSubFlag);
+}
+
+bool GameStateManager::getScoringExitedSub() {
+	return _scoringFlags.getFlag(kScoringExitedSubFlag);
+}
+
+bool GameStateManager::getScoringSawRobotAt54North() {
+	return _scoringFlags.getFlag(kScoringSawRobotAt54NorthFlag);
+}
+
+bool GameStateManager::getScoringPlayedWithClaw() {
+	return _scoringFlags.getFlag(kScoringPlayedWithClawFlag);
+}
+
+bool GameStateManager::getScoringUsedRetinalChip() {
+	return _scoringFlags.getFlag(kScoringUsedRetinalChipFlag);
+}
+
+bool GameStateManager::getScoringFinishedGlobeGame() {
+	return _scoringFlags.getFlag(kScoringFinishedGlobeGameFlag);
+}
+
+bool GameStateManager::getScoringStoppedNoradRobot() {
+	return _scoringFlags.getFlag(kScoringStoppedNoradRobotFlag);
+}
+
+bool GameStateManager::getScoringGotNoradOpMemChip() {
+	return _scoringFlags.getFlag(kScoringGotNoradOpMemChipFlag);
+}
+
+bool GameStateManager::getScoringFinishedNorad() {
+	return _scoringFlags.getFlag(kScoringFinishedNoradFlag);
+}
+
+bool GameStateManager::getScoringRemovedDart() {
+	return _scoringFlags.getFlag(kScoringRemovedDartFlag);
+}
+
+bool GameStateManager::getScoringAnalyzedDart() {
+	return _scoringFlags.getFlag(kScoringAnalyzedDartFlag);
+}
+
+bool GameStateManager::getScoringBuiltAntidote() {
+	return _scoringFlags.getFlag(kScoringBuiltAntidoteFlag);
+}
+
+bool GameStateManager::getScoringGotSinclairKey() {
+	return _scoringFlags.getFlag(kScoringGotSinclairKeyFlag);
+}
+
+bool GameStateManager::getScoringGotArgonCanister() {
+	return _scoringFlags.getFlag(kScoringGotArgonCanisterFlag);
+}
+
+bool GameStateManager::getScoringGotNitrogenCanister() {
+	return _scoringFlags.getFlag(kScoringGotNitrogenCanisterFlag);
+}
+
+bool GameStateManager::getScoringPlayedWithMessages() {
+	return _scoringFlags.getFlag(kScoringPlayedWithMessagesFlag);
+}
+
+bool GameStateManager::getScoringSawMorphExperiment() {
+	return _scoringFlags.getFlag(kScoringSawMorphExperimentFlag);
+}
+
+bool GameStateManager::getScoringEnteredSinclairOffice() {
+	return _scoringFlags.getFlag(kScoringEnteredSinclairOfficeFlag);
+}
+
+bool GameStateManager::getScoringSawBrochure() {
+	return _scoringFlags.getFlag(kScoringSawBrochureFlag);
+}
+
+bool GameStateManager::getScoringSawSinclairEntry1() {
+	return _scoringFlags.getFlag(kScoringSawSinclairEntry1Flag);
+}
+
+bool GameStateManager::getScoringSawSinclairEntry2() {
+	return _scoringFlags.getFlag(kScoringSawSinclairEntry2Flag);
+}
+
+bool GameStateManager::getScoringSawSinclairEntry3() {
+	return _scoringFlags.getFlag(kScoringSawSinclairEntry3Flag);
+}
+
+bool GameStateManager::getScoringSawWSCDirectory() {
+	return _scoringFlags.getFlag(kScoringSawWSCDirectoryFlag);
+}
+
+bool GameStateManager::getScoringUsedCrowBarInWSC() {
+	return _scoringFlags.getFlag(kScoringUsedCrowBarInWSCFlag);
+}
+
+bool GameStateManager::getScoringFinishedPlasmaDodge() {
+	return _scoringFlags.getFlag(kScoringFinishedPlasmaDodgeFlag);
+}
+
+bool GameStateManager::getScoringOpenedCatwalk() {
+	return _scoringFlags.getFlag(kScoringOpenedCatwalkFlag);
+}
+
+bool GameStateManager::getScoringStoppedWSCRobot() {
+	return _scoringFlags.getFlag(kScoringStoppedWSCRobotFlag);
+}
+
+bool GameStateManager::getScoringGotWSCOpMemChip() {
+	return _scoringFlags.getFlag(kScoringGotWSCOpMemChipFlag);
+}
+
+bool GameStateManager::getScoringFinishedWSC() {
+	return _scoringFlags.getFlag(kScoringFinishedWSCFlag);
+}
+
+bool GameStateManager::getScoringMarsGandhi() {
+	return _scoringFlags.getFlag(kScoringMarsGandhiFlag);
+}
+
+bool GameStateManager::getScoringNoradGandhi() {
+	return _scoringFlags.getFlag(kScoringNoradGandhiFlag);
+}
+
+bool GameStateManager::getScoringWSCGandhi() {
+	return _scoringFlags.getFlag(kScoringWSCGandhiFlag);
+}
+
+void GameStateManager::setWalkthroughMode(bool value) {
+	_globalFlags.setFlag(kGlobalWalkthroughFlag, value);
+}
+
+bool GameStateManager::getWalkthroughMode() {
+	return _globalFlags.getFlag(kGlobalWalkthroughFlag);
+}
+
+void GameStateManager::setShieldOn(bool value) {
+	_globalFlags.setFlag(kGlobalShieldOnFlag, value);
+}
+
+bool GameStateManager::getShieldOn() {
+	return _globalFlags.getFlag(kGlobalShieldOnFlag);
+}
+
+void GameStateManager::setEasterEgg(bool value) {
+	_globalFlags.setFlag(kGlobalEasterEggFlag, value);
+}
+
+bool GameStateManager::getEasterEgg() {
+	return _globalFlags.getFlag(kGlobalEasterEggFlag);
+}
+
+void GameStateManager::setBeenToWSC(bool value) {
+	_globalFlags.setFlag(kGlobalBeenToWSCFlag, value);
+}
+
+bool GameStateManager::getBeenToWSC() {
+	return _globalFlags.getFlag(kGlobalBeenToWSCFlag);
+}
+
+void GameStateManager::setBeenToMars(bool value) {
+	_globalFlags.setFlag(kGlobalBeenToMarsFlag, value);
+}
+
+bool GameStateManager::getBeenToMars() {
+	return _globalFlags.getFlag(kGlobalBeenToMarsFlag);
+}
+
+void GameStateManager::setBeenToNorad(bool value) {
+	_globalFlags.setFlag(kGlobalBeenToNoradFlag, value);
+}
+
+bool GameStateManager::getBeenToNorad() {
+	return _globalFlags.getFlag(kGlobalBeenToNoradFlag);
+}
+
+void GameStateManager::setWSCFinished(bool value) {
+	_globalFlags.setFlag(kGlobalWSCFinishedFlag, value);
+}
+
+bool GameStateManager::getWSCFinished() {
+	return _globalFlags.getFlag(kGlobalWSCFinishedFlag);
+}
+
+void GameStateManager::setMarsFinished(bool value) {
+	_globalFlags.setFlag(kGlobalMarsFinishedFlag, value);
+}
+
+bool GameStateManager::getMarsFinished() {
+	return _globalFlags.getFlag(kGlobalMarsFinishedFlag);
+}
+
+void GameStateManager::setNoradFinished(bool value) {
+	_globalFlags.setFlag(kGlobalNoradFinishedFlag, value);
+}
+
+bool GameStateManager::getNoradFinished() {
+	return _globalFlags.getFlag(kGlobalNoradFinishedFlag);
+}
+
+bool GameStateManager::allTimeZonesFinished() {
+	return getWSCFinished() && getMarsFinished() && getNoradFinished();
+}
+
+void GameStateManager::setTakenItemID(tItemID id, bool value) {
+	_itemTakenFlags.setFlag(id, value);
+}
+
+bool GameStateManager::isTakenItemID(tItemID id) {
+	return _itemTakenFlags.getFlag(id);
+}
+
+void GameStateManager::setTakenItem(CItem *item, bool value) {
+	setTakenItemID(item->GetObjectID(), value);
+}
+
+bool GameStateManager::isTakenItem(CItem *item) {
+	return isTakenItemID(item->GetObjectID());
+}
+
+void GameStateManager::setCaldoriaFuseTimeLimit(const TimeValue timeLimit) {
+	_caldoriaFuseTimeLimit = timeLimit;
+}
+
+TimeValue GameStateManager::getCaldoriaFuseTimeLimit() {
+	return _caldoriaFuseTimeLimit;
+}
+
+void GameStateManager::setCaldoriaSeenPullback(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSeenPullbackFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSeenPullback() {
+	return _caldoriaFlags.getFlag(kCaldoriaSeenPullbackFlag);
+}
+
+void GameStateManager::setCaldoriaMadeOJ(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaMadeOJFlag, value);
+}
+
+bool GameStateManager::getCaldoriaMadeOJ() {
+	return _caldoriaFlags.getFlag(kCaldoriaMadeOJFlag);
+}
+
+void GameStateManager::setCaldoriaWokenUp(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaWokenUpFlag, value);
+}
+
+bool GameStateManager::getCaldoriaWokenUp() {
+	return _caldoriaFlags.getFlag(kCaldoriaWokenUpFlag);
+}
+
+void GameStateManager::setCaldoriaDidRecalibration(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaDidRecalibrationFlag, value);
+}
+
+bool GameStateManager::getCaldoriaDidRecalibration() {
+	return _caldoriaFlags.getFlag(kCaldoriaDidRecalibrationFlag);
+}
+
+void GameStateManager::setCaldoriaSeenSinclairInElevator(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSeenSinclairInElevatorFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSeenSinclairInElevator() {
+	return _caldoriaFlags.getFlag(kCaldoriaSeenSinclairInElevatorFlag);
+}
+
+void GameStateManager::setCaldoriaINNAnnouncing(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaINNAnnouncingFlag, value);
+}
+
+bool GameStateManager::getCaldoriaINNAnnouncing() {
+	return _caldoriaFlags.getFlag(kCaldoriaINNAnnouncingFlag);
+}
+
+void GameStateManager::setCaldoriaSeenINN(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSeenINNFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSeenINN() {
+	return _caldoriaFlags.getFlag(kCaldoriaSeenINNFlag);
+}
+
+void GameStateManager::setCaldoriaSeenMessages(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSeenMessagesFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSeenMessages() {
+	return _caldoriaFlags.getFlag(kCaldoriaSeenMessagesFlag);
+}
+
+void GameStateManager::setCaldoriaSinclairShot(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSinclairShotFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSinclairShot() {
+	return _caldoriaFlags.getFlag(kCaldoriaSinclairShotFlag);
+}
+
+void GameStateManager::setCaldoriaBombDisarmed(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaBombDisarmedFlag, value);
+}
+
+bool GameStateManager::getCaldoriaBombDisarmed() {
+	return _caldoriaFlags.getFlag(kCaldoriaBombDisarmedFlag);
+}
+
+void GameStateManager::setCaldoriaRoofDoorOpen(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaRoofDoorOpenFlag, value);
+}
+
+bool GameStateManager::getCaldoriaRoofDoorOpen() {
+	return _caldoriaFlags.getFlag(kCaldoriaRoofDoorOpenFlag);
+}
+
+void GameStateManager::setCaldoriaDoneHygiene(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaDoneHygieneFlag, value);
+}
+
+bool GameStateManager::getCaldoriaDoneHygiene() {
+	return _caldoriaFlags.getFlag(kCaldoriaDoneHygieneFlag);
+}
+
+void GameStateManager::setCaldoriaSawVoiceAnalysis(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaSawVoiceAnalysisFlag, value);
+}
+
+bool GameStateManager::getCaldoriaSawVoiceAnalysis() {
+	return _caldoriaFlags.getFlag(kCaldoriaSawVoiceAnalysisFlag);
+}
+
+void GameStateManager::setCaldoriaDoorBombed(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaDoorBombedFlag, value);
+}
+
+bool GameStateManager::getCaldoriaDoorBombed() {
+	return _caldoriaFlags.getFlag(kCaldoriaDoorBombedFlag);
+}
+
+void GameStateManager::setCaldoriaGunAimed(bool value) {
+	_caldoriaFlags.setFlag(kCaldoriaGunAimedFlag, value);
+}
+
+bool GameStateManager::getCaldoriaGunAimed() {
+	return _caldoriaFlags.getFlag(kCaldoriaGunAimedFlag);
+}
+
+void GameStateManager::setRipTimerTime(TimeValue limit) {
+	_TSARipTimerTime = limit;
+}
+
+TimeValue GameStateManager::getRipTimerTime() {
+	return _TSARipTimerTime;
+}
+
+void GameStateManager::setTSAFuseTimeLimit(TimeValue limit) {
+	_TSAFuseTimeLimit = limit;
+}
+
+TimeValue GameStateManager::getTSAFuseTimeLimit() {
+	return _TSAFuseTimeLimit;
+}
+
+void GameStateManager::setTSAState(byte state) {
+	_TSAState = state;
+}
+
+byte GameStateManager::getTSAState() {
+	return _TSAState;
+}
+
+void GameStateManager::setT0BMonitorMode(byte mode) {
+	_T0BMonitorMode = mode;
+}
+
+byte GameStateManager::getT0BMonitorMode() {
+	return _T0BMonitorMode;
+}
+
+void GameStateManager::setT0BMonitorStart(TimeValue start) {
+	_T0BMonitorStart = start;
+}
+
+TimeValue GameStateManager::getT0BMonitorStart() {
+	return _T0BMonitorStart;
+}
+
+void GameStateManager::setTSAIDedAtDoor(bool value) {
+	_TSAFlags.setFlag(kTSAIDedAtDoorFlag, value);
+}
+
+bool GameStateManager::getTSAIDedAtDoor() {
+	return _TSAFlags.getFlag(kTSAIDedAtDoorFlag);
+}
+
+void GameStateManager::setTSA0BZoomedIn(bool value) {
+	_TSAFlags.setFlag(kTSA0BZoomedInFlag, value);
+}
+
+bool GameStateManager::getTSA0BZoomedIn() {
+	return _TSAFlags.getFlag(kTSA0BZoomedInFlag);
+}
+
+void GameStateManager::setTSAFrontDoorUnlockedOutside(bool value) {
+	_TSAFlags.setFlag(kTSAFrontDoorUnlockedOutsideFlag, value);
+}
+
+bool GameStateManager::getTSAFrontDoorUnlockedOutside() {
+	return _TSAFlags.getFlag(kTSAFrontDoorUnlockedOutsideFlag);
+}
+
+void GameStateManager::setTSAFrontDoorUnlockedInside(bool value) {
+	_TSAFlags.setFlag(kTSAFrontDoorUnlockedInsideFlag, value);
+}
+
+bool GameStateManager::getTSAFrontDoorUnlockedInside() {
+	return _TSAFlags.getFlag(kTSAFrontDoorUnlockedInsideFlag);
+}
+
+void GameStateManager::setTSASeenRobotGreeting(bool value) {
+	_TSAFlags.setFlag(kTSASeenRobotGreetingFlag, value);
+}
+
+bool GameStateManager::getTSASeenRobotGreeting() {
+	return _TSAFlags.getFlag(kTSASeenRobotGreetingFlag);
+}
+
+void GameStateManager::setTSASeenTheory(bool value) {
+	_TSAFlags.setFlag(kTSASeenTheoryFlag, value);
+}
+
+bool GameStateManager::getTSASeenTheory() {
+	return _TSAFlags.getFlag(kTSASeenTheoryFlag);
+}
+
+void GameStateManager::setTSASeenBackground(bool value) {
+	_TSAFlags.setFlag(kTSASeenBackgroundFlag, value);
+}
+
+bool GameStateManager::getTSASeenBackground() {
+	return _TSAFlags.getFlag(kTSASeenBackgroundFlag);
+}
+
+void GameStateManager::setTSASeenProcedure(bool value) {
+	_TSAFlags.setFlag(kTSASeenProcedureFlag, value);
+}
+
+bool GameStateManager::getTSASeenProcedure() {
+	return _TSAFlags.getFlag(kTSASeenProcedureFlag);
+}
+
+void GameStateManager::setTSASeenAgent3AtDoor(bool value) {
+	_TSAFlags.setFlag(kTSASeenAgent3AtDoorFlag, value);
+}
+
+bool GameStateManager::getTSASeenAgent3AtDoor() {
+	return _TSAFlags.getFlag(kTSASeenAgent3AtDoorFlag);
+}
+
+void GameStateManager::setTSACommandCenterLocked(bool value) {
+	_TSAFlags.setFlag(kTSACommandCenterLockedFlag, value);
+}
+
+bool GameStateManager::getTSACommandCenterLocked() {
+	return _TSAFlags.getFlag(kTSACommandCenterLockedFlag);
+}
+
+void GameStateManager::setTSASeenCaldoriaNormal(bool value) {
+	_TSAFlags.setFlag(kTSASeenCaldoriaNormalFlag, value);
+}
+
+bool GameStateManager::getTSASeenCaldoriaNormal() {
+	return _TSAFlags.getFlag(kTSASeenCaldoriaNormalFlag);
+}
+
+void GameStateManager::setTSASeenCaldoriaAltered(bool value) {
+	_TSAFlags.setFlag(kTSASeenCaldoriaAlteredFlag, value);
+}
+
+bool GameStateManager::getTSASeenCaldoriaAltered() {
+	return _TSAFlags.getFlag(kTSASeenCaldoriaAlteredFlag);
+}
+
+void GameStateManager::setTSASeenNoradNormal(bool value) {
+	_TSAFlags.setFlag(kTSASeenNoradNormalFlag, value);
+}
+
+bool GameStateManager::getTSASeenNoradNormal() {
+	return _TSAFlags.getFlag(kTSASeenNoradNormalFlag);
+}
+
+void GameStateManager::setTSASeenNoradAltered(bool value) {
+	_TSAFlags.setFlag(kTSASeenNoradAlteredFlag, value);
+}
+
+bool GameStateManager::getTSASeenNoradAltered() {
+	return _TSAFlags.getFlag(kTSASeenNoradAlteredFlag);
+}
+
+void GameStateManager::setTSASeenMarsNormal(bool value) {
+	_TSAFlags.setFlag(kTSASeenMarsNormalFlag, value);
+}
+
+bool GameStateManager::getTSASeenMarsNormal() {
+	return _TSAFlags.getFlag(kTSASeenMarsNormalFlag);
+}
+
+void GameStateManager::setTSASeenMarsAltered(bool value) {
+	_TSAFlags.setFlag(kTSASeenMarsAlteredFlag, value);
+}
+
+bool GameStateManager::getTSASeenMarsAltered() {
+	return _TSAFlags.getFlag(kTSASeenMarsAlteredFlag);
+}
+
+void GameStateManager::setTSASeenWSCNormal(bool value) {
+	_TSAFlags.setFlag(kTSASeenWSCNormalFlag, value);
+}
+
+bool GameStateManager::getTSASeenWSCNormal() {
+	return _TSAFlags.getFlag(kTSASeenWSCNormalFlag);
+}
+
+void GameStateManager::setTSASeenWSCAltered(bool value) {
+	_TSAFlags.setFlag(kTSASeenWSCAlteredFlag, value);
+}
+
+bool GameStateManager::getTSASeenWSCAltered() {
+	return _TSAFlags.getFlag(kTSASeenWSCAlteredFlag);
+}
+
+void GameStateManager::setTSABiosuitOn(bool value) {
+	_TSAFlags.setFlag(kTSABiosuitOnFlag, value);
+}
+
+bool GameStateManager::getTSABiosuitOn() {
+	return _TSAFlags.getFlag(kTSABiosuitOnFlag);
+}
+
+void GameStateManager::setPrehistoricTriedToExtendBridge(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricTriedToExtendBridgeFlag, value);
+}
+
+bool GameStateManager::getPrehistoricTriedToExtendBridge() {
+	return _prehistoricFlags.getFlag(kPrehistoricTriedToExtendBridgeFlag);
+}
+
+void GameStateManager::setPrehistoricSeenTimeStream(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricSeenTimeStreamFlag, value);
+}
+
+bool GameStateManager::getPrehistoricSeenTimeStream() {
+	return _prehistoricFlags.getFlag(kPrehistoricSeenTimeStreamFlag);
+}
+
+void GameStateManager::setPrehistoricSeenFlyer1(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricSeenFlyer1Flag, value);
+}
+
+bool GameStateManager::getPrehistoricSeenFlyer1() {
+	return _prehistoricFlags.getFlag(kPrehistoricSeenFlyer1Flag);
+}
+
+void GameStateManager::setPrehistoricSeenFlyer2(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricSeenFlyer2Flag, value);
+}
+
+bool GameStateManager::getPrehistoricSeenFlyer2() {
+	return _prehistoricFlags.getFlag(kPrehistoricSeenFlyer2Flag);
+}
+
+void GameStateManager::setPrehistoricSeenBridgeZoom(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricSeenBridgeZoomFlag, value);
+}
+
+bool GameStateManager::getPrehistoricSeenBridgeZoom() {
+	return _prehistoricFlags.getFlag(kPrehistoricSeenBridgeZoomFlag);
+}
+
+void GameStateManager::setPrehistoricBreakerThrown(bool value) {
+	_prehistoricFlags.setFlag(kPrehistoricBreakerThrownFlag, value);
+}
+
+bool GameStateManager::getPrehistoricBreakerThrown() {
+	return _prehistoricFlags.getFlag(kPrehistoricBreakerThrownFlag);
+}
+
+void GameStateManager::setNoradSeenTimeStream(bool value) {
+	_noradFlags.setFlag(kNoradSeenTimeStreamFlag, value);
+}
+
+bool GameStateManager::getNoradSeenTimeStream() {
+	return _noradFlags.getFlag(kNoradSeenTimeStreamFlag);
+}
+
+void GameStateManager::setNoradGassed(bool value) {
+	_noradFlags.setFlag(kNoradGassedFlag, value);
+}
+
+bool GameStateManager::getNoradGassed() {
+	return _noradFlags.getFlag(kNoradGassedFlag);
+}
+
+void GameStateManager::setNoradFillingStationOn(bool value) {
+	_noradFlags.setFlag(kNoradFillingStationOnFlag, value);
+}
+
+bool GameStateManager::getNoradFillingStationOn() {
+	return _noradFlags.getFlag(kNoradFillingStationOnFlag);
+}
+
+void GameStateManager::setNoradN22MessagePlayed(bool value) {
+	_noradFlags.setFlag(kNoradN22MessagePlayedFlag, value);
+}
+
+bool GameStateManager::getNoradN22MessagePlayed() {
+	return _noradFlags.getFlag(kNoradN22MessagePlayedFlag);
+}
+
+void GameStateManager::setNoradPlayedGlobeGame(bool value) {
+	_noradFlags.setFlag(kNoradPlayedGlobeGameFlag, value);
+}
+
+bool GameStateManager::getNoradPlayedGlobeGame() {
+	return _noradFlags.getFlag(kNoradPlayedGlobeGameFlag);
+}
+
+void GameStateManager::setNoradBeatRobotWithClaw(bool value) {
+	_noradFlags.setFlag(kNoradBeatRobotWithClawFlag, value);
+}
+
+bool GameStateManager::getNoradBeatRobotWithClaw() {
+	return _noradFlags.getFlag(kNoradBeatRobotWithClawFlag);
+}
+
+void GameStateManager::setNoradBeatRobotWithDoor(bool value) {
+	_noradFlags.setFlag(kNoradBeatRobotWithDoorFlag, value);
+}
+
+bool GameStateManager::getNoradBeatRobotWithDoor() {
+	return _noradFlags.getFlag(kNoradBeatRobotWithDoorFlag);
+}
+
+void GameStateManager::setNoradRetScanGood(bool value) {
+	_noradFlags.setFlag(kNoradRetScanGoodFlag, value);
+}
+
+bool GameStateManager::getNoradRetScanGood() {
+	return _noradFlags.getFlag(kNoradRetScanGoodFlag);
+}
+
+void GameStateManager::setNoradWaitingForLaser(bool value) {
+	_noradFlags.setFlag(kNoradWaitingForLaserFlag, value);
+}
+
+bool GameStateManager::getNoradWaitingForLaser() {
+	return _noradFlags.getFlag(kNoradWaitingForLaserFlag);
+}
+
+void GameStateManager::setNoradSubRoomPressure(uint16 pressure) {
+	_noradSubRoomPressure = pressure;
+}
+
+uint16 GameStateManager::getNoradSubRoomPressure() {
+	return _noradSubRoomPressure;
+}
+
+void GameStateManager::setNoradSubPrepState(tNoradSubPrepState state) {
+	_noradSubPrepState = state;
+}
+
+tNoradSubPrepState GameStateManager::getNoradSubPrepState() {
+	return _noradSubPrepState;
+}
+
+void GameStateManager::setNoradArrivedFromSub(bool value) {
+	_noradFlags.setFlag(kNoradArrivedFromSubFlag, value);
+}
+
+bool GameStateManager::getNoradArrivedFromSub() {
+	return _noradFlags.getFlag(kNoradArrivedFromSubFlag);
+}
+
+void GameStateManager::setMarsSeenTimeStream(bool value) {
+	_marsFlags.setFlag(kMarsSeenTimeStreamFlag, value);
+}
+
+bool GameStateManager::getMarsSeenTimeStream() {
+	return _marsFlags.getFlag(kMarsSeenTimeStreamFlag);
+}
+
+void GameStateManager::setMarsHeardUpperPodMessage(bool value) {
+	_marsFlags.setFlag(kMarsHeardUpperPodMessageFlag, value);
+}
+
+bool GameStateManager::getMarsHeardUpperPodMessage() {
+	return _marsFlags.getFlag(kMarsHeardUpperPodMessageFlag);
+}
+
+void GameStateManager::setMarsRobotThrownPlayer(bool value) {
+	_marsFlags.setFlag(kMarsRobotThrownPlayerFlag, value);
+}
+
+bool GameStateManager::getMarsRobotThrownPlayer() {
+	return _marsFlags.getFlag(kMarsRobotThrownPlayerFlag);
+}
+
+void GameStateManager::setMarsHeardCheckInMessage(bool value) {
+	_marsFlags.setFlag(kMarsHeardCheckInMessageFlag, value);
+}
+
+bool GameStateManager::getMarsHeardCheckInMessage() {
+	return _marsFlags.getFlag(kMarsHeardCheckInMessageFlag);
+}
+
+void GameStateManager::setMarsPodAtUpperPlatform(bool value) {
+	_marsFlags.setFlag(kMarsPodAtUpperPlatformFlag, value);
+}
+
+bool GameStateManager::getMarsPodAtUpperPlatform() {
+	return _marsFlags.getFlag(kMarsPodAtUpperPlatformFlag);
+}
+
+void GameStateManager::setMarsSeenThermalScan(bool value) {
+	_marsFlags.setFlag(kMarsSeenThermalScanFlag, value);
+}
+
+bool GameStateManager::getMarsSeenThermalScan() {
+	return _marsFlags.getFlag(kMarsSeenThermalScanFlag);
+}
+
+void GameStateManager::setMarsArrivedBelow(bool value) {
+	_marsFlags.setFlag(kMarsArrivedBelowFlag, value);
+}
+
+bool GameStateManager::getMarsArrivedBelow() {
+	return _marsFlags.getFlag(kMarsArrivedBelowFlag);
+}
+
+void GameStateManager::setMarsSeenRobotAtReactor(bool value) {
+	_marsFlags.setFlag(kMarsSeenRobotAtReactorFlag, value);
+}
+
+bool GameStateManager::getMarsSeenRobotAtReactor() {
+	return _marsFlags.getFlag(kMarsSeenRobotAtReactorFlag);
+}
+
+void GameStateManager::setMarsAvoidedReactorRobot(bool value) {
+	_marsFlags.setFlag(kMarsAvoidedReactorRobotFlag, value);
+}
+
+bool GameStateManager::getMarsAvoidedReactorRobot() {
+	return _marsFlags.getFlag(kMarsAvoidedReactorRobotFlag);
+}
+
+void GameStateManager::setMarsSecurityDown(bool value) {
+	_marsFlags.setFlag(kMarsSecurityDownFlag, value);
+}
+
+bool GameStateManager::getMarsSecurityDown() {
+	return _marsFlags.getFlag(kMarsSecurityDownFlag);
+}
+
+void GameStateManager::setMarsInAirlock(bool value) {
+	_marsFlags.setFlag(kMarsInAirlockFlag, value);
+}
+
+bool GameStateManager::getMarsInAirlock() {
+	return _marsFlags.getFlag(kMarsInAirlockFlag);
+}
+
+void GameStateManager::setMarsAirlockOpen(bool value) {
+	_marsFlags.setFlag(kMarsAirlockOpenFlag, value);
+}
+
+bool GameStateManager::getMarsAirlockOpen() {
+	return _marsFlags.getFlag(kMarsAirlockOpenFlag);
+}
+
+void GameStateManager::setMarsMaskOnFiller(bool value) {
+	_marsFlags.setFlag(kMarsMaskOnFillerFlag, value);
+}
+
+bool GameStateManager::getMarsMaskOnFiller() {
+	return _marsFlags.getFlag(kMarsMaskOnFillerFlag);
+}
+
+void GameStateManager::setMarsLockFrozen(bool value) {
+	_marsFlags.setFlag(kMarsLockFrozenFlag, value);
+}
+
+bool GameStateManager::getMarsLockFrozen() {
+	return _marsFlags.getFlag(kMarsLockFrozenFlag);
+}
+
+void GameStateManager::setMarsLockBroken(bool value) {
+	_marsFlags.setFlag(kMarsLockBrokenFlag, value);
+}
+
+bool GameStateManager::getMarsLockBroken() {
+	return _marsFlags.getFlag(kMarsLockBrokenFlag);
+}
+
+void GameStateManager::setMarsMazeDoorPair1(bool value) {
+	_marsFlags.setFlag(kMarsMazeDoorPair1Flag, value);
+}
+
+bool GameStateManager::getMarsMazeDoorPair1() {
+	return _marsFlags.getFlag(kMarsMazeDoorPair1Flag);
+}
+
+void GameStateManager::setMarsMazeDoorPair2(bool value) {
+	_marsFlags.setFlag(kMarsMazeDoorPair2Flag, value);
+}
+
+bool GameStateManager::getMarsMazeDoorPair2() {
+	return _marsFlags.getFlag(kMarsMazeDoorPair2Flag);
+}
+
+void GameStateManager::setMarsMazeDoorPair3(bool value) {
+	_marsFlags.setFlag(kMarsMazeDoorPair3Flag, value);
+}
+
+bool GameStateManager::getMarsMazeDoorPair3() {
+	return _marsFlags.getFlag(kMarsMazeDoorPair3Flag);
+}
+
+void GameStateManager::setMarsSawRobotLeave(bool value) {
+	_marsFlags.setFlag(kMarsSawRobotLeaveFlag, value);
+}
+
+bool GameStateManager::getMarsSawRobotLeave() {
+	return _marsFlags.getFlag(kMarsSawRobotLeaveFlag);
+}
+
+void GameStateManager::setMarsHitRobotWithCannon(bool flag) {
+	_marsFlags.setFlag(kMarsHitRobotWithCannonFlag, flag);
+}
+
+bool GameStateManager::getMarsHitRobotWithCannon() {
+	return _marsFlags.getFlag(kMarsHitRobotWithCannonFlag);
+}
+	
+void GameStateManager::setMarsReadyForShuttleTransport(bool value) {
+	_marsFlags.setFlag(kMarsReadyForShuttleTransportFlag, value);
+}
+
+bool GameStateManager::getMarsReadyForShuttleTransport() {
+	return _marsFlags.getFlag(kMarsReadyForShuttleTransportFlag);
+}
+
+void GameStateManager::setMarsFinishedCanyonChase(bool flag) {
+	_marsFlags.setFlag(kMarsFinishedCanyonChaseFlag, flag);
+}
+
+bool GameStateManager::getMarsFinishedCanyonChase() {
+	return _marsFlags.getFlag(kMarsFinishedCanyonChaseFlag);
+}
+	
+void GameStateManager::setMarsThreadedMaze(bool flag) {
+	_marsFlags.setFlag(kMarsThreadedMazeFlag, flag);
+}
+
+bool GameStateManager::getMarsThreadedMaze() {
+	return _marsFlags.getFlag(kMarsThreadedMazeFlag);
+}
+
+void GameStateManager::setWSCSeenTimeStream(bool value) {
+	_WSCFlags.setFlag(kWSCSeenTimeStreamFlag, value);
+}
+
+bool GameStateManager::getWSCSeenTimeStream() {
+	return _WSCFlags.getFlag(kWSCSeenTimeStreamFlag);
+}
+
+void GameStateManager::setWSCPoisoned(bool value) {
+	_WSCFlags.setFlag(kWSCPoisonedFlag, value);
+}
+
+bool GameStateManager::getWSCPoisoned() {
+	return _WSCFlags.getFlag(kWSCPoisonedFlag);
+}
+
+void GameStateManager::setWSCAnsweredAboutDart(bool value) {
+	_WSCFlags.setFlag(kWSCAnsweredAboutDartFlag, value);
+}
+
+bool GameStateManager::getWSCAnsweredAboutDart() {
+	return _WSCFlags.getFlag(kWSCAnsweredAboutDartFlag);
+}
+
+void GameStateManager::setWSCRemovedDart(bool value) {
+	_WSCFlags.setFlag(kWSCRemovedDartFlag, value);
+}
+
+bool GameStateManager::getWSCRemovedDart() {
+	return _WSCFlags.getFlag(kWSCRemovedDartFlag);
+}
+
+void GameStateManager::setWSCAnalyzerOn(bool value) {
+	_WSCFlags.setFlag(kWSCAnalyzerOnFlag, value);
+}
+
+bool GameStateManager::getWSCAnalyzerOn() {
+	return _WSCFlags.getFlag(kWSCAnalyzerOnFlag);
+}
+
+void GameStateManager::setWSCDartInAnalyzer(bool value) {
+	_WSCFlags.setFlag(kWSCDartInAnalyzerFlag, value);
+}
+
+bool GameStateManager::getWSCDartInAnalyzer() {
+	return _WSCFlags.getFlag(kWSCDartInAnalyzerFlag);
+}
+
+void GameStateManager::setWSCAnalyzedDart(bool value) {
+	_WSCFlags.setFlag(kWSCAnalyzedDartFlag, value);
+}
+
+bool GameStateManager::getWSCAnalyzedDart() {
+	return _WSCFlags.getFlag(kWSCAnalyzedDartFlag);
+}
+
+void GameStateManager::setWSCSawMorph(bool value) {
+	_WSCFlags.setFlag(kWSCSawMorphFlag, value);
+}
+
+bool GameStateManager::getWSCSawMorph() {
+	return _WSCFlags.getFlag(kWSCSawMorphFlag);
+}
+
+void GameStateManager::setWSCDesignedAntidote(bool value) {
+	_WSCFlags.setFlag(kWSCDesignedAntidoteFlag, value);
+}
+
+bool GameStateManager::getWSCDesignedAntidote() {
+	return _WSCFlags.getFlag(kWSCDesignedAntidoteFlag);
+}
+
+void GameStateManager::setWSCPickedUpAntidote(bool value) {
+	_WSCFlags.setFlag(kWSCPickedUpAntidoteFlag, value);
+}
+
+bool GameStateManager::getWSCPickedUpAntidote() {
+	return _WSCFlags.getFlag(kWSCPickedUpAntidoteFlag);
+}
+
+void GameStateManager::setWSCOfficeMessagesOpen(bool value) {
+	_WSCFlags.setFlag(kWSCOfficeMessagesOpenFlag, value);
+}
+
+bool GameStateManager::getWSCOfficeMessagesOpen() {
+	return _WSCFlags.getFlag(kWSCOfficeMessagesOpenFlag);
+}
+
+void GameStateManager::setWSCSeenNerd(bool value) {
+	_WSCFlags.setFlag(kWSCSeenNerdFlag, value);
+}
+
+bool GameStateManager::getWSCSeenNerd() {
+	return _WSCFlags.getFlag(kWSCSeenNerdFlag);
+}
+
+void GameStateManager::setWSCHeardPage1(bool value) {
+	_WSCFlags.setFlag(kWSCHeardPage1Flag, value);
+}
+
+bool GameStateManager::getWSCHeardPage1() {
+	return _WSCFlags.getFlag(kWSCHeardPage1Flag);
+}
+
+void GameStateManager::setWSCHeardPage2(bool value) {
+	_WSCFlags.setFlag(kWSCHeardPage2Flag, value);
+}
+
+bool GameStateManager::getWSCHeardPage2() {
+	return _WSCFlags.getFlag(kWSCHeardPage2Flag);
+}
+
+void GameStateManager::setWSCHeardCheckIn(bool value) {
+	_WSCFlags.setFlag(kWSCHeardCheckInFlag, value);
+}
+
+bool GameStateManager::getWSCHeardCheckIn() {
+	return _WSCFlags.getFlag(kWSCHeardCheckInFlag);
+}
+
+void GameStateManager::setWSCDidPlasmaDodge(bool value) {
+	_WSCFlags.setFlag(kWSCDidPlasmaDodgeFlag, value);
+}
+
+bool GameStateManager::getWSCDidPlasmaDodge() {
+	return _WSCFlags.getFlag(kWSCDidPlasmaDodgeFlag);
+}
+
+void GameStateManager::setWSCSeenSinclairLecture(bool value) {
+	_WSCFlags.setFlag(kWSCSeenSinclairLectureFlag, value);
+}
+
+bool GameStateManager::getWSCSeenSinclairLecture() {
+	return _WSCFlags.getFlag(kWSCSeenSinclairLectureFlag);
+}
+
+void GameStateManager::setWSCBeenAtWSC93(bool value) {
+	_WSCFlags.setFlag(kWSCBeenAtWSC93Flag, value);
+}
+
+bool GameStateManager::getWSCBeenAtWSC93() {
+	return _WSCFlags.getFlag(kWSCBeenAtWSC93Flag);
+}
+
+void GameStateManager::setWSCCatwalkDark(bool value) {
+	_WSCFlags.setFlag(kWSCCatwalkDarkFlag, value);
+}
+
+bool GameStateManager::getWSCCatwalkDark() {
+	return _WSCFlags.getFlag(kWSCCatwalkDarkFlag);
+}
+
+void GameStateManager::setWSCRobotDead(bool value) {
+	_WSCFlags.setFlag(kWSCRobotDeadFlag, value);
+}
+
+bool GameStateManager::getWSCRobotDead() {
+	return _WSCFlags.getFlag(kWSCRobotDeadFlag);
+}
+
+void GameStateManager::setWSCRobotGone(bool value) {
+	_WSCFlags.setFlag(kWSCRobotGoneFlag, value);
+}
+
+bool GameStateManager::getWSCRobotGone() {
+	return _WSCFlags.getFlag(kWSCRobotGoneFlag);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
new file mode 100755
index 0000000..af790ce
--- /dev/null
+++ b/engines/pegasus/gamestate.h
@@ -0,0 +1,938 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_GAMESTATE_H
+#define PEGASUS_GAMESTATE_H
+
+#include "common/singleton.h"
+
+#include "pegasus/types.h"
+#include "pegasus/Game_Shell/CItem.h"
+
+namespace Common {
+	class Error;
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+//	The only things saved in here are things which get written out to a saved game file...
+
+enum {
+	kGlobalWalkthroughFlag,
+	kGlobalShieldOnFlag,
+	kGlobalEasterEggFlag,
+	kGlobalBeenToWSCFlag,
+	kGlobalBeenToMarsFlag,
+	kGlobalBeenToNoradFlag,
+	kGlobalWSCFinishedFlag,
+	kGlobalMarsFinishedFlag,
+	kGlobalNoradFinishedFlag,
+	kNumGlobalFlags
+};
+
+enum {
+	kScoringSawINNFlag,
+	kScoringTookShowerFlag,
+	kScoringFixedHairFlag,
+	kScoringGotKeyCardFlag,
+	kScoringReadPaperFlag,
+	kScoringLookThroughTelescopeFlag,
+	kScoringSawCaldoriaKioskFlag,
+	kScoringGoToTSAFlag,
+	kScoringEnterTSAFlag,
+	kScoringSawBust1Flag,
+	kScoringSawBust2Flag,
+	kScoringSawBust3Flag,
+	kScoringSawBust4Flag,
+	kScoringSawBust5Flag,
+	kScoringSawBust6Flag,
+	kScoringSawTheoryFlag,
+	kScoringSawBackgroundFlag,
+	kScoringSawProcedureFlag,
+	kScoringGotJourneymanKeyFlag,
+	kScoringGotPegasusBiochipFlag,
+	kScoringGotBiosuitFlag,
+	kScoringGoToPrehistoricFlag,
+	kScoringPutLogInReaderFlag,
+	kScoringSawCaldoriaNormalFlag,
+	kScoringSawCaldoriaAlteredFlag,
+	kScoringSawNoradNormalFlag,
+	kScoringSawNoradAlteredFlag,
+	kScoringSawMarsNormalFlag,
+	kScoringSawMarsAlteredFlag,
+	kScoringSawWSCNormalFlag,
+	kScoringSawWSCAlteredFlag,
+	kScoringWentToReadyRoom2Flag,
+	kScoringWentAfterSinclairFlag,
+	kScoringUsedCardBombFlag,
+	kScoringShieldedCardBombFlag,
+	kScoringStunnedSinclairFlag,
+	kScoringDisarmedNukeFlag,
+	
+	kScoringThrewBreakerFlag,
+	kScoringExtendedBridgeFlag,
+	kScoringGotHistoricalLogFlag,
+	kScoringFinishedPrehistoricFlag,
+	
+	kScoringThrownByRobotFlag,
+	kScoringGotMarsCardFlag,
+	kScoringSawMarsKioskFlag,
+	kScoringSawTransportMapFlag,
+	kScoringGotCrowBarFlag,
+	kScoringTurnedOnTransportFlag,
+	kScoringGotOxygenMaskFlag,
+	kScoringAvoidedRobotFlag,
+	kScoringActivatedPlatformFlag,
+	kScoringUsedLiquidNitrogenFlag,
+	kScoringUsedCrowBarFlag,
+	kScoringFoundCardBombFlag,
+	kScoringDisarmedCardBombFlag,
+	kScoringGotCardBombFlag,
+	kScoringThreadedMazeFlag,
+	kScoringThreadedGearRoomFlag,
+	kScoringEnteredShuttleFlag,
+	kScoringEnteredLaunchTubeFlag,
+	kScoringStoppedRobotsShuttleFlag,
+	kScoringGotMarsOpMemChipFlag,
+	kScoringFinishedMarsFlag,
+	
+	kScoringSawSecurityMonitorFlag,
+	kScoringFilledOxygenCanisterFlag,
+	kScoringFilledArgonCanisterFlag,
+	kScoringSawUnconsciousOperatorFlag,
+	kScoringWentThroughPressureDoorFlag,
+	kScoringPreppedSubFlag,
+	kScoringEnteredSubFlag,
+	kScoringExitedSubFlag,
+	kScoringSawRobotAt54NorthFlag,
+	kScoringPlayedWithClawFlag,
+	kScoringUsedRetinalChipFlag,
+	kScoringFinishedGlobeGameFlag,
+	kScoringStoppedNoradRobotFlag,
+	kScoringGotNoradOpMemChipFlag,
+	kScoringFinishedNoradFlag,
+	
+	kScoringRemovedDartFlag,
+	kScoringAnalyzedDartFlag,
+	kScoringBuiltAntidoteFlag,
+	kScoringGotSinclairKeyFlag,
+	kScoringGotArgonCanisterFlag,
+	kScoringGotNitrogenCanisterFlag,
+	kScoringPlayedWithMessagesFlag,
+	kScoringSawMorphExperimentFlag,
+	kScoringEnteredSinclairOfficeFlag,
+	kScoringSawBrochureFlag,
+	kScoringSawSinclairEntry1Flag,
+	kScoringSawSinclairEntry2Flag,
+	kScoringSawSinclairEntry3Flag,
+	kScoringSawWSCDirectoryFlag,
+	kScoringUsedCrowBarInWSCFlag,
+	kScoringFinishedPlasmaDodgeFlag,
+	kScoringOpenedCatwalkFlag,
+	kScoringStoppedWSCRobotFlag,
+	kScoringGotWSCOpMemChipFlag,
+	kScoringFinishedWSCFlag,
+	
+	kScoringMarsGandhiFlag,
+	kScoringNoradGandhiFlag,
+	kScoringWSCGandhiFlag,
+	
+	kNumScoringFlags
+};
+
+enum {
+	kCaldoriaSeenPullbackFlag,
+	kCaldoriaMadeOJFlag,
+	kCaldoriaWokenUpFlag,
+	kCaldoriaDidRecalibrationFlag,
+	kCaldoriaSeenSinclairInElevatorFlag,
+	kCaldoriaINNAnnouncingFlag,
+	kCaldoriaSeenINNFlag,
+	kCaldoriaSeenMessagesFlag,
+	kCaldoriaSinclairShotFlag,
+	kCaldoriaBombDisarmedFlag,
+	kCaldoriaRoofDoorOpenFlag,
+	kCaldoriaDoneHygieneFlag,
+	kCaldoriaSawVoiceAnalysisFlag,
+	kCaldoriaDoorBombedFlag,
+	kCaldoriaGunAimedFlag,
+	kNumCaldoriaFlags
+};
+
+enum {
+	kCaldoriaNoFuseRunning,
+	kCaldoriaDoorBombFuseRunning,
+	kCaldoriaSinclairFuseRunning
+};
+
+enum {
+	kTSAIDedAtDoorFlag,
+	kTSA0BZoomedInFlag,
+	kTSAFrontDoorUnlockedOutsideFlag,
+	kTSAFrontDoorUnlockedInsideFlag,
+	kTSASeenRobotGreetingFlag,
+	kTSASeenTheoryFlag,
+	kTSASeenBackgroundFlag,
+	kTSASeenProcedureFlag,
+	kTSASeenAgent3AtDoorFlag,
+	kTSACommandCenterLockedFlag,
+	kTSASeenCaldoriaNormalFlag,
+	kTSASeenCaldoriaAlteredFlag,
+	kTSASeenNoradNormalFlag,
+	kTSASeenNoradAlteredFlag,
+	kTSASeenMarsNormalFlag,
+	kTSASeenMarsAlteredFlag,
+	kTSASeenWSCNormalFlag,
+	kTSASeenWSCAlteredFlag,
+	kTSABiosuitOnFlag,
+	kNumTSAFlags
+};
+
+enum {
+	kPrehistoricTriedToExtendBridgeFlag,
+	kPrehistoricSeenTimeStreamFlag,
+	kPrehistoricSeenFlyer1Flag,
+	kPrehistoricSeenFlyer2Flag,
+	kPrehistoricSeenBridgeZoomFlag,
+	kPrehistoricBreakerThrownFlag,
+	kNumPrehistoricFlags
+};
+
+enum {
+	kNoradSeenTimeStreamFlag,
+	kNoradGassedFlag,
+	kNoradFillingStationOnFlag,
+	kNoradN22MessagePlayedFlag,
+	kNoradArrivedFromSubFlag,
+	kNoradWaitingForLaserFlag,
+	kNoradRetScanGoodFlag,
+	kNoradPlayedGlobeGameFlag,
+	kNoradBeatRobotWithClawFlag,
+	kNoradBeatRobotWithDoorFlag,
+	kNumNoradFlags
+};
+
+enum {
+	kMarsSeenTimeStreamFlag,
+	kMarsHeardUpperPodMessageFlag,
+	kMarsRobotThrownPlayerFlag,
+	kMarsHeardCheckInMessageFlag,
+	kMarsPodAtUpperPlatformFlag,
+	kMarsSeenThermalScanFlag,
+	kMarsArrivedBelowFlag,
+	kMarsSeenRobotAtReactorFlag,
+	kMarsAvoidedReactorRobotFlag,
+	kMarsInAirlockFlag,
+	kMarsAirlockOpenFlag,
+	kMarsMaskOnFillerFlag,
+	kMarsLockFrozenFlag,
+	kMarsLockBrokenFlag,
+	kMarsMazeDoorPair1Flag,
+	kMarsMazeDoorPair2Flag,
+	kMarsMazeDoorPair3Flag,
+	kMarsSawRobotLeaveFlag,
+	kMarsSecurityDownFlag,
+	kMarsHitRobotWithCannonFlag,
+	kMarsReadyForShuttleTransportFlag,
+	kMarsFinishedCanyonChaseFlag,
+	kMarsThreadedMazeFlag,
+	kNumMarsFlags
+};
+
+enum {
+	kWSCSeenTimeStreamFlag,
+	kWSCPoisonedFlag,
+	kWSCAnsweredAboutDartFlag,
+	kWSCRemovedDartFlag,
+	kWSCAnalyzerOnFlag,
+	kWSCDartInAnalyzerFlag,
+	kWSCAnalyzedDartFlag,
+	kWSCSawMorphFlag,
+	kWSCDesignedAntidoteFlag,
+	kWSCPickedUpAntidoteFlag,
+	kWSCOfficeMessagesOpenFlag,
+	kWSCSeenNerdFlag,
+	kWSCHeardPage1Flag,
+	kWSCHeardPage2Flag,
+	kWSCHeardCheckInFlag,
+	kWSCDidPlasmaDodgeFlag,
+	kWSCSeenSinclairLectureFlag,
+	kWSCBeenAtWSC93Flag,
+	kWSCCatwalkDarkFlag,
+	kWSCRobotDeadFlag,
+	kWSCRobotGoneFlag,
+	kNumWSCFlags
+};
+
+class GameStateManager : public Common::Singleton<GameStateManager> {
+public:
+	GameStateManager() { resetGameState(); }
+
+	// Base game state
+	Common::Error writeGameState(Common::WriteStream *stream);
+	Common::Error readGameState(Common::ReadStream *stream);
+	
+	void resetGameState();
+	
+	void getCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	void setCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	
+	tNeighborhoodID getCurrentNeighborhood();
+	void setCurrentNeighborhood(const tNeighborhoodID neighborhood);
+	tRoomID getCurrentRoom();
+	void setCurrentRoom(const tRoomID room);
+	tDirectionConstant getCurrentDirection();
+	void setCurrentDirection(const tDirectionConstant direction);
+	
+	tRoomViewID getCurrentRoomAndView();
+	
+	void getNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	void	setNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+
+	tNeighborhoodID getNextNeighborhood();
+	void setNextNeighborhood(const tNeighborhoodID neighborhood);
+	tRoomID getNextRoom();
+	void setNextRoom(const tRoomID room);
+	tDirectionConstant getNextDirection();
+	void setNextDirection(const tDirectionConstant direction);
+	
+	void getLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
+	void setLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	
+	tNeighborhoodID getLastNeighborhood();
+	void setLastNeighborhood(const tNeighborhoodID neighborhood);
+	tRoomID getLastRoom();
+	void setLastRoom(const tRoomID room);
+	tDirectionConstant getLastDirection();
+	void setLastDirection(const tDirectionConstant direction);
+	
+	tRoomViewID getLastRoomAndView();
+	
+	void getOpenDoorLocation(tRoomID &room, tDirectionConstant &direction);
+	void setOpenDoorLocation(const tRoomID room, const tDirectionConstant direction);
+	tRoomID getOpenDoorRoom();
+	void setOpenDoorRoom(const tRoomID room);
+	tDirectionConstant getOpenDoorDirection();
+	void setOpenDoorDirection(const tDirectionConstant direction);
+	
+	tRoomViewID getDoorOpenRoomAndView();
+	
+	bool isCurrentDoorOpen();
+
+	// Pegasus Prime
+	
+	//	Scoring...
+	//	Scoring "Set" functions.
+	//	Caldoria/TSA scoring
+	void setScoringSawINN(const bool = true);
+	void setScoringTookShower(const bool = true);
+	void setScoringFixedHair(const bool = true);
+	void setScoringGotKeyCard(const bool = true);
+	void setScoringReadPaper(const bool = true);
+	void setScoringLookThroughTelescope(const bool = true);
+	void						setScoringSawCaldoriaKiosk(const bool = true);
+	void						setScoringGoToTSA(const bool = true);
+	void						setScoringEnterTSA(const bool = true);
+	void						setScoringSawBust1(const bool = true);
+	void						setScoringSawBust2(const bool = true);
+	void						setScoringSawBust3(const bool = true);
+	void						setScoringSawBust4(const bool = true);
+	void						setScoringSawBust5(const bool = true);
+	void						setScoringSawBust6(const bool = true);
+	void						setScoringSawTheory(const bool = true);
+	void						setScoringSawBackground(const bool = true);
+	void						setScoringSawProcedure(const bool = true);
+	void						setScoringGotJourneymanKey(const bool = true);
+	void						setScoringGotPegasusBiochip(const bool = true);
+	void						setScoringGotBiosuit(const bool = true);
+	void						setScoringGoToPrehistoric(const bool = true);
+	void						setScoringPutLogInReader(const bool = true);
+	void						setScoringSawCaldoriaNormal(const bool = true);
+	void						setScoringSawCaldoriaAltered(const bool = true);
+	void						setScoringSawNoradNormal(const bool = true);
+	void						setScoringSawNoradAltered(const bool = true);
+	void						setScoringSawMarsNormal(const bool = true);
+	void						setScoringSawMarsAltered(const bool = true);
+	void						setScoringSawWSCNormal(const bool = true);
+	void						setScoringSawWSCAltered(const bool = true);
+	void						setScoringWentToReadyRoom2(const bool = true);
+	void						setScoringWentAfterSinclair(const bool = true);
+	void						setScoringUsedCardBomb(const bool = true);
+	void						setScoringShieldedCardBomb(const bool = true);
+	void						setScoringStunnedSinclair(const bool = true);
+	void						setScoringDisarmedNuke(const bool = true);
+
+	//	Prehistoric scoring
+	void						setScoringThrewBreaker(const bool = true);
+	void						setScoringExtendedBridge(const bool = true);
+	void						setScoringGotHistoricalLog(const bool = true);
+	void						setScoringFinishedPrehistoric(const bool = true);
+
+	//	Mars scoring
+	void						setScoringThrownByRobot(const bool = true);
+	void						setScoringGotMarsCard(const bool = true);
+	void						setScoringSawMarsKiosk(const bool = true);
+	void						setScoringSawTransportMap(const bool = true);
+	void						setScoringGotCrowBar(const bool = true);
+	void						setScoringTurnedOnTransport(const bool = true);
+	void						setScoringGotOxygenMask(const bool = true);
+	void						setScoringAvoidedRobot(const bool = true);
+	void						setScoringActivatedPlatform(const bool = true);
+	void						setScoringUsedLiquidNitrogen(const bool = true);
+	void						setScoringUsedCrowBar(const bool = true);
+	void						setScoringFoundCardBomb(const bool = true);
+	void						setScoringDisarmedCardBomb(const bool = true);
+	void						setScoringGotCardBomb(const bool = true);
+	void						setScoringThreadedMaze(const bool = true);
+	void						setScoringThreadedGearRoom(const bool = true);
+	void						setScoringEnteredShuttle(const bool = true);
+	void						setScoringEnteredLaunchTube(const bool = true);
+	void						setScoringStoppedRobotsShuttle(const bool = true);
+	void						setScoringGotMarsOpMemChip(const bool = true);
+	void						setScoringFinishedMars(const bool = true);
+
+	//	Norad scoring
+	void						setScoringSawSecurityMonitor(const bool = true);
+	void						setScoringFilledOxygenCanister(const bool = true);
+	void						setScoringFilledArgonCanister(const bool = true);
+	void						setScoringSawUnconsciousOperator(const bool = true);
+	void						setScoringWentThroughPressureDoor(const bool = true);
+	void						setScoringPreppedSub(const bool = true);
+	void						setScoringEnteredSub(const bool = true);
+	void						setScoringExitedSub(const bool = true);
+	void						setScoringSawRobotAt54North(const bool = true);
+	void						setScoringPlayedWithClaw(const bool = true);
+	void						setScoringUsedRetinalChip(const bool = true);
+	void						setScoringFinishedGlobeGame(const bool = true);
+	void						setScoringStoppedNoradRobot(const bool = true);
+	void						setScoringGotNoradOpMemChip(const bool = true);
+	void						setScoringFinishedNorad(const bool = true);
+
+	//	WSC scoring
+	void						setScoringRemovedDart(const bool = true);
+	void						setScoringAnalyzedDart(const bool = true);
+	void						setScoringBuiltAntidote(const bool = true);
+	void						setScoringGotSinclairKey(const bool = true);
+	void						setScoringGotArgonCanister(const bool = true);
+	void						setScoringGotNitrogenCanister(const bool = true);
+	void						setScoringPlayedWithMessages(const bool = true);
+	void						setScoringSawMorphExperiment(const bool = true);
+	void						setScoringEnteredSinclairOffice(const bool = true);
+	void						setScoringSawBrochure(const bool = true);
+	void						setScoringSawSinclairEntry1(const bool = true);
+	void						setScoringSawSinclairEntry2(const bool = true);
+	void						setScoringSawSinclairEntry3(const bool = true);
+	void						setScoringSawWSCDirectory(const bool = true);
+	void						setScoringUsedCrowBarInWSC(const bool = true);
+	void						setScoringFinishedPlasmaDodge(const bool = true);
+	void						setScoringOpenedCatwalk(const bool = true);
+	void						setScoringStoppedWSCRobot(const bool = true);
+	void						setScoringGotWSCOpMemChip(const bool = true);
+	void						setScoringFinishedWSC(const bool = true);
+
+	//	Gandhi scoring
+	void						setScoringMarsGandhi(const bool = true);
+	void						setScoringNoradGandhi(const bool = true);
+	void						setScoringWSCGandhi(const bool = true);
+	
+	//	Scoring "Get" functions.
+	bool					getScoringSawINN();
+	bool					getScoringTookShower();
+	bool					getScoringFixedHair();
+	bool					getScoringGotKeyCard();
+	bool					getScoringReadPaper();
+	bool					getScoringLookThroughTelescope();
+	bool					getScoringSawCaldoriaKiosk();
+	bool					getScoringGoToTSA();
+	bool					getScoringEnterTSA();
+	bool					getScoringSawBust1();
+	bool					getScoringSawBust2();
+	bool					getScoringSawBust3();
+	bool					getScoringSawBust4();
+	bool					getScoringSawBust5();
+	bool					getScoringSawBust6();
+	bool					getScoringSawTheory();
+	bool					getScoringSawBackground();
+	bool					getScoringSawProcedure();
+	bool					getScoringGotJourneymanKey();
+	bool					getScoringGotPegasusBiochip();
+	bool					getScoringGotBiosuit();
+	bool					getScoringGoToPrehistoric();
+	bool					getScoringPutLogInReader();
+	bool					getScoringSawCaldoriaNormal();
+	bool					getScoringSawCaldoriaAltered();
+	bool					getScoringSawNoradNormal();
+	bool					getScoringSawNoradAltered();
+	bool					getScoringSawMarsNormal();
+	bool					getScoringSawMarsAltered();
+	bool					getScoringSawWSCNormal();
+	bool					getScoringSawWSCAltered();
+	bool					getScoringWentToReadyRoom2();
+	bool					getScoringWentAfterSinclair();
+	bool					getScoringUsedCardBomb();
+	bool					getScoringShieldedCardBomb();
+	bool					getScoringStunnedSinclair();
+	bool					getScoringDisarmedNuke();
+	bool					getScoringThrewBreaker();
+	bool					getScoringExtendedBridge();
+	bool					getScoringGotHistoricalLog();
+	bool					getScoringFinishedPrehistoric();
+	bool					getScoringThrownByRobot();
+	bool					getScoringGotMarsCard();
+	bool					getScoringSawMarsKiosk();
+	bool					getScoringSawTransportMap();
+	bool					getScoringGotCrowBar();
+	bool					getScoringTurnedOnTransport();
+	bool					getScoringGotOxygenMask();
+	bool					getScoringAvoidedRobot();
+	bool					getScoringActivatedPlatform();
+	bool					getScoringUsedLiquidNitrogen();
+	bool					getScoringUsedCrowBar();
+	bool					getScoringFoundCardBomb();
+	bool					getScoringDisarmedCardBomb();
+	bool					getScoringGotCardBomb();
+	bool					getScoringThreadedMaze();
+	bool					getScoringThreadedGearRoom();
+	bool					getScoringEnteredShuttle();
+	bool					getScoringEnteredLaunchTube();
+	bool					getScoringStoppedRobotsShuttle();
+	bool					getScoringGotMarsOpMemChip();
+	bool					getScoringFinishedMars();
+	bool					getScoringSawSecurityMonitor();
+	bool					getScoringFilledOxygenCanister();
+	bool					getScoringFilledArgonCanister();
+	bool					getScoringSawUnconsciousOperator();
+	bool					getScoringWentThroughPressureDoor();
+	bool					getScoringPreppedSub();
+	bool					getScoringEnteredSub();
+	bool					getScoringExitedSub();
+	bool					getScoringSawRobotAt54North();
+	bool					getScoringPlayedWithClaw();
+	bool					getScoringUsedRetinalChip();
+	bool					getScoringFinishedGlobeGame();
+	bool					getScoringStoppedNoradRobot();
+	bool					getScoringGotNoradOpMemChip();
+	bool					getScoringFinishedNorad();
+	bool					getScoringRemovedDart();
+	bool					getScoringAnalyzedDart();
+	bool					getScoringBuiltAntidote();
+	bool					getScoringGotSinclairKey();
+	bool					getScoringGotArgonCanister();
+	bool					getScoringGotNitrogenCanister();
+	bool					getScoringPlayedWithMessages();
+	bool					getScoringSawMorphExperiment();
+	bool					getScoringEnteredSinclairOffice();
+	bool					getScoringSawBrochure();
+	bool					getScoringSawSinclairEntry1();
+	bool					getScoringSawSinclairEntry2();
+	bool					getScoringSawSinclairEntry3();
+	bool					getScoringSawWSCDirectory();
+	bool					getScoringUsedCrowBarInWSC();
+	bool					getScoringFinishedPlasmaDodge();
+	bool					getScoringOpenedCatwalk();
+	bool					getScoringStoppedWSCRobot();
+	bool					getScoringGotWSCOpMemChip();
+	bool					getScoringFinishedWSC();
+	bool					getScoringMarsGandhi();
+	bool					getScoringNoradGandhi();
+	bool					getScoringWSCGandhi();
+
+	tGameScoreType			getCaldoriaTSAScore();
+	tGameScoreType			getPrehistoricScore();
+	tGameScoreType			getMarsScore();
+	tGameScoreType			getNoradScore();
+	tGameScoreType			getWSCScore();
+	tGameScoreType			getGandhiScore();
+	tGameScoreType			getTotalScore();
+
+	void					writeCaldoriaState(Common::WriteStream *stream);
+	void					readCaldoriaState(Common::ReadStream *stream);
+	void						resetCaldoriaState();
+	
+	void					writeTSAState(Common::WriteStream *stream);
+	void					readTSAState(Common::ReadStream *stream);
+	void						resetTSAState();
+	
+	void					writePrehistoricState(Common::WriteStream *stream);
+	void					readPrehistoricState(Common::ReadStream *stream);
+	void						resetPrehistoricState();
+	
+	void					writeNoradState(Common::WriteStream *stream);
+	void					readNoradState(Common::ReadStream *stream);
+	void						resetNoradState();
+	
+	void					writeMarsState(Common::WriteStream *stream);
+	void					readMarsState(Common::ReadStream *stream);
+	void						resetMarsState();
+	
+	void					writeWSCState(Common::WriteStream *stream);
+	void					readWSCState(Common::ReadStream *stream);
+	void						resetWSCState();
+	
+	//	Globals.
+	void						setWalkthroughMode(bool);
+	bool					getWalkthroughMode();
+	void						setShieldOn(bool);
+	bool					getShieldOn();
+	void						setEasterEgg(bool);
+	bool					getEasterEgg();
+	void						setBeenToWSC(bool value);
+	bool					getBeenToWSC();
+	void						setBeenToMars(bool value);
+	bool					getBeenToMars();
+	void						setBeenToNorad(bool value);
+	bool					getBeenToNorad();
+	void						setWSCFinished(bool);
+	bool					getWSCFinished();
+	void						setMarsFinished(bool);
+	bool					getMarsFinished();
+	void						setNoradFinished(bool);
+	bool					getNoradFinished();
+	bool					allTimeZonesFinished();
+	void						setTakenItemID(tItemID, bool);
+	bool					isTakenItemID(tItemID);
+	void						setTakenItem(CItem*, bool);
+	bool					isTakenItem(CItem*);
+	
+	//	Caldoria
+	void						setCaldoriaFuseTimeLimit(const TimeValue);
+	TimeValue				getCaldoriaFuseTimeLimit();
+	void						setCaldoriaSeenPullback(bool);
+	bool					getCaldoriaSeenPullback();
+	void						setCaldoriaMadeOJ(bool);
+	bool					getCaldoriaMadeOJ();
+	void						setCaldoriaWokenUp(bool);
+	bool					getCaldoriaWokenUp();
+	void						setCaldoriaDidRecalibration(bool);
+	bool					getCaldoriaDidRecalibration();
+	void						setCaldoriaSeenSinclairInElevator(bool);
+	bool					getCaldoriaSeenSinclairInElevator();
+	void						setCaldoriaINNAnnouncing(bool);
+	bool					getCaldoriaINNAnnouncing();
+	void						setCaldoriaSeenINN(bool);
+	bool					getCaldoriaSeenINN();
+	void						setCaldoriaSeenMessages(bool);
+	bool					getCaldoriaSeenMessages();
+	void						setCaldoriaSinclairShot(bool);
+	bool					getCaldoriaSinclairShot();
+	void						setCaldoriaBombDisarmed(bool);
+	bool					getCaldoriaBombDisarmed();
+	void						setCaldoriaRoofDoorOpen(bool);
+	bool					getCaldoriaRoofDoorOpen();
+	void						setCaldoriaDoneHygiene(bool);
+	bool					getCaldoriaDoneHygiene();
+	void						setCaldoriaSawVoiceAnalysis(bool);
+	bool					getCaldoriaSawVoiceAnalysis();
+	void						setCaldoriaDoorBombed(bool);
+	bool					getCaldoriaDoorBombed();
+	void						setCaldoriaGunAimed(bool);
+	bool					getCaldoriaGunAimed();
+	
+	//	TSA
+	void						setRipTimerTime(TimeValue);
+	TimeValue				getRipTimerTime();
+	void						setTSAFuseTimeLimit(TimeValue);
+	TimeValue				getTSAFuseTimeLimit();
+	void						setT0BMonitorMode(byte);
+	byte						getT0BMonitorMode();
+	void						setTSAState(byte);
+	byte						getTSAState();
+	void						setT0BMonitorStart(TimeValue);
+	TimeValue				getT0BMonitorStart();
+	void						setTSAIDedAtDoor(bool);
+	bool					getTSAIDedAtDoor();
+	void						setTSA0BZoomedIn(bool);
+	bool					getTSA0BZoomedIn();
+	void						setTSAFrontDoorUnlockedOutside(bool);
+	bool					getTSAFrontDoorUnlockedOutside();
+	void						setTSAFrontDoorUnlockedInside(bool);
+	bool					getTSAFrontDoorUnlockedInside();
+	void						setTSASeenRobotGreeting(bool);
+	bool					getTSASeenRobotGreeting();
+	void						setTSASeenTheory(bool);
+	bool					getTSASeenTheory();
+	void						setTSASeenBackground(bool);
+	bool					getTSASeenBackground();
+	void						setTSASeenProcedure(bool);
+	bool					getTSASeenProcedure();
+	void						setTSASeenAgent3AtDoor(bool);
+	bool					getTSASeenAgent3AtDoor();
+	void						setTSACommandCenterLocked(bool);
+	bool					getTSACommandCenterLocked();
+	void						setTSASeenCaldoriaNormal(bool);
+	bool					getTSASeenCaldoriaNormal();
+	void						setTSASeenCaldoriaAltered(bool);
+	bool					getTSASeenCaldoriaAltered();
+	void						setTSASeenNoradNormal(bool);
+	bool					getTSASeenNoradNormal();
+	void						setTSASeenNoradAltered(bool);
+	bool					getTSASeenNoradAltered();
+	void						setTSASeenMarsNormal(bool);
+	bool					getTSASeenMarsNormal();
+	void						setTSASeenMarsAltered(bool);
+	bool					getTSASeenMarsAltered();
+	void						setTSASeenWSCNormal(bool);
+	bool					getTSASeenWSCNormal();
+	void						setTSASeenWSCAltered(bool);
+	bool					getTSASeenWSCAltered();
+	void						setTSABiosuitOn(bool);
+	bool					getTSABiosuitOn();
+	
+	//	Prehistoric
+	void						setPrehistoricTriedToExtendBridge(bool);
+	bool					getPrehistoricTriedToExtendBridge();
+	void						setPrehistoricSeenTimeStream(bool);
+	bool					getPrehistoricSeenTimeStream();
+	void						setPrehistoricSeenFlyer1(bool);
+	bool					getPrehistoricSeenFlyer1();
+	void						setPrehistoricSeenFlyer2(bool);
+	bool					getPrehistoricSeenFlyer2();
+	void						setPrehistoricSeenBridgeZoom(bool);
+	bool					getPrehistoricSeenBridgeZoom();
+	void						setPrehistoricBreakerThrown(bool);
+	bool					getPrehistoricBreakerThrown();
+	
+	//	Norad
+	void						setNoradSeenTimeStream(bool);
+	bool					getNoradSeenTimeStream();
+	void						setNoradGassed(bool);
+	bool					getNoradGassed();
+	void						setNoradFillingStationOn(bool);
+	bool					getNoradFillingStationOn();
+	void						setNoradN22MessagePlayed(bool);
+	bool					getNoradN22MessagePlayed();
+	void						setNoradPlayedGlobeGame(bool);
+	bool					getNoradPlayedGlobeGame();
+	void						setNoradBeatRobotWithClaw(bool);
+	bool					getNoradBeatRobotWithClaw();
+	void						setNoradBeatRobotWithDoor(bool);
+	bool					getNoradBeatRobotWithDoor();
+	void						setNoradRetScanGood(bool);
+	bool					getNoradRetScanGood();
+	void						setNoradWaitingForLaser(bool);
+	bool					getNoradWaitingForLaser();
+	void						setNoradSubRoomPressure(uint16);
+	uint16					getNoradSubRoomPressure();
+	void						setNoradSubPrepState(tNoradSubPrepState);
+	tNoradSubPrepState		getNoradSubPrepState();
+	void						setNoradArrivedFromSub(bool);
+	bool					getNoradArrivedFromSub();
+	
+	//	Mars
+	void						setMarsSeenTimeStream(bool);
+	bool					getMarsSeenTimeStream();	
+	void						setMarsHeardUpperPodMessage(bool);
+	bool					getMarsHeardUpperPodMessage();
+	void						setMarsRobotThrownPlayer(bool);
+	bool					getMarsRobotThrownPlayer();
+	void						setMarsHeardCheckInMessage(bool);
+	bool					getMarsHeardCheckInMessage();
+	void						setMarsPodAtUpperPlatform(bool);
+	bool					getMarsPodAtUpperPlatform();
+	void						setMarsSeenThermalScan(bool);
+	bool					getMarsSeenThermalScan();
+	void						setMarsArrivedBelow(bool);
+	bool					getMarsArrivedBelow();
+	void						setMarsSeenRobotAtReactor(bool);
+	bool					getMarsSeenRobotAtReactor();
+	void						setMarsAvoidedReactorRobot(bool);
+	bool					getMarsAvoidedReactorRobot();
+	void						setMarsInAirlock(bool);
+	bool					getMarsInAirlock();
+	void						setMarsAirlockOpen(bool);
+	bool					getMarsAirlockOpen();
+	void						setMarsMaskOnFiller(bool);
+	bool					getMarsMaskOnFiller();
+	void						setMarsLockFrozen(bool);
+	bool					getMarsLockFrozen();
+	void						setMarsLockBroken(bool);
+	bool					getMarsLockBroken();
+	void						setMarsMazeDoorPair1(bool);
+	bool					getMarsMazeDoorPair1();
+	void						setMarsMazeDoorPair2(bool);
+	bool					getMarsMazeDoorPair2();
+	void						setMarsMazeDoorPair3(bool);
+	bool					getMarsMazeDoorPair3();
+	void						setMarsSawRobotLeave(bool);
+	bool					getMarsSawRobotLeave();
+	void						setMarsSecurityDown(bool);
+	bool					getMarsSecurityDown();
+	void						setMarsFinishedCanyonChase(bool);
+	bool					getMarsFinishedCanyonChase();
+	void						setMarsThreadedMaze(bool);
+	bool					getMarsThreadedMaze();
+	void						setMarsHitRobotWithCannon(bool);
+	bool					getMarsHitRobotWithCannon();
+	void						setMarsReadyForShuttleTransport(bool);
+	bool					getMarsReadyForShuttleTransport();
+
+	//	WSC
+	void						setWSCSeenTimeStream(bool);
+	bool					getWSCSeenTimeStream();
+	void						setWSCPoisoned(bool);
+	bool					getWSCPoisoned();
+	void						setWSCAnsweredAboutDart(bool);
+	bool					getWSCAnsweredAboutDart();
+	void						setWSCRemovedDart(bool);
+	bool					getWSCRemovedDart();
+	void						setWSCAnalyzerOn(bool);
+	bool					getWSCAnalyzerOn();
+	void						setWSCDartInAnalyzer(bool);
+	bool					getWSCDartInAnalyzer();
+	void						setWSCAnalyzedDart(bool);
+	bool					getWSCAnalyzedDart();
+	void						setWSCSawMorph(bool);
+	bool					getWSCSawMorph();
+	void						setWSCDesignedAntidote(bool);
+	bool					getWSCDesignedAntidote();
+	void						setWSCPickedUpAntidote(bool);
+	bool					getWSCPickedUpAntidote();
+	void						setWSCOfficeMessagesOpen(bool);
+	bool					getWSCOfficeMessagesOpen();
+	void						setWSCSeenNerd(bool);
+	bool					getWSCSeenNerd();
+	void						setWSCHeardPage1(bool);
+	bool					getWSCHeardPage1();
+	void						setWSCHeardPage2(bool);
+	bool					getWSCHeardPage2();
+	void						setWSCHeardCheckIn(bool);
+	bool					getWSCHeardCheckIn();
+	void						setWSCDidPlasmaDodge(bool);
+	bool					getWSCDidPlasmaDodge();
+	void						setWSCSeenSinclairLecture(bool);
+	bool					getWSCSeenSinclairLecture();
+	void						setWSCBeenAtWSC93(bool);
+	bool					getWSCBeenAtWSC93();
+	void						setWSCCatwalkDark(bool);
+	bool					getWSCCatwalkDark();
+	void						setWSCRobotDead(bool);
+	bool					getWSCRobotDead();
+	void						setWSCRobotGone(bool);
+	bool					getWSCRobotGone();
+
+protected:
+	friend class Common::Singleton<SingletonBaseType>;
+
+private:
+	// Base
+	tNeighborhoodID _currentNeighborhood;
+	tRoomID _currentRoom;
+	tDirectionConstant _currentDirection;
+	tNeighborhoodID _nextNeighborhoodID;
+	tRoomID _nextRoomID;
+	tDirectionConstant _nextDirection;
+	tNeighborhoodID _lastNeighborhood;
+	tRoomID _lastRoom;
+	tDirectionConstant _lastDirection;
+	tRoomID _openDoorRoom;
+	tDirectionConstant _openDoorDirection;
+
+	// Pegasus Prime
+	#define NUM_FLAGS (sizeof(Unit) * 8)
+	#define BIT_INDEX_SHIFT (sizeof(Unit) + 2 - (sizeof(Unit)) / 3)
+	#define BIT_INDEX_MASK (NUM_FLAGS - 1)
+	template <typename Unit, uint32 kNumFlags>
+	class FlagsArray {
+	public:
+		FlagsArray() { clearAllFlags(); }
+		void clearAllFlags() { memset(_flags, 0, sizeof(_flags)); }
+		void setAllFlags() { memset(_flags, ~((Unit)0), sizeof(_flags)); }
+		void setFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] |= 1 << (flag & BIT_INDEX_MASK); }
+		void clearFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] &= ~(1 << (flag & BIT_INDEX_MASK)); }
+		void setFlag(uint32 flag, bool val) { if (val) setFlag(flag); else clearFlag(flag); }
+		bool getFlag(uint32 flag) { return (_flags[flag >> BIT_INDEX_SHIFT] & (1 << (flag & BIT_INDEX_MASK))) != 0; }
+		bool anyFlagSet() {
+			for (uint32 i = 0; i < sizeof(_flags); i++)
+				if (_flags[i] != 0)
+					return true;
+			return false;
+		}
+
+		void readFromStream(Common::ReadStream *stream) {
+			// Shortcut
+			if (sizeof(Unit) == 1) {
+				stream->read(_flags, sizeof(_flags));
+				return;
+			}
+
+			for (uint32 i = 0; i < sizeof(_flags); i++) {
+				if (sizeof(Unit) == 2)
+					_flags[i] = stream->readUint16BE();
+				else /* if (sizeof(Unit) == 4) */
+					_flags[i] = stream->readUint32BE();
+			}
+		}
+
+		void writeToStream(Common::WriteStream *stream) {
+			// Shortcut
+			if (sizeof(Unit) == 1) {
+				stream->write(_flags, sizeof(_flags));
+				return;
+			}
+
+			for (uint32 i = 0; i < sizeof(_flags); i++) {
+				if (sizeof(Unit) == 2)
+					stream->writeUint16BE(_flags[i]);
+				else /* if (sizeof(Unit) == 4) */
+					stream->writeUint32BE(_flags[i]);
+			}
+		}
+
+	private:
+		Unit _flags[(kNumFlags - 1) / NUM_FLAGS + 1];
+	};
+
+	FlagsArray<byte, kNumGlobalFlags> _globalFlags;
+	FlagsArray<byte, kNumScoringFlags> _scoringFlags;
+	FlagsArray<uint32, kNumItems> _itemTakenFlags;
+	
+	FlagsArray<byte, kNumCaldoriaFlags> _caldoriaFlags;
+	TimeValue _caldoriaFuseTimeLimit;
+	
+	TimeValue _TSARipTimerTime;
+	TimeValue _TSAFuseTimeLimit;
+	byte _TSAState;
+	byte _T0BMonitorMode;
+	TimeValue _T0BMonitorStart;
+	FlagsArray<byte, kNumTSAFlags> _TSAFlags;
+	
+	FlagsArray<byte, kNumPrehistoricFlags> _prehistoricFlags;
+	
+	FlagsArray<byte, kNumNoradFlags> _noradFlags;
+	uint16 _noradSubRoomPressure;
+	tNoradSubPrepState _noradSubPrepState;
+	
+	FlagsArray<byte, kNumMarsFlags> _marsFlags;
+	
+	FlagsArray<byte, kNumWSCFlags> _WSCFlags;
+};
+
+} // End of namespace Pegasus
+
+#define GameState	(::Pegasus::GameStateManager::instance())
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 56a9589..4840190 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -4,12 +4,12 @@ MODULE_OBJS = \
 	console.o \
 	credits.o \
 	detection.o \
+	gamestate.o \
 	graphics.o \
 	menu.o \
 	overview.o \
 	pegasus.o \
 	video.o \
-	Game_Shell/CGameState.o \
 	Game_Shell/CInventory.o \
 	Game_Shell/CItem.o \
 	Game_Shell/CItemList.o \
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index 3aa8db6..d311656 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index 03bf52d..cd7bec4 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/extra.h b/engines/pegasus/neighborhood/extra.h
index 3658fbd..3320f51 100755
--- a/engines/pegasus/neighborhood/extra.h
+++ b/engines/pegasus/neighborhood/extra.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
index 3199a51..a9acfe7 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.h
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 1197c65..3d47dbf 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -26,14 +26,14 @@
 #include "common/debug.h"
 #include "common/stream.h"
 
+#include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
-#include "pegasus/game_shell/CGameState.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
 
 Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : _vm(vm), _resName(resName) {
-	CGameState::SetOpenDoorLocation(kNoRoomID, kNoDirection);
+	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 }
 
@@ -95,9 +95,9 @@ void Neighborhood::init() {
 }
 
 void Neighborhood::start() {
-	CGameState::SetCurrentRoom(CGameState::GetLastRoom());
-	CGameState::SetCurrentDirection(CGameState::GetLastDirection());
-	arriveAt(CGameState::GetNextRoom(), CGameState::GetNextDirection());
+	GameState.setCurrentRoom(GameState.getLastRoom());
+	GameState.setCurrentDirection(GameState.getLastDirection());
+	arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
 }
 
 void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
@@ -114,7 +114,7 @@ void Neighborhood::getExitEntry(const tRoomID room, const tDirectionConstant dir
 }
 
 TimeValue Neighborhood::getViewTime(const tRoomID room, const tDirectionConstant direction) {
-	if (CGameState::GetOpenDoorRoom() == room && CGameState::GetOpenDoorDirection() == direction) {
+	if (GameState.getOpenDoorRoom() == room && GameState.getOpenDoorDirection() == direction) {
 		// If we get here, the door entry for this location must exist.
 		DoorTable::Entry doorEntry = _doorTable.findEntry(room, direction, _currentAlternate);
 
@@ -174,13 +174,13 @@ void Neighborhood::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry)
 tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	DoorTable::Entry door;
 	
-	getExitEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), entry);
-	getDoorEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), door);
+	getExitEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), entry);
+	getDoorEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), door);
 
 	//	Fixed this so that doors that don't lead anywhere can be opened, but not walked
 	//	through.
 	if (door.flags & kDoorPresentMask) {
-		if (CGameState::IsCurrentDoorOpen()) {
+		if (GameState.isCurrentDoorOpen()) {
 			if (entry.exitRoom == kNoRoomID)
 				return kCantMoveBlocked;
 			else
@@ -198,7 +198,7 @@ tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 }
 
 tCanTurnReason Neighborhood::canTurn(tTurnDirection turn, tDirectionConstant &nextDir) {
-	nextDir = getTurnEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), turn);
+	nextDir = getTurnEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), turn);
 
 	if (nextDir == kNoDirection)
 		return kCantTurnNoTurn;
@@ -207,10 +207,10 @@ tCanTurnReason Neighborhood::canTurn(tTurnDirection turn, tDirectionConstant &ne
 }
 
 tCanOpenDoorReason Neighborhood::canOpenDoor(DoorTable::Entry &entry) {
-	getDoorEntry(CGameState::GetCurrentRoom(), CGameState::GetCurrentDirection(), entry);
+	getDoorEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), entry);
 
 	if (entry.flags & kDoorPresentMask) {
-		if (CGameState::IsCurrentDoorOpen())
+		if (GameState.isCurrentDoorOpen())
 			return kCantOpenAlreadyOpen;
 
 		if (entry.flags & kDoorLockedMask)
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index 1bfa589..f4fdf81 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/turn.h b/engines/pegasus/neighborhood/turn.h
index daeaf2f..48970d7 100755
--- a/engines/pegasus/neighborhood/turn.h
+++ b/engines/pegasus/neighborhood/turn.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/view.h b/engines/pegasus/neighborhood/view.h
index f1efb2b..6a732d5 100755
--- a/engines/pegasus/neighborhood/view.h
+++ b/engines/pegasus/neighborhood/view.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/neighborhood/zoom.h b/engines/pegasus/neighborhood/zoom.h
index e659b11..4046a76 100755
--- a/engines/pegasus/neighborhood/zoom.h
+++ b/engines/pegasus/neighborhood/zoom.h
@@ -29,7 +29,7 @@
 #include "common/array.h"
 #include "common/endian.h"
 
-#include "pegasus/Game_Shell/Headers/Game_Shell_Constants.h"
+#include "pegasus/constants.h"
 
 namespace Common {
 	class SeekableReadStream;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 598c97c..3093e9b 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -32,8 +32,8 @@
 #include "gui/saveload.h"
 
 #include "pegasus/console.h"
+#include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
-#include "pegasus/neighborhood/neighborhood.h"
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
@@ -231,17 +231,17 @@ void PegasusEngine::mainGameLoop() {
 	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
 	drawInterface();
 
-	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(_neighborhood).c_str(), getTimeZoneDesc(_neighborhood).c_str());
+	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(GameState.getCurrentNeighborhood()).c_str(), getTimeZoneDesc(GameState.getCurrentNeighborhood()).c_str());
 	_video->playMovie(navMovie, kViewScreenOffset, kViewScreenOffset);
 
 	_gameMode = kQuitMode;
 }
 
 void PegasusEngine::changeLocation(tNeighborhoodID neighborhood) {
-	_neighborhood = neighborhood;
+	GameState.setCurrentNeighborhood(neighborhood);
 
 	// Just a test...
-	Neighborhood *neighborhoodPtr = new Neighborhood(this, getTimeZoneDesc(_neighborhood), _neighborhood);
+	Neighborhood *neighborhoodPtr = new Neighborhood(this, getTimeZoneDesc(neighborhood), neighborhood);
 	neighborhoodPtr->init();
 	delete neighborhoodPtr;
 }
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index d6e312c..25fbc34 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -106,35 +106,6 @@ struct OverviewHotspot {
 	uint32 time;
 };
 
-// Taken from JMP PP Resources
-enum Item {
-	kAIBiochip = 128,
-	kInterfaceBiochip = 129, // NOT USED!
-	kMapBiochip = 130,
-	kOpticalBiochip = 131,
-	kPegasusBiochip = 132,
-	kRetinalScanBiochip = 133,
-	kShieldBiochip = 134,
-	kAirMask = 135,
-	kAntidote = 136,
-	kArgonCanister = 137,
-	kCardBomb = 138,
-	kCrowbar = 139,
-	kGasCanister = 140,
-	kHistoricalLog = 141,
-	kJourneymanKey = 142,
-	kKeyCard = 143,
-	kMachineGun = 144, // What the hell is this?
-	kMarsCard = 145,
-	kNitrogenCanister = 146,
-	kOrangeJuiceGlassFull = 147,
-	kOrangeJuiceGlassEmpty = 148,
-	kPoisonDart = 149,
-	kSinclairKey = 150,
-	kStunGun = 151,
-	kArgonPickup = 152 // ???
-};
-
 enum GameMode {
 	kIntroMode,
 	kMainMenuMode,
@@ -197,7 +168,6 @@ private:
 	// Game Variables
 	bool _adventureMode;
 	GameMode _gameMode;
-	tNeighborhoodID _neighborhood;
 	Common::Array<ItemLocationData> _itemLocationData;
 
 	// Console
diff --git a/engines/pegasus/scoring.h b/engines/pegasus/scoring.h
new file mode 100755
index 0000000..bd09f2b
--- /dev/null
+++ b/engines/pegasus/scoring.h
@@ -0,0 +1,281 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_SCORING_H
+#define PEGASUS_SCORING_H
+
+#include "pegasus/types.h"
+
+namespace Pegasus {
+
+/////////////////////////////////////////////
+//
+//	Scoring.
+
+const tCoordType kDeathScreenScoreLeft = 151;
+const tCoordType kDeathScreenScoreTop = 212;
+const tCoordType kDeathScreenScoreWidth = 124;
+const tCoordType kDeathScreenScoreHeight = 12;
+const tCoordType kDeathScreenScoreSkipVert = -16;
+
+//	Caldoria & TSA
+
+const tGameScoreType kSawINNScore					= 5;
+const tGameScoreType kTookShowerScore				= 2;
+const tGameScoreType kFixedHairScore				= 2;
+const tGameScoreType kGotKeyCardScore				= 5;
+const tGameScoreType kReadPaperScore				= 2;
+const tGameScoreType kLookThroughTelescopeScore		= 2;
+const tGameScoreType kSawCaldoriaKioskScore			= 2;
+const tGameScoreType kGoToTSAScore					= 3;
+
+const tGameScoreType kEnterTSAScore					= 2;
+const tGameScoreType kSawBust1Score					= 2;
+const tGameScoreType kSawBust2Score					= 2;
+const tGameScoreType kSawBust3Score					= 2;
+const tGameScoreType kSawBust4Score					= 2;
+const tGameScoreType kSawBust5Score					= 2;
+const tGameScoreType kSawBust6Score					= 2;
+const tGameScoreType kSawTheoryScore				= 4;
+const tGameScoreType kSawBackgroundScore			= 4;
+const tGameScoreType kSawProcedureScore				= 4;
+const tGameScoreType kGotJourneymanKeyScore			= 5;
+const tGameScoreType kGotPegasusBiochipScore		= 5;
+const tGameScoreType kGotBiosuitScore				= 5;
+const tGameScoreType kGoToPrehistoricScore			= 5;
+
+const tGameScoreType kPutLogInReaderScore			= 5;
+const tGameScoreType kSawCaldoriaNormalScore		= 2;
+const tGameScoreType kSawCaldoriaAlteredScore		= 2;
+const tGameScoreType kSawNoradNormalScore			= 2;
+const tGameScoreType kSawNoradAlteredScore			= 2;
+const tGameScoreType kSawMarsNormalScore			= 2;
+const tGameScoreType kSawMarsAlteredScore			= 2;
+const tGameScoreType kSawWSCNormalScore				= 2;
+const tGameScoreType kSawWSCAlteredScore			= 2;
+const tGameScoreType kWentToReadyRoom2Score			= 5;
+const tGameScoreType kWentAfterSinclairScore		= 5;
+const tGameScoreType kUsedCardBombScore				= 10;
+const tGameScoreType kShieldedCardBombScore			= 5;
+const tGameScoreType kStunnedSinclairScore			= 10;
+const tGameScoreType kDisarmedNukeScore				= 10;
+
+const tGameScoreType kMaxCaldoriaTSAScoreBefore		=	kSawINNScore +
+														kTookShowerScore +
+														kFixedHairScore +
+														kGotKeyCardScore +
+														kReadPaperScore +
+														kLookThroughTelescopeScore +
+														kSawCaldoriaKioskScore +
+														kGoToTSAScore +
+														kEnterTSAScore +
+														kSawBust1Score +
+														kSawBust2Score +
+														kSawBust3Score +
+														kSawBust4Score +
+														kSawBust5Score +
+														kSawBust6Score +
+														kSawTheoryScore +
+														kSawBackgroundScore +
+														kSawProcedureScore +
+														kGotJourneymanKeyScore +
+														kGotPegasusBiochipScore +
+														kGotBiosuitScore +
+														kGoToPrehistoricScore +
+														kPutLogInReaderScore +
+														kSawCaldoriaNormalScore +
+														kSawCaldoriaAlteredScore +
+														kSawNoradNormalScore +
+														kSawNoradAlteredScore +
+														kSawMarsNormalScore +
+														kSawMarsAlteredScore +
+														kSawWSCNormalScore +
+														kSawWSCAlteredScore +
+														kWentToReadyRoom2Score;
+
+const tGameScoreType kMaxCaldoriaTSAScoreAfter		=	kWentAfterSinclairScore +
+														kUsedCardBombScore +
+														kShieldedCardBombScore +
+														kStunnedSinclairScore +
+														kDisarmedNukeScore;
+
+const tGameScoreType kMaxCaldoriaTSAScore			=	kMaxCaldoriaTSAScoreBefore +
+														kMaxCaldoriaTSAScoreAfter;
+
+//	Prehistoric
+
+const tGameScoreType kThrewBreakerScore				= 10;
+const tGameScoreType kExtendedBridgeScore			= 10;
+const tGameScoreType kGotHistoricalLogScore			= 5;
+const tGameScoreType kFinishedPrehistoricScore		= 10;
+
+const tGameScoreType kMaxPrehistoricScore			=	kThrewBreakerScore +
+														kExtendedBridgeScore +
+														kGotHistoricalLogScore +
+														kFinishedPrehistoricScore;
+
+//	Mars
+
+const tGameScoreType kThrownByRobotScore			= 3;
+const tGameScoreType kGotMarsCardScore				= 5;
+const tGameScoreType kSawMarsKioskScore				= 2;
+const tGameScoreType kSawTransportMapScore			= 2;
+const tGameScoreType kGotCrowBarScore				= 5;
+const tGameScoreType kTurnedOnTransportScore		= 5;
+const tGameScoreType kGotOxygenMaskScore			= 5;
+const tGameScoreType kAvoidedRobotScore				= 5;
+const tGameScoreType kActivatedPlatformScore		= 2;
+const tGameScoreType kUsedLiquidNitrogenScore		= 3;
+const tGameScoreType kUsedCrowBarScore				= 3;
+const tGameScoreType kFoundCardBombScore			= 4;
+const tGameScoreType kDisarmedCardBombScore			= 8;
+const tGameScoreType kGotCardBombScore				= 5;
+const tGameScoreType kThreadedMazeScore				= 5;
+const tGameScoreType kThreadedGearRoomScore			= 2;
+const tGameScoreType kEnteredShuttleScore			= 2;
+const tGameScoreType kEnteredLaunchTubeScore		= 4;
+const tGameScoreType kStoppedRobotsShuttleScore		= 10;
+const tGameScoreType kGotMarsOpMemChipScore			= 10;
+const tGameScoreType kFinishedMarsScore				= 10;
+
+const tGameScoreType kMaxMarsScore					=	kThrownByRobotScore +
+														kGotMarsCardScore +
+														kSawMarsKioskScore +
+														kSawTransportMapScore +
+														kGotCrowBarScore +
+														kTurnedOnTransportScore +
+														kGotOxygenMaskScore +
+														kAvoidedRobotScore +
+														kActivatedPlatformScore +
+														kUsedLiquidNitrogenScore +
+														kUsedCrowBarScore +
+														kFoundCardBombScore +
+														kDisarmedCardBombScore +
+														kGotCardBombScore +
+														kThreadedMazeScore +
+														kThreadedGearRoomScore +
+														kEnteredShuttleScore +
+														kEnteredLaunchTubeScore +
+														kStoppedRobotsShuttleScore +
+														kGotMarsOpMemChipScore +
+														kFinishedMarsScore;
+
+//	Norad
+
+const tGameScoreType kSawSecurityMonitorScore		= 5;
+const tGameScoreType kFilledOxygenCanisterScore		= 5;
+const tGameScoreType kFilledArgonCanisterScore		= 5;
+const tGameScoreType kSawUnconsciousOperatorScore	= 5;
+const tGameScoreType kWentThroughPressureDoorScore	= 5;
+const tGameScoreType kPreppedSubScore				= 5;
+const tGameScoreType kEnteredSubScore				= 5;
+const tGameScoreType kExitedSubScore				= 10;
+const tGameScoreType kSawRobotAt54NorthScore		= 5;
+const tGameScoreType kPlayedWithClawScore			= 5;
+const tGameScoreType kUsedRetinalChipScore			= 5;
+const tGameScoreType kFinishedGlobeGameScore		= 10;
+const tGameScoreType kStoppedNoradRobotScore		= 10;
+const tGameScoreType kGotNoradOpMemChipScore		= 10;
+const tGameScoreType kFinishedNoradScore			= 10;
+
+const tGameScoreType kMaxNoradScore					=	kSawSecurityMonitorScore +
+														kFilledOxygenCanisterScore +
+														kFilledArgonCanisterScore +
+														kSawUnconsciousOperatorScore +
+														kWentThroughPressureDoorScore +
+														kPreppedSubScore +
+														kEnteredSubScore +
+														kExitedSubScore +
+														kSawRobotAt54NorthScore +
+														kPlayedWithClawScore +
+														kUsedRetinalChipScore +
+														kFinishedGlobeGameScore +
+														kStoppedNoradRobotScore +
+														kGotNoradOpMemChipScore +
+														kFinishedNoradScore;
+
+//	WSC
+
+const tGameScoreType kRemovedDartScore				= 5;
+const tGameScoreType kAnalyzedDartScore				= 5;
+const tGameScoreType kBuiltAntidoteScore			= 5;
+const tGameScoreType kGotSinclairKeyScore			= 5;
+const tGameScoreType kGotArgonCanisterScore 		= 5;
+const tGameScoreType kGotNitrogenCanisterScore		= 5;
+const tGameScoreType kPlayedWithMessagesScore		= 2;
+const tGameScoreType kSawMorphExperimentScore		= 3;
+const tGameScoreType kEnteredSinclairOfficeScore	= 2;
+const tGameScoreType kSawBrochureScore				= 3;
+const tGameScoreType kSawSinclairEntry1Score		= 3;
+const tGameScoreType kSawSinclairEntry2Score		= 3;
+const tGameScoreType kSawSinclairEntry3Score		= 3;
+const tGameScoreType kSawWSCDirectoryScore			= 3;
+const tGameScoreType kUsedCrowBarInWSCScore			= 5;
+const tGameScoreType kFinishedPlasmaDodgeScore		= 10;
+const tGameScoreType kOpenedCatwalkScore			= 3;
+const tGameScoreType kStoppedWSCRobotScore			= 10;
+const tGameScoreType kGotWSCOpMemChipScore			= 10;
+const tGameScoreType kFinishedWSCScore				= 10;
+
+const tGameScoreType kMaxWSCScore					=	kRemovedDartScore +
+														kAnalyzedDartScore +
+														kBuiltAntidoteScore +
+														kGotSinclairKeyScore +
+														kGotArgonCanisterScore +
+														kGotNitrogenCanisterScore +
+														kPlayedWithMessagesScore +
+														kSawMorphExperimentScore +
+														kEnteredSinclairOfficeScore +
+														kSawBrochureScore +
+														kSawSinclairEntry1Score +
+														kSawSinclairEntry2Score +
+														kSawSinclairEntry3Score +
+														kSawWSCDirectoryScore +
+														kUsedCrowBarInWSCScore +
+														kFinishedPlasmaDodgeScore +
+														kOpenedCatwalkScore +
+														kStoppedWSCRobotScore +
+														kGotWSCOpMemChipScore +
+														kFinishedWSCScore;
+
+//	Gandhi
+
+const tGameScoreType kMarsGandhiScore				= 10;
+const tGameScoreType kNoradGandhiScore				= 10;
+const tGameScoreType kWSCGandhiScore				= 10;
+
+const tGameScoreType kMaxGandhiScore				=	kMarsGandhiScore +
+														kNoradGandhiScore +
+														kWSCGandhiScore;
+
+const tGameScoreType kMaxTotalScore					=	kMaxCaldoriaTSAScore +
+														kMaxPrehistoricScore +
+														kMaxMarsScore +
+														kMaxNoradScore +
+														kMaxWSCScore +
+														kMaxGandhiScore;
+} // End of namespace Pegasus
+
+#endif
\ No newline at end of file
diff --git a/engines/pegasus/types.h b/engines/pegasus/types.h
new file mode 100755
index 0000000..6c51c93
--- /dev/null
+++ b/engines/pegasus/types.h
@@ -0,0 +1,185 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_TYPES_H
+#define PEGASUS_TYPES_H
+
+#include "common/scummsys.h"
+
+namespace Pegasus {
+
+// TODO: All of the "tMM"-prefixed defines should be replaced eventually
+// TODO: Probably all of these don't really need to be typedef'd...
+typedef int8 tMM8BitS;
+typedef uint8 tMM8BitU;
+
+typedef int16 tMM16BitS;
+typedef uint16 tMM16BitU;
+
+typedef int32 tMM32BitS;
+typedef uint32 tMM32BitU;
+
+typedef tMM8BitS tMM8BitID;
+typedef tMM16BitS tMM16BitID;
+typedef tMM32BitS tMM32BitID;
+
+typedef tMM8BitU tMM8BitFlags;
+typedef tMM16BitU tMM16BitFlags;
+typedef tMM32BitU tMM32BitFlags;
+
+typedef tMM32BitID tDisplayElementID;
+typedef tMM32BitS tDisplayOrder;
+
+typedef tMM16BitID tHotSpotID;
+typedef tMM32BitFlags tHotSpotFlags;
+
+typedef tMM8BitFlags tButtonState;
+typedef tMM32BitFlags tInputBits;
+
+typedef tMM8BitU tKeyMapType[16];
+typedef tMM8BitU tKeyType;
+typedef tMM8BitU tKeyMapIndexType;
+typedef tMM8BitU tKeyMapBitType;
+
+typedef tMM32BitID tNotificationID;
+typedef tMM32BitFlags tNotificationFlags;
+
+//	Mac types.
+typedef tMM16BitS tResIDType;
+typedef tMM16BitS tCoordType;
+typedef tMM16BitS tQDCopyMode;
+typedef tMM16BitS tResItemCountType;
+
+enum tCopyMode {
+	kNoMask,
+	kUseClipArea,
+	kUseTransparency
+};
+
+enum tSlideDirection {
+	kSlideLeftMask = 1,
+	kSlideRightMask = kSlideLeftMask << 1,
+	kSlideUpMask = kSlideRightMask << 1 << 1,
+	kSlideDownMask = kSlideUpMask << 1,
+	
+	kSlideHorizMask = kSlideLeftMask | kSlideRightMask,
+	kSlideVertMask = kSlideUpMask | kSlideDownMask,
+
+	kSlideUpLeftMask = kSlideLeftMask | kSlideUpMask,
+	kSlideUpRightMask = kSlideRightMask | kSlideUpMask,
+	kSlideDownLeftMask = kSlideLeftMask | kSlideDownMask,
+	kSlideDownRightMask = kSlideRightMask | kSlideDownMask
+};
+
+// ScummVM QuickTime/QuickDraw replacement types
+typedef uint TimeValue;
+typedef uint TimeScale;
+// TODO: Fixed and RGBColor
+
+typedef tMM16BitID tGameID;
+
+typedef tGameID tItemID;
+typedef tGameID tActorID;
+typedef tGameID tRoomID;
+typedef tGameID tNeighborhoodID;
+typedef tMM8BitU tAlternateID;
+typedef tMM8BitS tHotSpotActivationID;
+
+typedef tMM16BitS tWeightType;
+
+typedef tMM8BitU tDirectionConstant;
+typedef tMM8BitU tTurnDirection;
+
+// Meant to be room in low 16 bits and direction in high 16 bits.
+typedef tMM32BitU tRoomViewID;
+
+#define MakeRoomView(room, direction) (((tRoomViewID) (room)) | (((tRoomViewID) (direction)) << 16))
+
+typedef tMM32BitU tExtraID;
+
+typedef tMM16BitS tGameMode;
+
+typedef tMM16BitS tWeightType;
+
+typedef tMM16BitS tItemState;
+
+typedef tMM8BitS tDeathReason;
+
+typedef tMM32BitS tGameMenuCommand;
+
+typedef tMM32BitS tGameScoreType;
+
+typedef long tCanMoveForwardReason;
+
+typedef long tCanTurnReason;
+
+typedef long tCanOpenDoorReason;
+
+enum tInventoryResult {
+	kInventoryOK,
+	kTooMuchWeight,
+	kItemNotInInventory
+};
+
+typedef tMM32BitID tInteractionID;
+
+typedef tMM32BitID tAIConditionID;
+
+enum tEnergyStage {
+	kStageNoStage,
+	kStageCasual,				//	more than 50% energy
+	kStageWorried,				//	more than 25% energy
+	kStageNervous,				//	more than 5% energy
+	kStagePanicStricken			//	less than 5% energy
+};
+
+enum tNoradSubPrepState {
+	kSubNotPrepped,
+	kSubPrepped,
+	kSubDamaged
+};
+
+enum tLowerClientSignature {
+	kNoClientSignature,
+	kInventorySignature,
+	kBiochipSignature,
+	kAISignature
+};
+
+enum tLowerAreaSignature {
+	kLeftAreaSignature,
+	kMiddleAreaSignature,
+	kRightAreaSignature
+};
+
+enum tAirQuality {
+	kAirQualityGood,
+	kAirQualityDirty,
+	kAirQualityVacuum
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: cb7b382acfd29957c9522b08b6460526fc73983c
    https://github.com/scummvm/scummvm/commit/cb7b382acfd29957c9522b08b6460526fc73983c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-01T22:06:17-07:00

Commit Message:
PEGASUS: Restructure remaining (already converted) Game Shell classes

Changed paths:
  A engines/pegasus/items/inventory.cpp
  A engines/pegasus/items/inventory.h
  A engines/pegasus/items/item.cpp
  A engines/pegasus/items/item.h
  A engines/pegasus/items/itemlist.cpp
  A engines/pegasus/items/itemlist.h
  A engines/pegasus/sound.cpp
  A engines/pegasus/sound.h
  R engines/pegasus/Game_Shell/CInventory.cpp
  R engines/pegasus/Game_Shell/CItem.cpp
  R engines/pegasus/Game_Shell/CInventory.h
  R engines/pegasus/Game_Shell/CItem.h
  R engines/pegasus/Game_Shell/CItemList.cpp
  R engines/pegasus/Game_Shell/CItemList.h
  R engines/pegasus/MMShell/Sounds/MMSound.cpp
  R engines/pegasus/MMShell/Sounds/MMSound.h
    engines/pegasus/MMShell/Utilities/MMIDObject.h
    engines/pegasus/gamestate.cpp
    engines/pegasus/gamestate.h
    engines/pegasus/menu.cpp
    engines/pegasus/module.mk



diff --git a/engines/pegasus/Game_Shell/CInventory.cpp b/engines/pegasus/Game_Shell/CInventory.cpp
deleted file mode 100755
index 64e62b4..0000000
--- a/engines/pegasus/Game_Shell/CInventory.cpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/Game_Shell/CItem.h"
-#include "pegasus/Game_Shell/CInventory.h"
-
-namespace Pegasus {
-
-CInventory::CInventory() {
-	fWeightLimit = 100;
-	fOwnerID = kNoActorID;
-	fReferenceCount = 0;
-}
-
-CInventory::~CInventory() {
-}
-
-void CInventory::SetWeightLimit(tWeightType limit) {
-	fWeightLimit = limit;
-	//	*** What to do if the new weight limit is greater than the current weight?
-}
-
-tWeightType CInventory::GetWeight() {
-	tWeightType	result = 0;
-
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++)
-		result += (*it)->GetItemWeight();
-
-	return result;
-}
-
-//	If the item already belongs, just return kInventoryOK.
-tInventoryResult CInventory::AddItem(CItem *item) {
-	if (ItemInInventory(item))
-		return kInventoryOK;
-
-	if (GetWeight() + item->GetItemWeight() > fWeightLimit)
-		return kTooMuchWeight;
-
-	fInventoryList.push_back(item);
-	item->SetItemOwner(fOwnerID);
-
-	++fReferenceCount;
-	return kInventoryOK;
-}
-
-tInventoryResult CInventory::RemoveItem(CItem *item) {
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++) {
-		if (*it == item) {
-			fInventoryList.erase(it);
-			item->SetItemOwner(kNoActorID);
-
-			++fReferenceCount;
-			return kInventoryOK;
-		}
-	}
-
-	return kItemNotInInventory;
-}
-
-tInventoryResult CInventory::RemoveItem(tItemID id) {
-	CItem *item = FindItemByID(id);
-	
-	if (item) {
-		fInventoryList.remove(item);
-		item->SetItemOwner(kNoActorID);
-
-		++fReferenceCount;
-		return kInventoryOK;
-	}
-
-	return kItemNotInInventory;
-}
-
-void CInventory::RemoveAllItems() {
-	fInventoryList.clear();
-	++fReferenceCount;
-}
-
-bool CInventory::ItemInInventory(CItem *item) {
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++)
-		if (*it == item)
-			return true;
-
-	return false;
-}
-
-bool CInventory::ItemInInventory(tItemID id) {
-	return FindItemByID(id) != NULL;
-}
-
-CItem *CInventory::GetItemAt(int32 index) {
-	int32 i = 0;
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
-		if (i == index)
-			return *it;
-
-	return 0;
-}
-
-tItemID CInventory::GetItemIDAt(int32 index) {
-	CItem *item = GetItemAt(index);
-
-	if (item)
-		return item->GetObjectID();
-
-	return kNoItemID;
-}
-
-CItem *CInventory::FindItemByID(tItemID id) {
-	return fInventoryList.FindItemByID(id);
-}
-
-//	Return -1 if not found.
-
-int32 CInventory::FindIndexOf(CItem *item) {
-	uint32 i = 0;
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
-		if (*it == item)
-			return i;
-
-	return -1;
-}
-
-//	Return -1 if not found.
-
-int32 CInventory::FindIndexOf(tItemID id) {
-	uint32 i = 0;
-	for (CItemIterator it = fInventoryList.begin(); it != fInventoryList.end(); it++, i++)
-		if ((*it)->GetObjectID() == id)
-			return i;
-
-	return -1;
-}
-
-tWeightType CInventory::GetWeightLimit() {
-	return fWeightLimit;
-}
-
-int32 CInventory::GetNumItems() {
-	return fInventoryList.size();
-}
-
-void CInventory::SetOwnerID(const tActorID id) {
-	fOwnerID = id;
-}
-
-tActorID CInventory::GetOwnerID() const {
-	return fOwnerID;
-}
-
-} // End of namespae Pegasus
diff --git a/engines/pegasus/Game_Shell/CInventory.h b/engines/pegasus/Game_Shell/CInventory.h
deleted file mode 100755
index 45af5c3..0000000
--- a/engines/pegasus/Game_Shell/CInventory.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_GAMESHELL_CINVENTORY_H
-#define PEGASUS_GAMESHELL_CINVENTORY_H
-
-#include "pegasus/types.h"
-#include "pegasus/Game_Shell/CItemList.h"
-
-namespace Pegasus {
-
-class CItem;
-
-//	Inventories have a "current item". This item is the default item the player can
-//	use. In a text adventure system, the current item would be "it", as in
-//	"Hit the troll with it," where "it" would refer to some weapon which is the current
-//	item. In a graphic adventure, the current item would be the item the user selects
-//	to use with the mouse or other pointing device.
-
-class CInventory {
-public:
-	CInventory();
-	virtual ~CInventory();
-	
-	tWeightType GetWeightLimit();
-	void SetWeightLimit(tWeightType limit);
-	tWeightType GetWeight();
-	
-	virtual tInventoryResult AddItem(CItem *item);
-	virtual tInventoryResult RemoveItem(CItem *item);
-	virtual tInventoryResult RemoveItem(tItemID id);
-	virtual bool ItemInInventory(CItem *item);
-	virtual bool ItemInInventory(tItemID id);
-	virtual CItem *GetItemAt(int32 index);
-	virtual tItemID GetItemIDAt(int32 index);
-	virtual CItem *FindItemByID(tItemID id);
-	virtual int32 FindIndexOf(CItem *item);
-	virtual int32 FindIndexOf(tItemID id);
-	int32 GetNumItems();
-	virtual void RemoveAllItems();
-	
-	void SetOwnerID(const tActorID id);
-	tActorID GetOwnerID() const;
-	
-	uint32 GetReferenceCount() { return fReferenceCount; }
-
-protected:
-	tWeightType fWeightLimit;
-	tActorID fOwnerID;
-	CItemList fInventoryList;
-
-private:
-	uint32 fReferenceCount;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/Game_Shell/CItem.cpp b/engines/pegasus/Game_Shell/CItem.cpp
deleted file mode 100755
index b96c24c..0000000
--- a/engines/pegasus/Game_Shell/CItem.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/error.h"
-#include "common/stream.h"
-
-#include "pegasus/constants.h"
-#include "pegasus/Game_Shell/CItem.h"
-#include "pegasus/Game_Shell/CItemList.h"
-
-namespace Pegasus {
-
-CItem::CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) {
-	fItemNeighborhood = neighborhood;
-	fItemRoom = room;
-	fItemDirection = direction;
-	fItemWeight = 1;
-	fItemOwnerID = kNoActorID;
-	fItemState = 0;
-
-	gAllItems.push_back(this);
-}
-
-CItem::~CItem() {
-}
-
-Common::Error CItem::WriteToStream(Common::WriteStream *stream) {
-	stream->writeUint16BE(fItemNeighborhood);
-	stream->writeUint16BE(fItemRoom);
-	stream->writeByte(fItemDirection);
-	stream->writeUint16BE(fItemOwnerID);
-	stream->writeUint16BE(fItemState);
-
-	if (stream->err())
-		return Common::kWritingFailed;
-	
-	return Common::kNoError;
-}
-
-Common::Error CItem::ReadFromStream(Common::ReadStream *stream) {
-	fItemNeighborhood = stream->readUint16BE();
-	fItemRoom = stream->readUint16BE();
-	fItemDirection = stream->readByte();
-	fItemOwnerID = stream->readUint16BE();
-	fItemState = stream->readUint16BE();
-	
-	if (stream->err())
-		return Common::kReadingFailed;
-	
-	return Common::kNoError;
-}
-
-tActorID CItem::GetItemOwner() const {
-	return fItemOwnerID;
-}
-
-void CItem::SetItemOwner(const tActorID owner) {
-	fItemOwnerID = owner;
-}
-
-tWeightType CItem::GetItemWeight() {
-	return fItemWeight;
-}
-
-tItemState CItem::GetItemState() const {
-	return fItemState;
-}
-
-void CItem::SetItemState(const tItemState state) {
-	fItemState = state;
-}
-
-void CItem::GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
-	neighborhood = fItemNeighborhood;
-	room = fItemRoom;
-	direction = fItemDirection;
-}
-
-void CItem::SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
-	fItemNeighborhood = neighborhood;
-	fItemRoom = room;
-	fItemDirection = direction;
-}
-
-tNeighborhoodID CItem::GetItemNeighborhood() const {
-	return fItemNeighborhood;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CItem.h b/engines/pegasus/Game_Shell/CItem.h
deleted file mode 100755
index c923e1c..0000000
--- a/engines/pegasus/Game_Shell/CItem.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_GAMESHELL_CITEM_H
-#define PEGASUS_GAMESHELL_CITEM_H
-
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
-#include "pegasus/types.h"
-
-namespace Common {
-	class Error;
-	class ReadStream;
-	class WriteStream;
-}
-
-namespace Pegasus {
-
-/*
-
-	CItem is an object which can be picked up and carried around.
-	CItems have
-		a location
-		an ID.
-		weight
-		an owner (kNoActorID if no one is carrying the CItem)
-
-*/
-
-//	Item IDs.
-
-const tItemID kAirMask = 7;
-const tItemID kAntidote = 8;
-const tItemID kArgonCanister = 9;
-const tItemID kCardBomb = 10;
-const tItemID kCrowbar = 11;
-const tItemID kGasCanister = 12;
-const tItemID kHistoricalLog = 13;
-const tItemID kJourneymanKey = 14;
-const tItemID kKeyCard = 15;
-const tItemID kMachineGun = 16;
-const tItemID kMarsCard = 17;
-const tItemID kNitrogenCanister = 18;
-const tItemID kOrangeJuiceGlassFull = 19;
-const tItemID kOrangeJuiceGlassEmpty = 20;
-const tItemID kPoisonDart = 21;
-const tItemID kSinclairKey = 22;
-const tItemID kStunGun = 23;
-const tItemID kArgonPickup = 24;
-
-//	Biochips.
-
-const tItemID kAIBiochip = 0;
-const tItemID kInterfaceBiochip = 1;
-const tItemID kMapBiochip = 2;
-const tItemID kOpticalBiochip = 3;
-const tItemID kPegasusBiochip = 4;
-const tItemID kRetinalScanBiochip = 5;
-const tItemID kShieldBiochip = 6;
-
-const tItemID kNumItems = 25;
-
-//	Item States.
-
-const tItemState kAI000 = 0;
-const tItemState kAI005 = 1;
-const tItemState kAI006 = 2;
-const tItemState kAI010 = 3;
-const tItemState kAI015 = 4;
-const tItemState kAI016 = 5;
-const tItemState kAI020 = 6;
-const tItemState kAI024 = 7;
-const tItemState kAI100 = 8;
-const tItemState kAI101 = 9;
-const tItemState kAI105 = 10;
-const tItemState kAI106 = 11;
-const tItemState kAI110 = 12;
-const tItemState kAI111 = 13;
-const tItemState kAI115 = 14;
-const tItemState kAI116 = 15;
-const tItemState kAI120 = 16;
-const tItemState kAI121 = 17;
-const tItemState kAI124 = 18;
-const tItemState kAI125 = 19;
-const tItemState kAI126 = 20;
-const tItemState kAI200 = 21;
-const tItemState kAI201 = 22;
-const tItemState kAI202 = 23;
-const tItemState kAI205 = 24;
-const tItemState kAI206 = 25;
-const tItemState kAI210 = 26;
-const tItemState kAI211 = 27;
-const tItemState kAI212 = 28;
-const tItemState kAI215 = 29;
-const tItemState kAI216 = 30;
-const tItemState kAI220 = 31;
-const tItemState kAI221 = 32;
-const tItemState kAI222 = 33;
-const tItemState kAI224 = 34;
-const tItemState kAI225 = 35;
-const tItemState kAI226 = 36;
-const tItemState kAI300 = 37;
-const tItemState kAI301 = 38;
-const tItemState kAI302 = 39;
-const tItemState kAI303 = 40;
-const tItemState kAI305 = 41;
-const tItemState kAI306 = 42;
-const tItemState kAI310 = 43;
-const tItemState kAI311 = 44;
-const tItemState kAI312 = 45;
-const tItemState kAI313 = 46;
-const tItemState kAI315 = 47;
-const tItemState kAI316 = 48;
-const tItemState kAI320 = 49;
-const tItemState kAI321 = 50;
-const tItemState kAI322 = 51;
-const tItemState kAI323 = 52;
-const tItemState kAI324 = 53;
-const tItemState kAI325 = 54;
-const tItemState kAI326 = 55;
-const tItemState kNormalItem = 56;
-const tItemState kMapUnavailable = 57;
-const tItemState kMapEngaged = 58;
-const tItemState kOptical000 = 59;
-const tItemState kOptical001 = 60;
-const tItemState kOptical002 = 61;
-const tItemState kOptical010 = 62;
-const tItemState kOptical011 = 63;
-const tItemState kOptical012 = 64;
-const tItemState kOptical020 = 65;
-const tItemState kOptical021 = 66;
-const tItemState kOptical100 = 67;
-const tItemState kOptical101 = 68;
-const tItemState kOptical102 = 69;
-const tItemState kOptical110 = 70;
-const tItemState kOptical111 = 71;
-const tItemState kOptical112 = 72;
-const tItemState kOptical120 = 73;
-const tItemState kOptical121 = 74;
-const tItemState kOptical200 = 75;
-const tItemState kOptical201 = 76;
-const tItemState kOptical210 = 77;
-const tItemState kOptical211 = 78;
-const tItemState kPegasusTSA00 = 79;
-const tItemState kPegasusTSA10 = 80;
-const tItemState kPegasusPrehistoric00 = 81;
-const tItemState kPegasusPrehistoric01 = 82;
-const tItemState kPegasusPrehistoric10 = 83;
-const tItemState kPegasusPrehistoric11 = 84;
-const tItemState kPegasusMars00 = 85;
-const tItemState kPegasusMars01 = 86;
-const tItemState kPegasusMars10 = 87;
-const tItemState kPegasusMars11 = 88;
-const tItemState kPegasusNorad00 = 89;
-const tItemState kPegasusNorad01 = 90;
-const tItemState kPegasusNorad10 = 91;
-const tItemState kPegasusNorad11 = 92;
-const tItemState kPegasusWSC00 = 93;
-const tItemState kPegasusWSC01 = 94;
-const tItemState kPegasusWSC10 = 95;
-const tItemState kPegasusWSC11 = 96;
-const tItemState kPegasusCaldoria = 97;
-const tItemState kRetinalSimulating = 98;
-const tItemState kShieldNormal = 99;
-const tItemState kShieldRadiation = 100;
-const tItemState kShieldPlasma = 101;
-const tItemState kShieldCardBomb = 102;
-const tItemState kShieldDraining = 103;
-const tItemState kAirMaskEmptyOff = 104;
-const tItemState kAirMaskEmptyFilter = 105;
-const tItemState kAirMaskLowOff = 106;
-const tItemState kAirMaskLowFilter = 107;
-const tItemState kAirMaskLowOn = 108;
-const tItemState kAirMaskFullOff = 109;
-const tItemState kAirMaskFullFilter = 110;
-const tItemState kAirMaskFullOn = 111;
-const tItemState kArgonEmpty = 112;
-const tItemState kArgonFull = 113;
-const tItemState kFlashlightOff = 114;
-const tItemState kFlashlightOn = 115;
-const tItemState kNitrogenEmpty = 116;
-const tItemState kNitrogenFull = 117;
-const tItemState kFullGlass = 118;
-
-//	Extra IDs.
-
-const uint32 kRetinalScanSearching = 0;
-const uint32 kRetinalScanActivated = 1;
-const uint32 kShieldIntro = 2;
-const uint32 kRemoveAirMask = 3;
-const uint32 kRemoveArgon = 4;
-const uint32 kRemoveCrowbar = 5;
-const uint32 kGasCanLoop = 6;
-const uint32 kRemoveJourneymanKey = 7;
-const uint32 kRemoveMarsCard = 8;
-const uint32 kRemoveNitrogen = 9;
-const uint32 kRemoveGlass = 10;
-const uint32 kRemoveDart = 11;
-const uint32 kRemoveSinclairKey = 12;
-
-class CItem : public MMIDObject {
-public:
-	CItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	virtual ~CItem();
-	
-	// WriteToStream writes everything EXCEPT the item's ID.
-	// It is assumed that the calling function will write and read the ID.
-	virtual Common::Error WriteToStream(Common::WriteStream *stream);
-	virtual Common::Error ReadFromStream(Common::ReadStream *stream);
-	
-	virtual tActorID GetItemOwner() const;
-	virtual void SetItemOwner(const tActorID owner);
-	
-	void GetItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const;
-	void SetItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	tNeighborhoodID GetItemNeighborhood() const;
-	
-	virtual tWeightType GetItemWeight();
-	
-	virtual void SetItemState(const tItemState state);
-	virtual tItemState GetItemState() const;
-
-protected:
-	tNeighborhoodID fItemNeighborhood;
-	tRoomID	fItemRoom;
-	tDirectionConstant fItemDirection;
-	tActorID fItemOwnerID;
-	tWeightType fItemWeight;
-	tItemState fItemState;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/Game_Shell/CItemList.cpp b/engines/pegasus/Game_Shell/CItemList.cpp
deleted file mode 100755
index 256a895..0000000
--- a/engines/pegasus/Game_Shell/CItemList.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/error.h"
-#include "common/stream.h"
-
-#include "engines/pegasus/Game_Shell/CItem.h"
-#include "engines/pegasus/Game_Shell/CItemList.h"
-
-namespace Pegasus {
-
-// TODO: Don't use global construction!
-CItemList gAllItems;
-
-CItemList::CItemList() {
-}
-
-CItemList::~CItemList() {
-}
-
-Common::Error CItemList::WriteToStream(Common::WriteStream *stream) {
-	stream->writeUint32BE(size());
-
-	for (CItemIterator it = begin(); it != end(); it++) {
-		stream->writeUint16BE((*it)->GetObjectID());
-		(*it)->WriteToStream(stream);
-	}
-
-	if (stream->err())
-		return Common::kWritingFailed;
-	
-	return Common::kNoError;
-}
-
-Common::Error CItemList::ReadFromStream(Common::ReadStream *stream) {
-	uint32 itemCount = stream->readUint32BE();
-
-	for (uint32 i = 0; i < itemCount; i++) {
-		tItemID itemID = stream->readUint16BE();
-		gAllItems.FindItemByID(itemID)->ReadFromStream(stream);
-	}
-
-	if (stream->err())
-		return Common::kReadingFailed;
-	
-	return Common::kNoError;
-}
-
-CItem *CItemList::FindItemByID(const tItemID id) {
-	for (CItemIterator it = begin(); it != end(); it++)
-		if ((*it)->GetObjectID() == id)
-			return *it;
-
-	return 0;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/Game_Shell/CItemList.h b/engines/pegasus/Game_Shell/CItemList.h
deleted file mode 100755
index d4c0d56..0000000
--- a/engines/pegasus/Game_Shell/CItemList.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_GAMESHELL_CITEMLIST_H
-#define PEGASUS_GAMESHELL_CITEMLIST_H
-
-#include "common/list.h"
-
-#include "pegasus/types.h"
-
-namespace Common {
-	class ReadStream;
-	class WriteStream;
-}
-
-namespace Pegasus {
-
-class CItem;
-
-class CItemList : public Common::List<CItem *> {
-public:
-	CItemList();
-	virtual ~CItemList();
-	
-	virtual Common::Error WriteToStream(Common::WriteStream *stream);
-	virtual Common::Error ReadFromStream(Common::ReadStream *stream);
-	
-	CItem *FindItemByID(const tItemID id);
-};
-
-typedef CItemList::iterator CItemIterator;
-
-// TODO: Don't use global construction!
-extern CItemList gAllItems;
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Sounds/MMSound.cpp b/engines/pegasus/MMShell/Sounds/MMSound.cpp
deleted file mode 100755
index 23ac60b..0000000
--- a/engines/pegasus/MMShell/Sounds/MMSound.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "audio/audiostream.h"
-#include "audio/decoders/aiff.h"
-#include "common/file.h"
-#include "common/system.h"
-
-#include "engines/pegasus/MMShell/Sounds/MMSound.h"
-
-namespace Pegasus {
-
-MMSound::MMSound() {
-	_aiffStream = 0;
-	_volume = 0xFF;
-}
-
-MMSound::~MMSound() {
-	DisposeSound();
-}
-
-void MMSound::DisposeSound() {
-	StopSound();
-	delete _aiffStream; _aiffStream = 0;
-}
-
-void MMSound::InitFromAIFFFile(const Common::String &fileName) {
-	Common::File *file = new Common::File();
-	if (!file->open(fileName)) {
-		delete file;
-		return;
-	}
-
-	_aiffStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
-}
-
-#if 0
-// TODO!
-void MMSound::AttachFader(MMSoundFader *theFader) {
-	if (fTheFader)
-		fTheFader->AttachSound(NULL);
-
-	fTheFader = theFader;
-
-	if (fTheFader)
-		fTheFader->AttachSound(this);
-}
-#endif
-
-void MMSound::PlaySound() {
-	if (!SoundLoaded())
-		return;
-
-	StopSound();
-
-#if 0
-	// TODO!
-	if (fTheFader)
-		this->SetVolume(fTheFader->GetFaderValue());
-#endif
-
-	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _aiffStream, -1, _volume, 0, DisposeAfterUse::NO);
-}
-
-void MMSound::LoopSound() {
-	if (!SoundLoaded())
-		return;
-
-	StopSound();
-
-	// Create a looping stream
-	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_aiffStream, 0, DisposeAfterUse::NO);
-
-#if 0
-	// TODO!
-	// Assume that if there is a fader, we're going to fade the sound in.
-	if (fTheFader)
-		this->SetVolume(0);
-#endif
-
-	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
-}
-
-void MMSound::StopSound(void) {
-	g_system->getMixer()->stopHandle(_handle);
-}
-
-void MMSound::SetVolume(const uint16 volume) {
-	// Clipping the volume to [0x00, 0xFF] instead of Apple's [0, 0x100]
-	// We store the volume in case SetVolume is called before the sound starts
-
-	_volume = (volume == 0x100) ? 0xFF : volume;
-	g_system->getMixer()->setChannelVolume(_handle, _volume);
-}
-
-bool MMSound::IsPlaying() {
-	return SoundLoaded() && g_system->getMixer()->isSoundHandleActive(_handle);
-}
-
-bool MMSound::SoundLoaded() const {
-	return _aiffStream != 0;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Sounds/MMSound.h b/engines/pegasus/MMShell/Sounds/MMSound.h
deleted file mode 100755
index bb55782..0000000
--- a/engines/pegasus/MMShell/Sounds/MMSound.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_SOUNDS_MMSOUND_H
-#define PEGASUS_MMSHELL_SOUNDS_MMSOUND_H
-
-#include "audio/mixer.h"
-#include "common/str.h"
-
-namespace Audio {
-	class AudioStream;
-	class RewindableAudioStream;
-}
-
-namespace Pegasus {
-
-// TODO!
-//class MMSoundFader;
-
-//	Things you might want to do with sound:
-//		Start it
-//		Stop it
-//		Loop it
-//		Pause it
-//		Set the volume
-//		Set the pitch (rate)
-//		Pan the sound
-//		Change these settings dynamically over time
-
-class MMSound {
-public:
-	MMSound();
-	~MMSound();
-
-	// We only have one access point here because we should
-	// only be opening an AIFF file from a file name. We're
-	// not using the resource fork string resources.
-	void InitFromAIFFFile(const Common::String &fileName);
-
-	void DisposeSound();
-	bool SoundLoaded() const;
-	void PlaySound();
-	void LoopSound();
-	void StopSound();
-	void SetVolume(const uint16 volume);
-	bool IsPlaying();
-
-	// TODO!
-	//void AttachFader(MMSoundFader*);
-
-protected:
-	Audio::RewindableAudioStream *_aiffStream;
-	Audio::SoundHandle _handle;
-	byte _volume;
-
-	// TODO!
-	//MMSoundFader *fTheFader;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/MMShell/Utilities/MMIDObject.h
index b45c754..112d3b8 100755
--- a/engines/pegasus/MMShell/Utilities/MMIDObject.h
+++ b/engines/pegasus/MMShell/Utilities/MMIDObject.h
@@ -38,29 +38,29 @@ public:
 	MMIDObject(const tMM32BitID id);
 	~MMIDObject();
 	
-	tMM32BitID GetObjectID() const;
+	tMM32BitID getObjectID() const;
 
 private:
-	tMM32BitID fObjectID;
+	tMM32BitID _objectID;
 };
 
 inline MMIDObject::MMIDObject(const tMM32BitID id) {
-	fObjectID = id;
+	_objectID = id;
 }
 
 inline MMIDObject::~MMIDObject() {
 }
 
-inline tMM32BitID MMIDObject::GetObjectID() const {
-	return fObjectID;
+inline tMM32BitID MMIDObject::getObjectID() const {
+	return _objectID;
 }
 
 inline int operator==(const MMIDObject &arg1, const MMIDObject &arg2) {
-	return arg1.fObjectID == arg2.fObjectID;
+	return arg1._objectID == arg2._objectID;
 }
 
 inline int operator!=(const MMIDObject &arg1, const MMIDObject &arg2) {
-	return arg1.fObjectID != arg2.fObjectID;
+	return arg1._objectID != arg2._objectID;
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
index 2f4aed6..bc88c5e 100755
--- a/engines/pegasus/gamestate.cpp
+++ b/engines/pegasus/gamestate.cpp
@@ -1530,12 +1530,12 @@ bool GameStateManager::isTakenItemID(tItemID id) {
 	return _itemTakenFlags.getFlag(id);
 }
 
-void GameStateManager::setTakenItem(CItem *item, bool value) {
-	setTakenItemID(item->GetObjectID(), value);
+void GameStateManager::setTakenItem(Item *item, bool value) {
+	setTakenItemID(item->getObjectID(), value);
 }
 
-bool GameStateManager::isTakenItem(CItem *item) {
-	return isTakenItemID(item->GetObjectID());
+bool GameStateManager::isTakenItem(Item *item) {
+	return isTakenItemID(item->getObjectID());
 }
 
 void GameStateManager::setCaldoriaFuseTimeLimit(const TimeValue timeLimit) {
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index af790ce..4118b5d 100755
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -29,7 +29,7 @@
 #include "common/singleton.h"
 
 #include "pegasus/types.h"
-#include "pegasus/Game_Shell/CItem.h"
+#include "pegasus/items/item.h"
 
 namespace Common {
 	class Error;
@@ -615,8 +615,8 @@ public:
 	bool					allTimeZonesFinished();
 	void						setTakenItemID(tItemID, bool);
 	bool					isTakenItemID(tItemID);
-	void						setTakenItem(CItem*, bool);
-	bool					isTakenItem(CItem*);
+	void						setTakenItem(Item*, bool);
+	bool					isTakenItem(Item*);
 	
 	//	Caldoria
 	void						setCaldoriaFuseTimeLimit(const TimeValue);
diff --git a/engines/pegasus/items/inventory.cpp b/engines/pegasus/items/inventory.cpp
new file mode 100755
index 0000000..8f7eb46
--- /dev/null
+++ b/engines/pegasus/items/inventory.cpp
@@ -0,0 +1,175 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/constants.h"
+#include "pegasus/items/item.h"
+#include "pegasus/items/inventory.h"
+
+namespace Pegasus {
+
+Inventory::Inventory() {
+	_weightLimit = 100;
+	_ownerID = kNoActorID;
+	_referenceCount = 0;
+}
+
+Inventory::~Inventory() {
+}
+
+void Inventory::setWeightLimit(tWeightType limit) {
+	_weightLimit = limit;
+	//	*** What to do if the new weight limit is greater than the current weight?
+}
+
+tWeightType Inventory::getWeight() {
+	tWeightType	result = 0;
+
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++)
+		result += (*it)->getItemWeight();
+
+	return result;
+}
+
+//	If the item already belongs, just return kInventoryOK.
+tInventoryResult Inventory::addItem(Item *item) {
+	if (itemInInventory(item))
+		return kInventoryOK;
+
+	if (getWeight() + item->getItemWeight() > _weightLimit)
+		return kTooMuchWeight;
+
+	_inventoryList.push_back(item);
+	item->setItemOwner(_ownerID);
+
+	++_referenceCount;
+	return kInventoryOK;
+}
+
+tInventoryResult Inventory::removeItem(Item *item) {
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++) {
+		if (*it == item) {
+			_inventoryList.erase(it);
+			item->setItemOwner(kNoActorID);
+
+			++_referenceCount;
+			return kInventoryOK;
+		}
+	}
+
+	return kItemNotInInventory;
+}
+
+tInventoryResult Inventory::removeItem(tItemID id) {
+	Item *item = findItemByID(id);
+	
+	if (item) {
+		_inventoryList.remove(item);
+		item->setItemOwner(kNoActorID);
+
+		++_referenceCount;
+		return kInventoryOK;
+	}
+
+	return kItemNotInInventory;
+}
+
+void Inventory::removeAllItems() {
+	_inventoryList.clear();
+	++_referenceCount;
+}
+
+bool Inventory::itemInInventory(Item *item) {
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++)
+		if (*it == item)
+			return true;
+
+	return false;
+}
+
+bool Inventory::itemInInventory(tItemID id) {
+	return findItemByID(id) != NULL;
+}
+
+Item *Inventory::getItemAt(int32 index) {
+	int32 i = 0;
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++, i++)
+		if (i == index)
+			return *it;
+
+	return 0;
+}
+
+tItemID Inventory::getItemIDAt(int32 index) {
+	Item *item = getItemAt(index);
+
+	if (item)
+		return item->getObjectID();
+
+	return kNoItemID;
+}
+
+Item *Inventory::findItemByID(tItemID id) {
+	return _inventoryList.findItemByID(id);
+}
+
+//	Return -1 if not found.
+
+int32 Inventory::findIndexOf(Item *item) {
+	uint32 i = 0;
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++, i++)
+		if (*it == item)
+			return i;
+
+	return -1;
+}
+
+//	Return -1 if not found.
+
+int32 Inventory::findIndexOf(tItemID id) {
+	uint32 i = 0;
+	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++, i++)
+		if ((*it)->getObjectID() == id)
+			return i;
+
+	return -1;
+}
+
+tWeightType Inventory::getWeightLimit() {
+	return _weightLimit;
+}
+
+int32 Inventory::getNumItems() {
+	return _inventoryList.size();
+}
+
+void Inventory::setOwnerID(const tActorID id) {
+	_ownerID = id;
+}
+
+tActorID Inventory::getOwnerID() const {
+	return _ownerID;
+}
+
+} // End of namespae Pegasus
diff --git a/engines/pegasus/items/inventory.h b/engines/pegasus/items/inventory.h
new file mode 100755
index 0000000..7da782f
--- /dev/null
+++ b/engines/pegasus/items/inventory.h
@@ -0,0 +1,80 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORY_H
+#define PEGASUS_ITEMS_INVENTORY_H
+
+#include "pegasus/types.h"
+#include "pegasus/items/itemlist.h"
+
+namespace Pegasus {
+
+class Item;
+
+//	Inventories have a "current item". This item is the default item the player can
+//	use. In a text adventure system, the current item would be "it", as in
+//	"Hit the troll with it," where "it" would refer to some weapon which is the current
+//	item. In a graphic adventure, the current item would be the item the user selects
+//	to use with the mouse or other pointing device.
+
+class Inventory {
+public:
+	Inventory();
+	virtual ~Inventory();
+	
+	tWeightType getWeightLimit();
+	void setWeightLimit(tWeightType limit);
+	tWeightType getWeight();
+	
+	virtual tInventoryResult addItem(Item *item);
+	virtual tInventoryResult removeItem(Item *item);
+	virtual tInventoryResult removeItem(tItemID id);
+	virtual bool itemInInventory(Item *item);
+	virtual bool itemInInventory(tItemID id);
+	virtual Item *getItemAt(int32 index);
+	virtual tItemID getItemIDAt(int32 index);
+	virtual Item *findItemByID(tItemID id);
+	virtual int32 findIndexOf(Item *item);
+	virtual int32 findIndexOf(tItemID id);
+	int32 getNumItems();
+	virtual void removeAllItems();
+	
+	void setOwnerID(const tActorID id);
+	tActorID getOwnerID() const;
+	
+	uint32 getReferenceCount() { return _referenceCount; }
+
+protected:
+	tWeightType _weightLimit;
+	tActorID _ownerID;
+	ItemList _inventoryList;
+
+private:
+	uint32 _referenceCount;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
new file mode 100755
index 0000000..934dce6
--- /dev/null
+++ b/engines/pegasus/items/item.cpp
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "pegasus/constants.h"
+#include "pegasus/items/item.h"
+#include "pegasus/items/itemlist.h"
+
+namespace Pegasus {
+
+Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) {
+	_itemNeighborhood = neighborhood;
+	_itemRoom = room;
+	_itemDirection = direction;
+	_itemWeight = 1;
+	_itemOwnerID = kNoActorID;
+	_itemState = 0;
+
+	g_allItems.push_back(this);
+}
+
+Item::~Item() {
+}
+
+Common::Error Item::writeToStream(Common::WriteStream *stream) {
+	stream->writeUint16BE(_itemNeighborhood);
+	stream->writeUint16BE(_itemRoom);
+	stream->writeByte(_itemDirection);
+	stream->writeUint16BE(_itemOwnerID);
+	stream->writeUint16BE(_itemState);
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error Item::readFromStream(Common::ReadStream *stream) {
+	_itemNeighborhood = stream->readUint16BE();
+	_itemRoom = stream->readUint16BE();
+	_itemDirection = stream->readByte();
+	_itemOwnerID = stream->readUint16BE();
+	_itemState = stream->readUint16BE();
+	
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+tActorID Item::getItemOwner() const {
+	return _itemOwnerID;
+}
+
+void Item::setItemOwner(const tActorID owner) {
+	_itemOwnerID = owner;
+}
+
+tWeightType Item::getItemWeight() {
+	return _itemWeight;
+}
+
+tItemState Item::getItemState() const {
+	return _itemState;
+}
+
+void Item::setItemState(const tItemState state) {
+	_itemState = state;
+}
+
+void Item::getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
+	neighborhood = _itemNeighborhood;
+	room = _itemRoom;
+	direction = _itemDirection;
+}
+
+void Item::setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	_itemNeighborhood = neighborhood;
+	_itemRoom = room;
+	_itemDirection = direction;
+}
+
+tNeighborhoodID Item::getItemNeighborhood() const {
+	return _itemNeighborhood;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
new file mode 100755
index 0000000..37ad54e
--- /dev/null
+++ b/engines/pegasus/items/item.h
@@ -0,0 +1,255 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_ITEM_H
+#define PEGASUS_ITEMS_ITEM_H
+
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
+#include "pegasus/types.h"
+
+namespace Common {
+	class Error;
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+/*
+
+	Item is an object which can be picked up and carried around.
+	Items have
+		a location
+		an ID.
+		weight
+		an owner (kNoActorID if no one is carrying the Item)
+
+*/
+
+//	Item IDs.
+
+const tItemID kAirMask = 7;
+const tItemID kAntidote = 8;
+const tItemID kArgonCanister = 9;
+const tItemID kCardBomb = 10;
+const tItemID kCrowbar = 11;
+const tItemID kGasCanister = 12;
+const tItemID kHistoricalLog = 13;
+const tItemID kJourneymanKey = 14;
+const tItemID kKeyCard = 15;
+const tItemID kMachineGun = 16;
+const tItemID kMarsCard = 17;
+const tItemID kNitrogenCanister = 18;
+const tItemID kOrangeJuiceGlassFull = 19;
+const tItemID kOrangeJuiceGlassEmpty = 20;
+const tItemID kPoisonDart = 21;
+const tItemID kSinclairKey = 22;
+const tItemID kStunGun = 23;
+const tItemID kArgonPickup = 24;
+
+//	Biochips.
+
+const tItemID kAIBiochip = 0;
+const tItemID kInterfaceBiochip = 1;
+const tItemID kMapBiochip = 2;
+const tItemID kOpticalBiochip = 3;
+const tItemID kPegasusBiochip = 4;
+const tItemID kRetinalScanBiochip = 5;
+const tItemID kShieldBiochip = 6;
+
+const tItemID kNumItems = 25;
+
+//	Item States.
+
+const tItemState kAI000 = 0;
+const tItemState kAI005 = 1;
+const tItemState kAI006 = 2;
+const tItemState kAI010 = 3;
+const tItemState kAI015 = 4;
+const tItemState kAI016 = 5;
+const tItemState kAI020 = 6;
+const tItemState kAI024 = 7;
+const tItemState kAI100 = 8;
+const tItemState kAI101 = 9;
+const tItemState kAI105 = 10;
+const tItemState kAI106 = 11;
+const tItemState kAI110 = 12;
+const tItemState kAI111 = 13;
+const tItemState kAI115 = 14;
+const tItemState kAI116 = 15;
+const tItemState kAI120 = 16;
+const tItemState kAI121 = 17;
+const tItemState kAI124 = 18;
+const tItemState kAI125 = 19;
+const tItemState kAI126 = 20;
+const tItemState kAI200 = 21;
+const tItemState kAI201 = 22;
+const tItemState kAI202 = 23;
+const tItemState kAI205 = 24;
+const tItemState kAI206 = 25;
+const tItemState kAI210 = 26;
+const tItemState kAI211 = 27;
+const tItemState kAI212 = 28;
+const tItemState kAI215 = 29;
+const tItemState kAI216 = 30;
+const tItemState kAI220 = 31;
+const tItemState kAI221 = 32;
+const tItemState kAI222 = 33;
+const tItemState kAI224 = 34;
+const tItemState kAI225 = 35;
+const tItemState kAI226 = 36;
+const tItemState kAI300 = 37;
+const tItemState kAI301 = 38;
+const tItemState kAI302 = 39;
+const tItemState kAI303 = 40;
+const tItemState kAI305 = 41;
+const tItemState kAI306 = 42;
+const tItemState kAI310 = 43;
+const tItemState kAI311 = 44;
+const tItemState kAI312 = 45;
+const tItemState kAI313 = 46;
+const tItemState kAI315 = 47;
+const tItemState kAI316 = 48;
+const tItemState kAI320 = 49;
+const tItemState kAI321 = 50;
+const tItemState kAI322 = 51;
+const tItemState kAI323 = 52;
+const tItemState kAI324 = 53;
+const tItemState kAI325 = 54;
+const tItemState kAI326 = 55;
+const tItemState kNormalItem = 56;
+const tItemState kMapUnavailable = 57;
+const tItemState kMapEngaged = 58;
+const tItemState kOptical000 = 59;
+const tItemState kOptical001 = 60;
+const tItemState kOptical002 = 61;
+const tItemState kOptical010 = 62;
+const tItemState kOptical011 = 63;
+const tItemState kOptical012 = 64;
+const tItemState kOptical020 = 65;
+const tItemState kOptical021 = 66;
+const tItemState kOptical100 = 67;
+const tItemState kOptical101 = 68;
+const tItemState kOptical102 = 69;
+const tItemState kOptical110 = 70;
+const tItemState kOptical111 = 71;
+const tItemState kOptical112 = 72;
+const tItemState kOptical120 = 73;
+const tItemState kOptical121 = 74;
+const tItemState kOptical200 = 75;
+const tItemState kOptical201 = 76;
+const tItemState kOptical210 = 77;
+const tItemState kOptical211 = 78;
+const tItemState kPegasusTSA00 = 79;
+const tItemState kPegasusTSA10 = 80;
+const tItemState kPegasusPrehistoric00 = 81;
+const tItemState kPegasusPrehistoric01 = 82;
+const tItemState kPegasusPrehistoric10 = 83;
+const tItemState kPegasusPrehistoric11 = 84;
+const tItemState kPegasusMars00 = 85;
+const tItemState kPegasusMars01 = 86;
+const tItemState kPegasusMars10 = 87;
+const tItemState kPegasusMars11 = 88;
+const tItemState kPegasusNorad00 = 89;
+const tItemState kPegasusNorad01 = 90;
+const tItemState kPegasusNorad10 = 91;
+const tItemState kPegasusNorad11 = 92;
+const tItemState kPegasusWSC00 = 93;
+const tItemState kPegasusWSC01 = 94;
+const tItemState kPegasusWSC10 = 95;
+const tItemState kPegasusWSC11 = 96;
+const tItemState kPegasusCaldoria = 97;
+const tItemState kRetinalSimulating = 98;
+const tItemState kShieldNormal = 99;
+const tItemState kShieldRadiation = 100;
+const tItemState kShieldPlasma = 101;
+const tItemState kShieldCardBomb = 102;
+const tItemState kShieldDraining = 103;
+const tItemState kAirMaskEmptyOff = 104;
+const tItemState kAirMaskEmptyFilter = 105;
+const tItemState kAirMaskLowOff = 106;
+const tItemState kAirMaskLowFilter = 107;
+const tItemState kAirMaskLowOn = 108;
+const tItemState kAirMaskFullOff = 109;
+const tItemState kAirMaskFullFilter = 110;
+const tItemState kAirMaskFullOn = 111;
+const tItemState kArgonEmpty = 112;
+const tItemState kArgonFull = 113;
+const tItemState kFlashlightOff = 114;
+const tItemState kFlashlightOn = 115;
+const tItemState kNitrogenEmpty = 116;
+const tItemState kNitrogenFull = 117;
+const tItemState kFullGlass = 118;
+
+//	Extra IDs.
+
+const uint32 kRetinalScanSearching = 0;
+const uint32 kRetinalScanActivated = 1;
+const uint32 kShieldIntro = 2;
+const uint32 kRemoveAirMask = 3;
+const uint32 kRemoveArgon = 4;
+const uint32 kRemoveCrowbar = 5;
+const uint32 kGasCanLoop = 6;
+const uint32 kRemoveJourneymanKey = 7;
+const uint32 kRemoveMarsCard = 8;
+const uint32 kRemoveNitrogen = 9;
+const uint32 kRemoveGlass = 10;
+const uint32 kRemoveDart = 11;
+const uint32 kRemoveSinclairKey = 12;
+
+class Item : public MMIDObject {
+public:
+	Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	virtual ~Item();
+	
+	// WriteToStream writes everything EXCEPT the item's ID.
+	// It is assumed that the calling function will write and read the ID.
+	virtual Common::Error writeToStream(Common::WriteStream *stream);
+	virtual Common::Error readFromStream(Common::ReadStream *stream);
+	
+	virtual tActorID getItemOwner() const;
+	virtual void setItemOwner(const tActorID owner);
+	
+	void getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const;
+	void setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	tNeighborhoodID getItemNeighborhood() const;
+	
+	virtual tWeightType getItemWeight();
+	
+	virtual void setItemState(const tItemState state);
+	virtual tItemState getItemState() const;
+
+protected:
+	tNeighborhoodID _itemNeighborhood;
+	tRoomID	_itemRoom;
+	tDirectionConstant _itemDirection;
+	tActorID _itemOwnerID;
+	tWeightType _itemWeight;
+	tItemState _itemState;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
new file mode 100755
index 0000000..2b980d6
--- /dev/null
+++ b/engines/pegasus/items/itemlist.cpp
@@ -0,0 +1,79 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/error.h"
+#include "common/stream.h"
+
+#include "engines/pegasus/items/item.h"
+#include "engines/pegasus/items/itemlist.h"
+
+namespace Pegasus {
+
+// TODO: Don't use global construction!
+ItemList g_allItems;
+
+ItemList::ItemList() {
+}
+
+ItemList::~ItemList() {
+}
+
+Common::Error ItemList::writeToStream(Common::WriteStream *stream) {
+	stream->writeUint32BE(size());
+
+	for (ItemIterator it = begin(); it != end(); it++) {
+		stream->writeUint16BE((*it)->getObjectID());
+		(*it)->writeToStream(stream);
+	}
+
+	if (stream->err())
+		return Common::kWritingFailed;
+	
+	return Common::kNoError;
+}
+
+Common::Error ItemList::readFromStream(Common::ReadStream *stream) {
+	uint32 itemCount = stream->readUint32BE();
+
+	for (uint32 i = 0; i < itemCount; i++) {
+		tItemID itemID = stream->readUint16BE();
+		g_allItems.findItemByID(itemID)->readFromStream(stream);
+	}
+
+	if (stream->err())
+		return Common::kReadingFailed;
+	
+	return Common::kNoError;
+}
+
+Item *ItemList::findItemByID(const tItemID id) {
+	for (ItemIterator it = begin(); it != end(); it++)
+		if ((*it)->getObjectID() == id)
+			return *it;
+
+	return 0;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
new file mode 100755
index 0000000..dd9a4ba
--- /dev/null
+++ b/engines/pegasus/items/itemlist.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_ITEMLIST_H
+#define PEGASUS_ITEMS_ITEMLIST_H
+
+#include "common/list.h"
+
+#include "pegasus/types.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class Item;
+
+class ItemList : public Common::List<Item *> {
+public:
+	ItemList();
+	virtual ~ItemList();
+	
+	virtual Common::Error writeToStream(Common::WriteStream *stream);
+	virtual Common::Error readFromStream(Common::ReadStream *stream);
+	
+	Item *findItemByID(const tItemID id);
+};
+
+typedef ItemList::iterator ItemIterator;
+
+// TODO: Don't use global construction!
+extern ItemList g_allItems;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 577d96a..49d6014 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -25,8 +25,7 @@
 
 #include "pegasus/console.h"
 #include "pegasus/pegasus.h"
-
-#include "pegasus/MMShell/Sounds/MMSound.h"
+#include "pegasus/sound.h"
 
 namespace Pegasus {
 
@@ -46,9 +45,9 @@ enum {
 };	
 
 void PegasusEngine::runMainMenu() {
-	MMSound sound;
-	sound.InitFromAIFFFile("Sounds/Main Menu.aiff");
-	sound.LoopSound();
+	Sound sound;
+	sound.initFromAIFFFile("Sounds/Main Menu.aiff");
+	sound.loopSound();
 
 	// Note down how long since the last click
 	uint32 lastClickTime = _system->getMillis();
@@ -86,14 +85,14 @@ void PegasusEngine::runMainMenu() {
 				case Common::KEYCODE_RETURN:
 					if (buttonSelected != kDifficultyButton) {
 						drawMenuButtonSelected(buttonSelected);
-						sound.StopSound();
+						sound.stopSound();
 						setGameMode(buttonSelected);
 
 						if (_gameMode != kMainMenuMode)
 							return;
 						
 						drawMenu(buttonSelected);
-						sound.LoopSound();
+						sound.loopSound();
 					}
 					break;
 				case Common::KEYCODE_d:
@@ -122,7 +121,7 @@ void PegasusEngine::runMainMenu() {
 		return;
 
 	// Too slow! Go back and show the intro again.
-	sound.StopSound();
+	sound.stopSound();
 	_video->playMovie(_introDirectory + "/LilMovie.movie");
 	_gameMode = kIntroMode;
 }
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 4840190..4f44050 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -9,15 +9,15 @@ MODULE_OBJS = \
 	menu.o \
 	overview.o \
 	pegasus.o \
+	sound.o \
 	video.o \
-	Game_Shell/CInventory.o \
-	Game_Shell/CItem.o \
-	Game_Shell/CItemList.o \
+	items/inventory.o \
+	items/item.o \
+	items/itemlist.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
 	MMShell/Notification/MMNotification.o \
 	MMShell/Notification/MMNotificationManager.o \
 	MMShell/Notification/MMNotificationReceiver.o \
-	MMShell/Sounds/MMSound.o \
 	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMTimeValue.o \
 	MMShell/Utilities/MMUtilities.o \
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
new file mode 100755
index 0000000..5fcac11
--- /dev/null
+++ b/engines/pegasus/sound.cpp
@@ -0,0 +1,126 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "audio/audiostream.h"
+#include "audio/decoders/aiff.h"
+#include "common/file.h"
+#include "common/system.h"
+
+#include "pegasus/sound.h"
+
+namespace Pegasus {
+
+Sound::Sound() {
+	_aiffStream = 0;
+	_volume = 0xFF;
+}
+
+Sound::~Sound() {
+	disposeSound();
+}
+
+void Sound::disposeSound() {
+	stopSound();
+	delete _aiffStream; _aiffStream = 0;
+}
+
+void Sound::initFromAIFFFile(const Common::String &fileName) {
+	Common::File *file = new Common::File();
+	if (!file->open(fileName)) {
+		delete file;
+		return;
+	}
+
+	_aiffStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
+}
+
+#if 0
+// TODO!
+void Sound::attachFader(SoundFader *fader) {
+	if (_fader)
+		_fader->attachSound(NULL);
+
+	_fader = fader;
+
+	if (_fader)
+		_fader->attachSound(this);
+}
+#endif
+
+void Sound::playSound() {
+	if (!isSoundLoaded())
+		return;
+
+	stopSound();
+
+#if 0
+	// TODO!
+	if (_fader)
+		setVolume(_fader->getFaderValue());
+#endif
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _aiffStream, -1, _volume, 0, DisposeAfterUse::NO);
+}
+
+void Sound::loopSound() {
+	if (!isSoundLoaded())
+		return;
+
+	stopSound();
+
+	// Create a looping stream
+	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_aiffStream, 0, DisposeAfterUse::NO);
+
+#if 0
+	// TODO!
+	// Assume that if there is a fader, we're going to fade the sound in.
+	if (_fader)
+		setVolume(0);
+#endif
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
+}
+
+void Sound::stopSound(void) {
+	g_system->getMixer()->stopHandle(_handle);
+}
+
+void Sound::setVolume(const uint16 volume) {
+	// Clipping the volume to [0x00, 0xFF] instead of Apple's [0, 0x100]
+	// We store the volume in case SetVolume is called before the sound starts
+
+	_volume = (volume == 0x100) ? 0xFF : volume;
+	g_system->getMixer()->setChannelVolume(_handle, _volume);
+}
+
+bool Sound::isPlaying() {
+	return isSoundLoaded() && g_system->getMixer()->isSoundHandleActive(_handle);
+}
+
+bool Sound::isSoundLoaded() const {
+	return _aiffStream != 0;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
new file mode 100755
index 0000000..62ce51a
--- /dev/null
+++ b/engines/pegasus/sound.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_SOUND_H
+#define PEGASUS_SOUND_H
+
+#include "audio/mixer.h"
+#include "common/str.h"
+
+namespace Audio {
+	class AudioStream;
+	class RewindableAudioStream;
+}
+
+namespace Pegasus {
+
+// TODO!
+//class MMSoundFader;
+
+//	Things you might want to do with sound:
+//		Start it
+//		Stop it
+//		Loop it
+//		Pause it
+//		Set the volume
+//		Set the pitch (rate)
+//		Pan the sound
+//		Change these settings dynamically over time
+
+class Sound {
+public:
+	Sound();
+	~Sound();
+
+	// We only have one access point here because we should
+	// only be opening an AIFF file from a file name. We're
+	// not using the resource fork string resources.
+	void initFromAIFFFile(const Common::String &fileName);
+
+	void disposeSound();
+	bool isSoundLoaded() const;
+	void playSound();
+	void loopSound();
+	void stopSound();
+	void setVolume(const uint16 volume);
+	bool isPlaying();
+
+	// TODO!
+	//void attachFader(SoundFader *fader);
+
+protected:
+	Audio::RewindableAudioStream *_aiffStream;
+	Audio::SoundHandle _handle;
+	byte _volume;
+
+	// TODO!
+	//SoundFader *_fader;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: bfb0de109ab8cc27aae9ed9a46c55068ac20eecc
    https://github.com/scummvm/scummvm/commit/bfb0de109ab8cc27aae9ed9a46c55068ac20eecc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-04T09:33:32-07:00

Commit Message:
PEGASUS: Implement more item code

Changed paths:
  A engines/pegasus/items/biochips/biochipitem.cpp
  A engines/pegasus/items/biochips/biochipitem.h
  A engines/pegasus/items/inventory/inventoryitem.cpp
  A engines/pegasus/items/inventory/inventoryitem.h
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
new file mode 100755
index 0000000..a291a53
--- /dev/null
+++ b/engines/pegasus/items/biochips/biochipitem.cpp
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+
+#include "common/stream.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+BiochipItem::BiochipItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		Item(id, neighborhood, room, direction) {
+
+	PegasusEngine *vm = (PegasusEngine *)vm;
+
+	Common::SeekableReadStream *biochipInfo = vm->_resFork->getResource(MKTAG('B', 'i', 'o', 'I'), kItemBaseResID + id);
+	if (biochipInfo) {
+		_biochipInfoPanelTime = biochipInfo->readUint32BE();
+		delete biochipInfo;
+	} else {
+		_biochipInfoPanelTime = 0;
+	}
+
+	Common::SeekableReadStream *rightInfo = vm->_resFork->getResource(MKTAG('R', 'g', 'h', 't'), kItemBaseResID + id);
+	if (!rightInfo)
+		error("Could not find right info for biochip %d", id);
+
+	_rightAreaInfo = readItemState(rightInfo);
+	delete rightInfo;
+
+	setItemState(kNormalItem);
+}
+
+BiochipItem::~BiochipItem() {
+	delete[] _rightAreaInfo.entries;
+}
+
+tItemType BiochipItem::getItemType() {
+	return kBiochipItemType;
+}
+
+TimeValue BiochipItem::getRightAreaTime() const {
+	if (!_rightAreaInfo.entries)
+		return 0xffffffff;
+
+	TimeValue time;
+	tItemState state;
+
+	findItemStateEntryByState(_rightAreaInfo, _itemState, time);
+	if (time == 0xffffffff)
+		getItemStateEntry(_rightAreaInfo, 0, state, time);
+
+	return time;
+}
+
+//	Must affect images in right area.
+void BiochipItem::select() {
+	Item::select();
+
+	// TODO: AI
+}
+
+void BiochipItem::deselect() {
+	Item::deselect();
+
+	// TODO: AI
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/biochipitem.h b/engines/pegasus/items/biochips/biochipitem.h
new file mode 100755
index 0000000..904c23b
--- /dev/null
+++ b/engines/pegasus/items/biochips/biochipitem.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_BIOCHIPITEM_H
+#define PEGASUS_ITEMS_BIOCHIPS_BIOCHIPITEM_H
+
+#include "pegasus/items/item.h"
+
+namespace Pegasus {
+
+class BiochipItem : public Item {
+public:
+	BiochipItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~BiochipItem();
+	
+	virtual tItemType getItemType();
+	
+	TimeValue getPanelTime() const { return _biochipInfoPanelTime; }
+	TimeValue getRightAreaTime() const;
+	
+	// Must affect images in right area.
+	virtual void select();
+	virtual void deselect();
+
+protected:
+	TimeValue _biochipInfoPanelTime;
+	ItemStateInfo _rightAreaInfo;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
new file mode 100755
index 0000000..8682911
--- /dev/null
+++ b/engines/pegasus/items/inventory/inventoryitem.cpp
@@ -0,0 +1,107 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/stream.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+InventoryItem::InventoryItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		Item(id, neighborhood, room, direction) {
+
+	PegasusEngine *vm = (PegasusEngine *)vm;
+
+	Common::SeekableReadStream *leftInfo = vm->_resFork->getResource(MKTAG('L', 'e', 'f', 't'), kItemBaseResID + id);
+	if (leftInfo) {
+		_leftAreaInfo = readItemState(leftInfo);
+		delete leftInfo;
+	} else {
+		_leftAreaInfo.numEntries = 0;
+		_leftAreaInfo.entries = 0;
+	}
+
+	Common::SeekableReadStream *inventoryInfo = vm->_resFork->getResource(MKTAG('I', 'n', 'v', 'I'), kItemBaseResID + id);
+	if (inventoryInfo) {
+		_inventoryInfo.panelStart = inventoryInfo->readUint32BE();
+		_inventoryInfo.panelStop = inventoryInfo->readUint32BE();
+		delete inventoryInfo;
+	} else {
+		_inventoryInfo.panelStart = _inventoryInfo.panelStop = 0;
+	}
+
+	_itemAnimationTime = 0;
+}
+
+InventoryItem::~InventoryItem() {
+	delete[] _leftAreaInfo.entries;
+}
+
+tItemType InventoryItem::getItemType() {
+	return kInventoryItemType;
+}
+
+TimeValue InventoryItem::getLeftAreaTime() const {
+	if (!_leftAreaInfo.entries)
+		return 0xffffffff;
+
+	TimeValue time;
+	tItemState state;
+
+	findItemStateEntryByState(_leftAreaInfo, _itemState, time);
+	if (time == 0xffffffff)
+		getItemStateEntry(_leftAreaInfo, 0, state, time);
+
+	return time;
+}
+
+void InventoryItem::setAnimationTime(const TimeValue time) {
+	_itemAnimationTime = time;
+}
+
+TimeValue InventoryItem::getAnimationTime() const {
+	return _itemAnimationTime;
+}
+
+//	Must affect images in left area.
+void InventoryItem::select() {
+	Item::select();
+
+	// TODO: AI
+}
+
+void InventoryItem::deselect() {
+	Item::deselect();
+
+	// TODO: AI
+}
+
+void InventoryItem::getPanelTimes(TimeValue &start, TimeValue &stop) const {
+	start = _inventoryInfo.panelStart;
+	stop = _inventoryInfo.panelStop;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventory/inventoryitem.h b/engines/pegasus/items/inventory/inventoryitem.h
new file mode 100755
index 0000000..d3247d6
--- /dev/null
+++ b/engines/pegasus/items/inventory/inventoryitem.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
+#define PEGASUS_ITEMS_INVENTORY_INVENTORYITEM_H
+
+#include "pegasus/items/item.h"
+
+namespace Pegasus {
+
+// JMPInventoryInfo contains the resource data used by InventoryItems.
+
+struct JMPInventoryInfo {
+	TimeValue panelStart;
+	TimeValue panelStop;
+};
+
+class InventoryItem : public Item {
+public:
+	InventoryItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~InventoryItem();
+	
+	virtual tItemType getItemType();
+	
+	void getPanelTimes(TimeValue&, TimeValue&) const;
+	TimeValue getLeftAreaTime() const;
+	
+	void setAnimationTime(const TimeValue);
+	TimeValue getAnimationTime() const;
+	
+	virtual void toggleItemState() {}
+	
+	// Must affect images in left area.
+	virtual void select();
+	virtual void deselect();
+
+protected:
+	JMPInventoryInfo _inventoryInfo;
+	ItemStateInfo _leftAreaInfo;
+	TimeValue _itemAnimationTime;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index 934dce6..2043317 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -27,6 +27,7 @@
 #include "common/stream.h"
 
 #include "pegasus/constants.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/items/item.h"
 #include "pegasus/items/itemlist.h"
 
@@ -40,10 +41,87 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
 	_itemOwnerID = kNoActorID;
 	_itemState = 0;
 
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	Common::SeekableReadStream *info = vm->_resFork->getResource(kItemInfoResType, kItemBaseResID + id);
+	if (info) {
+		_itemInfo.infoLeftTime = info->readUint32BE();
+		_itemInfo.infoRightStart = info->readUint32BE();
+		_itemInfo.infoRightStop = info->readUint32BE();
+		_itemInfo.dragSpriteNormalID = info->readUint32BE();
+		_itemInfo.dragSpriteUsedID = info->readUint32BE();
+
+		if (vm->isDemo()) {
+			// Adjust info right times to account for the stuff that was chopped out of the
+			// info right movies.
+			// Assumes time scale of 600.
+
+			// Gap times in seconds
+			static const TimeValue kGap1 = 24;
+			static const TimeValue kGap2 = 34;
+			static const TimeValue kGap3 = 4;
+			static const TimeValue kGap4 = 4;
+
+			static const TimeValue kGapForGroup1 = kGap1;
+			static const TimeValue kGapForGroup2 = kGapForGroup1 + kGap2;
+			static const TimeValue kGapForGroup3 = kGapForGroup2 + kGap3;
+			static const TimeValue kGapForGroup4 = kGapForGroup3 + kGap4;
+
+			switch (id) {
+			case kHistoricalLog:
+			case kJourneymanKey:
+			case kKeyCard:
+				_itemInfo.infoRightStart -= 600 * kGapForGroup1;
+				_itemInfo.infoRightStop -= 600 * kGapForGroup1;
+				break;
+			case kAIBiochip:
+				_itemInfo.infoRightStart -= 600 * kGapForGroup2;
+				_itemInfo.infoRightStop -= 600 * kGapForGroup2;
+				break;
+			case kMapBiochip:
+				_itemInfo.infoRightStart -= 600 * kGapForGroup3;
+				_itemInfo.infoRightStop -= 600 * kGapForGroup3;
+				break;
+			case kPegasusBiochip:
+				_itemInfo.infoRightStart -= 600 * kGapForGroup4;
+				_itemInfo.infoRightStop -= 600 * kGapForGroup4;
+				break;
+			}
+		}
+
+		delete info;
+	} else {
+		memset(&_itemInfo, 0, sizeof(_itemInfo));
+	}
+
+	Common::SeekableReadStream *middleAreaInfo = vm->_resFork->getResource(kMiddleAreaInfoResType, kItemBaseResID + id);
+	if (!middleAreaInfo)
+		error("Middle area info not found for item %d", id);
+
+	_sharedAreaInfo = readItemState(middleAreaInfo);
+
+	delete middleAreaInfo;
+
+	Common::SeekableReadStream *extraInfo = vm->_resFork->getResource(kItemExtraInfoResType, kItemBaseResID + id);
+	if (!extraInfo)
+		error("Extra info not found for item %d", id);
+
+	_itemExtras.numEntries = extraInfo->readUint16BE();
+	for (uint16 i = 0; i < _itemExtras.numEntries; i++) {
+		_itemExtras.entries[i].extraID = extraInfo->readUint32BE();
+		_itemExtras.entries[i].extraArea = extraInfo->readUint16BE();
+		_itemExtras.entries[i].extraStart = extraInfo->readUint32BE();
+		_itemExtras.entries[i].extraStop = extraInfo->readUint32BE();
+	}
+
+	delete extraInfo;
+
 	g_allItems.push_back(this);
 }
 
 Item::~Item() {
+	delete[] _sharedAreaInfo.entries;
+	delete[] _itemExtras.entries;
 }
 
 Common::Error Item::writeToStream(Common::WriteStream *stream) {
@@ -78,6 +156,14 @@ tActorID Item::getItemOwner() const {
 
 void Item::setItemOwner(const tActorID owner) {
 	_itemOwnerID = owner;
+
+	if (owner == kNoActorID) {
+		if (isSelected())
+			deselect();
+		removedFromInventory();
+	} else {
+		addedToInventory();
+	}
 }
 
 tWeightType Item::getItemWeight() {
@@ -89,7 +175,10 @@ tItemState Item::getItemState() const {
 }
 
 void Item::setItemState(const tItemState state) {
-	_itemState = state;
+	if (state != _itemState) {
+		_itemState = state;
+		// TODO: Selection
+	}
 }
 
 void Item::getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
@@ -102,10 +191,76 @@ void Item::setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, c
 	_itemNeighborhood = neighborhood;
 	_itemRoom = room;
 	_itemDirection = direction;
+
+	if (neighborhood == kNoNeighborhoodID)
+		pickedUp();
+	else
+		dropped();
 }
 
 tNeighborhoodID Item::getItemNeighborhood() const {
 	return _itemNeighborhood;
 }
 
+TimeValue Item::getSharedAreaTime() const {
+	if (!_sharedAreaInfo.entries)
+		return 0xffffffff;
+
+	TimeValue time;
+	tItemState state;
+
+	findItemStateEntryByState(_sharedAreaInfo, _itemState, time);
+	if (time == 0xffffffff)
+		getItemStateEntry(_sharedAreaInfo, 0, state, time);
+
+	return time;
+}
+
+//	Must affect images in shared area.
+void Item::select() {
+	_isSelected = true;
+
+	// TODO: AI
+}
+
+void Item::deselect() {
+	_isActive = false;
+	_isSelected = false;
+
+	// TODO: AI
+}
+
+void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state, TimeValue &time) {	
+	if (index < info.numEntries) {
+		state = info.entries[index].itemState;
+		time = info.entries[index].itemTime;
+	} else {
+		state = kNoItemState;
+		time = 0xffffffff;
+	}
+}
+
+void Item::findItemStateEntryByState(ItemStateInfo info, tItemState state, TimeValue &time) {
+	for (uint16 i = 0; i < info.numEntries; i++) {
+		if (info.entries[i].itemState == state) {
+			time = info.entries[i].itemTime;
+			return;
+		}
+	}
+
+	time = 0xffffffff;
+}
+
+ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
+	ItemStateInfo info;
+
+	info.numEntries = stream->readUint16BE();
+	for (uint16 i = 0; i < info.numEntries; i++) {
+		info.entries[i].itemState = stream->readSint16BE();
+		info.entries[i].itemTime = stream->readUint32BE();
+	}
+
+	return info;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index 37ad54e..517ffc0 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -26,6 +26,8 @@
 #ifndef PEGASUS_ITEMS_ITEM_H
 #define PEGASUS_ITEMS_ITEM_H
 
+#include "common/endian.h"
+
 #include "pegasus/MMShell/Utilities/MMIDObject.h"
 #include "pegasus/types.h"
 
@@ -33,20 +35,68 @@ namespace Common {
 	class Error;
 	class ReadStream;
 	class WriteStream;
+	class SeekableReadStream;
 }
 
 namespace Pegasus {
 
-/*
+//	JMPItemInfo contains resource data used by all Items.
 
-	Item is an object which can be picked up and carried around.
-	Items have
-		a location
-		an ID.
-		weight
-		an owner (kNoActorID if no one is carrying the Item)
+struct JMPItemInfo {
+	TimeValue infoLeftTime;
+	TimeValue infoRightStart;
+	TimeValue infoRightStop;
+	uint32 dragSpriteNormalID;
+	uint32 dragSpriteUsedID;
+};
 
-*/
+//	ItemStateEntry contains a single state/TimeValue pair. The TimeValue is
+//	the time value to set the shared area movie that corresponds with the given
+//	state of an inventory item.
+
+struct ItemStateEntry {
+	tItemState itemState;
+	TimeValue itemTime;
+};
+
+//	ItemStateInfoHandle is an array of ItemStateEntry.
+
+struct ItemStateInfo {
+	uint16 numEntries; //	For easy ResEdit access
+	ItemStateEntry *entries;
+};
+
+//	ItemExtraEntry
+
+const short kLeftAreaExtra = 0;
+const short kMiddleAreaExtra = 1;
+const short kRightAreaExtra = 2;
+
+struct ItemExtraEntry {
+	uint32 extraID;
+	uint16 extraArea;
+	TimeValue extraStart;
+	TimeValue extraStop;
+};
+
+//	tItemExtraInfoHandle is an array of tItemExtraEntry.
+
+struct ItemExtraInfo {
+	uint16 numEntries;		//	For easy ResEdit access
+	ItemExtraEntry *entries;
+};
+
+//	Inventory info resource type and ID:
+//	Individual inventory items are stored in these resource types.
+//	Resource ID is item ID + kItemBaseResID.
+
+const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm');       // JMPItemInfoHandle
+const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't');   // ItemStateInfoHandle
+const uint32 kMiddleAreaInfoResType = MKTAG('M', 'i', 'd', 'l'); // ItemStateInfoHandle
+const uint32 kRightAreaInfoResType = MKTAG('R', 'g', 'h', 't');  // ItemStateInfoHandle
+const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r');	 // ItemExtraInfoHandle
+
+const uint16 kItemBaseResID = 128;
 
 //	Item IDs.
 
@@ -219,6 +269,22 @@ const uint32 kRemoveGlass = 10;
 const uint32 kRemoveDart = 11;
 const uint32 kRemoveSinclairKey = 12;
 
+enum tItemType {
+	kInventoryItemType,
+	kBiochipItemType
+};
+
+/*
+
+	Item is an object which can be picked up and carried around.
+	Items have
+		a location
+		an ID.
+		weight
+		an owner (kNoActorID if no one is carrying the Item)
+
+*/
+
 class Item : public MMIDObject {
 public:
 	Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
@@ -241,6 +307,41 @@ public:
 	virtual void setItemState(const tItemState state);
 	virtual tItemState getItemState() const;
 
+	virtual tItemType getItemType() = 0;
+	
+	TimeValue getInfoLeftTime() const;
+	void getInfoRightTimes(TimeValue&, TimeValue&) const;
+	TimeValue getSharedAreaTime() const;
+
+	//TODO
+	//MMSprite*						GetDragSprite(const tDisplayElementID) const;
+	
+	/*
+		select		--	called when this item becomes current. Also called when the inventory
+						panel holding this item is raised and this is the current item.
+		deselect	--	called when this item is no longer current.
+		activate	--	called on the current item when the panel is closed.
+	*/
+	//	In an override of these three member functions, you must call the inherited
+	//	member functions.
+	virtual void select();
+	virtual void deselect();
+	virtual bool isSelected() { return _isSelected; }
+	
+	virtual void activate() { _isActive = true; }
+	virtual bool isActive() { return _isActive; }
+	virtual void pickedUp() {}
+	virtual void addedToInventory() {}
+	virtual void removedFromInventory() {}
+	virtual void dropped() {}
+
+	//	Called when the shared area is taken by another item, but this item is still
+	//	selected.
+	virtual void giveUpSharedArea() {}
+	virtual void takeSharedArea() {}
+	
+	void findItemExtra(const uint32 extraID, ItemExtraEntry &entry);
+
 protected:
 	tNeighborhoodID _itemNeighborhood;
 	tRoomID	_itemRoom;
@@ -248,6 +349,16 @@ protected:
 	tActorID _itemOwnerID;
 	tWeightType _itemWeight;
 	tItemState _itemState;
+
+	JMPItemInfo _itemInfo;
+	ItemStateInfo _sharedAreaInfo;
+	ItemExtraInfo _itemExtras;
+	bool _isActive;
+	bool _isSelected;
+
+	static void getItemStateEntry(ItemStateInfo, uint32, tItemState&, TimeValue&);
+	static void findItemStateEntryByState(ItemStateInfo, tItemState, TimeValue&);
+	static ItemStateInfo readItemState(Common::SeekableReadStream *stream);
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 4f44050..be50ecb 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -14,6 +14,8 @@ MODULE_OBJS = \
 	items/inventory.o \
 	items/item.o \
 	items/itemlist.o \
+	items/biochips/biochipitem.o \
+	items/inventory/inventoryitem.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
 	MMShell/Notification/MMNotification.o \
 	MMShell/Notification/MMNotificationManager.o \
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 25fbc34..5c85251 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -66,41 +66,6 @@ struct ItemLocationData {
 	byte u1;
 };
 
-struct InventoryPanelEntry {
-	uint32 startTime;
-	uint32 endTime;
-};
-
-struct InventoryItemData {
-	uint32 leftFrameTime;
-	uint32 rightStartTime;
-	uint32 rightEndTime;
-	uint16 pict;        // Cannot use item at this spot
-	uint16 usablePict;  // Can use item at this spot
-};
-
-struct InventoryExtra {
-	uint32 id;
-	uint16 movie;
-	uint32 startTime;
-	uint32 endTime;
-};
-
-struct LeftAreaData {
-	uint16 frame;
-	uint32 time;
-};
-
-struct MiddleAreaData {
-	uint16 id;
-	uint32 time;
-};
-
-struct RightAreaData {
-	uint16 frame;
-	uint32 time;
-};
-
 struct OverviewHotspot {
 	Common::Rect rect;
 	uint32 time;


Commit: 4f8cf1ea4b7bb329c78cfe1b907b408fa6c9ce18
    https://github.com/scummvm/scummvm/commit/4f8cf1ea4b7bb329c78cfe1b907b408fa6c9ce18
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-04T17:22:00-07:00

Commit Message:
PEGASUS: Implement very basic hotspot loading

Need to get more complex regions loaded, though... will be a major problem

Changed paths:
  A engines/pegasus/hotspot.cpp
  A engines/pegasus/hotspot.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
new file mode 100755
index 0000000..f97ad1d
--- /dev/null
+++ b/engines/pegasus/hotspot.cpp
@@ -0,0 +1,218 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/hotspot.h"
+
+namespace Pegasus {
+
+HotspotList g_allHotspots;
+
+Hotspot::Hotspot(const tHotSpotID id) : MMIDObject(id) {
+	_spotFlags = kNoHotSpotFlags;
+	_spotActive = false;
+}
+
+Hotspot::~Hotspot() {
+}
+
+void Hotspot::setArea(const Common::Rect &area) {
+	_spotArea = area;
+}
+
+void Hotspot::setArea(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
+	_spotArea = Common::Rect(left, top, right, bottom);
+}
+
+void Hotspot::getBoundingBox(Common::Rect &r) const {
+	r = _spotArea;
+}
+
+void Hotspot::getCenter(Common::Point &pt) const {
+	pt.x = (_spotArea.left + _spotArea.right) / 2;
+	pt.y = (_spotArea.top + _spotArea.bottom) / 2;
+}
+
+void Hotspot::getCenter(tCoordType &h, tCoordType &v) const {
+	h = (_spotArea.left + _spotArea.right) / 2;
+	v = (_spotArea.top + _spotArea.bottom) / 2;
+}
+
+void Hotspot::setActive() {
+	_spotActive = true;
+}
+
+void Hotspot::setInactive() {
+	_spotActive = false;
+}
+
+void Hotspot::setHotspotFlags(const tHotSpotFlags flags) {
+	_spotFlags = flags;
+}
+
+void Hotspot::setMaskedHotspotFlags(const tHotSpotFlags flags, const tHotSpotFlags mask) {
+	_spotFlags = (_spotFlags & ~mask) | flags;
+}
+
+bool Hotspot::isSpotActive() const {
+	return _spotActive;
+}
+
+void Hotspot::moveSpotTo(const tCoordType h, const tCoordType v) {
+	_spotArea.moveTo(h, v);
+}
+
+void Hotspot::moveSpotTo(const Common::Point pt) {
+	_spotArea.moveTo(pt);
+}
+
+void Hotspot::moveSpot(const tCoordType h, const tCoordType v) {
+	_spotArea.translate(h, v);
+}
+
+void Hotspot::moveSpot(const Common::Point pt) {
+	_spotArea.translate(pt.x, pt.y);
+}
+
+bool Hotspot::pointInSpot(const Common::Point where) const {
+	return _spotActive && _spotArea.contains(where);
+}
+
+tHotSpotFlags Hotspot::getHotspotFlags() const {
+	return _spotFlags;
+}
+
+HotspotList::HotspotList() {
+}
+
+HotspotList::~HotspotList() {
+	// TODO: Should this call deleteHotspots()?
+}
+
+void HotspotList::deleteHotspots() {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		delete *it;
+
+	clear();
+}
+
+Hotspot *HotspotList::findHotspot(const Common::Point where) {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		if ((*it)->pointInSpot(where))
+			return *it;
+
+	return 0;
+}
+
+tHotSpotID HotspotList::findHotspotID(const Common::Point where) {
+	Hotspot *hotspot = findHotspot(where);
+	return hotspot ? hotspot->getObjectID() : kNoHotSpotID;
+}
+
+Hotspot *HotspotList::findHotspotByID(const tHotSpotID id) {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		if ((*it)->getObjectID() == id)
+			return *it;
+
+	return 0;
+}
+
+Hotspot *HotspotList::findHotspotByMask(const tHotSpotFlags flags) {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		if (((*it)->getHotspotFlags() & flags) == flags)
+			return *it;
+
+	return 0;
+}
+
+void HotspotList::activateMaskedHotspots(const tHotSpotFlags flags) {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		if (flags == kNoHotSpotFlags || ((*it)->getHotspotFlags() & flags) != 0)
+			(*it)->setActive();
+}
+
+void HotspotList::deactivateAllHotspots() {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		(*it)->setInactive();
+}
+
+void HotspotList::deactivateMaskedHotspots(const tHotSpotFlags flags) {
+	for (HotspotIterator it = begin(); it != end(); it++)
+		if (((*it)->getHotspotFlags() & flags) != 0)
+			(*it)->setInactive();
+}
+
+void HotspotList::activateOneHotspot(const tHotSpotID id) {
+	for (HotspotIterator it = begin(); it != end(); it++) {
+		if ((*it)->getObjectID() == id) {
+			(*it)->setActive();
+			return;
+		}
+	}
+}
+
+void HotspotList::deactivateOneHotspot(const tHotSpotID id) {
+	for (HotspotIterator it = begin(); it != end(); it++) {
+		if ((*it)->getObjectID() == id) {
+			(*it)->setInactive();
+			return;
+		}
+	}
+}
+
+void HotspotList::removeOneHotspot(const tHotSpotID id) {
+	for (HotspotIterator it = begin(); it != end(); it++) {
+		if ((*it)->getObjectID() == id) {
+			erase(it);
+			return;
+		}
+	}
+}
+
+void HotspotList::removeMaskedHotspots(const tHotSpotFlags flags) {
+	if (flags != kNoHotSpotFlags) {
+		for (HotspotIterator it = begin(); it != end(); ) {
+			if (((*it)->getHotspotFlags() & flags) != 0)
+				it = erase(it);
+			else
+				it++;
+		}
+	} else {
+		clear();
+	}
+}
+
+void HotspotList::setHotspotRect(const tHotSpotID id, const Common::Rect &r) {
+	Hotspot *hotspot = findHotspotByID(id);
+	if (hotspot)
+		hotspot->setArea(r);
+}
+
+void HotspotList::getHotspotRect(const tHotSpotID id, Common::Rect &r) {
+	Hotspot *hotspot = findHotspotByID(id);
+	if (hotspot)
+		hotspot->getBoundingBox(r);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
new file mode 100755
index 0000000..97bbf37
--- /dev/null
+++ b/engines/pegasus/hotspot.h
@@ -0,0 +1,114 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_HOTSPOT_H
+#define PEGASUS_HOTSPOT_H
+
+#include "common/list.h"
+#include "common/rect.h"
+
+#include "pegasus/constants.h"
+#include "pegasus/types.h"
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
+
+/*
+
+	Hot spots combine a pixel area, an ID value and an active flag.
+	
+	A point is considered in a hot spot if the point is in the hot spot's pixel area and
+	the active flag is set.
+	
+	In addition, hot spots have a 32 bit word of bit flags for filtering use.
+
+*/
+
+namespace Pegasus {
+
+class Hotspot : public MMIDObject {
+public:
+	Hotspot(const tHotSpotID);
+	virtual ~Hotspot();
+	
+	void setArea(const Common::Rect &);
+	void setArea(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
+	void getBoundingBox(Common::Rect &) const;
+	void getCenter(Common::Point&) const;
+	void getCenter(tCoordType&, tCoordType&) const;
+	
+	void moveSpotTo(const tCoordType, const tCoordType);
+	void moveSpotTo(const Common::Point);
+	void moveSpot(const tCoordType, const tCoordType);
+	void moveSpot(const Common::Point);
+	
+	bool pointInSpot(const Common::Point) const;
+	
+	void setActive();
+	void setInactive();
+	bool isSpotActive() const;
+	
+	tHotSpotFlags getHotspotFlags() const;
+	void setHotspotFlags(const tHotSpotFlags);
+	void setMaskedHotspotFlags(const tHotSpotFlags flags, const tHotSpotFlags mask);
+
+protected:
+	Common::Rect _spotArea;
+	tHotSpotFlags _spotFlags;
+	bool _spotActive;
+};
+
+class HotspotList : public Common::List<Hotspot *> {
+public:
+	HotspotList();
+	virtual ~HotspotList();
+
+	void deleteHotspots();
+
+	Hotspot *findHotspot(const Common::Point);
+	tHotSpotID findHotspotID(const Common::Point);
+	Hotspot * findHotspotByID(const tHotSpotID);
+	Hotspot * findHotspotByMask(const tHotSpotFlags);
+
+	void activateMaskedHotspots(const tHotSpotFlags = kNoHotSpotFlags);
+	void deactivateAllHotspots();
+	void deactivateMaskedHotspots(const tHotSpotFlags);
+
+	void activateOneHotspot(const tHotSpotID);
+	void deactivateOneHotspot(const tHotSpotID);
+	
+	void removeOneHotspot(const tHotSpotID);
+	void removeMaskedHotspots(const tHotSpotFlags = kNoHotSpotFlags);
+
+	void setHotspotRect(const tHotSpotID, const Common::Rect&);
+	void getHotspotRect(const tHotSpotID, Common::Rect&);
+};
+
+typedef HotspotList::iterator HotspotIterator;
+
+// FIXME: Remove global construction
+extern HotspotList g_allHotspots;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index be50ecb..7a2d5b1 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
 	detection.o \
 	gamestate.o \
 	graphics.o \
+	hotspot.o \
 	menu.o \
 	overview.o \
 	pegasus.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 3d47dbf..1a22831 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -38,6 +38,10 @@ Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNe
 }
 
 Neighborhood::~Neighborhood() {
+	for (HotspotIterator it = _neighborhoodHotspots.begin(); it != _neighborhoodHotspots.end(); it++)
+		g_allHotspots.remove(*it);
+
+	_neighborhoodHotspots.deleteHotspots();
 }
 
 void Neighborhood::init() {
@@ -91,6 +95,8 @@ void Neighborhood::init() {
 	_zoomTable.loadFromStream(stream);
 	delete stream;
 
+	createNeighborhoodSpots();
+
 	// TODO: AI, movies, notifications, buncha other stuff
 }
 
@@ -222,5 +228,44 @@ tCanOpenDoorReason Neighborhood::canOpenDoor(DoorTable::Entry &entry) {
 	return kCantOpenNoDoor;
 }
 
+void Neighborhood::createNeighborhoodSpots() {
+	Common::SeekableReadStream *hotspotList = _vm->_resFork->getResource(MKTAG('H', 'S', 'L', 's'), _resName);
+	if (!hotspotList)
+		error("Could not load neighborhood hotspots");
+
+	uint32 hotspotCount = hotspotList->readUint32BE();
+
+	while (hotspotCount--) {
+		uint16 id = hotspotList->readUint16BE();
+		uint32 flags = hotspotList->readUint32BE();
+		uint32 rgnSize = hotspotList->readUint32BE();
+
+		// duplicate of rgnSize
+		hotspotList->readUint16BE();
+
+		Common::Rect boundingBox;
+		boundingBox.top = hotspotList->readUint16BE();
+		boundingBox.left = hotspotList->readUint16BE();
+		boundingBox.bottom = hotspotList->readUint16BE();
+		boundingBox.right = hotspotList->readUint16BE();
+
+		debug(0, "Hotspot[%d]: Flags = %08x", id, flags); 
+		boundingBox.debugPrint(0, "\tBounding Box:");
+
+		// TODO: Handle non-rectangular hotspots
+		if (rgnSize != 10)
+			warning("Non-rectangular hotspot found - %d extra bytes", rgnSize - 10);
+		hotspotList->skip(rgnSize - 10);
+
+		Hotspot *hotspot = new Hotspot(id);
+		hotspot->setHotspotFlags(flags);
+		hotspot->setArea(boundingBox);
+
+		g_allHotspots.push_back(hotspot);
+		_neighborhoodHotspots.push_back(hotspot);
+	}
+
+	delete hotspotList;
+}
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 0b8be86..73f6c49 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -28,6 +28,7 @@
 
 #include "common/str.h"
 
+#include "pegasus/hotspot.h"
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
 #include "pegasus/neighborhood/extra.h"
@@ -79,6 +80,8 @@ public:
 	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
 
 protected:
+	virtual void createNeighborhoodSpots();
+
 	PegasusEngine *_vm;
 	Common::String _resName;
 	tNeighborhoodID _neighborhoodID;
@@ -93,6 +96,8 @@ protected:
 	ZoomTable _zoomTable;
 
 	tAlternateID _currentAlternate;
+
+	HotspotList _neighborhoodHotspots;
 };
 
 } // End of namespace Pegasus


Commit: 7070d886d9363935d0f4f73817190b2bf0a3666a
    https://github.com/scummvm/scummvm/commit/7070d886d9363935d0f4f73817190b2bf0a3666a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-04T18:49:42-07:00

Commit Message:
PEGASUS: Fix bug in the credits

Not that this code will be final (in all likelihood :P)

Changed paths:
    engines/pegasus/credits.cpp



diff --git a/engines/pegasus/credits.cpp b/engines/pegasus/credits.cpp
index 3c625fa..4ef723e 100644
--- a/engines/pegasus/credits.cpp
+++ b/engines/pegasus/credits.cpp
@@ -102,9 +102,11 @@ void PegasusEngine::runCredits() {
 					}
 					break;
 				case Common::KEYCODE_RETURN:
-					drawCredits(curButton, true, frame, creditsVideo);
-					_system->updateScreen();
-					continueLooping = (curButton != kCreditsMainMenu);
+					if (curButton == kCreditsMainMenu) {
+						drawCredits(curButton, true, frame, creditsVideo);
+						_system->updateScreen();
+						continueLooping = false;
+					}
 					break;
 				default:
 					break;


Commit: fe99e953194c356136cd1e2edb87142e2c18b1e5
    https://github.com/scummvm/scummvm/commit/fe99e953194c356136cd1e2edb87142e2c18b1e5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-05T12:47:19-07:00

Commit Message:
PEGASUS: Stub off spot sound code

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/sound.cpp
    engines/pegasus/sound.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 7a63cfc..509c9f3 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -221,6 +221,252 @@ const TimeValue kPlasmaImpactTime = kTwoSeconds;
 
 const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
 
+enum {
+	kButtonDownBit = 0,
+	kAutoButtonBit = 1,
+	kBitsPerButton = 2,
+	
+	kButtonDownMask = 1 << kButtonDownBit,
+	kAutoButtonMask = 1 << kAutoButtonBit,
+	
+	kButtonStateBits = kButtonDownMask | kAutoButtonMask,
+	
+	kRawButtonUp = 0,
+	kRawButtonDown = kButtonDownMask | kAutoButtonMask,
+	
+	kButtonUp = 0,
+	kButtonDown = kButtonDownMask,
+	kButtonAutoUp = kAutoButtonMask,
+	kButtonAutoDown = kButtonDownMask | kAutoButtonMask
+};
+
+enum {
+	kUpButtonNum = 0,
+	kLeftButtonNum = 1,
+	kDownButtonNum = 2,
+	kRightButtonNum = 3,
+	kLeftFireButtonNum = 4,
+	kRightFireButtonNum = 5,
+	kOneButtonNum = 6,
+	kTwoButtonNum = 7,
+	kThreeButtonNum = 8,
+	kFourButtonNum = 9,
+	kMod1ButtonNum = 10,
+	kMod2ButtonNum = 11,
+	kMod3ButtonNum = 12
+};
+
+enum {
+	kUpButtonShift = kUpButtonNum * kBitsPerButton,
+	kLeftButtonShift = kLeftButtonNum * kBitsPerButton,
+	kDownButtonShift = kDownButtonNum * kBitsPerButton,
+	kRightButtonShift = kRightButtonNum * kBitsPerButton,
+	kLeftFireButtonShift = kLeftFireButtonNum * kBitsPerButton,
+	kRightFireButtonShift = kRightFireButtonNum * kBitsPerButton,
+	kOneButtonShift = kOneButtonNum * kBitsPerButton,
+	kTwoButtonShift = kTwoButtonNum * kBitsPerButton,
+	kThreeButtonShift = kThreeButtonNum * kBitsPerButton,
+	kFourButtonShift = kFourButtonNum * kBitsPerButton,
+	kMod1ButtonShift = kMod1ButtonNum * kBitsPerButton,
+	kMod2ButtonShift = kMod2ButtonNum * kBitsPerButton,
+	kMod3ButtonShift = kMod3ButtonNum * kBitsPerButton
+};
+
+enum {
+	kAllUpBits =	(kButtonUp << kUpButtonShift) |
+					(kButtonUp << kLeftButtonShift) |
+					(kButtonUp << kDownButtonShift) |
+					(kButtonUp << kRightButtonShift) |
+					(kButtonUp << kLeftFireButtonShift) |
+					(kButtonUp << kRightFireButtonShift) |
+					(kButtonUp << kOneButtonShift) |
+					(kButtonUp << kTwoButtonShift) |
+					(kButtonUp << kThreeButtonShift) |
+					(kButtonUp << kFourButtonShift) |
+					(kButtonUp << kMod1ButtonShift) |
+					(kButtonUp << kMod2ButtonShift) |
+					(kButtonUp << kMod3ButtonShift),
+	kDirectionBits =	(kButtonDownMask << kUpButtonShift) |
+						(kButtonDownMask << kLeftButtonShift) |
+						(kButtonDownMask << kDownButtonShift) |
+						(kButtonDownMask << kRightButtonShift),
+	kButtonBits =	(kButtonDownMask << kLeftFireButtonShift) |
+					(kButtonDownMask << kRightFireButtonShift) |
+					(kButtonDownMask << kOneButtonShift) |
+					(kButtonDownMask << kTwoButtonShift) |
+					(kButtonDownMask << kThreeButtonShift) |
+					(kButtonDownMask << kFourButtonShift) |
+					(kButtonDownMask << kMod1ButtonShift) |
+					(kButtonDownMask << kMod2ButtonShift) |
+					(kButtonDownMask << kMod3ButtonShift),
+	kAllButtonDownBits = kDirectionBits | kButtonBits,
+	kAllAutoBits =	(kAutoButtonMask << kUpButtonShift) |
+					(kAutoButtonMask << kLeftButtonShift) |
+					(kAutoButtonMask << kDownButtonShift) |
+					(kAutoButtonMask << kRightButtonShift) |
+					(kAutoButtonMask << kLeftFireButtonShift) |
+					(kAutoButtonMask << kRightFireButtonShift) |
+					(kAutoButtonMask << kOneButtonShift) |
+					(kAutoButtonMask << kTwoButtonShift) |
+					(kAutoButtonMask << kThreeButtonShift) |
+					(kAutoButtonMask << kFourButtonShift) |
+					(kAutoButtonMask << kMod1ButtonShift) |
+					(kAutoButtonMask << kMod2ButtonShift) |
+					(kAutoButtonMask << kMod3ButtonShift),
+	
+	kFilterUpButton =			kButtonDownMask << kUpButtonShift,
+	kFilterUpAuto =				kAutoButtonMask << kUpButtonShift,
+	kFilterUpButtonAny =		kFilterUpButton | kFilterUpAuto,
+	kFilterLeftButton =			kButtonDownMask << kLeftButtonShift,
+	kFilterLeftAuto =			kAutoButtonMask << kLeftButtonShift,
+	kFilterLeftButtonAny =		kFilterLeftButton | kFilterLeftAuto,
+	kFilterDownButton =			kButtonDownMask << kDownButtonShift,
+	kFilterDownAuto =			kAutoButtonMask << kDownButtonShift,
+	kFilterDownButtonAny =		kFilterDownButton | kFilterDownAuto,
+	kFilterRightButton =		kButtonDownMask << kRightButtonShift,
+	kFilterRightAuto =			kAutoButtonMask << kRightButtonShift,
+	kFilterRightButtonAny =		kFilterRightButton | kFilterRightAuto,
+	kFilterLeftFireButton =		kButtonDownMask << kLeftFireButtonShift,
+	kFilterLeftFireAuto =		kAutoButtonMask << kLeftFireButtonShift,
+	kFilterLeftFireButtonAny =	kFilterLeftFireButton | kFilterLeftFireAuto,
+	kFilterRightFireButton =	kButtonDownMask << kRightFireButtonShift,
+	kFilterRightFireAuto =		kAutoButtonMask << kRightFireButtonShift,
+	kFilterRightFireButtonAny =	kFilterRightFireButton | kFilterRightFireAuto,
+	kFilterOneButton =			kButtonDownMask << kOneButtonShift,
+	kFilterOneAuto =			kAutoButtonMask << kOneButtonShift,
+	kFilterOneButtonAny =		kFilterOneButton | kFilterOneAuto,
+	kFilterTwoButton =			kButtonDownMask << kTwoButtonShift,
+	kFilterTwoAuto =			kAutoButtonMask << kTwoButtonShift,
+	kFilterTwoButtonAny =		kFilterTwoButton | kFilterTwoAuto,
+	kFilterThreeButton =		kButtonDownMask << kThreeButtonShift,
+	kFilterThreeAuto =			kAutoButtonMask << kThreeButtonShift,
+	kFilterThreeButtonAny =		kFilterThreeButton | kFilterThreeAuto,
+	kFilterFourButton =			kButtonDownMask << kFourButtonShift,
+	kFilterFourAuto =			kAutoButtonMask << kFourButtonShift,
+	kFilterFourButtonAny =		kFilterFourButton | kFilterFourAuto,
+	kFilterMod1Button =			kButtonDownMask << kMod1ButtonShift,
+	kFilterMod1Auto =			kAutoButtonMask << kMod1ButtonShift,
+	kFilterMod1ButtonAny =		kFilterMod1Button | kFilterMod1Auto,
+	kFilterMod2Button =			kButtonDownMask << kMod2ButtonShift,
+	kFilterMod2Auto =			kAutoButtonMask << kMod2ButtonShift,
+	kFilterMod2ButtonAny =		kFilterMod2Button | kFilterMod2Auto,
+	kFilterMod3Button =			kButtonDownMask << kMod3ButtonShift,
+	kFilterMod3Auto =			kAutoButtonMask << kMod3ButtonShift,
+	kFilterMod3ButtonAny =		kFilterMod3Button | kFilterMod3Auto,
+	
+	kFilterNoInput =			0,
+	kFilterAllInput =			kFilterUpButton |
+								kFilterUpAuto |
+								kFilterLeftButton |
+								kFilterLeftAuto |
+								kFilterDownButton |
+								kFilterDownAuto |
+								kFilterRightButton |
+								kFilterRightAuto |
+								kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto |
+								kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto |
+								kFilterMod1Button |
+								kFilterMod1Auto |
+								kFilterMod2Button |
+								kFilterMod2Auto |
+								kFilterMod3Button |
+								kFilterMod3Auto,
+	
+	kFilterAllDirections =		kFilterUpButton |
+								kFilterUpAuto |
+								kFilterLeftButton |
+								kFilterLeftAuto |
+								kFilterDownButton |
+								kFilterDownAuto |
+								kFilterRightButton |
+								kFilterRightAuto,
+	
+	kFilterButtons =			kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto,
+	
+	kFilterFireButtons =		kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto,
+	
+	kFilterAllButtons =			kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto |
+								kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto |
+								kFilterMod1Button |
+								kFilterMod1Auto |
+								kFilterMod2Button |
+								kFilterMod2Auto |
+								kFilterMod3Button |
+								kFilterMod3Auto,
+	
+	kFilterAllInputNoAuto =		kFilterUpButton |
+								kFilterLeftButton |
+								kFilterDownButton |
+								kFilterRightButton |
+								kFilterLeftFireButton |
+								kFilterRightFireButton |
+								kFilterOneButton |
+								kFilterTwoButton |
+								kFilterThreeButton |
+								kFilterFourButton |
+								kFilterMod1Button |
+								kFilterMod2Button |
+								kFilterMod3Button
+};
+
+const tNotificationID kNeighborhoodNotificationID = 1;
+const tNotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
+
+const tNotificationFlags kNeighborhoodMovieCompletedFlag = 1;
+const tNotificationFlags kMoveForwardCompletedFlag = kNeighborhoodMovieCompletedFlag << 1;
+const tNotificationFlags kStrideCompletedFlag = kMoveForwardCompletedFlag << 1;
+const tNotificationFlags kTurnCompletedFlag = kStrideCompletedFlag << 1;
+const tNotificationFlags kSpotCompletedFlag = kTurnCompletedFlag << 1;
+const tNotificationFlags kDoorOpenCompletedFlag = kSpotCompletedFlag << 1;
+const tNotificationFlags kExtraCompletedFlag = kDoorOpenCompletedFlag << 1;
+const tNotificationFlags kSpotSoundCompletedFlag = kExtraCompletedFlag << 1;
+const tNotificationFlags kDelayCompletedFlag = kSpotSoundCompletedFlag << 1;
+const tNotificationFlags kActionRequestCompletedFlag = kDelayCompletedFlag << 1;
+const tNotificationFlags kDeathExtraCompletedFlag = kActionRequestCompletedFlag << 1;
+const tNotificationFlags kLastNeighborhoodNotificationFlag = kDeathExtraCompletedFlag;
+
+const tNotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
+												kMoveForwardCompletedFlag |
+												kStrideCompletedFlag |
+												kTurnCompletedFlag |
+												kSpotCompletedFlag |
+												kDoorOpenCompletedFlag |
+												kExtraCompletedFlag |
+												kSpotSoundCompletedFlag |
+												kDelayCompletedFlag |
+												kActionRequestCompletedFlag |
+												kDeathExtraCompletedFlag;
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 1a22831..cf4a29e 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -32,9 +32,10 @@
 
 namespace Pegasus {
 
-Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : _vm(vm), _resName(resName) {
+Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : MMIDObject(id), _vm(vm), _resName(resName) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
+	_interruptionFilter = kFilterAllInput;
 }
 
 Neighborhood::~Neighborhood() {
@@ -96,6 +97,7 @@ void Neighborhood::init() {
 	delete stream;
 
 	createNeighborhoodSpots();
+	loadSoundSpots();
 
 	// TODO: AI, movies, notifications, buncha other stuff
 }
@@ -268,4 +270,125 @@ void Neighborhood::createNeighborhoodSpots() {
 	delete hotspotList;
 }
 
+void Neighborhood::loadSoundSpots() {
+	// TODO: Eventually push to the subclasses
+
+	Common::String fileName = "Sounds/";
+
+	switch (getObjectID()) {
+	case kCaldoriaID:
+		fileName += "Caldoria/Caldoria Spots";
+		break;
+	case kFullTSAID:
+	case kFinalTSAID:
+	case kTinyTSAID:
+		fileName += "TSA/TSA Spots";
+		break;
+	case kPrehistoricID:
+		fileName += "Prehistoric/Prehistoric Spots";
+		break;
+	case kMarsID:
+		fileName += "Mars/Mars Spots";
+		break;
+	case kWSCID:
+		fileName += "World Science Center/WSC Spots";
+		break;
+	case kNoradAlphaID:
+		fileName += "Norad/Norad Alpha Spots";
+		break;
+	case kNoradDeltaID:
+		fileName += "Norad/Norad Delta Spots";
+		break;
+	}
+
+	_spotSounds.initFromQuickTime(fileName);
+}
+
+void Neighborhood::popActionQueue() {	
+	if (!_actionQueue.empty()) {
+		tQueueRequest topRequest = _actionQueue.pop();
+
+		switch (topRequest.requestType) {
+			case kNavExtraRequest:
+				// TODO
+				break;
+			case kSpotSoundRequest:
+				_spotSounds.stopSound();
+				break;
+			case kDelayRequest:
+				// TODO
+				break;
+		}
+
+		serviceActionQueue();
+	}
+}
+
+void Neighborhood::serviceActionQueue() {
+	if (!_actionQueue.empty()) {
+		tQueueRequest &topRequest = _actionQueue.front();
+
+		if (!topRequest.playing) {
+			topRequest.playing = true;
+			switch (topRequest.requestType) {
+			case kNavExtraRequest:
+				// TODO
+				break;
+			case kSpotSoundRequest:
+				_spotSounds.stopSound();
+				_spotSounds.playSoundSegment(topRequest.start, topRequest.stop);
+				_interruptionFilter = topRequest.interruptionFilter;
+				// TODO: stop trigger
+				break;
+			case kDelayRequest:
+				// TODO
+				break;
+			}
+		}
+	} else {
+		_interruptionFilter = kFilterAllInput;
+	}
+}
+
+void Neighborhood::requestAction(const tQueueRequestType requestType, const tExtraID extra, const TimeValue in, const TimeValue out,
+		const tInputBits interruptionFilter, const tNotificationFlags flags) {
+
+	tQueueRequest request;
+	
+	request.requestType = requestType;
+	request.extra = extra;
+	request.start = in;
+	request.stop = out;
+	request.interruptionFilter = interruptionFilter;
+	request.playing = false;
+	request.flags = flags | kActionRequestCompletedFlag;
+
+	// TODO: notification
+
+	_actionQueue.push(request);
+	if (_actionQueue.size() == 1)
+		serviceActionQueue();
+}
+
+void Neighborhood::requestExtraSequence(const tExtraID whichExtra, const tNotificationFlags flags, const tInputBits interruptionFilter) {
+	requestAction(kNavExtraRequest, whichExtra, 0, 0, interruptionFilter, flags);
+}
+
+void Neighborhood::requestSpotSound(const TimeValue in, const TimeValue out, const tInputBits interruptionFilter, const tNotificationFlags flags) {
+	requestAction(kSpotSoundRequest, 0xFFFFFFFF, in, out, interruptionFilter, flags);
+}
+
+void Neighborhood::requestDelay(const TimeValue delayDuration, const TimeScale delayScale, const tInputBits interruptionFilter, const tNotificationFlags flags) {
+	requestAction(kDelayRequest, 0xFFFFFFFF, delayDuration, delayScale, interruptionFilter, flags);
+}
+
+bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2) {
+	return arg1.requestType == arg2.requestType && arg1.extra == arg2.extra &&
+			arg1.start == arg2.start && arg1.stop == arg2.stop;
+}
+
+bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2) {
+	return !operator==(arg1, arg2);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 73f6c49..269443c 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -26,9 +26,12 @@
 #ifndef PEGASUS_NEIGHBORHOOD_H
 #define PEGASUS_NEIGHBORHOOD_H
 
+#include "common/queue.h"
 #include "common/str.h"
 
 #include "pegasus/hotspot.h"
+#include "pegasus/sound.h"
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
 #include "pegasus/neighborhood/extra.h"
@@ -40,6 +43,7 @@
 
 namespace Pegasus {
 
+class MMNotification;
 class PegasusEngine;
 
 // Pegasus Prime neighborhood id's
@@ -52,11 +56,35 @@ const tNeighborhoodID kMarsID = 5;
 const tNeighborhoodID kWSCID = 6;
 const tNeighborhoodID kNoradAlphaID = 7;
 const tNeighborhoodID kNoradDeltaID = 8;
-//	The sub chase is not really a neighborhood, but we define a constant that is used
-//	to allow an easy transition out of Norad Alpha.
+// The sub chase is not really a neighborhood, but we define a constant that is used
+// to allow an easy transition out of Norad Alpha.
 const tNeighborhoodID kNoradSubChaseID = 1000;
 
-class Neighborhood {
+enum tQueueRequestType {
+	kNavExtraRequest,
+	kSpotSoundRequest,
+	kDelayRequest
+};
+
+// For delay requests, start is interpreted as the total delay and stop is interpreted
+// as the scale the delay is in.
+// For extra requests, start and stop are not used.
+struct tQueueRequest {
+	tQueueRequestType requestType;
+	tExtraID extra;
+	TimeValue start, stop;
+	tInputBits interruptionFilter;
+	bool playing;
+	tNotificationFlags flags;
+	MMNotification *notification;
+};
+
+bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
+bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
+
+typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
+
+class Neighborhood : public MMIDObject {
 public:
 	Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
@@ -79,12 +107,22 @@ public:
 	tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
 	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
 
+	void requestExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
+	void requestSpotSound(const TimeValue, const TimeValue, const tInputBits interruptionFilter, const tNotificationFlags);
+	void requestDelay(const TimeValue, const TimeScale, const tInputBits interruptionFilter, const tNotificationFlags);
+
+	virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
+
 protected:
 	virtual void createNeighborhoodSpots();
+	virtual void loadSoundSpots();
+
+	void popActionQueue();
+	void serviceActionQueue();
+	void requestAction(const tQueueRequestType, const tExtraID, const TimeValue, const TimeValue, const tInputBits, const tNotificationFlags);
 
 	PegasusEngine *_vm;
 	Common::String _resName;
-	tNeighborhoodID _neighborhoodID;
 
 	DoorTable _doorTable;
 	ExitTable _exitTable;
@@ -98,6 +136,12 @@ protected:
 	tAlternateID _currentAlternate;
 
 	HotspotList _neighborhoodHotspots;
+
+	NeighborhoodActionQueue _actionQueue;
+
+	Sound _spotSounds;
+
+	tInputBits _interruptionFilter;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
index 5fcac11..5db1d90 100755
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@ -25,6 +25,7 @@
 
 #include "audio/audiostream.h"
 #include "audio/decoders/aiff.h"
+#include "audio/decoders/quicktime.h"
 #include "common/file.h"
 #include "common/system.h"
 
@@ -33,7 +34,7 @@
 namespace Pegasus {
 
 Sound::Sound() {
-	_aiffStream = 0;
+	_stream = 0;
 	_volume = 0xFF;
 }
 
@@ -43,17 +44,25 @@ Sound::~Sound() {
 
 void Sound::disposeSound() {
 	stopSound();
-	delete _aiffStream; _aiffStream = 0;
+	delete _stream; _stream = 0;
 }
 
 void Sound::initFromAIFFFile(const Common::String &fileName) {
+	disposeSound();
+
 	Common::File *file = new Common::File();
 	if (!file->open(fileName)) {
 		delete file;
 		return;
 	}
 
-	_aiffStream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
+	_stream = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
+}
+
+void Sound::initFromQuickTime(const Common::String &fileName) {
+	disposeSound();
+
+	_stream = Audio::makeQuickTimeStream(fileName);
 }
 
 #if 0
@@ -81,7 +90,7 @@ void Sound::playSound() {
 		setVolume(_fader->getFaderValue());
 #endif
 
-	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _aiffStream, -1, _volume, 0, DisposeAfterUse::NO);
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, _volume, 0, DisposeAfterUse::NO);
 }
 
 void Sound::loopSound() {
@@ -91,7 +100,7 @@ void Sound::loopSound() {
 	stopSound();
 
 	// Create a looping stream
-	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_aiffStream, 0, DisposeAfterUse::NO);
+	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
 
 #if 0
 	// TODO!
@@ -103,7 +112,29 @@ void Sound::loopSound() {
 	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
 }
 
-void Sound::stopSound(void) {
+void Sound::playSoundSegment(uint32 start, uint32 end) {
+	if (!isSoundLoaded())
+		return;
+
+	stopSound();
+
+	Audio::AudioStream *subStream = new Audio::SubSeekableAudioStream(_stream, Audio::Timestamp(0, start, 600), Audio::Timestamp(0, end, 600), DisposeAfterUse::NO);
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, subStream, -1, _volume, 0, DisposeAfterUse::YES);
+}
+
+void Sound::loopSoundSegment(uint32 start, uint32 end) {
+	if (!isSoundLoaded())
+		return;
+
+	stopSound();
+
+	Audio::AudioStream *subLoopStream = new Audio::SubLoopingAudioStream(_stream, 0, Audio::Timestamp(0, start, 600), Audio::Timestamp(0, end, 600), DisposeAfterUse::NO);
+
+	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, subLoopStream, -1, _volume, 0, DisposeAfterUse::YES);
+}
+
+void Sound::stopSound() {
 	g_system->getMixer()->stopHandle(_handle);
 }
 
@@ -120,7 +151,7 @@ bool Sound::isPlaying() {
 }
 
 bool Sound::isSoundLoaded() const {
-	return _aiffStream != 0;
+	return _stream != 0;
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
index 62ce51a..99607d4 100755
--- a/engines/pegasus/sound.h
+++ b/engines/pegasus/sound.h
@@ -30,14 +30,13 @@
 #include "common/str.h"
 
 namespace Audio {
-	class AudioStream;
-	class RewindableAudioStream;
+	class SeekableAudioStream;
 }
 
 namespace Pegasus {
 
 // TODO!
-//class MMSoundFader;
+//class SoundFader;
 
 //	Things you might want to do with sound:
 //		Start it
@@ -59,10 +58,17 @@ public:
 	// not using the resource fork string resources.
 	void initFromAIFFFile(const Common::String &fileName);
 
+	// Unlike the original game, we're going to use a regular
+	// audio stream for sound spots. The original treated them
+	// as movies.
+	void initFromQuickTime(const Common::String &fileName);
+
 	void disposeSound();
 	bool isSoundLoaded() const;
 	void playSound();
 	void loopSound();
+	void playSoundSegment(uint32 start, uint32 end);
+	void loopSoundSegment(uint32 start, uint32 end);
 	void stopSound();
 	void setVolume(const uint16 volume);
 	bool isPlaying();
@@ -71,7 +77,7 @@ public:
 	//void attachFader(SoundFader *fader);
 
 protected:
-	Audio::RewindableAudioStream *_aiffStream;
+	Audio::SeekableAudioStream *_stream;
 	Audio::SoundHandle _handle;
 	byte _volume;
 


Commit: dbb538dd048b7dc6c155a560dc847b98ba8c85cb
    https://github.com/scummvm/scummvm/commit/dbb538dd048b7dc6c155a560dc847b98ba8c85cb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-05T13:18:04-07:00

Commit Message:
PEGASUS: Cleanup and hookup the notification code

Changed paths:
  A engines/pegasus/notification.cpp
  A engines/pegasus/notification.h
  R engines/pegasus/MMShell/Notification/MMNotification.cpp
  R engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
  R engines/pegasus/MMShell/Notification/MMNotificationManager.h
  R engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
  R engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
  R engines/pegasus/MMShell/Notification/MMNotification.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/MMShell/Notification/MMNotification.cpp b/engines/pegasus/MMShell/Notification/MMNotification.cpp
deleted file mode 100755
index e91417a..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotification.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/MMShell/Notification/MMNotification.h"
-#include "pegasus/MMShell/Notification/MMNotificationManager.h"
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-typedef tReceiverList::iterator tReceiverIterator;
-
-MMNotification::MMNotification(const tNotificationID id, MMNotificationManager *owner) : MMIDObject(id) {
-	fOwner = owner;
-	fCurrentFlags = kNoNotificationFlags;
-	if (fOwner)
-		fOwner->AddNotification(this);
-}
-
-MMNotification::~MMNotification() {
-	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
-		it->fReceiver->NewNotification(NULL);
-
-	if (fOwner)
-		fOwner->RemoveNotification(this);
-}
-
-//	Selectively set or clear notificiation bits.
-//	Wherever mask is 0, leave existing bits untouched.
-//	Wherever mask is 1, set bit equivalent to flags.
-void MMNotification::NotifyMe(MMNotificationReceiver* receiver, tNotificationFlags flags, tNotificationFlags mask) {
-	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++) {
-		if (it->fReceiver == receiver) {
-			it->fMask = (it->fMask & ~mask) | (flags & mask);
-			receiver->NewNotification(this);
-			return;
-		}
-	}
-
-	tReceiverEntry newEntry;
-	newEntry.fReceiver = receiver;
-	newEntry.fMask = flags;
-	fReceivers.push_back(newEntry);
-
-	receiver->NewNotification(this);
-}
-
-void MMNotification::CancelNotification(MMNotificationReceiver *receiver) {
-	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
-		if (it->fReceiver == receiver)
-			fReceivers.erase(it);
-}
-
-void MMNotification::SetNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
-	fCurrentFlags = (fCurrentFlags & ~mask) | flags;
-}
-
-void MMNotification::CheckReceivers() {	
-	tNotificationFlags currentFlags = fCurrentFlags;
-	fCurrentFlags = kNoNotificationFlags;
-
-	for (tReceiverIterator it = fReceivers.begin(); it != fReceivers.end(); it++)
-		if (it->fMask & currentFlags)
-			it->fReceiver->ReceiveNotification(this, currentFlags);
-}
-
-//	Receiver entries are equal if their receivers are equal.
-
-int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
-	return	entry1.fReceiver == entry2.fReceiver;
-}
-
-int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
-	return	entry1.fReceiver != entry2.fReceiver;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotification.h b/engines/pegasus/MMShell/Notification/MMNotification.h
deleted file mode 100755
index 2c6dddd..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotification.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATION_H
-
-#include "common/list.h"
-
-#include "pegasus/types.h"
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
-
-namespace Pegasus {
-
-class MMNotificationManager;
-class MMNotificationReceiver;
-
-struct tReceiverEntry {
-	MMNotificationReceiver *fReceiver;
-	tNotificationFlags fMask;
-};
-
-int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
-int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
-
-typedef Common::List<tReceiverEntry> tReceiverList;
-
-/*
-	A notification can have 32 flags associated with it, which can be user-defined.
-*/
-
-class MMNotification : public MMIDObject {
-friend class MMNotificationManager;
-
-public:
-	MMNotification(const tNotificationID id, MMNotificationManager *owner);
-	virtual ~MMNotification();
-
-	//	NotifyMe will have this receiver notified when any of the specified notification
-	//	flags are set.
-	//	If there is already a notification set for this receiver, NotifyMe does a bitwise
-	//	OR with the receiver's current notification flags.
-
-	//	Can selectively set or clear notification bits by using the flags and mask argument.
-
-	void NotifyMe(MMNotificationReceiver*, tNotificationFlags flags, tNotificationFlags mask);
-	void CancelNotification(MMNotificationReceiver *receiver);
-	
-	void SetNotificationFlags(tNotificationFlags flags,	tNotificationFlags mask);
-	tNotificationFlags GetNotificationFlags() { return fCurrentFlags; }
-	
-	void ClearNotificationFlags() { SetNotificationFlags(0, ~(tNotificationFlags)0); }
-
-protected:
-	void CheckReceivers();
-	
-	MMNotificationManager *fOwner;
-	tReceiverList fReceivers;
-	tNotificationFlags fCurrentFlags;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp b/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
deleted file mode 100755
index 4bcaa79..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/MMShell/Notification/MMNotificationManager.h"
-
-namespace Pegasus {
-
-typedef tNotificationList::iterator tNotificationIterator;
-
-MMNotificationManager::MMNotificationManager() {
-}
-
-MMNotificationManager::~MMNotificationManager() {
-	DetachNotifications();
-}
-
-void MMNotificationManager::AddNotification(MMNotification *notification) {
-	fNotifications.push_back(notification);
-}
-
-void MMNotificationManager::RemoveNotification(MMNotification *notification) {
-	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
-		if ((*it) == notification)
-			fNotifications.erase(it);
-}
-
-void MMNotificationManager::DetachNotifications() {
-	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
-		(*it)->fOwner = 0;
-}
-
-void MMNotificationManager::CheckNotifications() {
-	for (tNotificationIterator it = fNotifications.begin(); it != fNotifications.end(); it++)
-		if ((*it)->fCurrentFlags != kNoNotificationFlags)
-			(*it)->CheckReceivers();
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationManager.h b/engines/pegasus/MMShell/Notification/MMNotificationManager.h
deleted file mode 100755
index 3df455f..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationManager.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONMANAGER_H
-
-#include "common/list.h"
-
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-class MMNotification;
-
-typedef Common::List<MMNotification *> tNotificationList;
-
-class MMNotificationManager : public MMNotificationReceiver {
-friend class MMNotification;
-
-public:
-	MMNotificationManager();
-	virtual ~MMNotificationManager();
-	
-	void CheckNotifications();
-
-protected:
-	void AddNotification(MMNotification *notification);
-	void RemoveNotification(MMNotification *notification);
-	void DetachNotifications();
-	
-	tNotificationList fNotifications;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
deleted file mode 100755
index 037cf18..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/MMShell/Notification/MMNotificationReceiver.h"
-
-namespace Pegasus {
-
-MMNotificationReceiver::MMNotificationReceiver() {
-	fNotification = NULL;
-}
-
-MMNotificationReceiver::~MMNotificationReceiver() {
-	if (fNotification)
-		fNotification->CancelNotification(this);
-}
-
-void MMNotificationReceiver::ReceiveNotification(MMNotification *, const tNotificationFlags) {
-}
-
-void MMNotificationReceiver::NewNotification(MMNotification *notification) {
-	fNotification = notification;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h b/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
deleted file mode 100755
index cb72047..0000000
--- a/engines/pegasus/MMShell/Notification/MMNotificationReceiver.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
-#define PEGASUS_MMSHELL_NOTIFICATION_MMNOTIFICATIONRECEIVER_H
-
-#include "pegasus/MMShell/Notification/MMNotification.h"
-
-namespace Pegasus {
-
-class MMNotificationReceiver {
-friend class MMNotification;
-
-public:
-	MMNotificationReceiver();
-	virtual ~MMNotificationReceiver();
-	
-protected:
-	//	ReceiveNotification is called automatically whenever a notification that this
-	//	receiver depends on has its flags set
-	
-	virtual void ReceiveNotification(MMNotification *, const tNotificationFlags);
-	virtual void NewNotification(MMNotification *notification);
-
-private:
-	MMNotification *fNotification;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 7a2d5b1..642e94a 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS = \
 	graphics.o \
 	hotspot.o \
 	menu.o \
+	notification.o \
 	overview.o \
 	pegasus.o \
 	sound.o \
@@ -18,9 +19,6 @@ MODULE_OBJS = \
 	items/biochips/biochipitem.o \
 	items/inventory/inventoryitem.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
-	MMShell/Notification/MMNotification.o \
-	MMShell/Notification/MMNotificationManager.o \
-	MMShell/Notification/MMNotificationReceiver.o \
 	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMTimeValue.o \
 	MMShell/Utilities/MMUtilities.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index cf4a29e..8048fa4 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -108,6 +108,13 @@ void Neighborhood::start() {
 	arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
 }
 
+void Neighborhood::receiveNotification(Notification *, const tNotificationFlags flags) {
+	if (flags & kMoveForwardCompletedFlag)
+		arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
+
+	// TODO: Other types
+}
+
 void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
 	// TODO
 }
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 269443c..d567a5b 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -30,6 +30,7 @@
 #include "common/str.h"
 
 #include "pegasus/hotspot.h"
+#include "pegasus/notification.h"
 #include "pegasus/sound.h"
 #include "pegasus/MMShell/Utilities/MMIDObject.h"
 #include "pegasus/neighborhood/door.h"
@@ -43,7 +44,6 @@
 
 namespace Pegasus {
 
-class MMNotification;
 class PegasusEngine;
 
 // Pegasus Prime neighborhood id's
@@ -76,7 +76,7 @@ struct tQueueRequest {
 	tInputBits interruptionFilter;
 	bool playing;
 	tNotificationFlags flags;
-	MMNotification *notification;
+	Notification *notification;
 };
 
 bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
@@ -84,7 +84,7 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
 typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
-class Neighborhood : public MMIDObject {
+class Neighborhood : public MMIDObject, public NotificationReceiver {
 public:
 	Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
@@ -114,6 +114,8 @@ public:
 	virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
 
 protected:
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+
 	virtual void createNeighborhoodSpots();
 	virtual void loadSoundSpots();
 
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
new file mode 100755
index 0000000..f03e470
--- /dev/null
+++ b/engines/pegasus/notification.cpp
@@ -0,0 +1,143 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/constants.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+typedef tReceiverList::iterator tReceiverIterator;
+
+Notification::Notification(const tNotificationID id, NotificationManager *owner) : MMIDObject(id) {
+	_owner = owner;
+	_currentFlags = kNoNotificationFlags;
+	if (_owner)
+		_owner->addNotification(this);
+}
+
+Notification::~Notification() {
+	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+		it->receiver->newNotification(NULL);
+
+	if (_owner)
+		_owner->removeNotification(this);
+}
+
+//	Selectively set or clear notificiation bits.
+//	Wherever mask is 0, leave existing bits untouched.
+//	Wherever mask is 1, set bit equivalent to flags.
+void Notification::notifyMe(NotificationReceiver *receiver, tNotificationFlags flags, tNotificationFlags mask) {
+	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
+		if (it->receiver == receiver) {
+			it->mask = (it->mask & ~mask) | (flags & mask);
+			receiver->newNotification(this);
+			return;
+		}
+	}
+
+	tReceiverEntry newEntry;
+	newEntry.receiver = receiver;
+	newEntry.mask = flags;
+	_receivers.push_back(newEntry);
+
+	receiver->newNotification(this);
+}
+
+void Notification::cancelNotification(NotificationReceiver *receiver) {
+	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+		if (it->receiver == receiver)
+			_receivers.erase(it);
+}
+
+void Notification::setNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
+	_currentFlags = (_currentFlags & ~mask) | flags;
+}
+
+void Notification::checkReceivers() {	
+	tNotificationFlags currentFlags = _currentFlags;
+	_currentFlags = kNoNotificationFlags;
+
+	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+		if (it->mask & currentFlags)
+			it->receiver->receiveNotification(this, currentFlags);
+}
+
+//	Receiver entries are equal if their receivers are equal.
+
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+	return	entry1.receiver == entry2.receiver;
+}
+
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2) {
+	return	entry1.receiver != entry2.receiver;
+}
+
+NotificationReceiver::NotificationReceiver() {
+	_notification = NULL;
+}
+
+NotificationReceiver::~NotificationReceiver() {
+	if (_notification)
+		_notification->cancelNotification(this);
+}
+
+void NotificationReceiver::receiveNotification(Notification *, const tNotificationFlags) {
+}
+
+void NotificationReceiver::newNotification(Notification *notification) {
+	_notification = notification;
+}
+
+typedef tNotificationList::iterator tNotificationIterator;
+
+NotificationManager::NotificationManager() {
+}
+
+NotificationManager::~NotificationManager() {
+	detachNotifications();
+}
+
+void NotificationManager::addNotification(Notification *notification) {
+	_notifications.push_back(notification);
+}
+
+void NotificationManager::removeNotification(Notification *notification) {
+	for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+		if ((*it) == notification)
+			_notifications.erase(it);
+}
+
+void NotificationManager::detachNotifications() {
+	for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+		(*it)->_owner = 0;
+}
+
+void NotificationManager::checkNotifications() {
+	for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+		if ((*it)->_currentFlags != kNoNotificationFlags)
+			(*it)->checkReceivers();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
new file mode 100755
index 0000000..d276f45
--- /dev/null
+++ b/engines/pegasus/notification.h
@@ -0,0 +1,122 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NOTIFICATION_H
+#define PEGASUS_NOTIFICATION_H
+
+#include "common/list.h"
+
+#include "pegasus/types.h"
+#include "pegasus/MMShell/Utilities/MMIDObject.h"
+
+namespace Pegasus {
+
+class NotificationManager;
+class NotificationReceiver;
+
+struct tReceiverEntry {
+	NotificationReceiver *receiver;
+	tNotificationFlags mask;
+};
+
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
+
+typedef Common::List<tReceiverEntry> tReceiverList;
+
+/*
+	A notification can have 32 flags associated with it, which can be user-defined.
+*/
+
+class Notification : public MMIDObject {
+friend class NotificationManager;
+
+public:
+	Notification(const tNotificationID id, NotificationManager *owner);
+	virtual ~Notification();
+
+	//	NotifyMe will have this receiver notified when any of the specified notification
+	//	flags are set.
+	//	If there is already a notification set for this receiver, NotifyMe does a bitwise
+	//	OR with the receiver's current notification flags.
+
+	//	Can selectively set or clear notification bits by using the flags and mask argument.
+
+	void notifyMe(NotificationReceiver*, tNotificationFlags flags, tNotificationFlags mask);
+	void cancelNotification(NotificationReceiver *receiver);
+	
+	void setNotificationFlags(tNotificationFlags flags,	tNotificationFlags mask);
+	tNotificationFlags getNotificationFlags() { return _currentFlags; }
+	
+	void clearNotificationFlags() { setNotificationFlags(0, ~(tNotificationFlags)0); }
+
+protected:
+	void checkReceivers();
+	
+	NotificationManager *_owner;
+	tReceiverList _receivers;
+	tNotificationFlags _currentFlags;
+};
+
+class NotificationReceiver {
+friend class Notification;
+
+public:
+	NotificationReceiver();
+	virtual ~NotificationReceiver();
+	
+protected:
+	//	ReceiveNotification is called automatically whenever a notification that this
+	//	receiver depends on has its flags set
+	
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual void newNotification(Notification *notification);
+
+private:
+	Notification *_notification;
+};
+
+typedef Common::List<Notification *> tNotificationList;
+
+class NotificationManager : public NotificationReceiver {
+friend class Notification;
+
+public:
+	NotificationManager();
+	virtual ~NotificationManager();
+	
+	void checkNotifications();
+
+protected:
+	void addNotification(Notification *notification);
+	void removeNotification(Notification *notification);
+	void detachNotifications();
+	
+	tNotificationList _notifications;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 74054cff2d43ee641ac87b9d27ac915523b63e83
    https://github.com/scummvm/scummvm/commit/74054cff2d43ee641ac87b9d27ac915523b63e83
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-05T13:24:06-07:00

Commit Message:
PEGASUS: Remove unused MMResourceFile code

We'll just use our resource code instead

Changed paths:
  R engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
  R engines/pegasus/MMShell/Utilities/MMResourceFile.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp b/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
deleted file mode 100755
index 6743a8b..0000000
--- a/engines/pegasus/MMShell/Utilities/MMResourceFile.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/endian.h"
-#include "common/error.h"
-#include "common/macresman.h"
-#include "common/stream.h"
-
-#include "pegasus/MMShell/Utilities/MMResourceFile.h"
-
-namespace Pegasus {
-
-MMResourceFile::MMResourceFile() {
-	_resFork = 0;
-}
-
-MMResourceFile::~MMResourceFile() {
-	if (IsFileOpen())
-		CloseResourceFile();
-}
-
-Common::Error MMResourceFile::UsePathname(const Common::String &str) {
-	if (IsFileOpen())
-		return Common::kUnknownError;
-
-	_fileName = str;
-	return Common::kNoError;
-}
-
-Common::Error MMResourceFile::OpenResourceFile() {
-	if (IsFileOpen() || _fileName.empty())
-		return Common::kUnknownError;
-
-	_resFork = new Common::MacResManager();
-
-	if (!_resFork->open(_fileName)) {
-		delete _resFork; _resFork = 0;
-		return Common::kReadingFailed;
-	}
-
-	return Common::kNoError;
-}
-
-Common::Error MMResourceFile::CloseResourceFile() {
-	if (!IsFileOpen())
-		return Common::kUnknownError;
-
-	delete _resFork;
-	_resFork = 0;
-	return Common::kNoError;
-}
-
-Common::Error MMResourceFile::GetResource(const uint32 type, const tResIDType id, Common::SeekableReadStream *&h) {
-	if (!IsFileOpen())
-		return Common::kUnknownError;
-
-	// Look how well our API fits in!
-	h = _resFork->getResource(type, id);
-	return Common::kNoError;
-}
-
-Common::Error MMResourceFile::GetResource(const uint32 type, const Common::String &name, Common::SeekableReadStream *&h) {
-	if (!IsFileOpen())
-		return Common::kUnknownError;
-
-	// Look how well our API fits in!
-	h = _resFork->getResource(type, name);
-	return Common::kNoError;
-}
-
-Common::Error MMResourceFile::GetCIcon(const tResIDType id, Common::SeekableReadStream *&icon) {
-	Common::Error err = GetResource(MKTAG('c', 'i', 'c', 'n'), id, icon);
-
-	if (err.getCode() != Common::kNoError)
-		return err;
-
-	return (icon == 0) ? Common::kUnknownError : Common::kNoError;
-}
-
-bool MMResourceFile::IsFileOpen() const {
-	return _resFork != 0;
-}
-
-} // End of namespace Pegasus
\ No newline at end of file
diff --git a/engines/pegasus/MMShell/Utilities/MMResourceFile.h b/engines/pegasus/MMShell/Utilities/MMResourceFile.h
deleted file mode 100755
index 9bd0cd9..0000000
--- a/engines/pegasus/MMShell/Utilities/MMResourceFile.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_UTILITIES_MMRESOURCEFILE
-#define PEGASUS_MMSHELL_UTILITIES_MMRESOURCEFILE
-
-#include "common/str.h"
-
-#include "pegasus/types.h"
-
-namespace Common {
-	class Error;
-	class MacResManager;
-	class SeekableReadStream;
-}
-
-namespace Pegasus {
-
-class MMResourceFile {
-public:
-	MMResourceFile();
-	virtual ~MMResourceFile();
-
-	Common::Error UsePathname(const Common::String &str);
-
-	// For ScummVM, we don't need this function
-	//OSErr MMResourceFile::UseFSSpec(const FSSpec&);
-	
-	virtual Common::Error OpenResourceFile();
-	virtual Common::Error CloseResourceFile();
-	bool IsFileOpen() const;
-	
-	virtual Common::Error GetResource(const uint32 type, const tResIDType id, Common::SeekableReadStream *&h);
-	virtual Common::Error GetResource(const uint32 type, const Common::String &name, Common::SeekableReadStream *&h);
-
-	// This function is unused!
-	//virtual OSErr PutResource(const ResType, const tResIDType, const Common::String &, Handle);
-
-	// For ScummVM, we will be hardcoding the file names so these two functions
-	// do nothing for us
-	//virtual OSErr GetIndString(const tResIDType, const short, Str255&);
-	//virtual OSErr GetIndString(const Str255, const short, Str255&);
-
-	virtual Common::Error GetCIcon(const tResIDType id, Common::SeekableReadStream *&icon);
-
-protected:
-	Common::MacResManager *_resFork;
-	Common::String _fileName;
-};
-
-} // End of namespace Pegasus
-
-#endif
\ No newline at end of file
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 642e94a..d3bcbcb 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -19,7 +19,6 @@ MODULE_OBJS = \
 	items/biochips/biochipitem.o \
 	items/inventory/inventoryitem.o \
 	MMShell/Base_Classes/MMFunctionPtr.o \
-	MMShell/Utilities/MMResourceFile.o \
 	MMShell/Utilities/MMTimeValue.o \
 	MMShell/Utilities/MMUtilities.o \
 	neighborhood/door.o \


Commit: 593aec681d138f7106b034530f5b5eb89643bce1
    https://github.com/scummvm/scummvm/commit/593aec681d138f7106b034530f5b5eb89643bce1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-05T13:46:39-07:00

Commit Message:
PEGASUS: Restructure remaining MMShell code into the base code

MMTimeValue has been removed, as Common::Timestamp will just be used instead

Changed paths:
  A engines/pegasus/util.cpp
  A engines/pegasus/util.h
  R engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
  R engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
  R engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
  R engines/pegasus/MMShell/Utilities/MMTimeValue.h
  R engines/pegasus/MMShell/Utilities/MMUtilities.h
  R engines/pegasus/MMShell/Utilities/MMUtilities.cpp
  R engines/pegasus/MMShell/Utilities/MMIDObject.h
    engines/pegasus/hotspot.cpp
    engines/pegasus/hotspot.h
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/notification.cpp
    engines/pegasus/notification.h



diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
deleted file mode 100755
index 9a2543d..0000000
--- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/MMShell/Base_Classes/MMFunctionPtr.h"
-
-namespace Pegasus {
-
-MMFunctionPtr::MMFunctionPtr() {
-	fTheFunction = 0;
-	fFunctionArg = 0;
-}
-
-MMFunctionPtr::~MMFunctionPtr() {
-}
-
-void MMFunctionPtr::SetFunctionPtr(tFunctionPtr theFunction, void *functionArg) {
-	fTheFunction = theFunction;
-	fFunctionArg = functionArg;
-}
-
-void MMFunctionPtr::CallFunction() {
-	if (fTheFunction != 0)
-		(*fTheFunction)(this, fFunctionArg);
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h b/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
deleted file mode 100755
index 4aa18ca..0000000
--- a/engines/pegasus/MMShell/Base_Classes/MMFunctionPtr.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H
-#define PEGASUS_MMSHELL_BASECLASSES_MMFUNCTIONPTR_H
-
-namespace Pegasus {
-
-class MMFunctionPtr;
-
-typedef void (*tFunctionPtr)(MMFunctionPtr *theFunction, void *functionArg);
-
-class MMFunctionPtr {
-public:
-	MMFunctionPtr();
-	virtual ~MMFunctionPtr();
-	
-	void SetFunctionPtr(tFunctionPtr theFunction, void *functionArg);
-
-protected:
-	void CallFunction();
-	
-	tFunctionPtr fTheFunction;
-	void *fFunctionArg;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Utilities/MMIDObject.h b/engines/pegasus/MMShell/Utilities/MMIDObject.h
deleted file mode 100755
index 112d3b8..0000000
--- a/engines/pegasus/MMShell/Utilities/MMIDObject.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_MMIDOBJECT_H
-#define PEGASUS_MMSHELL_MMIDOBJECT_H
-
-#include "pegasus/types.h"
-
-namespace Pegasus {
-
-class MMIDObject {
-friend inline int operator==(const MMIDObject &arg1, const MMIDObject &arg1);
-friend inline int operator!=(const MMIDObject &arg2, const MMIDObject &arg2);
-
-public:
-	MMIDObject(const tMM32BitID id);
-	~MMIDObject();
-	
-	tMM32BitID getObjectID() const;
-
-private:
-	tMM32BitID _objectID;
-};
-
-inline MMIDObject::MMIDObject(const tMM32BitID id) {
-	_objectID = id;
-}
-
-inline MMIDObject::~MMIDObject() {
-}
-
-inline tMM32BitID MMIDObject::getObjectID() const {
-	return _objectID;
-}
-
-inline int operator==(const MMIDObject &arg1, const MMIDObject &arg2) {
-	return arg1._objectID == arg2._objectID;
-}
-
-inline int operator!=(const MMIDObject &arg1, const MMIDObject &arg2) {
-	return arg1._objectID != arg2._objectID;
-}
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp b/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
deleted file mode 100755
index 92971a6..0000000
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/constants.h"
-#include "pegasus/MMShell/Utilities/MMTimeValue.h"
-
-namespace Pegasus {
-
-MMTimeValue::MMTimeValue() {
-	fTheTime = 0;
-	fTheScale = kDefaultTimeScale;
-}
-
-TimeValue MMTimeValue::GetTime() const {
-	return fTheTime;
-}
-
-void MMTimeValue::GetTime(TimeValue &time, const TimeScale scale) const {
-	time = fTheTime * fTheScale / scale;
-}
-
-void MMTimeValue::SetTime(const TimeValue time) {
-	fTheTime = time;
-}
-
-void MMTimeValue::SetTime(const TimeValue time, const TimeScale scale) {
-	fTheTime = time * scale / fTheScale;
-}
-
-TimeScale MMTimeValue::GetScale() const {
-	return fTheScale;
-}
-
-void MMTimeValue::SetScale(const TimeScale scale) {
-	fTheScale = scale;
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Utilities/MMTimeValue.h b/engines/pegasus/MMShell/Utilities/MMTimeValue.h
deleted file mode 100755
index a112f9c..0000000
--- a/engines/pegasus/MMShell/Utilities/MMTimeValue.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_MMTIMEVALUE_H
-#define PEGASUS_MMSHELL_MMTIMEVALUE_H
-
-#include "pegasus/types.h"
-
-namespace Pegasus {
-
-class MMTimeValue {
-public:
-	MMTimeValue();
-	
-	TimeValue GetTime() const;
-	void GetTime(TimeValue &time, const TimeScale scale) const;
-	void SetTime(const TimeValue time);
-	void SetTime(const TimeValue time, const TimeScale scale);
-	
-	TimeScale GetScale() const;
-	void SetScale(const TimeScale scale);
-
-protected:
-	TimeValue fTheTime;
-	TimeScale fTheScale;
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp b/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
deleted file mode 100755
index e6bd146..0000000
--- a/engines/pegasus/MMShell/Utilities/MMUtilities.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/random.h"
-#include "common/util.h"
-
-#include "pegasus/MMShell/Utilities/MMUtilities.h"
-
-namespace Pegasus {
-
-inline int32 Round(const int32 a, const int32 b) {
-	if (b < 0)
-		if (a < 0)
-			return -((a - (-b >> 1)) / -b);
-		else
-			return -((a + (-b >> 1)) / -b);
-	else
-		if (a < 0)
-			return (a - (b >> 1)) / b;
-		else
-			return (a + (b >> 1)) / b;
-}
-
-int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2) {
-	if (start2 == stop2)
-		return start2;
-	else
-		return start2 + Round((current1 - start1) * (stop2 - start2), (stop1 - start1));
-}
-
-void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random) {	
-	if (count > 1) {
-		for (int32 i = 1; i < count; ++i) {
-			int32 j = random.getRandomNumber(i);
-			if (j != i)
-				SWAP(arr[i], arr[j]);
-		}
-	}
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/MMShell/Utilities/MMUtilities.h b/engines/pegasus/MMShell/Utilities/MMUtilities.h
deleted file mode 100755
index d5f7e54..0000000
--- a/engines/pegasus/MMShell/Utilities/MMUtilities.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H
-#define PEGASUS_MMSHELL_UTILITIES_MMUTILITIES_H
-
-#include "common/scummsys.h"
-
-namespace Common {
-	class RandomSource;
-}
-
-namespace Pegasus {
-
-int32 LinearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2);
-
-void ShuffleArray(int32 *arr, int32 count, Common::RandomSource &random);
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
index f97ad1d..58ca353 100755
--- a/engines/pegasus/hotspot.cpp
+++ b/engines/pegasus/hotspot.cpp
@@ -29,7 +29,7 @@ namespace Pegasus {
 
 HotspotList g_allHotspots;
 
-Hotspot::Hotspot(const tHotSpotID id) : MMIDObject(id) {
+Hotspot::Hotspot(const tHotSpotID id) : IDObject(id) {
 	_spotFlags = kNoHotSpotFlags;
 	_spotActive = false;
 }
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
index 97bbf37..d5a2fb0 100755
--- a/engines/pegasus/hotspot.h
+++ b/engines/pegasus/hotspot.h
@@ -31,7 +31,7 @@
 
 #include "pegasus/constants.h"
 #include "pegasus/types.h"
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
+#include "pegasus/util.h"
 
 /*
 
@@ -46,7 +46,7 @@
 
 namespace Pegasus {
 
-class Hotspot : public MMIDObject {
+class Hotspot : public IDObject {
 public:
 	Hotspot(const tHotSpotID);
 	virtual ~Hotspot();
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index 2043317..cdd8129 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -33,7 +33,7 @@
 
 namespace Pegasus {
 
-Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : MMIDObject(id) {
+Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : IDObject(id) {
 	_itemNeighborhood = neighborhood;
 	_itemRoom = room;
 	_itemDirection = direction;
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index 517ffc0..f623df5 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -28,8 +28,8 @@
 
 #include "common/endian.h"
 
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
 #include "pegasus/types.h"
+#include "pegasus/util.h"
 
 namespace Common {
 	class Error;
@@ -285,7 +285,7 @@ enum tItemType {
 
 */
 
-class Item : public MMIDObject {
+class Item : public IDObject {
 public:
 	Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
 	virtual ~Item();
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index d3bcbcb..5b8898f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -12,15 +12,13 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	sound.o \
+	util.o \
 	video.o \
 	items/inventory.o \
 	items/item.o \
 	items/itemlist.o \
 	items/biochips/biochipitem.o \
 	items/inventory/inventoryitem.o \
-	MMShell/Base_Classes/MMFunctionPtr.o \
-	MMShell/Utilities/MMTimeValue.o \
-	MMShell/Utilities/MMUtilities.o \
 	neighborhood/door.o \
 	neighborhood/exit.o \
 	neighborhood/extra.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 8048fa4..39efda3 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -32,7 +32,7 @@
 
 namespace Pegasus {
 
-Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : MMIDObject(id), _vm(vm), _resName(resName) {
+Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : IDObject(id), _vm(vm), _resName(resName) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 	_interruptionFilter = kFilterAllInput;
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index d567a5b..baeed7d 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -32,7 +32,7 @@
 #include "pegasus/hotspot.h"
 #include "pegasus/notification.h"
 #include "pegasus/sound.h"
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
+#include "pegasus/util.h"
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
 #include "pegasus/neighborhood/extra.h"
@@ -84,7 +84,7 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
 typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
-class Neighborhood : public MMIDObject, public NotificationReceiver {
+class Neighborhood : public IDObject, public NotificationReceiver {
 public:
 	Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
index f03e470..9725cfb 100755
--- a/engines/pegasus/notification.cpp
+++ b/engines/pegasus/notification.cpp
@@ -30,7 +30,7 @@ namespace Pegasus {
 
 typedef tReceiverList::iterator tReceiverIterator;
 
-Notification::Notification(const tNotificationID id, NotificationManager *owner) : MMIDObject(id) {
+Notification::Notification(const tNotificationID id, NotificationManager *owner) : IDObject(id) {
 	_owner = owner;
 	_currentFlags = kNoNotificationFlags;
 	if (_owner)
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
index d276f45..ded6647 100755
--- a/engines/pegasus/notification.h
+++ b/engines/pegasus/notification.h
@@ -29,7 +29,7 @@
 #include "common/list.h"
 
 #include "pegasus/types.h"
-#include "pegasus/MMShell/Utilities/MMIDObject.h"
+#include "pegasus/util.h"
 
 namespace Pegasus {
 
@@ -50,7 +50,7 @@ typedef Common::List<tReceiverEntry> tReceiverList;
 	A notification can have 32 flags associated with it, which can be user-defined.
 */
 
-class Notification : public MMIDObject {
+class Notification : public IDObject {
 friend class NotificationManager;
 
 public:
diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
new file mode 100755
index 0000000..a4c9a35
--- /dev/null
+++ b/engines/pegasus/util.cpp
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/random.h"
+#include "common/util.h"
+
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+IDObject::IDObject(const tMM32BitID id) {
+	_objectID = id;
+}
+
+IDObject::~IDObject() {
+}
+
+tMM32BitID IDObject::getObjectID() const {
+	return _objectID;
+}
+
+int operator==(const IDObject &arg1, const IDObject &arg2) {
+	return arg1.getObjectID() == arg2.getObjectID();
+}
+
+int operator!=(const IDObject &arg1, const IDObject &arg2) {
+	return arg1.getObjectID() != arg2.getObjectID();
+}
+
+FunctionPtr::FunctionPtr() {
+	_function = 0;
+	_functionArg = 0;
+}
+
+FunctionPtr::~FunctionPtr() {
+}
+
+void FunctionPtr::setFunctionPtr(tFunctionPtr function, void *functionArg) {
+	_function = function;
+	_functionArg = functionArg;
+}
+
+void FunctionPtr::callFunction() {
+	if (_function != 0)
+		(*_function)(this, _functionArg);
+}
+
+inline int32 pegasusRound(const int32 a, const int32 b) {
+	if (b < 0)
+		if (a < 0)
+			return -((a - (-b >> 1)) / -b);
+		else
+			return -((a + (-b >> 1)) / -b);
+	else
+		if (a < 0)
+			return (a - (b >> 1)) / b;
+		else
+			return (a + (b >> 1)) / b;
+}
+
+int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2) {
+	if (start2 == stop2)
+		return start2;
+	else
+		return start2 + pegasusRound((current1 - start1) * (stop2 - start2), (stop1 - start1));
+}
+
+void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random) {	
+	if (count > 1) {
+		for (int32 i = 1; i < count; ++i) {
+			int32 j = random.getRandomNumber(i);
+			if (j != i)
+				SWAP(arr[i], arr[j]);
+		}
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
new file mode 100755
index 0000000..83c0c33
--- /dev/null
+++ b/engines/pegasus/util.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MMSHELL_MMIDOBJECT_H
+#define PEGASUS_MMSHELL_MMIDOBJECT_H
+
+#include "pegasus/types.h"
+
+namespace Common {
+	class RandomSource;
+}
+
+namespace Pegasus {
+
+class IDObject {
+public:
+	IDObject(const tMM32BitID id);
+	~IDObject();
+	
+	tMM32BitID getObjectID() const;
+
+private:
+	tMM32BitID _objectID;
+};
+
+class FunctionPtr;
+
+typedef void (*tFunctionPtr)(FunctionPtr *theFunction, void *functionArg);
+
+class FunctionPtr {
+public:
+	FunctionPtr();
+	virtual ~FunctionPtr();
+	
+	void setFunctionPtr(tFunctionPtr function, void *functionArg);
+
+protected:
+	void callFunction();
+	
+	tFunctionPtr _function;
+	void *_functionArg;
+};
+
+int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2);
+
+void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random);
+
+} // End of namespace Pegasus
+
+#endif


Commit: cbcae58caf674198bf19f4b8bb3bf07c0a30055b
    https://github.com/scummvm/scummvm/commit/cbcae58caf674198bf19f4b8bb3bf07c0a30055b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-06T13:06:53-07:00

Commit Message:
PEGASUS: Properly handle regions in hotspots

Changed paths:
    engines/pegasus/hotspot.cpp
    engines/pegasus/hotspot.h
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
index 58ca353..b8ff97a 100755
--- a/engines/pegasus/hotspot.cpp
+++ b/engines/pegasus/hotspot.cpp
@@ -23,12 +23,123 @@
  *
  */
 
+#include "common/stream.h"
+
 #include "pegasus/hotspot.h"
 
 namespace Pegasus {
 
 HotspotList g_allHotspots;
 
+Region::Region(Common::ReadStream *stream) {
+	uint16 length = stream->readUint16BE();
+
+	assert(length >= 10);
+
+	_bounds.top = stream->readUint16BE();
+	_bounds.left = stream->readUint16BE();
+	_bounds.bottom = stream->readUint16BE();
+	_bounds.right = stream->readUint16BE();
+
+	_bounds.debugPrint(0, "Bounds:");
+
+	if (length == 10)
+		return;
+
+	length -= 10;
+
+	while (length > 0) {
+		Vector v;
+		v.y = stream->readUint16BE();
+		length -= 2;
+
+		if (v.y == 0x7fff)
+			break;
+
+		debug(0, "y: %d", v.y);
+
+		// Normalize y to _bounds
+		v.y -= _bounds.top;
+
+		while (length > 0) {
+			Run run;
+			run.start = stream->readUint16BE();
+			length -= 2;
+
+			if (run.start == 0x7fff)
+				break;
+
+			run.end = stream->readUint16BE();
+			length -= 2;
+
+			debug(0, "\t[%d, %d)", run.start, run.end);
+
+			// Normalize to _bounds
+			run.start -= _bounds.left;
+			run.end -= _bounds.left;
+
+			v.push_back(run);
+		}
+
+		_vectors.push_back(v);
+	}
+}
+
+Region::Region(const Common::Rect &rect) {
+	_bounds = rect;
+}
+
+bool Region::pointInRegion(const Common::Point &point) const {
+	if (!_bounds.contains(point))
+		return false;
+
+	bool pixelActive = false;
+
+	// Normalize the points to _bounds
+	uint16 x = point.x - _bounds.left;
+	uint16 y = point.y - _bounds.top;
+
+	for (Common::List<Vector>::const_iterator v = _vectors.begin(); v != _vectors.end(); v++) {
+		if (v->y > y)
+			return pixelActive;
+
+		for (Vector::const_iterator run = v->begin(); run != v->end(); run++) {
+			if (x >= run->start && x < run->end) {
+				pixelActive = !pixelActive;
+				break;
+			}
+		}
+	}
+
+	// the case if the region is just a rect
+	return true;
+}
+
+void Region::moveTo(tCoordType h, tCoordType v) {
+	_bounds.moveTo(h, v);
+}
+
+void Region::moveTo(const Common::Point &point) {
+	_bounds.moveTo(point);
+}
+
+void Region::translate(tCoordType h, tCoordType v) {
+	_bounds.translate(h, v);
+}
+
+void Region::translate(const Common::Point &point) {
+	_bounds.translate(point.x, point.y);
+}
+
+void Region::getCenter(tCoordType &h, tCoordType &v) const {
+	h = (_bounds.left + _bounds.right) / 2;
+	v = (_bounds.top + _bounds.bottom) / 2;
+}
+
+void Region::getCenter(Common::Point &point) const {
+	getCenter(point.x, point.y);
+}
+
 Hotspot::Hotspot(const tHotSpotID id) : IDObject(id) {
 	_spotFlags = kNoHotSpotFlags;
 	_spotActive = false;
@@ -38,25 +149,23 @@ Hotspot::~Hotspot() {
 }
 
 void Hotspot::setArea(const Common::Rect &area) {
-	_spotArea = area;
+	_spotArea = Region(area);
 }
 
 void Hotspot::setArea(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
-	_spotArea = Common::Rect(left, top, right, bottom);
+	_spotArea = Region(Common::Rect(left, top, right, bottom));
 }
 
 void Hotspot::getBoundingBox(Common::Rect &r) const {
-	r = _spotArea;
+	r = _spotArea.getBoundingBox();
 }
 
 void Hotspot::getCenter(Common::Point &pt) const {
-	pt.x = (_spotArea.left + _spotArea.right) / 2;
-	pt.y = (_spotArea.top + _spotArea.bottom) / 2;
+	_spotArea.getCenter(pt);
 }
 
 void Hotspot::getCenter(tCoordType &h, tCoordType &v) const {
-	h = (_spotArea.left + _spotArea.right) / 2;
-	v = (_spotArea.top + _spotArea.bottom) / 2;
+	_spotArea.getCenter(h, v);
 }
 
 void Hotspot::setActive() {
@@ -96,7 +205,7 @@ void Hotspot::moveSpot(const Common::Point pt) {
 }
 
 bool Hotspot::pointInSpot(const Common::Point where) const {
-	return _spotActive && _spotArea.contains(where);
+	return _spotActive && _spotArea.pointInRegion(where);
 }
 
 tHotSpotFlags Hotspot::getHotspotFlags() const {
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
index d5a2fb0..aafb96c 100755
--- a/engines/pegasus/hotspot.h
+++ b/engines/pegasus/hotspot.h
@@ -44,16 +44,55 @@
 
 */
 
+namespace Common {
+	class ReadStream;
+}
+
 namespace Pegasus {
 
+// Our implementation of QuickDraw regions
+class Region {
+public:
+	Region() {}
+	Region(Common::ReadStream *stream);
+	Region(const Common::Rect &rect);
+
+	Common::Rect getBoundingBox() const { return _bounds; }
+
+	bool pointInRegion(const Common::Point &point) const;
+
+	void moveTo(tCoordType h, tCoordType v);
+	void moveTo(const Common::Point &point);
+	void translate(tCoordType h, tCoordType v);
+	void translate(const Common::Point &point);
+	void getCenter(tCoordType &h, tCoordType &v) const;
+	void getCenter(Common::Point &point) const;
+
+private:
+	Common::Rect _bounds;
+
+	struct Run {
+		uint16 start, end;
+	};
+
+	class Vector : public Common::List<Run> {
+	public:
+		uint16 y;
+	};
+
+	Common::List<Vector> _vectors;
+};
+
 class Hotspot : public IDObject {
 public:
 	Hotspot(const tHotSpotID);
 	virtual ~Hotspot();
-	
+
+	void setArea(const Region &region) { _spotArea = region; }
 	void setArea(const Common::Rect &);
 	void setArea(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
 	void getBoundingBox(Common::Rect &) const;
+	void getArea(Region &) const;
 	void getCenter(Common::Point&) const;
 	void getCenter(tCoordType&, tCoordType&) const;
 	
@@ -73,7 +112,7 @@ public:
 	void setMaskedHotspotFlags(const tHotSpotFlags flags, const tHotSpotFlags mask);
 
 protected:
-	Common::Rect _spotArea;
+	Region _spotArea;
 	tHotSpotFlags _spotFlags;
 	bool _spotActive;
 };
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 39efda3..8381188 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -249,26 +249,16 @@ void Neighborhood::createNeighborhoodSpots() {
 		uint32 flags = hotspotList->readUint32BE();
 		uint32 rgnSize = hotspotList->readUint32BE();
 
-		// duplicate of rgnSize
-		hotspotList->readUint16BE();
+		int32 startPos = hotspotList->pos();
 
-		Common::Rect boundingBox;
-		boundingBox.top = hotspotList->readUint16BE();
-		boundingBox.left = hotspotList->readUint16BE();
-		boundingBox.bottom = hotspotList->readUint16BE();
-		boundingBox.right = hotspotList->readUint16BE();
+		debug(0, "Hotspot %d:", id);
+		Region region(hotspotList);
 
-		debug(0, "Hotspot[%d]: Flags = %08x", id, flags); 
-		boundingBox.debugPrint(0, "\tBounding Box:");
-
-		// TODO: Handle non-rectangular hotspots
-		if (rgnSize != 10)
-			warning("Non-rectangular hotspot found - %d extra bytes", rgnSize - 10);
-		hotspotList->skip(rgnSize - 10);
+		hotspotList->seek(startPos + rgnSize);
 
 		Hotspot *hotspot = new Hotspot(id);
 		hotspot->setHotspotFlags(flags);
-		hotspot->setArea(boundingBox);
+		hotspot->setArea(region);
 
 		g_allHotspots.push_back(hotspot);
 		_neighborhoodHotspots.push_back(hotspot);


Commit: e56546a83d3dd3c9bf0d301b547d499e4b06b636
    https://github.com/scummvm/scummvm/commit/e56546a83d3dd3c9bf0d301b547d499e4b06b636
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-06T17:59:06-07:00

Commit Message:
PEGASUS: Implement two of the base input classes

Changed paths:
  A engines/pegasus/input.cpp
  A engines/pegasus/input.h
    engines/pegasus/constants.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 509c9f3..dd12727 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -187,8 +187,6 @@ const TimeValue kFiveMinutesPerSixtyTicks = kFiveMinutes * kSixtyTicksPerSecond;
 const TimeValue kTenMinutesPerSixtyTicks = kTenMinutes * kSixtyTicksPerSecond;
 
 //	Time in seconds you can hang around Caldoria without going to work...
-//const TimeValue kCaldoriaUncreatedTimeLimit = kFifteenMinutes;
-//const TimeValue kCaldoriaUncreatedTimeLimit = kTwentyMinutes;
 const TimeValue kLateWarning2TimeLimit = kFiveMinutes;
 const TimeValue kLateWarning3TimeLimit = kTenMinutes;
 
@@ -221,224 +219,6 @@ const TimeValue kPlasmaImpactTime = kTwoSeconds;
 
 const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
 
-enum {
-	kButtonDownBit = 0,
-	kAutoButtonBit = 1,
-	kBitsPerButton = 2,
-	
-	kButtonDownMask = 1 << kButtonDownBit,
-	kAutoButtonMask = 1 << kAutoButtonBit,
-	
-	kButtonStateBits = kButtonDownMask | kAutoButtonMask,
-	
-	kRawButtonUp = 0,
-	kRawButtonDown = kButtonDownMask | kAutoButtonMask,
-	
-	kButtonUp = 0,
-	kButtonDown = kButtonDownMask,
-	kButtonAutoUp = kAutoButtonMask,
-	kButtonAutoDown = kButtonDownMask | kAutoButtonMask
-};
-
-enum {
-	kUpButtonNum = 0,
-	kLeftButtonNum = 1,
-	kDownButtonNum = 2,
-	kRightButtonNum = 3,
-	kLeftFireButtonNum = 4,
-	kRightFireButtonNum = 5,
-	kOneButtonNum = 6,
-	kTwoButtonNum = 7,
-	kThreeButtonNum = 8,
-	kFourButtonNum = 9,
-	kMod1ButtonNum = 10,
-	kMod2ButtonNum = 11,
-	kMod3ButtonNum = 12
-};
-
-enum {
-	kUpButtonShift = kUpButtonNum * kBitsPerButton,
-	kLeftButtonShift = kLeftButtonNum * kBitsPerButton,
-	kDownButtonShift = kDownButtonNum * kBitsPerButton,
-	kRightButtonShift = kRightButtonNum * kBitsPerButton,
-	kLeftFireButtonShift = kLeftFireButtonNum * kBitsPerButton,
-	kRightFireButtonShift = kRightFireButtonNum * kBitsPerButton,
-	kOneButtonShift = kOneButtonNum * kBitsPerButton,
-	kTwoButtonShift = kTwoButtonNum * kBitsPerButton,
-	kThreeButtonShift = kThreeButtonNum * kBitsPerButton,
-	kFourButtonShift = kFourButtonNum * kBitsPerButton,
-	kMod1ButtonShift = kMod1ButtonNum * kBitsPerButton,
-	kMod2ButtonShift = kMod2ButtonNum * kBitsPerButton,
-	kMod3ButtonShift = kMod3ButtonNum * kBitsPerButton
-};
-
-enum {
-	kAllUpBits =	(kButtonUp << kUpButtonShift) |
-					(kButtonUp << kLeftButtonShift) |
-					(kButtonUp << kDownButtonShift) |
-					(kButtonUp << kRightButtonShift) |
-					(kButtonUp << kLeftFireButtonShift) |
-					(kButtonUp << kRightFireButtonShift) |
-					(kButtonUp << kOneButtonShift) |
-					(kButtonUp << kTwoButtonShift) |
-					(kButtonUp << kThreeButtonShift) |
-					(kButtonUp << kFourButtonShift) |
-					(kButtonUp << kMod1ButtonShift) |
-					(kButtonUp << kMod2ButtonShift) |
-					(kButtonUp << kMod3ButtonShift),
-	kDirectionBits =	(kButtonDownMask << kUpButtonShift) |
-						(kButtonDownMask << kLeftButtonShift) |
-						(kButtonDownMask << kDownButtonShift) |
-						(kButtonDownMask << kRightButtonShift),
-	kButtonBits =	(kButtonDownMask << kLeftFireButtonShift) |
-					(kButtonDownMask << kRightFireButtonShift) |
-					(kButtonDownMask << kOneButtonShift) |
-					(kButtonDownMask << kTwoButtonShift) |
-					(kButtonDownMask << kThreeButtonShift) |
-					(kButtonDownMask << kFourButtonShift) |
-					(kButtonDownMask << kMod1ButtonShift) |
-					(kButtonDownMask << kMod2ButtonShift) |
-					(kButtonDownMask << kMod3ButtonShift),
-	kAllButtonDownBits = kDirectionBits | kButtonBits,
-	kAllAutoBits =	(kAutoButtonMask << kUpButtonShift) |
-					(kAutoButtonMask << kLeftButtonShift) |
-					(kAutoButtonMask << kDownButtonShift) |
-					(kAutoButtonMask << kRightButtonShift) |
-					(kAutoButtonMask << kLeftFireButtonShift) |
-					(kAutoButtonMask << kRightFireButtonShift) |
-					(kAutoButtonMask << kOneButtonShift) |
-					(kAutoButtonMask << kTwoButtonShift) |
-					(kAutoButtonMask << kThreeButtonShift) |
-					(kAutoButtonMask << kFourButtonShift) |
-					(kAutoButtonMask << kMod1ButtonShift) |
-					(kAutoButtonMask << kMod2ButtonShift) |
-					(kAutoButtonMask << kMod3ButtonShift),
-	
-	kFilterUpButton =			kButtonDownMask << kUpButtonShift,
-	kFilterUpAuto =				kAutoButtonMask << kUpButtonShift,
-	kFilterUpButtonAny =		kFilterUpButton | kFilterUpAuto,
-	kFilterLeftButton =			kButtonDownMask << kLeftButtonShift,
-	kFilterLeftAuto =			kAutoButtonMask << kLeftButtonShift,
-	kFilterLeftButtonAny =		kFilterLeftButton | kFilterLeftAuto,
-	kFilterDownButton =			kButtonDownMask << kDownButtonShift,
-	kFilterDownAuto =			kAutoButtonMask << kDownButtonShift,
-	kFilterDownButtonAny =		kFilterDownButton | kFilterDownAuto,
-	kFilterRightButton =		kButtonDownMask << kRightButtonShift,
-	kFilterRightAuto =			kAutoButtonMask << kRightButtonShift,
-	kFilterRightButtonAny =		kFilterRightButton | kFilterRightAuto,
-	kFilterLeftFireButton =		kButtonDownMask << kLeftFireButtonShift,
-	kFilterLeftFireAuto =		kAutoButtonMask << kLeftFireButtonShift,
-	kFilterLeftFireButtonAny =	kFilterLeftFireButton | kFilterLeftFireAuto,
-	kFilterRightFireButton =	kButtonDownMask << kRightFireButtonShift,
-	kFilterRightFireAuto =		kAutoButtonMask << kRightFireButtonShift,
-	kFilterRightFireButtonAny =	kFilterRightFireButton | kFilterRightFireAuto,
-	kFilterOneButton =			kButtonDownMask << kOneButtonShift,
-	kFilterOneAuto =			kAutoButtonMask << kOneButtonShift,
-	kFilterOneButtonAny =		kFilterOneButton | kFilterOneAuto,
-	kFilterTwoButton =			kButtonDownMask << kTwoButtonShift,
-	kFilterTwoAuto =			kAutoButtonMask << kTwoButtonShift,
-	kFilterTwoButtonAny =		kFilterTwoButton | kFilterTwoAuto,
-	kFilterThreeButton =		kButtonDownMask << kThreeButtonShift,
-	kFilterThreeAuto =			kAutoButtonMask << kThreeButtonShift,
-	kFilterThreeButtonAny =		kFilterThreeButton | kFilterThreeAuto,
-	kFilterFourButton =			kButtonDownMask << kFourButtonShift,
-	kFilterFourAuto =			kAutoButtonMask << kFourButtonShift,
-	kFilterFourButtonAny =		kFilterFourButton | kFilterFourAuto,
-	kFilterMod1Button =			kButtonDownMask << kMod1ButtonShift,
-	kFilterMod1Auto =			kAutoButtonMask << kMod1ButtonShift,
-	kFilterMod1ButtonAny =		kFilterMod1Button | kFilterMod1Auto,
-	kFilterMod2Button =			kButtonDownMask << kMod2ButtonShift,
-	kFilterMod2Auto =			kAutoButtonMask << kMod2ButtonShift,
-	kFilterMod2ButtonAny =		kFilterMod2Button | kFilterMod2Auto,
-	kFilterMod3Button =			kButtonDownMask << kMod3ButtonShift,
-	kFilterMod3Auto =			kAutoButtonMask << kMod3ButtonShift,
-	kFilterMod3ButtonAny =		kFilterMod3Button | kFilterMod3Auto,
-	
-	kFilterNoInput =			0,
-	kFilterAllInput =			kFilterUpButton |
-								kFilterUpAuto |
-								kFilterLeftButton |
-								kFilterLeftAuto |
-								kFilterDownButton |
-								kFilterDownAuto |
-								kFilterRightButton |
-								kFilterRightAuto |
-								kFilterLeftFireButton |
-								kFilterLeftFireAuto |
-								kFilterRightFireButton |
-								kFilterRightFireAuto |
-								kFilterOneButton |
-								kFilterOneAuto |
-								kFilterTwoButton |
-								kFilterTwoAuto |
-								kFilterThreeButton |
-								kFilterThreeAuto |
-								kFilterFourButton |
-								kFilterFourAuto |
-								kFilterMod1Button |
-								kFilterMod1Auto |
-								kFilterMod2Button |
-								kFilterMod2Auto |
-								kFilterMod3Button |
-								kFilterMod3Auto,
-	
-	kFilterAllDirections =		kFilterUpButton |
-								kFilterUpAuto |
-								kFilterLeftButton |
-								kFilterLeftAuto |
-								kFilterDownButton |
-								kFilterDownAuto |
-								kFilterRightButton |
-								kFilterRightAuto,
-	
-	kFilterButtons =			kFilterOneButton |
-								kFilterOneAuto |
-								kFilterTwoButton |
-								kFilterTwoAuto |
-								kFilterThreeButton |
-								kFilterThreeAuto |
-								kFilterFourButton |
-								kFilterFourAuto,
-	
-	kFilterFireButtons =		kFilterLeftFireButton |
-								kFilterLeftFireAuto |
-								kFilterRightFireButton |
-								kFilterRightFireAuto,
-	
-	kFilterAllButtons =			kFilterLeftFireButton |
-								kFilterLeftFireAuto |
-								kFilterRightFireButton |
-								kFilterRightFireAuto |
-								kFilterOneButton |
-								kFilterOneAuto |
-								kFilterTwoButton |
-								kFilterTwoAuto |
-								kFilterThreeButton |
-								kFilterThreeAuto |
-								kFilterFourButton |
-								kFilterFourAuto |
-								kFilterMod1Button |
-								kFilterMod1Auto |
-								kFilterMod2Button |
-								kFilterMod2Auto |
-								kFilterMod3Button |
-								kFilterMod3Auto,
-	
-	kFilterAllInputNoAuto =		kFilterUpButton |
-								kFilterLeftButton |
-								kFilterDownButton |
-								kFilterRightButton |
-								kFilterLeftFireButton |
-								kFilterRightFireButton |
-								kFilterOneButton |
-								kFilterTwoButton |
-								kFilterThreeButton |
-								kFilterFourButton |
-								kFilterMod1Button |
-								kFilterMod2Button |
-								kFilterMod3Button
-};
-
 const tNotificationID kNeighborhoodNotificationID = 1;
 const tNotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
 
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
new file mode 100755
index 0000000..bb147fb
--- /dev/null
+++ b/engines/pegasus/input.cpp
@@ -0,0 +1,138 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/events.h"
+#include "common/system.h"
+
+#include "pegasus/input.h"
+
+namespace Pegasus {
+
+InputDevice::InputDevice() {
+	_lastRawBits = kAllUpBits;
+}
+
+InputDevice::~InputDevice() {
+}
+
+void InputDevice::getInput(Input &input, const tInputBits filter) {
+	// TODO: Save/Load keys
+
+	tInputBits currentBits = 0;
+
+	Common::Event event;
+	while (g_system->getEventManager()->pollEvent(event)) {
+		// We only care about two events here
+		// We're mapping from ScummVM events to pegasus events, which
+		// are based on pippin events.
+		if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) {
+			switch (event.kbd.keycode) {
+			case Common::KEYCODE_UP:
+			case Common::KEYCODE_KP8:
+				currentBits |= (kRawButtonDown << kUpButtonShift);
+				break;
+			case Common::KEYCODE_LEFT:
+			case Common::KEYCODE_KP4:
+				currentBits |= (kRawButtonDown << kLeftButtonShift);
+				break;
+			case Common::KEYCODE_DOWN:
+			case Common::KEYCODE_KP5:
+				currentBits |= (kRawButtonDown << kDownButtonShift);
+				break;
+			case Common::KEYCODE_RIGHT:
+			case Common::KEYCODE_KP6:
+				currentBits |= (kRawButtonDown << kRightButtonShift);
+				break;
+			case Common::KEYCODE_RETURN:
+			case Common::KEYCODE_SPACE:
+				currentBits |= (kRawButtonDown << kTwoButtonShift);
+				break;
+			case Common::KEYCODE_t:
+			case Common::KEYCODE_KP_EQUALS:
+				currentBits |= (kRawButtonDown << kThreeButtonShift);
+				break;
+			case Common::KEYCODE_i:
+			case Common::KEYCODE_KP_DIVIDE:
+				currentBits |= (kRawButtonDown << kFourButtonShift);
+				break;
+			case Common::KEYCODE_q:
+				currentBits |= (kRawButtonDown << kMod1ButtonShift);
+				break;
+			case Common::KEYCODE_ESCAPE:
+			case Common::KEYCODE_p:
+				currentBits |= (kRawButtonDown << kMod3ButtonShift);
+				break;
+			case Common::KEYCODE_TILDE:
+			case Common::KEYCODE_NUMLOCK: // Yes, the original uses Num Lock/Clear on the Mac...
+				currentBits |= (kRawButtonDown << kLeftFireButtonShift);
+				break;
+			case Common::KEYCODE_DELETE:
+				currentBits |= (kRawButtonDown << kRightFireButtonShift);
+				break;
+			default:
+				break;
+			}
+
+			if (event.kbd.flags & Common::KBD_ALT) // Alt, option, same thing!
+				currentBits |= (kRawButtonDown << kMod2ButtonShift);
+		}
+	}
+
+	// Update mouse button state
+	// Note that we don't use EVENT_LBUTTONUP/EVENT_LBUTTONDOWN because
+	// they do not show if the button is being held down. We're treating
+	// both mouse buttons as the same for ease of use.
+	if (g_system->getEventManager()->getButtonState() != 0)
+		currentBits |= (kRawButtonDown << kTwoButtonShift);
+
+	// Update the mouse position too
+	input.setInputLocation(g_system->getEventManager()->getMousePos());
+	_lastRawBits = currentBits;
+
+	tInputBits filteredBits = currentBits & filter;
+	input.setInputBits((filteredBits & kAllButtonDownBits) | (filteredBits & _lastRawBits & kAllAutoBits));
+}
+
+//	Wait until the input device stops returning input allowed by filter...
+void InputDevice::waitInput(const tInputBits filter) {
+	if (filter != 0) {
+		for (;;) {
+			Input input;
+			getInput(input, filter);
+			if (!input.anyInput())
+				break;
+		}
+	}
+}
+
+int operator==(const Input &arg1, const Input &arg2) {
+	return arg1._inputState == arg2._inputState;
+}
+
+int operator!=(const Input &arg1, const Input &arg2) {
+	return !operator==(arg1, arg2);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
new file mode 100755
index 0000000..463e3d0
--- /dev/null
+++ b/engines/pegasus/input.h
@@ -0,0 +1,373 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_INPUT_H
+#define PEGASUS_INPUT_H
+
+#include "common/rect.h"
+
+#include "pegasus/constants.h"
+#include "pegasus/types.h"
+
+namespace Pegasus {
+
+class Hotspot;
+class Input;
+
+class InputDevice {
+public:
+	InputDevice();
+	~InputDevice();
+
+	void getInput(Input&, const tInputBits);
+
+	void waitInput(const tInputBits);
+
+protected:
+	tInputBits _lastRawBits;
+};
+
+enum {
+	kButtonDownBit = 0,
+	kAutoButtonBit = 1,
+	kBitsPerButton = 2,
+	
+	kButtonDownMask = 1 << kButtonDownBit,
+	kAutoButtonMask = 1 << kAutoButtonBit,
+	
+	kButtonStateBits = kButtonDownMask | kAutoButtonMask,
+	
+	kRawButtonUp = 0,
+	kRawButtonDown = kButtonDownMask | kAutoButtonMask,
+	
+	kButtonUp = 0,
+	kButtonDown = kButtonDownMask,
+	kButtonAutoUp = kAutoButtonMask,
+	kButtonAutoDown = kButtonDownMask | kAutoButtonMask
+};
+
+enum {
+	kUpButtonNum = 0,
+	kLeftButtonNum = 1,
+	kDownButtonNum = 2,
+	kRightButtonNum = 3,
+	kLeftFireButtonNum = 4,
+	kRightFireButtonNum = 5,
+	kOneButtonNum = 6,
+	kTwoButtonNum = 7,
+	kThreeButtonNum = 8,
+	kFourButtonNum = 9,
+	kMod1ButtonNum = 10,
+	kMod2ButtonNum = 11,
+	kMod3ButtonNum = 12
+};
+
+enum {
+	kUpButtonShift = kUpButtonNum * kBitsPerButton,
+	kLeftButtonShift = kLeftButtonNum * kBitsPerButton,
+	kDownButtonShift = kDownButtonNum * kBitsPerButton,
+	kRightButtonShift = kRightButtonNum * kBitsPerButton,
+	kLeftFireButtonShift = kLeftFireButtonNum * kBitsPerButton,
+	kRightFireButtonShift = kRightFireButtonNum * kBitsPerButton,
+	kOneButtonShift = kOneButtonNum * kBitsPerButton,
+	kTwoButtonShift = kTwoButtonNum * kBitsPerButton,
+	kThreeButtonShift = kThreeButtonNum * kBitsPerButton,
+	kFourButtonShift = kFourButtonNum * kBitsPerButton,
+	kMod1ButtonShift = kMod1ButtonNum * kBitsPerButton,
+	kMod2ButtonShift = kMod2ButtonNum * kBitsPerButton,
+	kMod3ButtonShift = kMod3ButtonNum * kBitsPerButton
+};
+
+enum {
+	kAllUpBits =	(kButtonUp << kUpButtonShift) |
+					(kButtonUp << kLeftButtonShift) |
+					(kButtonUp << kDownButtonShift) |
+					(kButtonUp << kRightButtonShift) |
+					(kButtonUp << kLeftFireButtonShift) |
+					(kButtonUp << kRightFireButtonShift) |
+					(kButtonUp << kOneButtonShift) |
+					(kButtonUp << kTwoButtonShift) |
+					(kButtonUp << kThreeButtonShift) |
+					(kButtonUp << kFourButtonShift) |
+					(kButtonUp << kMod1ButtonShift) |
+					(kButtonUp << kMod2ButtonShift) |
+					(kButtonUp << kMod3ButtonShift),
+	kDirectionBits =	(kButtonDownMask << kUpButtonShift) |
+						(kButtonDownMask << kLeftButtonShift) |
+						(kButtonDownMask << kDownButtonShift) |
+						(kButtonDownMask << kRightButtonShift),
+	kButtonBits =	(kButtonDownMask << kLeftFireButtonShift) |
+					(kButtonDownMask << kRightFireButtonShift) |
+					(kButtonDownMask << kOneButtonShift) |
+					(kButtonDownMask << kTwoButtonShift) |
+					(kButtonDownMask << kThreeButtonShift) |
+					(kButtonDownMask << kFourButtonShift) |
+					(kButtonDownMask << kMod1ButtonShift) |
+					(kButtonDownMask << kMod2ButtonShift) |
+					(kButtonDownMask << kMod3ButtonShift),
+	kAllButtonDownBits = kDirectionBits | kButtonBits,
+	kAllAutoBits =	(kAutoButtonMask << kUpButtonShift) |
+					(kAutoButtonMask << kLeftButtonShift) |
+					(kAutoButtonMask << kDownButtonShift) |
+					(kAutoButtonMask << kRightButtonShift) |
+					(kAutoButtonMask << kLeftFireButtonShift) |
+					(kAutoButtonMask << kRightFireButtonShift) |
+					(kAutoButtonMask << kOneButtonShift) |
+					(kAutoButtonMask << kTwoButtonShift) |
+					(kAutoButtonMask << kThreeButtonShift) |
+					(kAutoButtonMask << kFourButtonShift) |
+					(kAutoButtonMask << kMod1ButtonShift) |
+					(kAutoButtonMask << kMod2ButtonShift) |
+					(kAutoButtonMask << kMod3ButtonShift),
+	
+	kFilterUpButton =			kButtonDownMask << kUpButtonShift,
+	kFilterUpAuto =				kAutoButtonMask << kUpButtonShift,
+	kFilterUpButtonAny =		kFilterUpButton | kFilterUpAuto,
+	kFilterLeftButton =			kButtonDownMask << kLeftButtonShift,
+	kFilterLeftAuto =			kAutoButtonMask << kLeftButtonShift,
+	kFilterLeftButtonAny =		kFilterLeftButton | kFilterLeftAuto,
+	kFilterDownButton =			kButtonDownMask << kDownButtonShift,
+	kFilterDownAuto =			kAutoButtonMask << kDownButtonShift,
+	kFilterDownButtonAny =		kFilterDownButton | kFilterDownAuto,
+	kFilterRightButton =		kButtonDownMask << kRightButtonShift,
+	kFilterRightAuto =			kAutoButtonMask << kRightButtonShift,
+	kFilterRightButtonAny =		kFilterRightButton | kFilterRightAuto,
+	kFilterLeftFireButton =		kButtonDownMask << kLeftFireButtonShift,
+	kFilterLeftFireAuto =		kAutoButtonMask << kLeftFireButtonShift,
+	kFilterLeftFireButtonAny =	kFilterLeftFireButton | kFilterLeftFireAuto,
+	kFilterRightFireButton =	kButtonDownMask << kRightFireButtonShift,
+	kFilterRightFireAuto =		kAutoButtonMask << kRightFireButtonShift,
+	kFilterRightFireButtonAny =	kFilterRightFireButton | kFilterRightFireAuto,
+	kFilterOneButton =			kButtonDownMask << kOneButtonShift,
+	kFilterOneAuto =			kAutoButtonMask << kOneButtonShift,
+	kFilterOneButtonAny =		kFilterOneButton | kFilterOneAuto,
+	kFilterTwoButton =			kButtonDownMask << kTwoButtonShift,
+	kFilterTwoAuto =			kAutoButtonMask << kTwoButtonShift,
+	kFilterTwoButtonAny =		kFilterTwoButton | kFilterTwoAuto,
+	kFilterThreeButton =		kButtonDownMask << kThreeButtonShift,
+	kFilterThreeAuto =			kAutoButtonMask << kThreeButtonShift,
+	kFilterThreeButtonAny =		kFilterThreeButton | kFilterThreeAuto,
+	kFilterFourButton =			kButtonDownMask << kFourButtonShift,
+	kFilterFourAuto =			kAutoButtonMask << kFourButtonShift,
+	kFilterFourButtonAny =		kFilterFourButton | kFilterFourAuto,
+	kFilterMod1Button =			kButtonDownMask << kMod1ButtonShift,
+	kFilterMod1Auto =			kAutoButtonMask << kMod1ButtonShift,
+	kFilterMod1ButtonAny =		kFilterMod1Button | kFilterMod1Auto,
+	kFilterMod2Button =			kButtonDownMask << kMod2ButtonShift,
+	kFilterMod2Auto =			kAutoButtonMask << kMod2ButtonShift,
+	kFilterMod2ButtonAny =		kFilterMod2Button | kFilterMod2Auto,
+	kFilterMod3Button =			kButtonDownMask << kMod3ButtonShift,
+	kFilterMod3Auto =			kAutoButtonMask << kMod3ButtonShift,
+	kFilterMod3ButtonAny =		kFilterMod3Button | kFilterMod3Auto,
+	
+	kFilterNoInput =			0,
+	kFilterAllInput =			kFilterUpButton |
+								kFilterUpAuto |
+								kFilterLeftButton |
+								kFilterLeftAuto |
+								kFilterDownButton |
+								kFilterDownAuto |
+								kFilterRightButton |
+								kFilterRightAuto |
+								kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto |
+								kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto |
+								kFilterMod1Button |
+								kFilterMod1Auto |
+								kFilterMod2Button |
+								kFilterMod2Auto |
+								kFilterMod3Button |
+								kFilterMod3Auto,
+	
+	kFilterAllDirections =		kFilterUpButton |
+								kFilterUpAuto |
+								kFilterLeftButton |
+								kFilterLeftAuto |
+								kFilterDownButton |
+								kFilterDownAuto |
+								kFilterRightButton |
+								kFilterRightAuto,
+	
+	kFilterButtons =			kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto,
+	
+	kFilterFireButtons =		kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto,
+	
+	kFilterAllButtons =			kFilterLeftFireButton |
+								kFilterLeftFireAuto |
+								kFilterRightFireButton |
+								kFilterRightFireAuto |
+								kFilterOneButton |
+								kFilterOneAuto |
+								kFilterTwoButton |
+								kFilterTwoAuto |
+								kFilterThreeButton |
+								kFilterThreeAuto |
+								kFilterFourButton |
+								kFilterFourAuto |
+								kFilterMod1Button |
+								kFilterMod1Auto |
+								kFilterMod2Button |
+								kFilterMod2Auto |
+								kFilterMod3Button |
+								kFilterMod3Auto,
+	
+	kFilterAllInputNoAuto =		kFilterUpButton |
+								kFilterLeftButton |
+								kFilterDownButton |
+								kFilterRightButton |
+								kFilterLeftFireButton |
+								kFilterRightFireButton |
+								kFilterOneButton |
+								kFilterTwoButton |
+								kFilterThreeButton |
+								kFilterFourButton |
+								kFilterMod1Button |
+								kFilterMod2Button |
+								kFilterMod3Button
+};
+
+/*
+
+	Buttons are defined as:
+		up, left, down, right		direction buttons.
+		fireLeft, fireRight:		fire buttons.
+		mod1, mod2, mod3:			modifier buttons, similar to shift, control, etc.
+		a, b, c, d:					general purpose buttons.
+	
+	button state is held as bits in a long word, two bits per button.
+	
+	Filter bits:
+		for each button, two bits are assigned for filtering. If bit 0 is set, the
+		corresponding button is available for "button down" input. If bit 1 is set,
+		the corresponding button is available for "auto down" input. Note that bit
+		1 is meaningful only if bit 0 is set.
+	
+*/
+
+class Input {
+friend int operator==(const Input &, const Input &);
+friend int operator!=(const Input &, const Input &);
+friend class InputDevice;
+
+public:
+	Input() { clearInput(); }
+
+	bool upButtonDown() const { return (_inputState & (kButtonStateBits << kUpButtonShift)) == (kButtonDown << kUpButtonShift); }
+	bool upButtonAutoDown() const { return (_inputState & (kButtonStateBits << kUpButtonShift)) == (kButtonAutoDown << kUpButtonShift); }
+	bool upButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kUpButtonShift)) != 0; }
+	
+	bool leftButtonDown() const { return (_inputState & (kButtonStateBits << kLeftButtonShift)) == (kButtonDown << kLeftButtonShift); }
+	bool leftButtonAutoDown() const { return (_inputState & (kButtonStateBits << kLeftButtonShift)) == (kButtonAutoDown << kLeftButtonShift); }
+	bool leftButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kLeftButtonShift)) != 0; }
+	
+	bool downButtonDown() const { return (_inputState & (kButtonStateBits << kDownButtonShift)) == (kButtonDown << kDownButtonShift); }
+	bool downButtonAutoDown() const { return (_inputState & (kButtonStateBits << kDownButtonShift)) == (kButtonAutoDown << kDownButtonShift); }
+	bool downButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kDownButtonShift)) != 0; }
+	
+	bool rightButtonDown() const { return (_inputState & (kButtonStateBits << kRightButtonShift)) == (kButtonDown << kRightButtonShift); }
+	bool rightButtonAutoDown() const { return (_inputState & (kButtonStateBits << kRightButtonShift)) == (kButtonAutoDown << kRightButtonShift); }
+	bool rightButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kRightButtonShift)) != 0; }
+	
+	bool leftFireButtonDown() const { return (_inputState & (kButtonStateBits << kLeftFireButtonShift)) == (kButtonDown << kLeftFireButtonShift); }
+	bool leftFireButtonAutoDown() const { return (_inputState & (kButtonStateBits << kLeftFireButtonShift)) == (kButtonAutoDown << kLeftFireButtonShift); }
+	bool leftFireButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kLeftFireButtonShift)) != 0; }
+	
+	bool rightFireButtonDown() const { return (_inputState & (kButtonStateBits << kRightFireButtonShift)) == (kButtonDown << kRightFireButtonShift); }
+	bool rightFireButtonAutoDown() const { return (_inputState & (kButtonStateBits << kRightFireButtonShift)) == (kButtonAutoDown << kRightFireButtonShift); }
+	bool rightFireButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kRightFireButtonShift)) != 0; }
+	
+	bool oneButtonDown() const { return	(_inputState & (kButtonStateBits << kOneButtonShift)) == (kButtonDown << kOneButtonShift); }
+	bool oneButtonAutoDown() const { return (_inputState & (kButtonStateBits << kOneButtonShift)) == (kButtonAutoDown << kOneButtonShift); }
+	bool oneButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kOneButtonShift)) != 0; }
+
+	bool twoButtonDown() const { return (_inputState & (kButtonStateBits << kTwoButtonShift)) == (kButtonDown << kTwoButtonShift); }
+	bool twoButtonAutoDown() const { return (_inputState & (kButtonStateBits << kTwoButtonShift)) == (kButtonAutoDown << kTwoButtonShift); }
+	bool twoButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kTwoButtonShift)) != 0; }
+	
+	bool threeButtonDown() const { return (_inputState & (kButtonStateBits << kThreeButtonShift)) == (kButtonDown << kThreeButtonShift); }
+	bool threeButtonAutoDown() const { return (_inputState & (kButtonStateBits << kThreeButtonShift)) == (kButtonAutoDown << kThreeButtonShift); }
+	bool threeButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kThreeButtonShift)) != 0; }
+	
+	bool fourButtonDown() const { return (_inputState & (kButtonStateBits << kFourButtonShift)) == (kButtonDown << kFourButtonShift); }
+	bool fourButtonAutoDown() const { return (_inputState & (kButtonStateBits << kFourButtonShift)) == (kButtonAutoDown << kFourButtonShift); }
+	bool fourButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kFourButtonShift)) != 0; }
+	
+	bool mod1ButtonDown() const { return (_inputState & (kButtonStateBits << kMod1ButtonShift)) == (kButtonDown << kMod1ButtonShift); }
+	bool mod1ButtonAutoDown() const { return (_inputState & (kButtonStateBits << kMod1ButtonShift)) == (kButtonAutoDown << kMod1ButtonShift); }
+	bool mod1ButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kMod1ButtonShift)) != 0; }
+	
+	bool mod2ButtonDown() const { return (_inputState & (kButtonStateBits << kMod2ButtonShift)) == (kButtonDown << kMod2ButtonShift); }
+	bool mod2ButtonAutoDown() const { return (_inputState & (kButtonStateBits << kMod2ButtonShift)) == (kButtonAutoDown << kMod2ButtonShift); }
+	bool mod2ButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kMod2ButtonShift)) != 0; }
+	
+	bool mod3ButtonDown() const { return (_inputState & (kButtonStateBits << kMod3ButtonShift)) == (kButtonDown << kMod3ButtonShift); }
+	bool mod3ButtonAutoDown() const { return (_inputState & (kButtonStateBits << kMod3ButtonShift)) == (kButtonAutoDown << kMod3ButtonShift); }
+	bool mod3ButtonAnyDown() const { return (_inputState & (kButtonAutoDown << kMod3ButtonShift)) != 0; }
+	
+	bool allAutoInput() const { return (_inputState & kAllAutoBits) != 0; }
+	bool anyDirectionInput() const { return (_inputState & kDirectionBits) != 0; }
+	bool anyButtonInput() const { return (_inputState & kButtonBits) != 0; }
+	bool anyInput() const { return _inputState != 0; }
+	
+	void getInputLocation(Common::Point &where) const { where = _inputLocation; }
+	
+	bool anyInputBitSet(const tInputBits bits) const { return (_inputState & bits) != 0; }
+	
+	void clearInput() {
+		_inputState = kAllUpBits;
+		_inputLocation.x = 0;
+		_inputLocation.y = 0;
+	}
+
+protected:
+	void setInputBits(const tInputBits state) { _inputState = state; }
+	void setInputLocation(const Common::Point &where) { _inputLocation = where; }
+	
+	tInputBits _inputState;
+	Common::Point _inputLocation;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 5b8898f..8d3ee52 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS = \
 	gamestate.o \
 	graphics.o \
 	hotspot.o \
+	input.o \
 	menu.o \
 	notification.o \
 	overview.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 8381188..461f4b0 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -27,6 +27,7 @@
 #include "common/stream.h"
 
 #include "pegasus/gamestate.h"
+#include "pegasus/input.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/neighborhood/neighborhood.h"
 


Commit: 937c06c304c3ec462477e652092e5877f45c05f7
    https://github.com/scummvm/scummvm/commit/937c06c304c3ec462477e652092e5877f45c05f7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-07T10:11:08-07:00

Commit Message:
PEGASUS: Remove unused MMAction class

Changed paths:
  R engines/pegasus/MMShell/Base_Classes/MMAction.h



diff --git a/engines/pegasus/MMShell/Base_Classes/MMAction.h b/engines/pegasus/MMShell/Base_Classes/MMAction.h
deleted file mode 100755
index 8ad34a8..0000000
--- a/engines/pegasus/MMShell/Base_Classes/MMAction.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_MMSHELL_BASECLASSES_MMACTION_H
-#define PEGASUS_MMSHELL_BASECLASSES_MMACTION_H
-
-namespace Pegasus {
-
-class MMAction {
-public:
-	virtual	~MMAction() {}
-	
-	virtual void InvokeAction() {}
-};
-
-} // End of namespace Pegasus
-
-#endif


Commit: ecd81a9a6d84e74fa89b0905620bcc342ef68da5
    https://github.com/scummvm/scummvm/commit/ecd81a9a6d84e74fa89b0905620bcc342ef68da5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-07T10:13:34-07:00

Commit Message:
PEGASUS: Add Idler framework

Changed paths:
  A engines/pegasus/timers.cpp
  A engines/pegasus/timers.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 8d3ee52..50e9b54 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -13,6 +13,7 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	sound.o \
+	timers.o \
 	util.o \
 	video.o \
 	items/inventory.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 3093e9b..466945e 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -34,6 +34,7 @@
 #include "pegasus/console.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/timers.h"
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
@@ -281,4 +282,17 @@ GUI::Debugger *PegasusEngine::getDebugger() {
 	return _console;
 }
 
+void PegasusEngine::addIdler(Idler *idler) {
+	_idlers.push_back(idler);
+}
+
+void PegasusEngine::removeIdler(Idler *idler) {
+	_idlers.remove(idler);
+}
+
+void PegasusEngine::giveIdleTime() {
+	for (Common::List<Idler *>::iterator it = _idlers.begin(); it != _idlers.end(); it++)
+		(*it)->useIdleTime();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 5c85251..53593c1 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -23,6 +23,7 @@
 #ifndef PEGASUS_H
 #define PEGASUS_H
 
+#include "common/list.h"
 #include "common/macresman.h"
 #include "common/scummsys.h"
 #include "common/system.h"
@@ -46,6 +47,7 @@ struct PegasusGameDescription;
 class SoundManager;
 class VideoManager;
 class GraphicsManager;
+class Idler;
 
 enum ItemLocation {
 	kItemLocationCaldoria = 0,
@@ -96,6 +98,9 @@ public:
 
 	bool isDemo() const;
 
+	void addIdler(Idler *idler);
+	void removeIdler(Idler *idler);
+
 private:
 	// Intro
 	void runIntro();
@@ -141,6 +146,10 @@ private:
 	// Intro Directory Code
 	bool detectOpeningClosingDirectory();
 	Common::String _introDirectory;
+
+	// Idlers
+	Common::List<Idler *> _idlers;
+	void giveIdleTime();
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
new file mode 100755
index 0000000..5908854
--- /dev/null
+++ b/engines/pegasus/timers.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+Idler::Idler() {
+	_isIdling = false;
+}
+
+Idler::~Idler() {
+	stopIdling();
+}
+
+void Idler::startIdling() {
+	if (!isIdling()) {
+		((PegasusEngine *)g_engine)->addIdler(this);
+		_isIdling = true;
+	}
+}
+
+void Idler::stopIdling() {
+	if (isIdling()) {
+		((PegasusEngine *)g_engine)->removeIdler(this);
+		_isIdling = false;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
new file mode 100755
index 0000000..e4bb410
--- /dev/null
+++ b/engines/pegasus/timers.h
@@ -0,0 +1,50 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+ 
+#ifndef PEGASUS_TIMERS_H
+#define PEGASUS_TIMERS_H
+
+namespace Pegasus {
+
+class Idler {
+friend class PegasusEngine;
+
+public:
+	Idler();
+	virtual ~Idler();
+	
+	virtual void startIdling();
+	virtual void stopIdling();
+	bool isIdling() const { return _isIdling; }
+	
+protected:
+	virtual void useIdleTime() {}
+
+	bool _isIdling;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 715c95ecfc30f53bdf2f35ab883654ea80ee154b
    https://github.com/scummvm/scummvm/commit/715c95ecfc30f53bdf2f35ab883654ea80ee154b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-08T10:11:38-07:00

Commit Message:
PEGASUS: Fix stupid bugs in the item code

Changed paths:
    engines/pegasus/items/biochips/biochipitem.cpp
    engines/pegasus/items/inventory/inventoryitem.cpp
    engines/pegasus/items/item.cpp



diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
index a291a53..71065f1 100755
--- a/engines/pegasus/items/biochips/biochipitem.cpp
+++ b/engines/pegasus/items/biochips/biochipitem.cpp
@@ -34,7 +34,7 @@ namespace Pegasus {
 BiochipItem::BiochipItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
 		Item(id, neighborhood, room, direction) {
 
-	PegasusEngine *vm = (PegasusEngine *)vm;
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
 
 	Common::SeekableReadStream *biochipInfo = vm->_resFork->getResource(MKTAG('B', 'i', 'o', 'I'), kItemBaseResID + id);
 	if (biochipInfo) {
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
index 8682911..ffa745a 100755
--- a/engines/pegasus/items/inventory/inventoryitem.cpp
+++ b/engines/pegasus/items/inventory/inventoryitem.cpp
@@ -33,7 +33,7 @@ namespace Pegasus {
 InventoryItem::InventoryItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
 		Item(id, neighborhood, room, direction) {
 
-	PegasusEngine *vm = (PegasusEngine *)vm;
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
 
 	Common::SeekableReadStream *leftInfo = vm->_resFork->getResource(MKTAG('L', 'e', 'f', 't'), kItemBaseResID + id);
 	if (leftInfo) {
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index cdd8129..126bbfe 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -48,8 +48,8 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
 		_itemInfo.infoLeftTime = info->readUint32BE();
 		_itemInfo.infoRightStart = info->readUint32BE();
 		_itemInfo.infoRightStop = info->readUint32BE();
-		_itemInfo.dragSpriteNormalID = info->readUint32BE();
-		_itemInfo.dragSpriteUsedID = info->readUint32BE();
+		_itemInfo.dragSpriteNormalID = info->readUint16BE();
+		_itemInfo.dragSpriteUsedID = info->readUint16BE();
 
 		if (vm->isDemo()) {
 			// Adjust info right times to account for the stuff that was chopped out of the
@@ -95,18 +95,20 @@ Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID r
 	}
 
 	Common::SeekableReadStream *middleAreaInfo = vm->_resFork->getResource(kMiddleAreaInfoResType, kItemBaseResID + id);
-	if (!middleAreaInfo)
-		error("Middle area info not found for item %d", id);
-
-	_sharedAreaInfo = readItemState(middleAreaInfo);
-
-	delete middleAreaInfo;
+	if (middleAreaInfo) {
+		_sharedAreaInfo = readItemState(middleAreaInfo);
+		delete middleAreaInfo;
+	} else {
+		// Only kArgonPickup does not have this
+		memset(&_sharedAreaInfo, 0, sizeof(_sharedAreaInfo));
+	}
 
 	Common::SeekableReadStream *extraInfo = vm->_resFork->getResource(kItemExtraInfoResType, kItemBaseResID + id);
 	if (!extraInfo)
 		error("Extra info not found for item %d", id);
 
 	_itemExtras.numEntries = extraInfo->readUint16BE();
+	_itemExtras.entries = new ItemExtraEntry[_itemExtras.numEntries];
 	for (uint16 i = 0; i < _itemExtras.numEntries; i++) {
 		_itemExtras.entries[i].extraID = extraInfo->readUint32BE();
 		_itemExtras.entries[i].extraArea = extraInfo->readUint16BE();
@@ -255,6 +257,7 @@ ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
 	ItemStateInfo info;
 
 	info.numEntries = stream->readUint16BE();
+	info.entries = new ItemStateEntry[info.numEntries];
 	for (uint16 i = 0; i < info.numEntries; i++) {
 		info.entries[i].itemState = stream->readSint16BE();
 		info.entries[i].itemTime = stream->readUint32BE();


Commit: 0e14012edd8341842c8f14fbe7eeec266fdb17b5
    https://github.com/scummvm/scummvm/commit/0e14012edd8341842c8f14fbe7eeec266fdb17b5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-08T10:12:26-07:00

Commit Message:
PEGASUS: Begin loading items

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 466945e..d6b3d54 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -35,6 +35,8 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
@@ -76,7 +78,7 @@ Common::Error PegasusEngine::run() {
 	if (!_biochipLid->open("Images/Lids/Biochip Lid Sequence") || !_biochipLid->hasResFork())
 		error("Could not open Biochip Lid Sequence");
 
-	loadItemLocationData();
+	createItems();
 
 	if (!isDemo() && !detectOpeningClosingDirectory()) {
 		Common::String message = "Missing intro directory. ";
@@ -191,25 +193,51 @@ bool PegasusEngine::detectOpeningClosingDirectory() {
 	return true;
 }
 
-void PegasusEngine::loadItemLocationData() {
+void PegasusEngine::createItems() {
 	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 
 	uint16 entryCount = res->readUint16BE();
 
 	for (uint16 i = 0; i < entryCount; i++) {
-		ItemLocationData loc;
-		loc.id = res->readUint16BE(); // Which is always == i, anyway
-		loc.location = (ItemLocation)res->readUint16BE();
-		loc.u0 = res->readUint16BE();
-		loc.u1 = res->readByte();
-		debug(1, "Item[%d]: ID = %d, location = %x, u0 = %d, u1 = %d", i, loc.id, loc.location, loc.u0, loc.u1);
-		res->readByte();
-		_itemLocationData.push_back(loc);
+		tItemID itemID = res->readUint16BE();
+		tNeighborhoodID neighborhoodID = res->readUint16BE();
+		tRoomID roomID = res->readUint16BE();
+		tDirectionConstant direction = res->readByte();
+		res->readByte(); // alignment
+
+		createItem(itemID, neighborhoodID, roomID, direction);
 	}
 
 	delete res;
 }
 
+void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction) {
+	switch (itemID) {
+	case kInterfaceBiochip:
+		// Unused in game, but still in the data - no need to load it
+		break;
+	case kMapBiochip:
+	case kAIBiochip:
+	case kPegasusBiochip:
+	case kRetinalScanBiochip:
+	case kShieldBiochip:
+	case kOpticalBiochip:
+		// TODO: Specialized biochip classes
+		new BiochipItem(itemID, neighborhoodID, roomID, direction);
+		break;
+	case kAirMask:
+	case kKeyCard:
+	case kGasCanister:
+		// TODO: Specialized inventory item classes
+		new InventoryItem(itemID, neighborhoodID, roomID, direction);
+		break;
+	default:
+		// Everything else is a normal inventory item
+		new InventoryItem(itemID, neighborhoodID, roomID, direction);
+		break;
+	}
+}
+
 void PegasusEngine::runIntro() {
 	_video->playMovieCentered(_introDirectory + "/BandaiLogo.movie");
 	VideoHandle handle = _video->playBackgroundMovie(_introDirectory + "/Big Movie.movie");
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 53593c1..e013565 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -49,25 +49,8 @@ class VideoManager;
 class GraphicsManager;
 class Idler;
 
-enum ItemLocation {
-	kItemLocationCaldoria = 0,
-	kItemLocationTSA = 1,
-	kItemLocationNorad = 4, // ???
-	kItemLocationMars = 5,
-	kItemLocationWSC = 6,
-	kItemLocationPrehistoric = 7,
-	kItemLocationBuiltIn = 0xffff
-};
-
 static const int kViewScreenOffset = 64;
 
-struct ItemLocationData {
-	uint16 id;
-	ItemLocation location;
-	uint16 u0;
-	byte u1;
-};
-
 struct OverviewHotspot {
 	Common::Rect rect;
 	uint32 time;
@@ -128,7 +111,6 @@ private:
 
 	// Main Game Functions
 	void mainGameLoop();
-	void loadItemLocationData();
 	void changeLocation(tNeighborhoodID neighborhood);
 
 	// Misc Functions
@@ -138,7 +120,6 @@ private:
 	// Game Variables
 	bool _adventureMode;
 	GameMode _gameMode;
-	Common::Array<ItemLocationData> _itemLocationData;
 
 	// Console
 	PegasusConsole *_console;
@@ -150,6 +131,10 @@ private:
 	// Idlers
 	Common::List<Idler *> _idlers;
 	void giveIdleTime();
+
+	// Items
+	void createItems();
+	void createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction);
 };
 
 } // End of namespace Pegasus


Commit: 5a7ca3553ca480021c0992e83e9644eeeba2f724
    https://github.com/scummvm/scummvm/commit/5a7ca3553ca480021c0992e83e9644eeeba2f724
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-08T17:38:12-07:00

Commit Message:
PEGASUS: Create separate Cursor class for cursors

Changed paths:
  A engines/pegasus/cursor.cpp
  A engines/pegasus/cursor.h
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/module.mk
    engines/pegasus/overview.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
new file mode 100755
index 0000000..c0af27b
--- /dev/null
+++ b/engines/pegasus/cursor.cpp
@@ -0,0 +1,179 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/events.h"
+#include "common/stream.h"
+#include "common/system.h"
+#include "graphics/cursorman.h"
+#include "graphics/pict.h"
+#include "graphics/surface.h"
+
+#include "pegasus/cursor.h"
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+Cursor::Cursor() {
+	_cursorObscured = false;
+	_index = -1;
+}
+
+Cursor::~Cursor() {
+	for (uint32 i = 0; i < _info.size(); i++) {
+		if (_info[i].surface) {
+			_info[i].surface->free();
+			delete _info[i].surface;
+		}
+		delete[] _info[i].palette;
+	}
+}
+
+void Cursor::addCursorFrames(uint16 id) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	Common::SeekableReadStream *cursStream = vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), id);
+	if (!cursStream)
+		error("Could not load cursor frames set %d", id);
+
+	uint16 frameCount = cursStream->readUint16BE();
+	for (uint16 i = 0; i < frameCount; i++) {
+		CursorInfo info;
+		info.tag = cursStream->readUint16BE();
+		info.hotspot.x = cursStream->readUint16BE();
+		info.hotspot.y = cursStream->readUint16BE();
+		info.surface = 0;
+		info.palette = 0;
+		info.colorCount = 0;
+		_info.push_back(info);
+	}
+
+	delete cursStream;
+
+	setCurrentFrameIndex(0);
+}
+
+void Cursor::setCurrentFrameIndex(int32 index) {
+	if (_index != index) {
+		_index = index;
+		if (index != -1) {
+			loadCursorImage(_info[index]);
+			CursorMan.replaceCursorPalette(_info[index].palette, 0, _info[index].colorCount);
+			CursorMan.replaceCursor((byte *)_info[index].surface->pixels, _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, 0);
+		}
+	}
+}
+
+int32 Cursor::getCurrentFrameIndex() const {
+	return _index;
+}
+
+void Cursor::show() {
+	if (!isVisible())
+		CursorMan.showMouse(true);
+
+	_cursorObscured = false;
+}
+
+void Cursor::hide() {
+	CursorMan.showMouse(false);
+	setCurrentFrameIndex(0);
+}
+
+void Cursor::hideUntilMoved() {
+	if (!_cursorObscured) {
+		hide();
+		_cursorObscured = true;
+	}
+}
+
+void Cursor::useIdleTime() {
+	if (g_system->getEventManager()->getMousePos() != _cursorLocation) {
+		_cursorLocation = g_system->getEventManager()->getMousePos();
+		if (_index != -1 && _cursorObscured)
+			show();
+	}
+}
+
+void Cursor::getCursorLocation(Common::Point &pt) const {
+	pt = _cursorLocation;
+}
+
+bool Cursor::isVisible() {
+	return CursorMan.isVisible();
+}
+
+void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
+	if (cursorInfo.surface)
+		return;
+
+	cursorInfo.surface = new Graphics::Surface();
+
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	Common::SeekableReadStream *cicnStream = vm->_resFork->getResource(MKTAG('c', 'i', 'c', 'n'), cursorInfo.tag);
+
+	if (!cicnStream)
+		error("Failed to find color icon %d", cursorInfo.tag);
+	
+	// PixMap section
+	Graphics::PictDecoder::PixMap pixMap = Graphics::PictDecoder::readPixMap(cicnStream);
+	
+	// Mask section
+	cicnStream->readUint32BE(); // mask baseAddr
+	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
+	cicnStream->skip(3 * 2); // mask rect
+	/* uint16 maskHeight = */ cicnStream->readUint16BE();
+
+	// Bitmap section
+	cicnStream->readUint32BE(); // baseAddr
+	uint16 rowBytes = cicnStream->readUint16BE();
+	cicnStream->readUint16BE(); // top
+	cicnStream->readUint16BE(); // left
+	uint16 height = cicnStream->readUint16BE(); // bottom
+	cicnStream->readUint16BE(); // right
+	
+	// Data section
+	cicnStream->readUint32BE(); // icon handle
+	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
+	cicnStream->skip(rowBytes * height);
+	
+	// Palette section
+	cicnStream->readUint32BE(); // always 0
+	cicnStream->readUint16BE(); // always 0
+	cursorInfo.colorCount = cicnStream->readUint16BE() + 1;
+	
+	cursorInfo.palette = new byte[256 * cursorInfo.colorCount];
+	for (uint16 i = 0; i < cursorInfo.colorCount; i++) {
+		cicnStream->readUint16BE();
+		cursorInfo.palette[i * 3] = cicnStream->readUint16BE() >> 8;
+		cursorInfo.palette[i * 3 + 1] = cicnStream->readUint16BE() >> 8;
+		cursorInfo.palette[i * 3 + 2] = cicnStream->readUint16BE() >> 8;
+	}
+	
+	// PixMap data
+	cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
+	cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height());
+	delete cicnStream;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/cursor.h b/engines/pegasus/cursor.h
new file mode 100755
index 0000000..ada82e3
--- /dev/null
+++ b/engines/pegasus/cursor.h
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_CURSOR_H
+#define PEGASUS_CURSOR_H
+
+#include "common/array.h"
+#include "common/rect.h"
+
+#include "pegasus/timers.h"
+
+namespace Graphics {
+	struct Surface;
+}
+
+namespace Pegasus {
+
+// The original cursor code was in the graphics code directly,
+// unlike ScummVM where we have the cursor code separate. We're
+// going to go with CursorManager here and therefore not inherit
+// from the Sprite class.
+
+class Cursor : private Idler {
+public:
+	Cursor();
+	virtual ~Cursor();
+
+	void addCursorFrames(uint16 id);
+
+	void setCurrentFrameIndex(int32 index);
+	int32 getCurrentFrameIndex() const;
+
+	void show();
+	void hide();
+	void hideUntilMoved();
+	bool isVisible();
+
+	void getCursorLocation(Common::Point &) const;
+
+protected:
+	virtual void useIdleTime();
+
+private:
+	struct CursorInfo {
+		uint16 tag;
+		Common::Point hotspot;
+		Graphics::Surface *surface;
+		byte *palette;
+		uint16 colorCount;
+	};
+
+	Common::Point _cursorLocation;
+	Common::Array<CursorInfo> _info;
+	bool _cursorObscured;
+	int _index;
+
+	void loadCursorImage(CursorInfo &cursorInfo);
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 2042b8f..28aafdb 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -26,7 +26,6 @@
 #include "common/file.h"
 #include "common/textconsole.h"
 #include "engines/util.h"
-#include "graphics/cursorman.h"
 
 namespace Pegasus {
 	
@@ -135,83 +134,6 @@ uint32 GraphicsManager::getColor(byte r, byte g, byte b) {
 	return _vm->_system->getScreenFormat().RGBToColor(r, g, b);
 }
 
-void GraphicsManager::setCursor(uint16 cursor) {
-	Common::SeekableReadStream *cicnStream = _vm->_resFork->getResource(MKTAG('c', 'i', 'c', 'n'), cursor);
-	
-	// PixMap section
-	Graphics::PictDecoder::PixMap pixMap = _pictDecoder->readPixMap(cicnStream);
-	
-	// Mask section
-	cicnStream->readUint32BE(); // mask baseAddr
-	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
-	cicnStream->skip(3 * 2); // mask rect
-	/* uint16 maskHeight = */ cicnStream->readUint16BE();
-
-	// Bitmap section
-	cicnStream->readUint32BE(); // baseAddr
-	uint16 rowBytes = cicnStream->readUint16BE();
-	cicnStream->readUint16BE(); // top
-	cicnStream->readUint16BE(); // left
-	uint16 height = cicnStream->readUint16BE(); // bottom
-	cicnStream->readUint16BE(); // right
-	
-	// Data section
-	cicnStream->readUint32BE(); // icon handle
-	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
-	cicnStream->skip(rowBytes * height);
-	
-	// Palette section
-	cicnStream->readUint32BE(); // always 0
-	cicnStream->readUint16BE(); // always 0
-	uint16 colorCount = cicnStream->readUint16BE() + 1;
-	
-	byte *colors = new byte[256 * 3];;
-	for (uint16 i = 0; i < colorCount; i++) {
-		cicnStream->readUint16BE();
-		colors[i * 3] = cicnStream->readUint16BE() >> 8;
-		colors[i * 3 + 1] = cicnStream->readUint16BE() >> 8;
-		colors[i * 3 + 2] = cicnStream->readUint16BE() >> 8;
-	}
-	
-	// PixMap data
-	byte *data = new byte[pixMap.rowBytes * pixMap.bounds.height()];
-	cicnStream->read(data, pixMap.rowBytes * pixMap.bounds.height());
-	delete cicnStream;
-	
-	// Now to go get the hotspots
-	Common::SeekableReadStream *cursStream = NULL;
-	
-	if (cursor >= kMainCursor && cursor <= kGrabbingHand)
-		cursStream = _vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), kMainCursor);
-	else // if (cursor == kTargetingReticle1 || cursor == kTargetingReticle2)
-		cursStream = _vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), kTargetingReticle1);
-
-	// Go through the stream until we find the right cursor hotspot
-	uint16 x = 0, y = 0;
-	uint16 numHotspots = cursStream->readUint16BE();
-	
-	for (uint16 i = 0; i < numHotspots; i++) {
-		uint16 res = cursStream->readUint16BE();
-		uint16 tempX = cursStream->readUint16BE();
-		uint16 tempY = cursStream->readUint16BE();
-		
-		if (res == cursor) {
-			x = tempX;
-			y = tempY;
-			break;
-		}
-	}
-	
-	// We have the bitmap and the hotspot, let's do this!
-	CursorMan.replaceCursorPalette(colors, 0, colorCount);
-	CursorMan.replaceCursor(data, pixMap.rowBytes, pixMap.bounds.height(), x, y, 0);
-	CursorMan.showMouse(true);
-	_vm->_system->updateScreen();
-
-	delete[] colors;
-	delete[] data;
-}
-
 int GraphicsManager::getImageSlot(const Common::String &filename) {
 	// Let's find a match, an open slot, or the oldest image slot
 	uint32 oldestAge = 0xffffffff;
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 7607c62..4135373 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -34,20 +34,6 @@
 namespace Pegasus {
 
 enum {
-	// The main cursors
-	kMainCursor = 128,
-	kZoomInCursor = 129,
-	kZoomOutCursor = 130,
-	kPointingCursor = 131,
-	kInteractHand = 132,
-	kGrabbingHand = 133,
-	
-	// Reticles when using the Mars shuttle
-	kTargetingReticle1 = 900,
-	kTargetingReticle2 = 901
-}; 
-
-enum {
 	kImageCacheSize = 10
 };
 
@@ -66,7 +52,6 @@ public:
 
 	void drawPict(Common::String filename, int x, int y, bool updateScreen = true);
 	void drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen = true);
-	void setCursor(uint16 cursor);
 	uint32 getColor(byte r, byte g, byte b);
 	
 private:		
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 50e9b54..06cfd03 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/pegasus
 MODULE_OBJS = \
 	console.o \
 	credits.o \
+	cursor.o \
 	detection.o \
 	gamestate.o \
 	graphics.o \
diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
index adbfbdb..8e82708 100644
--- a/engines/pegasus/overview.cpp
+++ b/engines/pegasus/overview.cpp
@@ -25,13 +25,14 @@
 #include "graphics/cursorman.h"
 #include "video/qt_decoder.h"
 
+#include "pegasus/cursor.h"
 #include "pegasus/pegasus.h"
 
 namespace Pegasus {
 
 void PegasusEngine::runInterfaceOverview() {
-	CursorMan.showMouse(true);
-	_gfx->setCursor(kPointingCursor);
+	_cursor->setCurrentFrameIndex(3);
+	_cursor->show();
 
 	Video::QuickTimeDecoder *overviewVideo = new Video::QuickTimeDecoder();
 	if (!overviewVideo->loadFile("Images/Interface/Overview Mac.movie"))
@@ -103,7 +104,7 @@ void PegasusEngine::runInterfaceOverview() {
 		_system->delayMillis(10);
 	}
 
-	CursorMan.showMouse(false);
+	_cursor->hide();
 	delete overviewVideo;
 }
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d6b3d54..f604a24 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -32,6 +32,7 @@
 #include "gui/saveload.h"
 
 #include "pegasus/console.h"
+#include "pegasus/cursor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
@@ -42,7 +43,7 @@
 //#define RUN_INTERFACE_TEST
 
 #ifdef RUN_INTERFACE_TEST
-#include "pegasus/MMShell/Sounds/MMSound.h"
+#include "pegasus/sound.h"
 #endif
 
 namespace Pegasus {
@@ -57,6 +58,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _inventoryLid;
 	delete _biochipLid;
 	delete _console;
+	delete _cursor;
 }
 
 Common::Error PegasusEngine::run() {
@@ -66,6 +68,7 @@ Common::Error PegasusEngine::run() {
 	_resFork = new Common::MacResManager();
 	_inventoryLid = new Common::MacResManager();
 	_biochipLid = new Common::MacResManager();
+	_cursor = new Cursor();
 	_gameMode = kIntroMode;
 	_adventureMode = true;
 	
@@ -78,8 +81,13 @@ Common::Error PegasusEngine::run() {
 	if (!_biochipLid->open("Images/Lids/Biochip Lid Sequence") || !_biochipLid->hasResFork())
 		error("Could not open Biochip Lid Sequence");
 
+	// Initialize items
 	createItems();
 
+	// Initialize cursors
+	_cursor->addCursorFrames(0x80); // Main
+	_cursor->addCursorFrames(900);  // Mars Shuttle
+
 	if (!isDemo() && !detectOpeningClosingDirectory()) {
 		Common::String message = "Missing intro directory. ";
 
@@ -116,11 +124,12 @@ Common::Error PegasusEngine::run() {
 #if defined(RUN_SUB_MOVIE)
 	_video->playMovie("Images/Norad Alpha/Sub Chase Movie");
 #elif defined(RUN_INTERFACE_TEST)
+	_cursor->setCurrentFrameIndex(0);
+	_cursor->show();
 	drawInterface();
-	_gfx->setCursor(kMainCursor);
-	MMSound sound;
-	sound.InitFromAIFFFile("Sounds/Caldoria/Apartment Music.aiff");
-	sound.LoopSound();
+	Sound sound;
+	sound.initFromAIFFFile("Sounds/Caldoria/Apartment Music.aiff");
+	sound.loopSound();
 
 	while (!shouldQuit()) {
 		Common::Event event;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index e013565..35ee117 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -48,6 +48,7 @@ class SoundManager;
 class VideoManager;
 class GraphicsManager;
 class Idler;
+class Cursor;
 
 static const int kViewScreenOffset = 64;
 
@@ -131,6 +132,7 @@ private:
 	// Idlers
 	Common::List<Idler *> _idlers;
 	void giveIdleTime();
+	Cursor *_cursor;
 
 	// Items
 	void createItems();


Commit: e532af93180c53a80bd4a7e96ab42e7e67e13e97
    https://github.com/scummvm/scummvm/commit/e532af93180c53a80bd4a7e96ab42e7e67e13e97
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-08T20:04:28-07:00

Commit Message:
PEGASUS: Add and hookup the InputHandler class

Changed paths:
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index bb147fb..37f9945 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -26,7 +26,9 @@
 #include "common/events.h"
 #include "common/system.h"
 
+#include "pegasus/cursor.h"
 #include "pegasus/input.h"
+#include "pegasus/pegasus.h"
 
 namespace Pegasus {
 
@@ -135,4 +137,134 @@ int operator!=(const Input &arg1, const Input &arg2) {
 	return !operator==(arg1, arg2);
 }
 
+InputHandler *InputHandler::_inputHandler = 0;
+InputDevice InputHandler::_inputDevice;
+bool InputHandler::_invalHotspots = false;
+tInputBits InputHandler::_lastFilter = kFilterNoInput;
+
+InputHandler *InputHandler::setInputHandler(InputHandler *currentHandler) {
+	InputHandler *result = 0;
+
+	if (_inputHandler != currentHandler && (!_inputHandler || _inputHandler->releaseInputFocus())) {
+		result = _inputHandler;
+		_inputHandler = currentHandler;
+		if (_inputHandler)
+			_inputHandler->grabInputFocus();
+	}
+
+	return result;
+}
+
+void InputHandler::pollForInput() {
+	if (_inputHandler) {
+		Input input;
+		Hotspot *cursorSpot;
+
+		InputHandler::getInput(input, cursorSpot);
+		if (_inputHandler->isClickInput(input, cursorSpot))
+			_inputHandler->clickInHotspot(input, cursorSpot);
+		else
+			_inputHandler->handleInput(input, cursorSpot);
+	}
+}
+
+void InputHandler::getInput(Input &input, Hotspot *&cursorSpot) {
+	Cursor *cursor = ((PegasusEngine *)g_engine)->_cursor;
+	
+	if (_inputHandler)
+		_lastFilter = _inputHandler->getInputFilter();
+	else
+		_lastFilter = kFilterAllInput;
+
+	_inputDevice.getInput(input, _lastFilter);
+
+	if (_inputHandler && _inputHandler->wantsCursor() && (_lastFilter & _inputHandler->getClickFilter()) != 0) {
+		if (cursor->isVisible()) {
+			g_allHotspots.deactivateAllHotspots();
+			_inputHandler->activateHotspots();
+
+			Common::Point cursorLocation;
+			cursor->getCursorLocation(cursorLocation);
+			cursorSpot = g_allHotspots.findHotspot(cursorLocation);
+
+			if (_inputHandler)
+				_inputHandler->updateCursor(cursorLocation, cursorSpot);
+		} else {
+			cursor->hideUntilMoved();
+		}
+	} else {
+		cursor->hide();
+	}
+}
+
+void InputHandler::readInputDevice(Input &input) {
+	_inputDevice.getInput(input, kFilterAllInput);
+}
+
+InputHandler::InputHandler(InputHandler *nextHandler) {
+	_nextHandler = nextHandler;
+	allowInput(true);
+}
+
+InputHandler::~InputHandler() {
+	if (_inputHandler == this)
+		setInputHandler(_nextHandler);
+}
+
+void InputHandler::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_nextHandler)
+		_nextHandler->handleInput(input, cursorSpot);
+}
+
+void InputHandler::clickInHotspot(const Input &input, const Hotspot *cursorSpot) {
+	if (_nextHandler)
+		_nextHandler->clickInHotspot(input, cursorSpot);
+}
+
+bool InputHandler::isClickInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_nextHandler)
+		return _nextHandler->isClickInput(input, cursorSpot);
+
+	return false;
+}
+
+void InputHandler::activateHotspots() {
+	if (_nextHandler)
+		_nextHandler->activateHotspots();
+}
+
+tInputBits InputHandler::getInputFilter() {
+	if (_allowInput) {
+		if (_nextHandler)
+			return _nextHandler->getInputFilter();
+		else
+			return kFilterAllInput;
+	}
+
+	return kFilterNoInput;
+}
+
+tInputBits InputHandler::getClickFilter() {
+	if (_allowInput && _nextHandler)
+		return _nextHandler->getClickFilter();
+
+	return kFilterNoInput;
+}
+
+void InputHandler::updateCursor(const Common::Point cursorLocation, const Hotspot *cursorSpot) {
+	if (_nextHandler)
+		_nextHandler->updateCursor(cursorLocation, cursorSpot);
+}
+
+bool InputHandler::wantsCursor() {
+	if (_allowInput) {
+		if (_nextHandler)
+			return _nextHandler->wantsCursor();
+		else
+			return true;
+	}
+
+	return false;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 463e3d0..432ff80 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -368,6 +368,52 @@ protected:
 	Common::Point _inputLocation;
 };
 
+class InputHandler {
+public:
+	static InputHandler *setInputHandler(InputHandler*);
+	static InputHandler *getCurrentHandler() { return _inputHandler; }
+	static InputDevice *getCurrentInputDevice() { return &_inputDevice; }
+	static void pollForInput();
+	static void getInput(Input&, Hotspot*&);
+	static void readInputDevice(Input&);
+	static void invalHotspots() { _invalHotspots = true; }
+	static tInputBits getCurrentFilter() { return _lastFilter; }
+		
+	InputHandler(InputHandler*);
+	virtual ~InputHandler();
+	
+	virtual void setNextHandler(InputHandler *nextHandler) { _nextHandler = nextHandler; }
+	virtual InputHandler *getNextHandler() { return _nextHandler; }
+	
+	virtual void handleInput(const Input&, const Hotspot*);
+	virtual void clickInHotspot(const Input&, const Hotspot*);
+	
+	virtual void activateHotspots();
+	virtual void updateCursor(const Common::Point, const Hotspot*);
+	virtual bool isClickInput(const Input&, const Hotspot*);
+	virtual bool wantsCursor();
+	
+	virtual bool releaseInputFocus() { return true; }
+	virtual void grabInputFocus() {}
+	
+	//	This returns bits set for what kinds of input to accept.
+	virtual tInputBits getInputFilter();
+
+	//	This returns bits defining what input constitutes a "click."
+	virtual tInputBits getClickFilter();
+
+	virtual void allowInput(const bool allow) { _allowInput = allow; }
+
+protected:
+	static InputHandler *_inputHandler;
+	static InputDevice _inputDevice; // TODO: Remove global constructor
+	static bool _invalHotspots;
+	static tInputBits _lastFilter;
+	
+	InputHandler *_nextHandler;
+	bool _allowInput;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 461f4b0..75a8df9 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -33,7 +33,7 @@
 
 namespace Pegasus {
 
-Neighborhood::Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : IDObject(id), _vm(vm), _resName(resName) {
+Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 	_interruptionFilter = kFilterAllInput;
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index baeed7d..d294ffe 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -84,9 +84,9 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
 typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
-class Neighborhood : public IDObject, public NotificationReceiver {
+class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler {
 public:
-	Neighborhood(PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
+	Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
 
 	virtual void init();
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index f604a24..39eb7d5 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -48,7 +48,7 @@
 
 namespace Pegasus {
 
-PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
+PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc) {
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -279,7 +279,7 @@ void PegasusEngine::changeLocation(tNeighborhoodID neighborhood) {
 	GameState.setCurrentNeighborhood(neighborhood);
 
 	// Just a test...
-	Neighborhood *neighborhoodPtr = new Neighborhood(this, getTimeZoneDesc(neighborhood), neighborhood);
+	Neighborhood *neighborhoodPtr = new Neighborhood(this, this, getTimeZoneDesc(neighborhood), neighborhood);
 	neighborhoodPtr->init();
 	delete neighborhoodPtr;
 }
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 35ee117..8ab891d 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -33,6 +33,7 @@
 #include "engines/engine.h"
 
 #include "pegasus/graphics.h"
+#include "pegasus/input.h"
 #include "pegasus/video.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
@@ -64,9 +65,8 @@ enum GameMode {
 	kQuitMode
 };
 
-class PegasusEngine : public ::Engine {
-protected:
-	Common::Error run();
+class PegasusEngine : public ::Engine, public InputHandler {
+friend class InputHandler;
 
 public:
 	PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc);
@@ -85,6 +85,11 @@ public:
 	void addIdler(Idler *idler);
 	void removeIdler(Idler *idler);
 
+protected:
+	Common::Error run();
+
+	Cursor *_cursor;
+
 private:
 	// Intro
 	void runIntro();
@@ -132,7 +137,6 @@ private:
 	// Idlers
 	Common::List<Idler *> _idlers;
 	void giveIdleTime();
-	Cursor *_cursor;
 
 	// Items
 	void createItems();


Commit: bbda19ab8033d67d2f2ea72e2ddb9a0b925fa0ac
    https://github.com/scummvm/scummvm/commit/bbda19ab8033d67d2f2ea72e2ddb9a0b925fa0ac
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-09T11:09:20-07:00

Commit Message:
PEGASUS: Add DisplayElement class and begin porting over the graphics API

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 28aafdb..cec8595 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -4,6 +4,9 @@
  * are too numerous to list here. Please refer to the COPYRIGHT
  * file distributed with this source distribution.
  *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -19,7 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
- 
+
 #include "pegasus/graphics.h"
 
 #include "common/endian.h"
@@ -28,17 +31,149 @@
 #include "engines/util.h"
 
 namespace Pegasus {
-	
+
+DisplayElement::DisplayElement(const tDisplayElementID id) : IDObject(id) {
+	_elementIsDisplaying = false;
+	_elementIsVisible = false;
+	_elementOrder = 0;
+	_triggeredElement = this;
+	_nextElement = 0;
+}
+
+DisplayElement::~DisplayElement() {
+	if (isDisplaying())
+		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+}
+
+void DisplayElement::setDisplayOrder(const tDisplayOrder order) {
+	if (_elementOrder != order) {
+		_elementOrder = order;
+		if (isDisplaying()) {
+			((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+			((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
+			triggerRedraw();
+		}
+	}
+}
+
+void DisplayElement::startDisplaying() {
+	if (!isDisplaying()) {
+		((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
+		triggerRedraw();
+	}
+}
+
+void DisplayElement::stopDisplaying() {
+	if (isDisplaying()) {
+		triggerRedraw();
+		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+	}
+}
+
+void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
+	_bounds = Common::Rect(left, top, right, bottom);
+}
+
+void DisplayElement::getBounds(Common::Rect &r) const {
+	r = _bounds;
+}
+
+void DisplayElement::sizeElement(const tCoordType h, const tCoordType v) {
+	_bounds.right = _bounds.left + h;
+	_bounds.bottom = _bounds.top + v;
+}
+
+void DisplayElement::moveElementTo(const tCoordType h, const tCoordType v) {
+	_bounds.moveTo(h, v);
+}
+
+void DisplayElement::moveElement(const tCoordType dh, const tCoordType dv) {
+	_bounds.translate(dh, dv);
+}
+
+void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
+	h = _bounds.left;
+	v = _bounds.top;
+}
+
+void DisplayElement::centerElementAt(const tCoordType h, const tCoordType v) {
+	_bounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
+}
+
+void DisplayElement::getCenter(tCoordType &h, tCoordType &v) const {
+	h = (_bounds.left + _bounds.right) / 2;
+	v = (_bounds.top + _bounds.bottom) / 2;
+}
+
+void DisplayElement::setBounds(const Common::Rect &r) {
+	if (r != _bounds) {
+		triggerRedraw();
+		_bounds = r;
+		triggerRedraw();
+	}
+}
+
+void DisplayElement::hide() {
+	if (_elementIsVisible) {
+		triggerRedraw();
+		_elementIsVisible = false;
+	}
+}
+
+void DisplayElement::show() {
+	if (!_elementIsVisible) {
+		_elementIsVisible = true;
+		triggerRedraw();
+	}
+}
+
+//	Only invalidates this element's bounding rectangle if all these conditions are true:
+//	--	The triggered element is this element.
+//	--	The element is displaying on the display list.
+//	--	The element is visible.
+//	--	The element is part of the active layer OR is one of the reserved items.
+void DisplayElement::triggerRedraw() {
+	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+
+	if (_triggeredElement == this) {
+		if (validToDraw(gfx->getBackOfActiveLayer(), gfx->getFrontOfActiveLayer()))
+			gfx->invalRect(_bounds);
+	} else {
+		_triggeredElement->triggerRedraw();
+	}
+}
+
+void DisplayElement::setTriggeredElement(DisplayElement *element) {
+	if (element)
+		_triggeredElement = element;
+	else
+		_triggeredElement = this;
+}
+
+bool DisplayElement::validToDraw(tDisplayOrder backLayer, tDisplayOrder frontLayer) {
+	return	isDisplaying() && _elementIsVisible &&
+			(getObjectID() <= kHighestReservedElementID ||
+			(getDisplayOrder() >= backLayer &&
+			getDisplayOrder() <= frontLayer));
+}
+
 GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	initGraphics(640, 480, true, NULL);
-	
+
+	// Old
 	_pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
 
 	for (int i = 0; i < kImageCacheSize; i++)
 		_cache[i].surface = 0;
+
+	// New
+	_backLayer = kMinAvailableOrder;
+	_frontLayer = kMaxAvailableOrder;
+	_firstDisplayElement = _lastDisplayElement = 0;
 }
 	
 GraphicsManager::~GraphicsManager() {
+	// Old
 	delete _pictDecoder;
 
 	for (int i = 0; i < kImageCacheSize; i++) {
@@ -168,5 +303,99 @@ int GraphicsManager::getImageSlot(const Common::String &filename) {
 	_cache[slot].lastUsed = _vm->_system->getMillis();
 	return slot;
 }
+
+void GraphicsManager::invalRect(const Common::Rect &rect) {
+	// We're using a simpler algorithm for dirty rect handling than the original
+	// The original was way too overcomplicated for what we need here now.
+
+	if (_dirtyRect.width() == 0 || _dirtyRect.height() == 0) {
+		// We have no dirty rect, so this is now our dirty rect
+		_dirtyRect = rect;
+	} else {
+		// Expand our dirty rect to include rect
+		_dirtyRect.left = MIN<int>(_dirtyRect.left, rect.left);
+		_dirtyRect.top = MIN<int>(_dirtyRect.top, rect.top);
+		_dirtyRect.right = MAX<int>(_dirtyRect.right, rect.right);
+		_dirtyRect.bottom = MAX<int>(_dirtyRect.bottom, rect.bottom);
+	}
+}
+
+void GraphicsManager::addDisplayElement(DisplayElement *newElement) {
+	newElement->_elementOrder = CLIP<int>(newElement->_elementOrder, kMinAvailableOrder, kMaxAvailableOrder);
+
+	if (_firstDisplayElement) {
+		DisplayElement *runner = _firstDisplayElement;
+		DisplayElement *lastRunner = 0;
+
+		// Search for first element whose display order is greater than
+		// the new element's and add the new element just before it.
+		while (runner) {
+			if (newElement->_elementOrder < runner->_elementOrder) {
+				if (lastRunner) {
+					lastRunner->_nextElement = newElement;
+					newElement->_nextElement = runner;
+				} else {
+					newElement->_nextElement = _firstDisplayElement;
+					_firstDisplayElement = newElement;
+				}
+				break;
+			}
+			lastRunner = runner;
+			runner = runner->_nextElement;
+		}
+
+		// If got here and runner == NULL, we ran through the whole list without
+		// inserting, so add at the end.
+		if (!runner) {
+			_lastDisplayElement->_nextElement = newElement;
+			_lastDisplayElement = newElement;
+		}
+	} else {
+		_firstDisplayElement = newElement;
+		_lastDisplayElement = newElement;
+	}
+
+	newElement->_elementIsDisplaying = true;
+}
+
+void GraphicsManager::removeDisplayElement(DisplayElement *oldElement) {
+	if (!_firstDisplayElement)
+		return;
+
+	if (oldElement == _firstDisplayElement) {
+		if (oldElement == _lastDisplayElement) {
+			_firstDisplayElement = 0;
+			_lastDisplayElement = 0;
+		} else {
+			_firstDisplayElement = oldElement->_nextElement;
+		}
+
+		invalRect(oldElement->_bounds);
+	} else {
+		// Scan list for element.
+		// If we get here, we know that the list has at least one item, and it
+		// is not the first item, so we can skip it.
+		DisplayElement *runner = _firstDisplayElement->_nextElement;
+		DisplayElement *lastRunner = _firstDisplayElement;
+
+		while (runner) {
+			if (runner == oldElement) {
+				lastRunner->_nextElement = runner->_nextElement;
+
+				if (oldElement == _lastDisplayElement)
+					_lastDisplayElement = lastRunner;
+
+				invalRect(oldElement->_bounds);
+				break;
+			}
+
+			lastRunner = runner;
+			runner = runner->_nextElement;
+		}
+	}
+
+	oldElement->_nextElement = 0;
+	oldElement->_elementIsDisplaying = false;
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 4135373..6778adb 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -4,6 +4,9 @@
  * are too numerous to list here. Please refer to the COPYRIGHT
  * file distributed with this source distribution.
  *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -30,9 +33,55 @@
 #include "graphics/surface.h"
 
 #include "pegasus/pegasus.h"
+#include "pegasus/util.h"
 
 namespace Pegasus {
 
+class DisplayElement : public IDObject {
+friend class GraphicsManager;
+public:
+	DisplayElement(const tDisplayElementID);
+	virtual ~DisplayElement();
+	
+	void setDisplayOrder(const tDisplayOrder);
+	tDisplayOrder getDisplayOrder() const { return _elementOrder; }
+	
+	bool validToDraw(tDisplayOrder, tDisplayOrder);
+	
+	virtual void draw(const Common::Rect&) {}
+	bool isDisplaying() { return _elementIsDisplaying; }
+	virtual void startDisplaying();
+	virtual void stopDisplaying();
+	
+	virtual void show();
+	virtual void hide();
+	bool isVisible() { return _elementIsVisible; }
+	
+	// triggerRedraw only triggers a draw if the element is displaying and visible.
+	void triggerRedraw();
+	void setTriggeredElement(DisplayElement *);
+	
+	virtual void setBounds(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
+	virtual void setBounds(const Common::Rect&);
+	virtual void getBounds(Common::Rect&) const;
+	virtual void sizeElement(const tCoordType, const tCoordType);
+	virtual void moveElementTo(const tCoordType, const tCoordType);
+	virtual void moveElement(const tCoordType, const tCoordType);
+	virtual void getLocation(tCoordType&, tCoordType&) const;
+	virtual void getCenter(tCoordType&, tCoordType&) const;
+	virtual void centerElementAt(const tCoordType, const tCoordType);
+
+protected:
+	Common::Rect _bounds;
+	bool _elementIsVisible;
+	DisplayElement *_triggeredElement;
+
+	// Used only by PegasusEngine
+	bool _elementIsDisplaying;
+	tDisplayOrder _elementOrder;
+	DisplayElement *_nextElement;
+};
+
 enum {
 	kImageCacheSize = 10
 };
@@ -50,17 +99,30 @@ public:
 	GraphicsManager(PegasusEngine *vm);
 	~GraphicsManager();
 
+	// Older "temporary" API
 	void drawPict(Common::String filename, int x, int y, bool updateScreen = true);
 	void drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen = true);
 	uint32 getColor(byte r, byte g, byte b);
-	
+
+	// Newer "to-be-used" API
+	void addDisplayElement(DisplayElement *element);
+	void removeDisplayElement(DisplayElement *element);
+	void invalRect(const Common::Rect &rect);
+	tDisplayOrder getBackOfActiveLayer() const { return _backLayer; }
+	tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
 private:		
 	PegasusEngine *_vm;
-	Graphics::PictDecoder *_pictDecoder;
 
+	// Older "temporary" API
+	Graphics::PictDecoder *_pictDecoder;
 	Graphics::Surface *decodeImage(const Common::String &filename);
 	ImageCache _cache[kImageCacheSize];
 	int getImageSlot(const Common::String &filename);
+
+	// Newer "to-be-used" API
+	Common::Rect _dirtyRect;
+	tDisplayOrder _backLayer, _frontLayer;
+	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 };
 
 } // End of namespace Pegasus


Commit: d3fde69770b5a3065fa3ae1da76e443d6d185147
    https://github.com/scummvm/scummvm/commit/d3fde69770b5a3065fa3ae1da76e443d6d185147
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-10T07:41:36-07:00

Commit Message:
PEGASUS: Implement two of the primitive-based DisplayElements

Changed paths:
  A engines/pegasus/elements.cpp
  A engines/pegasus/elements.h
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
new file mode 100644
index 0000000..132c19a
--- /dev/null
+++ b/engines/pegasus/elements.cpp
@@ -0,0 +1,241 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/elements.h"
+#include "pegasus/graphics.h"
+
+namespace Pegasus {
+
+DisplayElement::DisplayElement(const tDisplayElementID id) : IDObject(id) {
+	_elementIsDisplaying = false;
+	_elementIsVisible = false;
+	_elementOrder = 0;
+	_triggeredElement = this;
+	_nextElement = 0;
+}
+
+DisplayElement::~DisplayElement() {
+	if (isDisplaying())
+		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+}
+
+void DisplayElement::setDisplayOrder(const tDisplayOrder order) {
+	if (_elementOrder != order) {
+		_elementOrder = order;
+		if (isDisplaying()) {
+			((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+			((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
+			triggerRedraw();
+		}
+	}
+}
+
+void DisplayElement::startDisplaying() {
+	if (!isDisplaying()) {
+		((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
+		triggerRedraw();
+	}
+}
+
+void DisplayElement::stopDisplaying() {
+	if (isDisplaying()) {
+		triggerRedraw();
+		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
+	}
+}
+
+void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
+	_bounds = Common::Rect(left, top, right, bottom);
+}
+
+void DisplayElement::getBounds(Common::Rect &r) const {
+	r = _bounds;
+}
+
+void DisplayElement::sizeElement(const tCoordType h, const tCoordType v) {
+	_bounds.right = _bounds.left + h;
+	_bounds.bottom = _bounds.top + v;
+}
+
+void DisplayElement::moveElementTo(const tCoordType h, const tCoordType v) {
+	_bounds.moveTo(h, v);
+}
+
+void DisplayElement::moveElement(const tCoordType dh, const tCoordType dv) {
+	_bounds.translate(dh, dv);
+}
+
+void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
+	h = _bounds.left;
+	v = _bounds.top;
+}
+
+void DisplayElement::centerElementAt(const tCoordType h, const tCoordType v) {
+	_bounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
+}
+
+void DisplayElement::getCenter(tCoordType &h, tCoordType &v) const {
+	h = (_bounds.left + _bounds.right) / 2;
+	v = (_bounds.top + _bounds.bottom) / 2;
+}
+
+void DisplayElement::setBounds(const Common::Rect &r) {
+	if (r != _bounds) {
+		triggerRedraw();
+		_bounds = r;
+		triggerRedraw();
+	}
+}
+
+void DisplayElement::hide() {
+	if (_elementIsVisible) {
+		triggerRedraw();
+		_elementIsVisible = false;
+	}
+}
+
+void DisplayElement::show() {
+	if (!_elementIsVisible) {
+		_elementIsVisible = true;
+		triggerRedraw();
+	}
+}
+
+//	Only invalidates this element's bounding rectangle if all these conditions are true:
+//	--	The triggered element is this element.
+//	--	The element is displaying on the display list.
+//	--	The element is visible.
+//	--	The element is part of the active layer OR is one of the reserved items.
+void DisplayElement::triggerRedraw() {
+	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+
+	if (_triggeredElement == this) {
+		if (validToDraw(gfx->getBackOfActiveLayer(), gfx->getFrontOfActiveLayer()))
+			gfx->invalRect(_bounds);
+	} else {
+		_triggeredElement->triggerRedraw();
+	}
+}
+
+void DisplayElement::setTriggeredElement(DisplayElement *element) {
+	if (element)
+		_triggeredElement = element;
+	else
+		_triggeredElement = this;
+}
+
+bool DisplayElement::validToDraw(tDisplayOrder backLayer, tDisplayOrder frontLayer) {
+	return	isDisplaying() && _elementIsVisible &&
+			(getObjectID() <= kHighestReservedElementID ||
+			(getDisplayOrder() >= backLayer &&
+			getDisplayOrder() <= frontLayer));
+}
+
+DropHighlight::DropHighlight(const tDisplayElementID id) : DisplayElement(id) {
+	_highlightColor = g_system->getScreenFormat().RGBToColor(0x48, 0x80, 0xD8);
+	_thickness = 2;
+	_cornerDiameter = 0;
+}
+
+void DropHighlight::draw(const Common::Rect &) {
+	Graphics::Surface *screen = g_system->lockScreen();
+
+	// Since this is only used in two different ways, I'm only
+	// going to implement it in those two ways. Deal with it.
+
+	Common::Rect rect = _bounds;
+	screen->frameRect(rect, _highlightColor);
+	rect.grow(1);
+	screen->frameRect(rect, _highlightColor);
+
+	if (_cornerDiameter == 8 && _thickness == 4) {
+		rect.grow(1);
+		screen->frameRect(rect, _highlightColor);
+		screen->hLine(rect.left + 1, rect.top - 1, rect.right - 2, _highlightColor);
+		screen->hLine(rect.left + 1, rect.bottom, rect.right - 2, _highlightColor);
+		screen->vLine(rect.left - 1, rect.top + 1, rect.bottom - 2, _highlightColor);
+		screen->vLine(rect.right, rect.top + 1, rect.bottom - 2, _highlightColor);
+	}
+
+	g_system->unlockScreen();
+}
+
+EnergyBar::EnergyBar(const tDisplayElementID id) : DisplayElement(id) {
+	_maxEnergy = 0;
+	_energyLevel = 0;
+	_barColor = 0;
+}
+
+void EnergyBar::checkRedraw() {	
+	if (_elementIsVisible) {
+		Common::Rect r;
+		calcLevelRect(r);
+		if (r != _levelRect)
+			triggerRedraw();
+	}
+}
+
+void EnergyBar::setEnergyLevel(const uint32 newLevel) {
+	if (_energyLevel != newLevel) {
+		_energyLevel = newLevel;
+		checkRedraw();
+	}
+}
+
+void EnergyBar::setMaxEnergy(const uint32 newMax) {
+	if (_maxEnergy != newMax) {
+		if (_energyLevel > newMax)
+			_energyLevel = newMax;
+		_maxEnergy = newMax;
+		checkRedraw();
+	}
+}
+
+void EnergyBar::setBounds(const Common::Rect &r) {
+	DisplayElement::setBounds(r);
+	checkRedraw();
+}
+
+void EnergyBar::draw(const Common::Rect &r) {
+	Common::Rect levelRect;
+	calcLevelRect(levelRect);
+
+	if (r.intersects(levelRect)) {
+		Graphics::Surface *screen = g_system->lockScreen();
+		screen->fillRect(levelRect, _barColor);
+		g_system->lockScreen();
+	}
+}
+
+void EnergyBar::calcLevelRect(Common::Rect &r) const {
+	if (_maxEnergy > 0) {
+		r = _bounds;
+		r.left = r.right - _bounds.width() * _energyLevel / _maxEnergy;
+	} else {
+		r = Common::Rect(0, 0, 0, 0);
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
new file mode 100644
index 0000000..2fc7a3a
--- /dev/null
+++ b/engines/pegasus/elements.h
@@ -0,0 +1,139 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ELEMENTS_H
+#define PEGASUS_ELEMENTS_H
+
+#include "common/rect.h"
+#include "common/str.h"
+#include "common/system.h"
+#include "graphics/pict.h"
+#include "graphics/surface.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+class DisplayElement : public IDObject {
+friend class GraphicsManager;
+public:
+	DisplayElement(const tDisplayElementID);
+	virtual ~DisplayElement();
+	
+	void setDisplayOrder(const tDisplayOrder);
+	tDisplayOrder getDisplayOrder() const { return _elementOrder; }
+	
+	bool validToDraw(tDisplayOrder, tDisplayOrder);
+	
+	virtual void draw(const Common::Rect&) {}
+	bool isDisplaying() { return _elementIsDisplaying; }
+	virtual void startDisplaying();
+	virtual void stopDisplaying();
+	
+	virtual void show();
+	virtual void hide();
+	bool isVisible() { return _elementIsVisible; }
+	
+	// triggerRedraw only triggers a draw if the element is displaying and visible.
+	void triggerRedraw();
+	void setTriggeredElement(DisplayElement *);
+	
+	virtual void setBounds(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
+	virtual void setBounds(const Common::Rect&);
+	virtual void getBounds(Common::Rect&) const;
+	virtual void sizeElement(const tCoordType, const tCoordType);
+	virtual void moveElementTo(const tCoordType, const tCoordType);
+	virtual void moveElement(const tCoordType, const tCoordType);
+	virtual void getLocation(tCoordType&, tCoordType&) const;
+	virtual void getCenter(tCoordType&, tCoordType&) const;
+	virtual void centerElementAt(const tCoordType, const tCoordType);
+
+protected:
+	Common::Rect _bounds;
+	bool _elementIsVisible;
+	DisplayElement *_triggeredElement;
+
+	// Used only by PegasusEngine
+	bool _elementIsDisplaying;
+	tDisplayOrder _elementOrder;
+	DisplayElement *_nextElement;
+};
+
+// I'm using the proper "highlight" instead of the evil
+// QuickDraw "hilite" :P (deal with it!)
+class DropHighlight : public DisplayElement {
+public:
+	DropHighlight(const tDisplayElementID);
+	virtual ~DropHighlight() {}
+
+	void setHighlightColor(const uint32 &highlight) { _highlightColor = highlight; }
+	void getHighlightColor(uint32 &highlight) const { highlight = _highlightColor; } 
+
+	void setHighlightThickness(const uint16 thickness) { _thickness = thickness; }
+	uint16 getHighlightThickness() const { return _thickness; }
+
+	void setHighlightCornerDiameter(const uint16 diameter) { _cornerDiameter = diameter; }
+	uint16 getHighlightCornerDiameter() const { return _cornerDiameter; }
+
+	virtual void draw(const Common::Rect&);
+
+protected:
+	uint32 _highlightColor;
+	uint16 _thickness;
+	uint16 _cornerDiameter;
+};
+
+class EnergyBar : public DisplayElement {
+public:
+	EnergyBar(const tDisplayElementID);
+	virtual ~EnergyBar() {}
+	
+	void getBarColor(uint32 &color) const { color = _barColor; }
+	void setBarColor(const uint32 &color) { _barColor = color; }
+	
+	long getEnergyLevel() const { return _energyLevel; }
+	void setEnergyLevel(const uint32);
+	
+	long getMaxEnergy() const { return _maxEnergy; }
+	void setMaxEnergy(const uint32);
+	
+	virtual void setBounds(const Common::Rect&);
+	
+	virtual void draw(const Common::Rect&);
+
+protected:
+	void calcLevelRect(Common::Rect&) const;
+	void checkRedraw();
+	
+	uint32 _energyLevel;
+	uint32 _maxEnergy;
+	Common::Rect _levelRect;
+	uint32 _barColor;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index cec8595..abff3df 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -23,139 +23,14 @@
  *
  */
 
-#include "pegasus/graphics.h"
-
-#include "common/endian.h"
 #include "common/file.h"
 #include "common/textconsole.h"
 #include "engines/util.h"
 
-namespace Pegasus {
-
-DisplayElement::DisplayElement(const tDisplayElementID id) : IDObject(id) {
-	_elementIsDisplaying = false;
-	_elementIsVisible = false;
-	_elementOrder = 0;
-	_triggeredElement = this;
-	_nextElement = 0;
-}
-
-DisplayElement::~DisplayElement() {
-	if (isDisplaying())
-		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
-}
-
-void DisplayElement::setDisplayOrder(const tDisplayOrder order) {
-	if (_elementOrder != order) {
-		_elementOrder = order;
-		if (isDisplaying()) {
-			((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
-			((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
-			triggerRedraw();
-		}
-	}
-}
-
-void DisplayElement::startDisplaying() {
-	if (!isDisplaying()) {
-		((PegasusEngine *)g_engine)->_gfx->addDisplayElement(this);
-		triggerRedraw();
-	}
-}
-
-void DisplayElement::stopDisplaying() {
-	if (isDisplaying()) {
-		triggerRedraw();
-		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
-	}
-}
-
-void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
-	_bounds = Common::Rect(left, top, right, bottom);
-}
-
-void DisplayElement::getBounds(Common::Rect &r) const {
-	r = _bounds;
-}
-
-void DisplayElement::sizeElement(const tCoordType h, const tCoordType v) {
-	_bounds.right = _bounds.left + h;
-	_bounds.bottom = _bounds.top + v;
-}
-
-void DisplayElement::moveElementTo(const tCoordType h, const tCoordType v) {
-	_bounds.moveTo(h, v);
-}
-
-void DisplayElement::moveElement(const tCoordType dh, const tCoordType dv) {
-	_bounds.translate(dh, dv);
-}
-
-void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
-	h = _bounds.left;
-	v = _bounds.top;
-}
-
-void DisplayElement::centerElementAt(const tCoordType h, const tCoordType v) {
-	_bounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
-}
-
-void DisplayElement::getCenter(tCoordType &h, tCoordType &v) const {
-	h = (_bounds.left + _bounds.right) / 2;
-	v = (_bounds.top + _bounds.bottom) / 2;
-}
-
-void DisplayElement::setBounds(const Common::Rect &r) {
-	if (r != _bounds) {
-		triggerRedraw();
-		_bounds = r;
-		triggerRedraw();
-	}
-}
-
-void DisplayElement::hide() {
-	if (_elementIsVisible) {
-		triggerRedraw();
-		_elementIsVisible = false;
-	}
-}
-
-void DisplayElement::show() {
-	if (!_elementIsVisible) {
-		_elementIsVisible = true;
-		triggerRedraw();
-	}
-}
-
-//	Only invalidates this element's bounding rectangle if all these conditions are true:
-//	--	The triggered element is this element.
-//	--	The element is displaying on the display list.
-//	--	The element is visible.
-//	--	The element is part of the active layer OR is one of the reserved items.
-void DisplayElement::triggerRedraw() {
-	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
-
-	if (_triggeredElement == this) {
-		if (validToDraw(gfx->getBackOfActiveLayer(), gfx->getFrontOfActiveLayer()))
-			gfx->invalRect(_bounds);
-	} else {
-		_triggeredElement->triggerRedraw();
-	}
-}
-
-void DisplayElement::setTriggeredElement(DisplayElement *element) {
-	if (element)
-		_triggeredElement = element;
-	else
-		_triggeredElement = this;
-}
+#include "pegasus/elements.h"
+#include "pegasus/graphics.h"
 
-bool DisplayElement::validToDraw(tDisplayOrder backLayer, tDisplayOrder frontLayer) {
-	return	isDisplaying() && _elementIsVisible &&
-			(getObjectID() <= kHighestReservedElementID ||
-			(getDisplayOrder() >= backLayer &&
-			getDisplayOrder() <= frontLayer));
-}
+namespace Pegasus {
 
 GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	initGraphics(640, 480, true, NULL);
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 6778adb..d8919e5 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -37,51 +37,6 @@
 
 namespace Pegasus {
 
-class DisplayElement : public IDObject {
-friend class GraphicsManager;
-public:
-	DisplayElement(const tDisplayElementID);
-	virtual ~DisplayElement();
-	
-	void setDisplayOrder(const tDisplayOrder);
-	tDisplayOrder getDisplayOrder() const { return _elementOrder; }
-	
-	bool validToDraw(tDisplayOrder, tDisplayOrder);
-	
-	virtual void draw(const Common::Rect&) {}
-	bool isDisplaying() { return _elementIsDisplaying; }
-	virtual void startDisplaying();
-	virtual void stopDisplaying();
-	
-	virtual void show();
-	virtual void hide();
-	bool isVisible() { return _elementIsVisible; }
-	
-	// triggerRedraw only triggers a draw if the element is displaying and visible.
-	void triggerRedraw();
-	void setTriggeredElement(DisplayElement *);
-	
-	virtual void setBounds(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
-	virtual void setBounds(const Common::Rect&);
-	virtual void getBounds(Common::Rect&) const;
-	virtual void sizeElement(const tCoordType, const tCoordType);
-	virtual void moveElementTo(const tCoordType, const tCoordType);
-	virtual void moveElement(const tCoordType, const tCoordType);
-	virtual void getLocation(tCoordType&, tCoordType&) const;
-	virtual void getCenter(tCoordType&, tCoordType&) const;
-	virtual void centerElementAt(const tCoordType, const tCoordType);
-
-protected:
-	Common::Rect _bounds;
-	bool _elementIsVisible;
-	DisplayElement *_triggeredElement;
-
-	// Used only by PegasusEngine
-	bool _elementIsDisplaying;
-	tDisplayOrder _elementOrder;
-	DisplayElement *_nextElement;
-};
-
 enum {
 	kImageCacheSize = 10
 };
@@ -92,6 +47,7 @@ struct ImageCache {
 	uint32 lastUsed;
 };
 
+class DisplayElement;
 class PegasusEngine;
 
 class GraphicsManager {
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 06cfd03..0f697f3 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS = \
 	credits.o \
 	cursor.o \
 	detection.o \
+	elements.o \
 	gamestate.o \
 	graphics.o \
 	hotspot.o \


Commit: 1ac6abaeff4813d75abd4ac58a13e22eaef2ab71
    https://github.com/scummvm/scummvm/commit/1ac6abaeff4813d75abd4ac58a13e22eaef2ab71
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-15T17:39:37-07:00

Commit Message:
PEGASUS: Stub off the base timebase code

This is not tested, and hopefully just works without anymore changes. I hate QuickTime :P

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 132c19a..695a6e5 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -23,6 +23,9 @@
  *
  */
 
+#include "common/macresman.h"
+#include "common/stream.h"
+
 #include "pegasus/elements.h"
 #include "pegasus/graphics.h"
 
@@ -238,4 +241,122 @@ void EnergyBar::calcLevelRect(Common::Rect &r) const {
 	}
 }
 
+IdlerAnimation::IdlerAnimation(const tDisplayElementID id) : Animation(id) {
+	_lastTime = 0xffffffff;
+}
+
+void IdlerAnimation::startDisplaying() {
+	if (!isDisplaying()) {
+		Animation::startDisplaying();
+		startIdling();
+	}
+}
+
+void IdlerAnimation::stopDisplaying() {
+	if (isDisplaying()) {
+		Animation::stopDisplaying();
+		stopIdling();
+	}
+}
+
+void IdlerAnimation::useIdleTime() {
+	uint32 currentTime = getTime();
+
+	if (currentTime != _lastTime) {
+		_lastTime = currentTime;
+		timeChanged(_lastTime);
+	}
+}
+
+void IdlerAnimation::timeChanged(const TimeValue) {
+	triggerRedraw();
+}
+
+FrameSequence::FrameSequence(const tDisplayElementID id) : IdlerAnimation(id) {
+	_duration = 0;
+	_currentFrameNum = 0;
+	_resFork = new Common::MacResManager();
+}
+
+FrameSequence::~FrameSequence() {
+	delete _resFork;
+}
+
+void FrameSequence::useFileName(const Common::String &fileName) {
+	_resFork->open(fileName);
+}
+
+void FrameSequence::openFrameSequence() {
+	if (!_resFork->hasResFork())
+		return;
+
+	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('P', 'F', 'r', 'm'), 0x80);
+
+	if (!res)
+		return;
+
+	uint32 scale = res->readUint32BE();
+	_bounds.top = res->readUint16BE();
+	_bounds.left = res->readUint16BE();
+	_bounds.bottom = res->readUint16BE();
+	_bounds.right = res->readUint16BE();
+	_numFrames = res->readUint16BE();
+	_duration = 0;
+
+	_frameTimes.clear();
+	for (uint32 i = 0; i < _numFrames; i++) {
+		TimeValue time = res->readUint32BE();
+		_duration += time;
+		_frameTimes.push_back(_duration);
+	}
+
+	setScale(scale);
+	setSegment(0, _duration);
+	setTime(0);
+	_currentFrameNum = 0;
+	newFrame(_currentFrameNum);
+	triggerRedraw();
+
+	delete res;
+}
+
+void FrameSequence::closeFrameSequence() {
+	stop();
+	_resFork->close();
+	_duration = 0;
+	_numFrames = 0;
+	_frameTimes.clear();
+}
+
+void FrameSequence::timeChanged(const TimeValue time) {
+	int16 frameNum = 0;
+	for (int16 i = _numFrames - 1; i >= 0; i--) {
+		if (_frameTimes[i] < time) {
+			frameNum = i;
+			break;
+		}
+	}
+
+	if (frameNum != _currentFrameNum) {
+		_currentFrameNum = frameNum;
+		newFrame(_currentFrameNum);
+		triggerRedraw();
+	}
+}
+
+void FrameSequence::setFrameNum(const int16 frameNum) {
+	int16 f = CLIP<int>(frameNum, 0, _numFrames);
+
+	if (_currentFrameNum != f) {
+		_currentFrameNum = f;
+		setTime(_frameTimes[f]);
+		newFrame(f);
+		triggerRedraw();
+	}
+}
+
+bool FrameSequence::isSequenceOpen() const {
+	return _numFrames != 0;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 2fc7a3a..460b9a7 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -33,8 +33,13 @@
 #include "graphics/surface.h"
 
 #include "pegasus/pegasus.h"
+#include "pegasus/timers.h"
 #include "pegasus/util.h"
 
+namespace Common {
+	class MacResManager;
+}
+
 namespace Pegasus {
 
 class DisplayElement : public IDObject {
@@ -134,6 +139,60 @@ protected:
 	uint32 _barColor;
 };
 
+class Animation : public DisplayElement, public DynamicElement {
+public:
+	Animation(const tDisplayElementID id) : DisplayElement(id) {}
+};
+
+class IdlerAnimation : public Animation, public Idler {
+public:
+	IdlerAnimation(const tDisplayElementID);
+	
+	virtual void startDisplaying();
+	virtual void stopDisplaying();
+	
+	TimeValue getLastTime() const { return _lastTime; }
+
+protected:
+	virtual void useIdleTime();
+	virtual void timeChanged(const TimeValue);
+	
+	TimeValue _lastTime;
+};
+
+//	This class reads PICT resources and plays them like a movie.
+//	Assumes there is a resource of type 'PFrm' describing the time values for each
+//	PICT frame, as well as the total time in the movie.
+//	Assumes that PICT frames begin at PICT 128
+
+class FrameSequence : public IdlerAnimation {
+public:
+	FrameSequence(const tDisplayElementID);
+	virtual ~FrameSequence();
+
+	void useFileName(const Common::String &fileName);
+
+	virtual void openFrameSequence();
+	virtual void closeFrameSequence();
+	bool isSequenceOpen() const;
+	
+	uint16 getNumFrames() const { return _numFrames; }
+	virtual uint16 getFrameNum() const { return _currentFrameNum; }
+	virtual void setFrameNum(const int16);
+
+protected:		
+	virtual void timeChanged(const TimeValue);
+	virtual void newFrame(const uint16) {}
+
+	Common::MacResManager *_resFork;
+	TimeValue _duration;
+
+	uint16 _numFrames;
+	Common::Array<TimeValue> _frameTimes;
+
+	uint16 _currentFrameNum;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 39eb7d5..dacc2a0 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -332,4 +332,12 @@ void PegasusEngine::giveIdleTime() {
 		(*it)->useIdleTime();
 }
 
+void PegasusEngine::addTimeBase(TimeBase *timeBase) {
+	_timeBases.push_back(timeBase);
+}
+
+void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
+	_timeBases.remove(timeBase);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 8ab891d..5074aab 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -50,6 +50,7 @@ class VideoManager;
 class GraphicsManager;
 class Idler;
 class Cursor;
+class TimeBase;
 
 static const int kViewScreenOffset = 64;
 
@@ -85,6 +86,9 @@ public:
 	void addIdler(Idler *idler);
 	void removeIdler(Idler *idler);
 
+	void addTimeBase(TimeBase *timeBase);
+	void removeTimeBase(TimeBase *timeBase);
+
 protected:
 	Common::Error run();
 
@@ -141,6 +145,9 @@ private:
 	// Items
 	void createItems();
 	void createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction);
+
+	// TimeBases
+	Common::List<TimeBase *> _timeBases;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 5908854..fe487e9 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/pegasus.h"
+#include "pegasus/notification.h"
 #include "pegasus/timers.h"
 
 namespace Pegasus {
@@ -50,4 +51,285 @@ void Idler::stopIdling() {
 	}
 }
 
+TimeBase::TimeBase(const TimeScale preferredScale) {
+	_preferredScale = preferredScale;
+	_callBackList = 0;
+	_paused = false;
+	_flags = 0;
+	((PegasusEngine *)g_engine)->addTimeBase(this);
+}
+
+TimeBase::~TimeBase() {
+	if (_master)
+		_master->_slaves.remove(this);
+
+	((PegasusEngine *)g_engine)->removeTimeBase(this);
+	disposeAllCallBacks();
+
+	// TODO: Remove slaves? Make them remove themselves?
+}
+
+void TimeBase::setTime(const TimeValue time, const TimeScale scale) {
+	// So, we're saying the *current* time from g_system->getMillis() is
+	// what time/scale is. Which means we need to subtract time/scale from
+	// the offset so that g_system->getMillis() - _currentOffset is
+	// equal to time/scale.
+	_timeOffset = g_system->getMillis() - time * 1000 / ((scale == 0) ? _preferredScale : scale);
+
+	// TODO: Also adjust the slaves' offsets (once we're actually using the
+	// masters for calculating time)
+}
+
+TimeValue TimeBase::getTime(const TimeScale scale) {
+	if (_paused)
+		return _pausedTime;
+
+	Common::Rational normalTime = Common::Rational((g_system->getMillis() - _timeOffset) * ((scale == 0) ? _preferredScale : scale), 1000);
+
+	// Adjust it according to our rate
+	return (normalTime * getEffectiveRate()).toInt();
+}
+
+void TimeBase::setRate(const Common::Rational rate) {
+	if (rate == 0) {
+		_paused = false;
+		_timeOffset = 0;
+	} else if (_timeOffset != 0) {
+		// Convert the time from the old rate to the new rate
+		_timeOffset = g_system->getMillis() - (rate * (g_system->getMillis() - _timeOffset) / _rate).toInt();
+	} else {
+		// TODO: Check this
+		setTime(_startTime, _startScale);
+	}
+
+	_rate = rate;
+}
+
+Common::Rational TimeBase::getEffectiveRate() const {
+	return _rate * ((_master == 0) ? 1 : _master->getEffectiveRate());
+}
+
+void TimeBase::start() {
+	if (_paused)
+		_pausedRate = 1;
+	else
+		setRate(1);
+}
+
+void TimeBase::stop() {
+	setRate(0);
+	_paused = false;
+}
+
+void TimeBase::pause() {
+	if (isRunning() && !_paused) {
+		_pausedRate = getRate();
+		stop();
+		_pausedTime = getTime();
+		_paused = true;
+	}
+}
+
+void TimeBase::resume() {
+	if (_paused) {
+		setRate(_pausedRate);
+		_paused = false;
+	}
+}
+
+bool TimeBase::isRunning() {
+	if (_paused && _pausedRate != 0)
+		return true;
+
+	Common::Rational rate = getRate();
+
+	if (rate == 0)
+		return false;
+
+	if (getFlags() & kLoopTimeBase)
+		return true;
+
+	if (rate > 0)
+		return getTime() < getStop();
+
+	return getTime() > getStart();
+}
+
+void TimeBase::setStart(const TimeValue startTime, const TimeScale scale) {
+	_startTime = startTime;
+	_startScale = (scale == 0) ? _preferredScale : scale;
+}
+
+TimeValue TimeBase::getStart(const TimeScale scale) const {
+	if (scale)
+		return _startTime * scale / _startScale;
+
+	return _startTime * _preferredScale / _startScale;
+}
+
+void TimeBase::setStop(const TimeValue stopTime, const TimeScale scale) {
+	_stopTime = stopTime;
+	_stopScale = (scale == 0) ? _preferredScale : scale;
+}
+
+TimeValue TimeBase::getStop(const TimeScale scale) const {
+	if (scale)
+		return _stopTime * scale / _stopScale;
+
+	return _stopTime * _preferredScale / _stopScale;
+}
+
+void TimeBase::setSegment(const TimeValue startTime, const TimeValue stopTime, const TimeScale scale) {
+	setStart(startTime, scale);
+	setStop(stopTime, scale);
+}
+
+void TimeBase::getSegment(TimeValue &startTime, TimeValue &stopTime, const TimeScale scale) const {
+	startTime = getStart(scale);
+	stopTime = getStop(scale);
+}
+
+TimeValue TimeBase::getDuration(const TimeScale scale) const {
+	TimeValue startTime, stopTime;
+	getSegment(startTime, stopTime, scale);
+	return stopTime - startTime;
+}
+
+void TimeBase::setMasterTimeBase(TimeBase *tb) {
+	// TODO: We're just ignoring the master (except for effective rate)
+	// for now to simplify things
+	if (_master)
+		_master->_slaves.remove(this);
+
+	_master = tb;
+
+	if (_master)
+		_master->_slaves.push_back(this);
+}
+
+void TimeBase::checkCallBacks() {
+	uint32 time = getTime();
+	uint32 startTime = getStart();
+	uint32 stopTime = getStop();
+
+	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
+		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
+			if (time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
+				runner->callBack();
+		} else if (runner->_type == kCallBackAtExtremes) {
+			if (runner->_trigger == kTriggerAtStop) {
+				if (time >= stopTime)
+					runner->callBack();
+			} else if (runner->_trigger == kTriggerAtStart) {
+				if (time <= startTime)
+					runner->callBack();
+			}
+		}
+	}
+
+	if (getFlags() & kLoopTimeBase) {
+		// Loop
+		if (time >= startTime)
+			setTime(stopTime);
+		else if (time <= stopTime)
+			setTime(startTime);
+	}
+}
+
+//	Protected functions only called by TimeBaseCallBack.
+
+void TimeBase::addCallBack(TimeBaseCallBack *callBack) {
+	callBack->_nextCallBack = _callBackList;
+	_callBackList = callBack;
+}
+
+void TimeBase::removeCallBack(TimeBaseCallBack *callBack) {	
+	if (_callBackList == callBack) {
+		_callBackList = callBack->_nextCallBack;
+	} else {
+		TimeBaseCallBack *runner, *prevRunner;
+	
+		for (runner = _callBackList->_nextCallBack, prevRunner = _callBackList; runner != callBack; prevRunner = runner, runner = runner->_nextCallBack)
+			;
+
+		prevRunner->_nextCallBack = runner->_nextCallBack;
+	}
+
+	callBack->_nextCallBack = 0;
+}
+
+void TimeBase::disposeAllCallBacks() {
+	TimeBaseCallBack *nextRunner;
+	
+	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = nextRunner) {
+		nextRunner = runner->_nextCallBack;
+		runner->disposeCallBack();
+		runner->_nextCallBack = 0;
+	}
+
+	_callBackList = 0;
+}
+
+TimeBaseCallBack::TimeBaseCallBack() {
+	_timeBase = 0;
+	_nextCallBack = 0;
+	_trigger = kTriggerNone;
+	_type = kCallBackNone;
+}
+
+TimeBaseCallBack::~TimeBaseCallBack() {
+	releaseCallBack();
+}
+
+void TimeBaseCallBack::initCallBack(TimeBase *tb, CallBackType type) {
+	releaseCallBack();
+	_timeBase = tb;
+	_timeBase->addCallBack(this);
+	_type = type;
+}
+
+void TimeBaseCallBack::releaseCallBack() {
+	if (_timeBase)
+		_timeBase->removeCallBack(this);
+	disposeCallBack();
+}
+
+void TimeBaseCallBack::disposeCallBack() {
+	_timeBase = 0;
+}
+
+void TimeBaseCallBack::scheduleCallBack(CallBackTrigger trigger, uint32 param2, uint32 param3) {
+	// TODO: Rename param2/param3?
+	_trigger = trigger;
+	_param2 = param2;
+	_param3 = param3;
+}
+
+void TimeBaseCallBack::cancelCallBack() {
+	_trigger = kTriggerNone;
+}
+
+IdlerTimeBase::IdlerTimeBase() {
+	_lastTime = 0xffffffff;
+	startIdling();
+}
+
+void IdlerTimeBase::useIdleTime() {	
+	uint32 currentTime = getTime();
+	if (currentTime != _lastTime) {
+		_lastTime = currentTime;
+		timeChanged(_lastTime);
+	}
+}
+
+NotificationCallBack::NotificationCallBack() {
+	_callBackFlag = 0;
+	_notifier = 0;
+}
+
+void NotificationCallBack::callBack() {
+	if (_notifier)
+		_notifier->setNotificationFlags(_callBackFlag, _callBackFlag);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index e4bb410..9ce3093 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -26,6 +26,10 @@
 #ifndef PEGASUS_TIMERS_H
 #define PEGASUS_TIMERS_H
 
+#include "common/rational.h"
+
+#include "pegasus/constants.h"
+
 namespace Pegasus {
 
 class Idler {
@@ -45,6 +49,168 @@ protected:
 	bool _isIdling;
 };
 
+enum {
+	kLoopTimeBase           = 1,
+	kPalindromeLoopTimeBase = 2,
+	kMaintainTimeBaseZero   = 4
+};
+
+class TimeBaseCallBack;
+
+class TimeBase {
+friend class TimeBaseCallBack;
+public:
+	TimeBase(const TimeScale = kDefaultTimeScale);
+	virtual ~TimeBase();
+	
+	virtual void setTime(const TimeValue, const TimeScale = 0);
+	virtual TimeValue getTime(const TimeScale = 0);
+	
+	virtual void setScale(const TimeScale scale) { _preferredScale = scale; }
+	virtual TimeScale getScale() const { return _preferredScale; }
+	
+	virtual void setRate(const Common::Rational);
+	virtual Common::Rational getRate() const { return _rate; }
+	
+	virtual void start();
+	virtual void stop();
+	virtual bool isRunning();
+	
+	virtual void pause();
+	virtual void resume();
+	bool isPaused() const { return _paused; }
+	
+	virtual void setFlags(const uint32 flags) { _flags = flags; }
+	virtual uint32 getFlags() const { return _flags; }
+	
+	virtual void setStart(const TimeValue, const TimeScale = 0);
+	virtual TimeValue getStart(const TimeScale = 0) const;
+	
+	virtual void setStop(const TimeValue, const TimeScale = 0);
+	virtual TimeValue getStop(const TimeScale = 0) const;
+	
+	virtual void setSegment(const TimeValue, const TimeValue, const TimeScale = 0);
+	virtual void getSegment(TimeValue&, TimeValue&, const TimeScale = 0) const;
+	
+	virtual TimeValue getDuration(const TimeScale = 0) const;
+
+	virtual void setMasterTimeBase(TimeBase *timeBase);
+		
+	void disposeAllCallBacks();
+
+	// ScummVM's API additions (to replace the need for actual timers)
+	void checkCallBacks();
+
+protected:
+	void addCallBack(TimeBaseCallBack *);
+	void removeCallBack(TimeBaseCallBack *);
+
+	TimeBase *_master;
+	TimeScale _preferredScale;
+	TimeBaseCallBack *_callBackList;
+	Common::Rational _rate, _pausedRate;
+	bool _paused;
+	uint32 _startTime, _startScale;
+	uint32 _stopTime, _stopScale;
+	int32 _timeOffset;
+	uint32 _flags;
+	TimeValue _pausedTime;
+
+private:
+	Common::Rational getEffectiveRate() const;
+
+	Common::List<TimeBase *> _slaves;
+};
+
+// Type passed to initCallBack()
+enum CallBackType {
+	kCallBackNone = 0,
+	kCallBackAtTime = 1,
+	kCallBackAtExtremes = 4
+};
+
+// Trigger passed to scheduleCallBack()
+enum CallBackTrigger {
+	kTriggerNone = 0,
+
+	// AtTime flags
+	kTriggerTimeFwd = 1,
+
+	// AtExtremes flags
+	kTriggerAtStart = 1,
+	kTriggerAtStop = 2
+};
+
+class TimeBaseCallBack {
+friend class TimeBase;
+
+public:
+	TimeBaseCallBack();
+	virtual ~TimeBaseCallBack();
+
+	void initCallBack(TimeBase *, CallBackType type);
+
+	void releaseCallBack();
+
+	void scheduleCallBack(CallBackTrigger trigger, uint32 param2, uint32 param3);
+	void cancelCallBack();
+
+protected:
+	virtual void callBack() = 0;
+
+	TimeBase *_timeBase;
+	
+	// Owned and operated by TimeBase;
+	TimeBaseCallBack *_nextCallBack;
+
+	// Our storage of the QuickTime timer crap
+	CallBackType _type;
+	CallBackTrigger _trigger;
+	uint32 _param2, _param3;
+
+private:
+	void disposeCallBack();
+};
+
+class IdlerTimeBase : public Idler, public TimeBase {
+public:
+	IdlerTimeBase();
+	virtual ~IdlerTimeBase() { stopIdling(); }
+
+	TimeValue getLastTime() const { return _lastTime; }
+
+protected:
+	virtual void useIdleTime();
+	virtual void timeChanged(const TimeValue) {}
+	
+	TimeValue _lastTime;
+
+};
+
+class Notification;
+
+class NotificationCallBack : public TimeBaseCallBack {
+public:
+	NotificationCallBack();
+	virtual ~NotificationCallBack() {}
+	
+	void setNotification(Notification *notifier) { _notifier = notifier; }
+
+	void setCallBackFlag(const tNotificationFlags flag) { _callBackFlag = flag; }
+	tNotificationFlags getCallBackFlag() const { return _callBackFlag; }
+	
+protected:
+	void callBack();
+	
+	Notification *_notifier;
+	tNotificationFlags _callBackFlag;
+};
+
+class DynamicElement : public TimeBase {
+public:
+	TimeValue percentSeconds(const uint32 percent) { return getScale() * percent / 100; }
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: dc0254c1ce10647f179a674e924d17a62640007f
    https://github.com/scummvm/scummvm/commit/dc0254c1ce10647f179a674e924d17a62640007f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-15T17:50:21-07:00

Commit Message:
PEGASUS: Implement very basic screen updating (new API)

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 695a6e5..f9881e7 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -163,7 +163,7 @@ DropHighlight::DropHighlight(const tDisplayElementID id) : DisplayElement(id) {
 }
 
 void DropHighlight::draw(const Common::Rect &) {
-	Graphics::Surface *screen = g_system->lockScreen();
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
 
 	// Since this is only used in two different ways, I'm only
 	// going to implement it in those two ways. Deal with it.
@@ -181,8 +181,6 @@ void DropHighlight::draw(const Common::Rect &) {
 		screen->vLine(rect.left - 1, rect.top + 1, rect.bottom - 2, _highlightColor);
 		screen->vLine(rect.right, rect.top + 1, rect.bottom - 2, _highlightColor);
 	}
-
-	g_system->unlockScreen();
 }
 
 EnergyBar::EnergyBar(const tDisplayElementID id) : DisplayElement(id) {
@@ -225,11 +223,8 @@ void EnergyBar::draw(const Common::Rect &r) {
 	Common::Rect levelRect;
 	calcLevelRect(levelRect);
 
-	if (r.intersects(levelRect)) {
-		Graphics::Surface *screen = g_system->lockScreen();
-		screen->fillRect(levelRect, _barColor);
-		g_system->lockScreen();
-	}
+	if (r.intersects(levelRect))
+		((PegasusEngine *)g_engine)->_gfx->getWorkArea()->fillRect(levelRect, _barColor);
 }
 
 void EnergyBar::calcLevelRect(Common::Rect &r) const {
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index abff3df..d5d6350 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -35,6 +35,9 @@ namespace Pegasus {
 GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	initGraphics(640, 480, true, NULL);
 
+	if (_vm->_system->getScreenFormat().bytesPerPixel == 1)
+		error("No true color mode available");
+
 	// Old
 	_pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
 
@@ -45,6 +48,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_backLayer = kMinAvailableOrder;
 	_frontLayer = kMaxAvailableOrder;
 	_firstDisplayElement = _lastDisplayElement = 0;
+	_workArea.create(640, 480, _vm->_system->getScreenFormat());
 }
 	
 GraphicsManager::~GraphicsManager() {
@@ -57,6 +61,9 @@ GraphicsManager::~GraphicsManager() {
 			delete _cache[i].surface;
 		}
 	}
+
+	// New
+	_workArea.free();
 }
 
 Graphics::Surface *GraphicsManager::decodeImage(const Common::String &filename) {
@@ -272,5 +279,35 @@ void GraphicsManager::removeDisplayElement(DisplayElement *oldElement) {
 	oldElement->_nextElement = 0;
 	oldElement->_elementIsDisplaying = false;
 }
+
+void GraphicsManager::updateDisplay() {
+	// TODO: Check for cursor move/change
+
+	bool screenDirty = false;
+
+	if (!_dirtyRect.isEmpty()) {
+		for (DisplayElement *runner = _firstDisplayElement; runner != 0; runner = runner->_nextElement) {
+			Common::Rect bounds;
+			runner->getBounds(bounds);
+
+			// TODO: Better logic; it does a bit more work than it probably needs to
+			// but it should work fine for now.
+			if (bounds.intersects(_dirtyRect) && runner->validToDraw(_backLayer, _frontLayer))
+				runner->draw(bounds);
+		}
+
+		// Copy only the dirty rect to the screen
+		g_system->copyRectToScreen((byte *)_workArea.pixels, _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height());
+
+		// Mark the screen as dirty
+		screenDirty = true;
+
+		// Clear the dirty rect
+		_dirtyRect = Common::Rect();
+	}
+
+	if (screenDirty)
+		g_system->updateScreen();
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index d8919e5..d4f9628 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -66,6 +66,9 @@ public:
 	void invalRect(const Common::Rect &rect);
 	tDisplayOrder getBackOfActiveLayer() const { return _backLayer; }
 	tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
+	void updateDisplay();
+	Graphics::Surface *getWorkArea() { return &_workArea; }
+
 private:		
 	PegasusEngine *_vm;
 
@@ -79,6 +82,7 @@ private:
 	Common::Rect _dirtyRect;
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
+	Graphics::Surface _workArea;
 };
 
 } // End of namespace Pegasus


Commit: ecde87260c1db0de463f294b551402c08e731d0e
    https://github.com/scummvm/scummvm/commit/ecde87260c1db0de463f294b551402c08e731d0e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-16T06:17:00-07:00

Commit Message:
PEGASUS: Fix saving/loading the game state

Changed paths:
    engines/pegasus/gamestate.cpp
    engines/pegasus/gamestate.h



diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
index bc88c5e..5c889bd 100755
--- a/engines/pegasus/gamestate.cpp
+++ b/engines/pegasus/gamestate.cpp
@@ -45,6 +45,7 @@ Common::Error GameStateManager::writeGameState(Common::WriteStream *stream) {
 	stream->writeByte(_nextDirection);
 	stream->writeUint16BE(_lastNeighborhood);
 	stream->writeUint16BE(_lastRoom);
+	stream->writeByte(_lastDirection);
 	stream->writeUint16BE(_openDoorRoom);
 	stream->writeByte(_openDoorDirection);
 
@@ -74,6 +75,7 @@ Common::Error GameStateManager::readGameState(Common::ReadStream *stream) {
 	_nextDirection = stream->readByte();
 	_lastNeighborhood = stream->readUint16BE();
 	_lastRoom = stream->readUint16BE();
+	_lastDirection = stream->readByte();
 	_openDoorRoom = stream->readUint16BE();
 	_openDoorDirection = stream->readByte();	
 
@@ -599,13 +601,13 @@ void GameStateManager::resetPrehistoricState() {
 void GameStateManager::writeNoradState(Common::WriteStream *stream) {
 	_noradFlags.writeToStream(stream);
 	stream->writeUint16BE(_noradSubRoomPressure);
-	stream->writeUint32BE(_noradSubPrepState); // FIXME: sizeof(enum)!
+	stream->writeByte(_noradSubPrepState);
 }
 
 void GameStateManager::readNoradState(Common::ReadStream *stream) {
 	_noradFlags.readFromStream(stream);
 	_noradSubRoomPressure = stream->readUint16BE();
-	_noradSubPrepState = (tNoradSubPrepState)stream->readUint32BE(); // FIXME: sizeof(enum)!
+	_noradSubPrepState = (tNoradSubPrepState)stream->readByte();
 }
 
 void GameStateManager::resetNoradState() {
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index 4118b5d..f356829 100755
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -27,6 +27,7 @@
 #define PEGASUS_GAMESTATE_H
 
 #include "common/singleton.h"
+#include "common/util.h"
 
 #include "pegasus/types.h"
 #include "pegasus/items/item.h"
@@ -879,7 +880,7 @@ private:
 				return;
 			}
 
-			for (uint32 i = 0; i < sizeof(_flags); i++) {
+			for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
 				if (sizeof(Unit) == 2)
 					_flags[i] = stream->readUint16BE();
 				else /* if (sizeof(Unit) == 4) */
@@ -894,7 +895,7 @@ private:
 				return;
 			}
 
-			for (uint32 i = 0; i < sizeof(_flags); i++) {
+			for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
 				if (sizeof(Unit) == 2)
 					stream->writeUint16BE(_flags[i]);
 				else /* if (sizeof(Unit) == 4) */


Commit: 2ae8a97c4d915b04e9824f2478812041e4c088f0
    https://github.com/scummvm/scummvm/commit/2ae8a97c4d915b04e9824f2478812041e4c088f0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-16T06:20:41-07:00

Commit Message:
PEGASUS: Stub off loading/saving games

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/detection.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index dd12727..b9b8540 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -26,6 +26,8 @@
 #ifndef PEGASUS_CONSTANTS_H
 #define PEGASUS_CONSTANTS_H
 
+#include "common/endian.h"
+
 #include "pegasus/types.h"
 
 namespace Pegasus {
@@ -247,6 +249,21 @@ const tNotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
 												kActionRequestCompletedFlag |
 												kDeathExtraCompletedFlag;
 
+const uint32 kPegasusPrimeCreator = MKTAG('J', 'P', 'P', 'P');
+const uint32 kPegasusPrimeContinueType = MKTAG('P', 'P', 'C', 'T');
+
+const uint32 kPegasusPrimeDisk1GameType = MKTAG('P', 'P', 'G', '1');
+const uint32 kPegasusPrimeDisk2GameType = MKTAG('P', 'P', 'G', '2');
+const uint32 kPegasusPrimeDisk3GameType = MKTAG('P', 'P', 'G', '3');
+const uint32 kPegasusPrimeDisk4GameType = MKTAG('P', 'P', 'G', '4');
+
+// We only support one of the save versions; the rest are from betas
+// and we are not supporting them.
+const uint32 kPegasusPrimeVersion = 0x00009019;
+
+const char kNormalSave = 0;
+const char kContinueSave = 1;
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index 9c486f7..af651c8 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -25,6 +25,7 @@
 #include "engines/advancedDetector.h"
 #include "common/config-manager.h"
 #include "common/file.h"
+#include "common/savefile.h"
 
 #include "pegasus/pegasus.h"
 
@@ -36,7 +37,9 @@ struct PegasusGameDescription {
 
 bool PegasusEngine::hasFeature(EngineFeature f) const {
 	return
-		(f == kSupportsRTL);
+		(f == kSupportsRTL)
+		|| (f == kSupportsLoadingDuringRuntime)
+		|| (f == kSupportsSavingDuringRuntime);
 }
 
 bool PegasusEngine::isDemo() const {
@@ -98,9 +101,44 @@ public:
 		return "The Journeyman Project: Pegasus Prime (C) Presto Studios";
 	}
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
+	virtual SaveStateList listSaves(const char *target) const;
+	virtual int getMaximumSaveSlot() const { return 999; }
+	virtual void removeSaveState(const char *target, int slot) const;
 };
 
+bool PegasusMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+		(f == kSupportsListSaves)
+		|| (f == kSupportsDeleteSave);
+}
+
+SaveStateList PegasusMetaEngine::listSaves(const char *target) const {
+	// The original had no pattern, so the user must rename theirs
+	// Note that we ignore the target because saves are compatible between
+	// all versions
+	Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav");
+
+	SaveStateList saveList;
+	for (uint32 i = 0; i < filenames.size(); i++) {
+		// Isolate the description from the file name
+		Common::String desc = filenames[i].c_str() + 8;
+		for (int j = 0; j < 4; j++)
+			desc.deleteLastChar();
+		
+		saveList.push_back(SaveStateDescriptor(i, desc));
+	}
+
+	return saveList;
+}
+
+void PegasusMetaEngine::removeSaveState(const char *target, int slot) const {
+	// See listSaves() for info on the pattern
+	Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav");
+	g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str());
+}
+
 bool PegasusMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	const Pegasus::PegasusGameDescription *gd = (const Pegasus::PegasusGameDescription *)desc;
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index dacc2a0..3a9c7d1 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -25,6 +25,8 @@
 #include "common/events.h"
 #include "common/file.h"
 #include "common/fs.h"
+#include "common/memstream.h"
+#include "common/savefile.h"
 #include "common/textconsole.h"
 #include "common/translation.h"
 #include "base/plugins.h"
@@ -36,6 +38,7 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
+#include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/items/inventory/inventoryitem.h"
 
@@ -49,6 +52,8 @@
 namespace Pegasus {
 
 PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc) {
+	_continuePoint = 0;
+	_saveAllowed = _loadAllowed = true;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -59,6 +64,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _biochipLid;
 	delete _console;
 	delete _cursor;
+	delete _continuePoint;
 }
 
 Common::Error PegasusEngine::run() {
@@ -340,4 +346,146 @@ void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
 	_timeBases.remove(timeBase);
 }
 
+bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
+	// TODO: Dispose currently running stuff (neighborhood, etc.)
+
+	// Signature
+	uint32 creator = stream->readUint32BE();
+	if (creator != kPegasusPrimeCreator) {
+		warning("Bad save creator '%s'", tag2str(creator));
+		return false;
+	}
+
+	uint32 gameType = stream->readUint32BE();
+	int saveType;
+
+	switch (gameType) {
+	case kPegasusPrimeDisk1GameType:
+	case kPegasusPrimeDisk2GameType:
+	case kPegasusPrimeDisk3GameType:
+	case kPegasusPrimeDisk4GameType:
+		saveType = kNormalSave;
+		break;
+	case kPegasusPrimeContinueType:
+		saveType = kContinueSave;
+		break;
+	default:
+		// There are five other possible game types on the Pippin
+		// version, but hopefully we don't see any of those here
+		warning("Unhandled pegasus game type '%s'", tag2str(gameType));
+		return false;
+	}
+
+	uint32 version = stream->readUint32BE();
+	if (version != kPegasusPrimeVersion) {
+		warning("Where did you get this save? It's a beta (v%04x)!", version & 0x7fff);
+		return false;
+	}
+
+	// Game State
+	GameState.readGameState(stream);
+
+	// TODO: Energy
+	stream->readUint32BE();
+
+	// TODO: Death reason
+	stream->readByte();
+
+	// TODO: This is as far as we can go right now
+	return true;
+
+	// Items
+	g_allItems.readFromStream(stream);
+
+	// TODO: Player Inventory
+	// TODO: Player BioChips
+	// TODO: Disc check
+	// TODO: Jump to environment
+	// TODO: AI rules
+
+	// Make a new continue point if this isn't already one
+	if (saveType == kNormalSave)
+		makeContinuePoint();
+
+	return true;
+}
+
+bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
+	// Not ready yet! :P
+	return false;
+
+	// Signature
+	stream->writeUint32BE(kPegasusPrimeCreator);
+
+	if (saveType == kNormalSave) {
+		// TODO: Disc check
+		stream->writeUint32BE(kPegasusPrimeDisk1GameType);
+	} else { // Continue
+		stream->writeUint32BE(kPegasusPrimeContinueType);
+	}
+
+	stream->writeUint32BE(kPegasusPrimeVersion);
+
+	// Game State
+	GameState.writeGameState(stream);
+
+	// TODO: Energy
+	stream->writeUint32BE(0);
+
+	// TODO: Death reason
+	stream->writeByte(0);
+
+	// Items
+	g_allItems.writeToStream(stream);
+
+	// TODO: Player Inventory
+	// TODO: Player BioChips
+	// TODO: Jump to environment
+	// TODO: AI rules
+	return true;
+}
+
+void PegasusEngine::makeContinuePoint() {
+	delete _continuePoint;
+
+	Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);
+	writeToStream(&newPoint, kContinueSave);
+	_continuePoint = new Common::MemoryReadStream(newPoint.getData(), newPoint.size(), DisposeAfterUse::YES);
+}
+
+void PegasusEngine::loadFromContinuePoint() {
+	// Failure to load a continue point is fatal
+
+	if (!_continuePoint)
+		error("Attempting to load from non-existant continue point");
+
+	if (!loadFromStream(_continuePoint))
+		error("Failed loading continue point");
+}
+
+Common::Error PegasusEngine::loadGameState(int slot) {
+	Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
+	Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);
+	if (!loadFile)
+		return Common::kUnknownError;
+
+	bool valid = loadFromStream(loadFile);
+	warning("pos = %d", loadFile->pos());
+	delete loadFile;
+
+	return valid ? Common::kNoError : Common::kUnknownError;
+}
+
+Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
+	Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
+	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
+	if (!saveFile)
+		return Common::kUnknownError;
+
+	bool valid = writeToStream(saveFile, kNormalSave);
+	delete saveFile;
+
+	return valid ? Common::kNoError : Common::kUnknownError;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 5074aab..8d49050 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -72,22 +72,29 @@ friend class InputHandler;
 public:
 	PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc);
 	virtual ~PegasusEngine();
-	
+
+	// Engine stuff
 	const PegasusGameDescription *_gameDescription;
 	bool hasFeature(EngineFeature f) const;
 	GUI::Debugger *getDebugger();
-	
+	bool canLoadGameStateCurrently() { return _loadAllowed; }
+	bool canSaveGameStateCurrently() { return _saveAllowed; }
+	Common::Error loadGameState(int slot);
+	Common::Error saveGameState(int slot, const Common::String &desc);
+
+	// Base classes
 	VideoManager *_video;
 	GraphicsManager *_gfx;
 	Common::MacResManager *_resFork, *_inventoryLid, *_biochipLid;
 
+	// Misc.
 	bool isDemo() const;
-
 	void addIdler(Idler *idler);
 	void removeIdler(Idler *idler);
-
 	void addTimeBase(TimeBase *timeBase);
 	void removeTimeBase(TimeBase *timeBase);
+	void swapSaveAllowed(bool allow) { _saveAllowed = allow; }
+	void swapLoadAllowed(bool allow) { _loadAllowed = allow; }
 
 protected:
 	Common::Error run();
@@ -148,6 +155,14 @@ private:
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;
+
+	// Save/Load
+	bool loadFromStream(Common::ReadStream *stream);
+	bool writeToStream(Common::WriteStream *stream, int saveType);
+	void makeContinuePoint();
+	void loadFromContinuePoint();
+	Common::ReadStream *_continuePoint;
+	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
 };
 
 } // End of namespace Pegasus


Commit: da74436aa4d1c25f5120caa75197c2c4d9e0d1bc
    https://github.com/scummvm/scummvm/commit/da74436aa4d1c25f5120caa75197c2c4d9e0d1bc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-16T16:06:22-07:00

Commit Message:
PEGASUS: Implement fader support

Changed paths:
  A engines/pegasus/fader.cpp
  A engines/pegasus/fader.h
    engines/pegasus/module.mk
    engines/pegasus/sound.cpp
    engines/pegasus/sound.h
    engines/pegasus/timers.h



diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
new file mode 100755
index 0000000..c3cfe9d
--- /dev/null
+++ b/engines/pegasus/fader.cpp
@@ -0,0 +1,214 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/fader.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+Fader::Fader() {
+	_currentValue = 0;
+	_currentFaderMove._numKnots = 0;
+}
+
+void Fader::setFaderValue(const uint32 newValue) {
+	_currentValue = newValue;
+}
+
+bool Fader::initFaderMove(const FaderMoveSpec &spec) {	
+	bool faderMoves = false;
+	uint32 value = 0;
+
+	if (spec._numKnots > 0) {
+		stopFader();
+		value = spec._knots[0].knotValue;
+		TimeValue startTime = spec._knots[0].knotTime;
+
+		if (startTime != 0xffffffff) {
+			if (spec._numKnots > 1) {
+				TimeValue stopTime = spec._knots[spec._numKnots - 1].knotTime;
+
+				if (spec._faderScale > 0) {
+					if (stopTime > startTime) {
+						for (uint32 i = 1; i < spec._numKnots; ++i) {
+							if (spec._knots[i - 1].knotValue != spec._knots[i].knotValue) {
+								faderMoves = true;
+								break;
+							}
+						}
+
+						if (faderMoves)
+							_currentFaderMove = spec;
+					} else if (spec._knots[spec._numKnots - 1].knotValue != value) {
+						value = spec._knots[spec._numKnots - 1].knotValue;
+					}
+				}
+			}
+		}
+	}
+
+	setFaderValue(value);
+	return faderMoves;
+}
+
+void Fader::startFader(const FaderMoveSpec &spec) {
+	if (initFaderMove(spec)) {
+		setFlags(0);
+		setScale(spec._faderScale);
+		setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
+		setTime(spec._knots[0].knotTime);
+		start();
+	}
+}
+
+void Fader::startFaderSync(const FaderMoveSpec &spec) {
+	if (initFaderMove(spec)) {
+		setFlags(0);
+		setScale(spec._faderScale);
+		setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
+		setTime(spec._knots[0].knotTime);
+		start();
+
+		while (isFading())
+			useIdleTime();
+
+		// Once more, for good measure, to make sure that there are no boundary
+		// condition problems.
+		useIdleTime();
+		stopFader();
+	}
+}
+
+void Fader::loopFader(const FaderMoveSpec &spec) {
+	if (initFaderMove(spec)) {
+		setFlags(kLoopTimeBase);
+		setScale(spec._faderScale);
+		setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
+		setTime(spec._knots[0].knotTime);
+		start();
+	}
+}
+
+void Fader::stopFader() {
+	stop();
+}
+
+void Fader::pauseFader() {
+	stopFader();
+}
+
+void Fader::continueFader() {
+	if (getTime() < getStop())
+		start();
+}
+
+void Fader::timeChanged(const TimeValue newTime) {	
+	if (_currentFaderMove._numKnots != 0) {
+		uint32 i;
+		for (i = 0; i < _currentFaderMove._numKnots; i++)
+			if (_currentFaderMove._knots[i].knotTime > newTime)
+				break;
+
+		uint32 newValue;
+		if (i == 0)
+			newValue = _currentFaderMove._knots[0].knotValue;
+		else if (i == _currentFaderMove._numKnots)
+			newValue = _currentFaderMove._knots[i - 1].knotValue;
+		else
+			newValue = linearInterp(_currentFaderMove._knots[i - 1].knotTime, _currentFaderMove._knots[i].knotTime, newTime, _currentFaderMove._knots[i - 1].knotValue, _currentFaderMove._knots[i].knotValue);
+
+		if (newValue != _currentValue)
+			setFaderValue(newValue);
+	}
+}
+
+void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
+	_numKnots = 1;
+	_knots[0].knotTime = 0;
+	_knots[0].knotValue = knotValue;
+}
+
+void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeValue time1, const uint32 value1, const TimeValue time2, const uint32 value2) {
+	_numKnots = 2;
+	_faderScale = faderScale;
+	_knots[0].knotTime = time1;
+	_knots[0].knotValue = value1;
+	_knots[1].knotTime = time2;
+	_knots[1].knotValue = value2;
+}
+
+void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const uint32 knotValue) {	
+	if (_numKnots != kMaxFaderKnots) {
+		uint32 index;
+		for (index = 0; index < _numKnots; index++) {
+			if (knotTime == _knots[index].knotTime) {
+				_knots[index].knotValue = knotValue;
+				return;
+			} else if (knotTime < _knots[index].knotTime) {
+				break;
+			}
+		}
+
+		for (uint32 i = _numKnots; i > index; i--)
+			_knots[i] = _knots[i - 1];
+
+		_knots[index].knotTime = knotTime;
+		_knots[index].knotValue = knotValue;
+		_numKnots++;
+	}
+}
+
+void FaderAnimation::setFaderValue(const uint32 newValue) {
+	if (getFaderValue() != newValue) {
+		Fader::setFaderValue(newValue);
+		triggerRedraw();
+	}
+}
+
+SoundFader::SoundFader() {
+	_sound = 0;
+	_masterVolume = 0xff;
+}
+
+void SoundFader::attachSound(Sound *sound) {
+	if (!sound && isFading())
+		stopFader();
+
+	_sound = sound;
+}
+
+void SoundFader::setFaderValue(const uint32 newVolume) {	
+	if (_sound)
+		_sound->setVolume((newVolume * _masterVolume) >> 8);
+
+	_currentValue = newVolume;
+}
+
+void SoundFader::setMasterVolume(const uint16 masterVolume) {
+	_masterVolume = masterVolume;
+	setFaderValue(getFaderValue());
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
new file mode 100755
index 0000000..5ca1a5c
--- /dev/null
+++ b/engines/pegasus/fader.h
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_FADER_H
+#define PEGASUS_FADER_H
+
+#include "pegasus/elements.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class Fader;
+
+class FaderMoveSpec {
+friend class Fader;
+public:
+	FaderMoveSpec() {
+		_faderScale = kDefaultTimeScale;
+		_numKnots = 0;
+	}
+
+	FaderMoveSpec(const TimeScale scale) {
+		_faderScale = scale;
+		_numKnots = 0;
+	}
+
+	void setFaderScale(const TimeScale scale) { _faderScale = scale; }
+	TimeScale getFaderScale() const { return _faderScale; }
+
+	void makeOneKnotFaderSpec(const uint32);
+	void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const uint32, const TimeValue, const uint32);
+
+	void insertFaderKnot(const TimeValue, const uint32);
+
+	uint32 getNumKnots() const { return _numKnots; }
+	uint32 getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
+	uint32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }
+
+protected:
+	struct FaderKnot {
+		TimeValue knotTime;
+		uint32 knotValue;
+	};
+	
+	TimeScale _faderScale;
+	uint32 _numKnots;
+
+	static const uint32 kMaxFaderKnots = 20;
+	FaderKnot _knots[kMaxFaderKnots];
+};
+
+class Fader : private IdlerTimeBase {
+public:
+	Fader();
+	virtual ~Fader() {}
+
+	virtual void setFaderValue(const uint32);
+	uint32 getFaderValue() const { return _currentValue; }
+	virtual void startFader(const FaderMoveSpec &);
+	virtual void startFaderSync(const FaderMoveSpec &);
+	virtual void loopFader(const FaderMoveSpec &);
+	virtual void stopFader();
+	virtual bool isFading() { return isRunning(); }
+
+	void pauseFader();
+	void continueFader();
+
+	void getCurrentFaderMove(FaderMoveSpec &spec) { spec = _currentFaderMove; }
+
+protected:
+	bool initFaderMove(const FaderMoveSpec &);
+	virtual void timeChanged(const TimeValue);
+	
+	uint32 _currentValue;
+	FaderMoveSpec _currentFaderMove;
+};
+
+class FaderAnimation : public DisplayElement, public Fader {
+public:
+	FaderAnimation(const tDisplayElementID id) : DisplayElement(id) {}
+	virtual ~FaderAnimation() {}
+
+	void setFaderValue(const uint32);
+};
+
+class Sound;
+
+class SoundFader : public Fader {
+friend class Sound;
+public:
+	SoundFader();
+	virtual ~SoundFader() {}
+
+	void setFaderValue(const uint32);
+
+	void setMasterVolume(const uint16);
+	uint16 getMasterVolume() const { return _masterVolume; }
+
+protected:
+	void attachSound(Sound *);
+
+	Sound *_sound;
+	uint16 _masterVolume;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 0f697f3..ca262cb 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS = \
 	cursor.o \
 	detection.o \
 	elements.o \
+	fader.o \
 	gamestate.o \
 	graphics.o \
 	hotspot.o \
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
index 5db1d90..847106a 100755
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@ -29,6 +29,7 @@
 #include "common/file.h"
 #include "common/system.h"
 
+#include "pegasus/fader.h"
 #include "pegasus/sound.h"
 
 namespace Pegasus {
@@ -36,6 +37,7 @@ namespace Pegasus {
 Sound::Sound() {
 	_stream = 0;
 	_volume = 0xFF;
+	_fader = 0;
 }
 
 Sound::~Sound() {
@@ -65,18 +67,15 @@ void Sound::initFromQuickTime(const Common::String &fileName) {
 	_stream = Audio::makeQuickTimeStream(fileName);
 }
 
-#if 0
-// TODO!
 void Sound::attachFader(SoundFader *fader) {
 	if (_fader)
-		_fader->attachSound(NULL);
+		_fader->attachSound(0);
 
 	_fader = fader;
 
 	if (_fader)
 		_fader->attachSound(this);
 }
-#endif
 
 void Sound::playSound() {
 	if (!isSoundLoaded())
@@ -84,11 +83,8 @@ void Sound::playSound() {
 
 	stopSound();
 
-#if 0
-	// TODO!
 	if (_fader)
 		setVolume(_fader->getFaderValue());
-#endif
 
 	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, _stream, -1, _volume, 0, DisposeAfterUse::NO);
 }
@@ -102,12 +98,9 @@ void Sound::loopSound() {
 	// Create a looping stream
 	Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
 
-#if 0
-	// TODO!
 	// Assume that if there is a fader, we're going to fade the sound in.
 	if (_fader)
 		setVolume(0);
-#endif
 
 	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
 }
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
index 99607d4..f66c3f4 100755
--- a/engines/pegasus/sound.h
+++ b/engines/pegasus/sound.h
@@ -35,8 +35,7 @@ namespace Audio {
 
 namespace Pegasus {
 
-// TODO!
-//class SoundFader;
+class SoundFader;
 
 //	Things you might want to do with sound:
 //		Start it
@@ -73,16 +72,14 @@ public:
 	void setVolume(const uint16 volume);
 	bool isPlaying();
 
-	// TODO!
-	//void attachFader(SoundFader *fader);
+	void attachFader(SoundFader *fader);
 
 protected:
 	Audio::SeekableAudioStream *_stream;
 	Audio::SoundHandle _handle;
 	byte _volume;
 
-	// TODO!
-	//SoundFader *_fader;
+	SoundFader *_fader;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 9ce3093..52f420e 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -26,6 +26,7 @@
 #ifndef PEGASUS_TIMERS_H
 #define PEGASUS_TIMERS_H
 
+#include "common/list.h"
 #include "common/rational.h"
 
 #include "pegasus/constants.h"


Commit: 3b9ab4f5cf6a868300e49067ec116ca8b15903c8
    https://github.com/scummvm/scummvm/commit/3b9ab4f5cf6a868300e49067ec116ca8b15903c8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-17T09:02:15-07:00

Commit Message:
COMMON: Add function to find the intersecting rectangle

Changed paths:
    common/rect.h



diff --git a/common/rect.h b/common/rect.h
index 768d1eb..1106ec1 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -170,6 +170,20 @@ struct Rect {
 	}
 
 	/**
+	 * Find the intersecting rectangle between this rectangle and the given rectangle
+	 *
+	 * @param r the intersecting rectangle
+	 *
+	 * @return the intersection of the rectangles or an empty rectangle if not intersecting
+	 */
+	Rect findIntersectingRect(const Rect &r) const {
+		if (!intersects(r))
+			return Rect();
+
+		return Rect(MAX(r.left, left), MAX(r.top, top), MIN(r.right, right), MIN(r.bottom, bottom));
+	}
+
+	/**
 	 * Extend this rectangle so that it contains r
 	 *
 	 * @param r the rectangle to extend by


Commit: 544224b43aa0f7d74e40fc11c18dbbb8bb7dfd81
    https://github.com/scummvm/scummvm/commit/544224b43aa0f7d74e40fc11c18dbbb8bb7dfd81
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-17T09:04:21-07:00

Commit Message:
PEGASUS: Add transition classes

Changed paths:
  A engines/pegasus/transition.cpp
  A engines/pegasus/transition.h
    engines/pegasus/module.mk
    engines/pegasus/util.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index ca262cb..01c069e 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
 	pegasus.o \
 	sound.o \
 	timers.o \
+	transition.o \
 	util.o \
 	video.o \
 	items/inventory.o \
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
new file mode 100755
index 0000000..20b9959
--- /dev/null
+++ b/engines/pegasus/transition.cpp
@@ -0,0 +1,150 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/system.h"
+
+#include "pegasus/transition.h"
+
+namespace Pegasus {
+
+ScreenFader::ScreenFader() {
+	_fadeTarget = getBlack();
+	// Initially, assume screens are on at full brightness.
+	Fader::setFaderValue(100);
+}
+
+void ScreenFader::doFadeOutSync(const TimeValue duration, const TimeValue scale, const uint32 fadeTarget) {
+	_fadeTarget = fadeTarget;
+
+	FaderMoveSpec spec;
+	spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 0);
+	startFaderSync(spec);
+}
+
+void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale, const uint32 fadeTarget) {
+	_fadeTarget = fadeTarget;
+
+	FaderMoveSpec spec;
+	spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 100);
+	startFaderSync(spec);
+}
+
+void ScreenFader::setFaderValue(const uint32 value) {
+	if (value != getFaderValue()) {
+		Fader::setFaderValue(value);
+
+		// TODO: Gamma fading
+	}
+}
+
+uint32 ScreenFader::getBlack() {
+	return g_system->getScreenFormat().RGBToColor(0, 0, 0);
+}
+
+Transition::Transition(const tDisplayElementID id) : FaderAnimation(id) {
+	_outPicture = 0;
+	_inPicture = 0;
+}
+
+void Transition::setBounds(const Common::Rect &r) {
+	FaderAnimation::setBounds(r);
+	_boundsWidth = _bounds.width();
+	_boundsHeight = _bounds.height();
+}
+
+void Transition::setInAndOutElements(DisplayElement *inElement, DisplayElement *outElement) {
+	_inPicture = inElement;
+	_outPicture = outElement;
+
+	Common::Rect r;
+
+	if (_outPicture)
+		_outPicture->getBounds(r);
+	else if (_inPicture)
+		_inPicture->getBounds(r);
+
+	setBounds(r);
+}
+
+void Slide::draw(const Common::Rect &r) {
+	Common::Rect oldBounds, newBounds;
+	
+	adjustSlideRects(oldBounds, newBounds);
+	drawElements(r, oldBounds, newBounds);
+}
+
+void Slide::adjustSlideRects(Common::Rect &oldBounds, Common::Rect &newBounds) {
+	oldBounds = _bounds;
+	newBounds = _bounds;
+}
+
+void Slide::drawElements(const Common::Rect &drawRect, const Common::Rect &oldBounds, const Common::Rect &newBounds) {
+	drawSlideElement(drawRect, oldBounds, _outPicture);
+	drawSlideElement(drawRect, newBounds, _inPicture);
+}
+
+void Slide::drawSlideElement(const Common::Rect &drawRect, const Common::Rect &oldBounds, DisplayElement *picture) {
+	if (picture && drawRect.intersects(oldBounds)) {
+		picture->moveElementTo(oldBounds.left, oldBounds.top);
+		picture->draw(drawRect.findIntersectingRect(oldBounds));
+	}
+}
+
+void Push::adjustSlideRects(Common::Rect &oldBounds, Common::Rect &newBounds) {
+	switch (_direction & kSlideHorizMask) {
+		case kSlideLeftMask:
+			newBounds.left = oldBounds.right = _bounds.right - pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
+			newBounds.right = newBounds.left + _boundsWidth;
+			oldBounds.left = oldBounds.right - _boundsWidth;
+			break;
+		case kSlideRightMask:
+			oldBounds.left = newBounds.right = _bounds.left + pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
+			oldBounds.right = oldBounds.left + _boundsWidth;
+			newBounds.left = newBounds.right - _boundsWidth;
+			break;
+		default:
+			newBounds.left = oldBounds.left = _bounds.left;
+			newBounds.right = oldBounds.right = _bounds.right;
+			break;
+	}
+	switch (_direction & kSlideVertMask) {
+		case kSlideDownMask:
+			oldBounds.top = newBounds.bottom = _bounds.top + pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
+			oldBounds.bottom = oldBounds.top + _boundsHeight;
+			newBounds.top = newBounds.bottom - _boundsHeight;
+			break;
+		case kSlideUpMask:
+			newBounds.top = oldBounds.bottom = _bounds.bottom - pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
+			newBounds.bottom = newBounds.top + _boundsHeight;
+			oldBounds.top = oldBounds.bottom - _boundsHeight;
+			break;
+		default:
+			newBounds.top = oldBounds.top = _bounds.top;
+			newBounds.bottom = oldBounds.bottom = _bounds.bottom;
+			break;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
new file mode 100755
index 0000000..d34f318
--- /dev/null
+++ b/engines/pegasus/transition.h
@@ -0,0 +1,105 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_TRANSITION_H
+#define PEGASUS_TRANSITION_H
+
+#include "pegasus/fader.h"
+
+namespace Pegasus {
+
+class ScreenFader : public Fader {
+public:
+	ScreenFader();
+	virtual ~ScreenFader() {}
+	
+	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
+	void doFadeInSync(const TimeValue = kHalfSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
+
+	void setFaderValue(const uint32);	
+
+protected:
+	uint32 _fadeTarget;
+
+private:
+	static uint32 getBlack();
+};
+
+//	Transitions are faders that range over [0,1000], which makes their
+//	"resolution" one tenth of a percent
+
+const long kTransitionBottom = 0;
+const long kTransitionTop = 1000;
+
+const long kTransitionRange = kTransitionTop - kTransitionBottom;
+
+class Transition : public FaderAnimation {
+public:
+	Transition(const tDisplayElementID id);
+	virtual ~Transition() {}
+	
+	virtual void setBounds(const Common::Rect &);
+	
+	virtual void setInAndOutElements(DisplayElement *, DisplayElement *);
+	DisplayElement *getInElement() { return _inPicture; }
+	DisplayElement *getOutElement() { return _outPicture; }
+
+protected:
+	DisplayElement *_outPicture;
+	DisplayElement *_inPicture;
+
+	tCoordType _boundsWidth, _boundsHeight;
+};
+
+class Slide : public Transition {
+public:
+	Slide(const tDisplayElementID id) : Transition(id) {}
+	virtual ~Slide() {}
+
+	virtual void setSlideDirection(tSlideDirection dir) { _direction = dir; }
+	virtual void draw(const Common::Rect &);
+
+	virtual void setDirection(const tSlideDirection dir) { _direction = dir; }
+
+protected:
+	virtual void adjustSlideRects(Common::Rect &, Common::Rect &);
+	virtual void drawElements(const Common::Rect &, const Common::Rect &, const Common::Rect &);
+	virtual void drawSlideElement(const Common::Rect &, const Common::Rect &, DisplayElement *);
+
+	tSlideDirection _direction;
+};
+
+class Push : public Slide {
+public:
+	Push(const tDisplayElementID id) : Slide(id) {}
+	virtual ~Push() {}
+
+protected:
+	virtual void adjustSlideRects(Common::Rect &, Common::Rect &);
+};
+
+} // End of namespace Pegasus
+
+#endif
\ No newline at end of file
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index 83c0c33..459c138 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -67,6 +67,8 @@ int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1,
 
 void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random);
 
+int32 pegasusRound(const int32 a, const int32 b);
+
 } // End of namespace Pegasus
 
 #endif


Commit: 331da0377b1baa82e7e10034cfe8655d8a7d9f31
    https://github.com/scummvm/scummvm/commit/331da0377b1baa82e7e10034cfe8655d8a7d9f31
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-17T09:24:51-07:00

Commit Message:
PEGASUS: Add the fuse classes

Changed paths:
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index fe487e9..03e7a64 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -332,4 +332,51 @@ void NotificationCallBack::callBack() {
 		_notifier->setNotificationFlags(_callBackFlag, _callBackFlag);
 }
 
+static const tNotificationFlags kFuseExpiredFlag = 1;
+
+Fuse::Fuse() : _fuseNotification(0, (NotificationManager *)((PegasusEngine *)g_engine)) {
+	_fuseNotification.notifyMe(this, kFuseExpiredFlag, kFuseExpiredFlag);
+	_fuseCallBack.setNotification(&_fuseNotification);
+	_fuseCallBack.initCallBack(&_fuseTimer, kCallBackAtExtremes);
+	_fuseCallBack.setCallBackFlag(kFuseExpiredFlag);
+}
+
+void Fuse::primeFuse(const TimeValue frequency, const TimeScale scale) {
+	stopFuse();
+	_fuseTimer.setScale(scale);
+	_fuseTimer.setSegment(0, frequency);
+	_fuseTimer.setTime(0);
+}
+
+void Fuse::lightFuse() {
+	if (!_fuseTimer.isRunning()) {
+		_fuseCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		_fuseTimer.start();
+	}
+}
+
+void Fuse::stopFuse() {
+	_fuseTimer.stop();
+	_fuseCallBack.cancelCallBack();
+	// Make sure the fuse has not triggered but not been caught yet...
+	_fuseNotification.setNotificationFlags(0, 0xffffffff);
+}
+
+void Fuse::advanceFuse(const TimeValue time) {
+	if (_fuseTimer.isRunning()) {
+		_fuseTimer.stop();
+		_fuseTimer.setTime(_fuseTimer.getTime() + time);
+		_fuseTimer.start();
+	}
+}
+
+TimeValue Fuse::getTimeRemaining() {
+	return _fuseTimer.getStop() - _fuseTimer.getTime();
+}
+
+void Fuse::receiveNotification(Notification *, const tNotificationFlags) {
+	stopFuse();
+	invokeAction();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 52f420e..55c2ba0 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -30,6 +30,8 @@
 #include "common/rational.h"
 
 #include "pegasus/constants.h"
+#include "pegasus/notification.h"
+#include "pegasus/util.h"
 
 namespace Pegasus {
 
@@ -188,8 +190,6 @@ protected:
 
 };
 
-class Notification;
-
 class NotificationCallBack : public TimeBaseCallBack {
 public:
 	NotificationCallBack();
@@ -212,6 +212,41 @@ public:
 	TimeValue percentSeconds(const uint32 percent) { return getScale() * percent / 100; }
 };
 
+class Fuse : private NotificationReceiver {
+public:
+	Fuse();
+	virtual ~Fuse() {}
+
+	void primeFuse(const TimeValue, const TimeScale = 1); // An appropriately named function :P
+	void lightFuse();
+	void stopFuse();
+	bool isFuseLit() { return _fuseTimer.isRunning() || _fuseTimer.isPaused(); }
+	void advanceFuse(const TimeValue);
+	TimeValue getTimeRemaining();
+	TimeScale getFuseScale() { return _fuseTimer.getScale(); }
+
+	void pauseFuse() { _fuseTimer.pause(); }
+	void resumeFuse() { _fuseTimer.resume(); }
+	bool isFusePaused() { return _fuseTimer.isPaused(); }
+
+protected:
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual void invokeAction() {}
+
+	TimeBase _fuseTimer;
+	NotificationCallBack _fuseCallBack;
+	Notification _fuseNotification;
+};
+
+class FuseFunction : public Fuse, public FunctionPtr {
+public:
+	FuseFunction();
+	virtual ~FuseFunction();
+
+protected:
+	virtual void invokeAction() { callFunction(); }
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: e90287f7f1063e9784239c5be558b7fb6cd3aa54
    https://github.com/scummvm/scummvm/commit/e90287f7f1063e9784239c5be558b7fb6cd3aa54
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-17T18:16:36-07:00

Commit Message:
COMMON: Add numerator/denominator getters for Rational

Changed paths:
    common/rational.h



diff --git a/common/rational.h b/common/rational.h
index 45aa6a7..8270d21 100644
--- a/common/rational.h
+++ b/common/rational.h
@@ -80,6 +80,9 @@ public:
 	double toDouble() const;
 	frac_t toFrac() const;
 
+	int getNumerator() const { return _num; }
+	int getDenominator() const { return _denom; }
+
 	void debugPrint(int debuglevel = 0, const char *caption = "Rational:") const;
 
 private:


Commit: 1390db1df12a8a853deca62df2e11a899c111fcf
    https://github.com/scummvm/scummvm/commit/1390db1df12a8a853deca62df2e11a899c111fcf
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-18T12:36:05-07:00

Commit Message:
PEGASUS: Rewrite TimeBase to be a bit more accurate with timing

Changed paths:
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 03e7a64..1699867 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -56,6 +56,16 @@ TimeBase::TimeBase(const TimeScale preferredScale) {
 	_callBackList = 0;
 	_paused = false;
 	_flags = 0;
+	_lastMillis = 0;
+	_time = 0;
+	_rate = 0;
+	_startTime = 0;
+	_startScale = 1;
+	_stopTime = 0xffffffff;
+	_stopScale = 1;
+	_master = 0;
+	_pausedRate = 0;
+	
 	((PegasusEngine *)g_engine)->addTimeBase(this);
 }
 
@@ -70,39 +80,18 @@ TimeBase::~TimeBase() {
 }
 
 void TimeBase::setTime(const TimeValue time, const TimeScale scale) {
-	// So, we're saying the *current* time from g_system->getMillis() is
-	// what time/scale is. Which means we need to subtract time/scale from
-	// the offset so that g_system->getMillis() - _currentOffset is
-	// equal to time/scale.
-	_timeOffset = g_system->getMillis() - time * 1000 / ((scale == 0) ? _preferredScale : scale);
-
-	// TODO: Also adjust the slaves' offsets (once we're actually using the
-	// masters for calculating time)
+	_time = Common::Rational(time, (scale == 0) ? _preferredScale : scale);
 }
 
 TimeValue TimeBase::getTime(const TimeScale scale) {
-	if (_paused)
-		return _pausedTime;
-
-	Common::Rational normalTime = Common::Rational((g_system->getMillis() - _timeOffset) * ((scale == 0) ? _preferredScale : scale), 1000);
-
-	// Adjust it according to our rate
-	return (normalTime * getEffectiveRate()).toInt();
+	return _time.getNumerator() * ((scale == 0) ? _preferredScale : scale) / _time.getDenominator();
 }
 
 void TimeBase::setRate(const Common::Rational rate) {
-	if (rate == 0) {
-		_paused = false;
-		_timeOffset = 0;
-	} else if (_timeOffset != 0) {
-		// Convert the time from the old rate to the new rate
-		_timeOffset = g_system->getMillis() - (rate * (g_system->getMillis() - _timeOffset) / _rate).toInt();
-	} else {
-		// TODO: Check this
-		setTime(_startTime, _startScale);
-	}
-
 	_rate = rate;
+
+	if (_rate == 0)
+		_paused = false;
 }
 
 Common::Rational TimeBase::getEffectiveRate() const {
@@ -125,7 +114,6 @@ void TimeBase::pause() {
 	if (isRunning() && !_paused) {
 		_pausedRate = getRate();
 		stop();
-		_pausedTime = getTime();
 		_paused = true;
 	}
 }
@@ -150,9 +138,9 @@ bool TimeBase::isRunning() {
 		return true;
 
 	if (rate > 0)
-		return getTime() < getStop();
+		return getTime() != getStop();
 
-	return getTime() > getStart();
+	return getTime() != getStart();
 }
 
 void TimeBase::setStart(const TimeValue startTime, const TimeScale scale) {
@@ -208,31 +196,55 @@ void TimeBase::setMasterTimeBase(TimeBase *tb) {
 }
 
 void TimeBase::checkCallBacks() {
-	uint32 time = getTime();
-	uint32 startTime = getStart();
-	uint32 stopTime = getStop();
+	// Nothing to do if we're paused or not running
+	if (_paused || !isRunning())
+		return;
+
+	Common::Rational startTime = Common::Rational(_startTime, _startScale);
+	Common::Rational stopTime = Common::Rational(_stopTime, _stopScale);
+
+	// First step: update the times
+	if (_lastMillis == 0) {
+		_lastMillis = g_system->getMillis();
+	} else {
+		uint32 curTime = g_system->getMillis();
+		if (_lastMillis == curTime) // No change
+			return;
+
+		_time += Common::Rational(curTime - _lastMillis, 1000) * getEffectiveRate();
+		_lastMillis = curTime;
+
+		// Clip time to the boundaries
+		if (_time >= stopTime)
+			_time = stopTime;
+		else if (_time <= startTime)
+			_time = startTime;
+	}
+
+	// TODO: Update the slaves?
 
+	// Check if we've triggered any callbacks
 	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
 		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
-			if (time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
+			if (_time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
 				runner->callBack();
 		} else if (runner->_type == kCallBackAtExtremes) {
 			if (runner->_trigger == kTriggerAtStop) {
-				if (time >= stopTime)
+				if (_time == stopTime)
 					runner->callBack();
 			} else if (runner->_trigger == kTriggerAtStart) {
-				if (time <= startTime)
+				if (_time == startTime)
 					runner->callBack();
 			}
 		}
 	}
 
+	// Loop if necessary
 	if (getFlags() & kLoopTimeBase) {
-		// Loop
-		if (time >= startTime)
-			setTime(stopTime);
-		else if (time <= stopTime)
-			setTime(startTime);
+		if (_time == startTime)
+			_time = stopTime;
+		else if (_time == stopTime)
+			_time = startTime;
 	}
 }
 
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 55c2ba0..04dd235 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -115,9 +115,10 @@ protected:
 	bool _paused;
 	uint32 _startTime, _startScale;
 	uint32 _stopTime, _stopScale;
-	int32 _timeOffset;
 	uint32 _flags;
-	TimeValue _pausedTime;
+
+	Common::Rational _time;
+	uint32 _lastMillis;
 
 private:
 	Common::Rational getEffectiveRate() const;


Commit: 8f6e6030999e7263062461eaf6e0fe378a3892ba
    https://github.com/scummvm/scummvm/commit/8f6e6030999e7263062461eaf6e0fe378a3892ba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-18T12:48:31-07:00

Commit Message:
PEGASUS: Add the Tracker class

Changed paths:
    engines/pegasus/input.cpp
    engines/pegasus/input.h



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 37f9945..9ef369e 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -267,4 +267,31 @@ bool InputHandler::wantsCursor() {
 	return false;
 }
 
+Tracker *Tracker::_currentTracker = 0;
+
+void Tracker::handleInput(const Input &input, const Hotspot *) {
+	if (stopTrackingInput(input))
+		stopTracking(input);
+	else if (isTracking())
+		continueTracking(input);
+}
+
+void Tracker::startTracking(const Input &) {
+	if (!isTracking()) {
+		_savedHandler = InputHandler::setInputHandler(this);
+		_currentTracker = this;
+	}
+}
+
+void Tracker::stopTracking(const Input &) {
+	if (isTracking()) {
+		_currentTracker = NULL;
+		InputHandler::setInputHandler(_savedHandler);
+	}
+}
+
+bool Tracker::isClickInput(const Input &input, const Hotspot *hotspot) {
+	return !isTracking() && InputHandler::isClickInput(input, hotspot);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 432ff80..4da0418 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -414,6 +414,41 @@ protected:
 	bool _allowInput;
 };
 
+
+/*
+
+	Tracker implements "dragging". A Tracker can receive a startTracking message,
+	which causes it to be the current tracker, as well as setting it up as the current
+	input handler. In addition, only one tracker can be tracking at a time, and no
+	other handler can be set up as the current handler until the track finishes. By
+	default, there is no next input handler for a Tracker, but this behavior can be
+	overridden if desired.
+
+*/
+
+class Tracker : public InputHandler {
+public:
+	Tracker() : InputHandler(0) {}
+	virtual ~Tracker();
+
+	virtual void handleInput(const Input &, const Hotspot *);
+	virtual bool stopTrackingInput(const Input &) { return false; }
+
+	virtual void startTracking(const Input &);
+	virtual void stopTracking(const Input &);
+	virtual void continueTracking(const Input &) {}
+
+	bool isTracking() { return this == _currentTracker; }
+	bool isClickInput(const Input &, const Hotspot *);
+
+	bool releaseInputFocus() { return !isTracking(); }
+
+protected:
+	static Tracker *_currentTracker;
+
+	InputHandler *_savedHandler;
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: 6ed2679cf1442cb647351792c97b126195a649e7
    https://github.com/scummvm/scummvm/commit/6ed2679cf1442cb647351792c97b126195a649e7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-19T16:07:11-07:00

Commit Message:
PEGASUS: Add the Surface classes

Renamed from GWorld; I'm trying to distance us from QuickDraw as much as possible :P

Changed paths:
  A engines/pegasus/surface.cpp
  A engines/pegasus/surface.h
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h
    engines/pegasus/graphics.cpp
    engines/pegasus/module.mk



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index f9881e7..faf46f7 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -28,6 +28,7 @@
 
 #include "pegasus/elements.h"
 #include "pegasus/graphics.h"
+#include "pegasus/surface.h"
 
 namespace Pegasus {
 
@@ -70,7 +71,10 @@ void DisplayElement::stopDisplaying() {
 }
 
 void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
-	_bounds = Common::Rect(left, top, right, bottom);
+	_bounds.left = left;
+	_bounds.top = top;
+	_bounds.right = right;
+	_bounds.bottom = bottom;
 }
 
 void DisplayElement::getBounds(Common::Rect &r) const {
@@ -354,4 +358,170 @@ bool FrameSequence::isSequenceOpen() const {
 	return _numFrames != 0;
 }
 
+Sprite::Sprite(const tDisplayElementID id) : DisplayElement(id) {
+	_numFrames = 0;
+	_currentFrameNum = 0xffffffff;
+	_currentFrame = 0;
+}
+
+Sprite::~Sprite() {
+	discardFrames();
+}
+
+void Sprite::discardFrames() {
+	if (!_frameArray.empty()) {
+		for (uint32 i = 0; i < _numFrames; i++) {
+			SpriteFrame *frame = _frameArray[i].frame;
+			frame->_referenceCount--;
+			if (frame->_referenceCount == 0)
+				delete frame;
+		}
+
+		_frameArray.clear();
+		_numFrames = 0;
+		_currentFrame = 0;
+		_currentFrameNum = 0xffffffff;
+		setBounds(0, 0, 0, 0);
+	}
+}
+
+void Sprite::addPICTResourceFrame(const tResIDType pictID, bool transparent, const tCoordType left, const tCoordType top) {
+	SpriteFrame *frame = new SpriteFrame();
+	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, pictID, transparent);
+	addFrame(frame, left, top);
+}
+
+uint32 Sprite::addFrame(SpriteFrame *frame, const tCoordType left, const tCoordType top) {
+	SpriteFrameRec frameRecord;
+	frameRecord.frame = frame;
+	frameRecord.frameLeft = left;
+	frameRecord.frameTop = top;
+	_frameArray.push_back(frameRecord);
+	_numFrames++;
+	frame->_referenceCount++;
+
+	Common::Rect frameBounds;
+	frame->getSurfaceBounds(frameBounds);
+
+	// 9/3/96
+	// BB Should this be + left or - left?
+	frameBounds.moveTo(_bounds.left + left, _bounds.top + top);
+
+	frameBounds.extend(_bounds);
+
+	if (_bounds != frameBounds)
+		setBounds(frameBounds);
+
+	return _numFrames - 1;
+}
+
+void Sprite::removeFrame(const uint32 frameNum) {
+	_frameArray[frameNum].frame->_referenceCount--;
+	if (_frameArray[frameNum].frame->_referenceCount == 0)
+		delete _frameArray[frameNum].frame;
+
+	// Calculate the new bounds
+	Common::Rect frameBounds;
+	for (uint32 i = 0; i < _numFrames; i++) {
+		if (i == frameNum)
+			continue;
+
+		Common::Rect r;
+		_frameArray[i].frame->getSurfaceBounds(r);
+		r.translate(_frameArray[i].frameLeft, _frameArray[i].frameTop);
+		frameBounds.extend(r);
+	}
+
+	_frameArray.remove_at(frameNum);
+
+	frameBounds.moveTo(_bounds.left, _bounds.top);
+	setBounds(frameBounds);
+
+	if (_currentFrameNum == frameNum)
+		triggerRedraw();
+	else if (_currentFrameNum != 0xffffffff && _currentFrameNum > frameNum)
+		--_currentFrameNum;
+}
+
+void Sprite::setCurrentFrameIndex(const int32 frameNum) {	
+	if (frameNum < 0) {
+		if (_currentFrameNum != 0xffffffff) {
+			_currentFrameNum = 0xffffffff;
+			_currentFrame = 0;
+			triggerRedraw();
+		}
+	} else if (_numFrames > 0) {
+		uint32 f = frameNum % _numFrames;
+		if (f != _currentFrameNum) {
+			_currentFrameNum = f;
+			_currentFrame = &_frameArray[f];
+			triggerRedraw();
+		}
+	}
+}
+
+SpriteFrame *Sprite::getFrame(const int32 index) {
+	if (index < 0 || (uint32)index >= _numFrames)
+		return 0;
+
+	return _frameArray[index].frame;
+}
+
+void Sprite::draw(const Common::Rect &r) {
+	if (_currentFrame) {
+		Common::Rect frameBounds;
+		_currentFrame->frame->getSurfaceBounds(frameBounds);
+
+		frameBounds.translate(_bounds.left + _currentFrame->frameLeft, _bounds.top + _currentFrame->frameTop);
+		Common::Rect r1 = frameBounds.findIntersectingRect(r);
+
+		Common::Rect r2 = frameBounds;
+		r2.translate(frameBounds.left - _bounds.left - _currentFrame->frameLeft, frameBounds.top - _bounds.top - _currentFrame->frameTop);
+
+		_currentFrame->frame->drawImage(r2, r1);
+	}
+}
+
+SpriteSequence::SpriteSequence(const tDisplayElementID id, const tDisplayElementID spriteID) :
+		FrameSequence(id), _sprite(spriteID), _transparent(false) {
+}
+
+void SpriteSequence::openFrameSequence() {	
+	if (!isSequenceOpen()) {
+		FrameSequence::openFrameSequence();
+
+		if (isSequenceOpen()) {
+			uint32 numFrames = getNumFrames();
+
+			for (uint32 i = 0; i < numFrames; ++i) {
+				SpriteFrame *frame = new SpriteFrame();
+				frame->initFromPICTResource(_resFork, i + 0x80, _transparent);
+				_sprite.addFrame(frame, 0, 0);
+			}
+
+			_sprite.setBounds(_bounds);
+		}
+	}
+}
+
+void SpriteSequence::closeFrameSequence() {
+	if (isSequenceOpen()) {
+		FrameSequence::closeFrameSequence();
+		_sprite.discardFrames();
+	}
+}
+
+void SpriteSequence::setBounds(const Common::Rect &bounds) {
+	FrameSequence::setBounds(bounds);
+	_sprite.setBounds(_bounds);
+}
+
+void SpriteSequence::draw(const Common::Rect &r) {
+	_sprite.draw(r);
+}
+
+void SpriteSequence::newFrame(const uint16 frame) {
+	_sprite.setCurrentFrameIndex(frame);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 460b9a7..97f982a 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -193,6 +193,66 @@ protected:
 	uint16 _currentFrameNum;
 };
 
+class SpriteFrame;
+
+class Sprite : public DisplayElement {
+friend class SpriteFrame;
+public:
+	Sprite(const tDisplayElementID);
+	virtual ~Sprite();
+
+	virtual void addPICTResourceFrame(const tResIDType, const bool, const tCoordType, const tCoordType);
+	virtual uint32 addFrame(SpriteFrame *, const tCoordType, const tCoordType);
+	virtual void removeFrame(const uint32);
+	virtual void discardFrames();
+	
+	// Setting the current frame.
+	// If the index is negative, sets the current frame to NULL and hides the sprite.
+	// If the index is larger than the number of frames in the sprite, the number
+	// is treated modulo the number of frames.
+	virtual void setCurrentFrameIndex(const int32);
+	virtual uint32 getCurrentFrameIndex() const { return _currentFrameNum; }
+	
+	virtual SpriteFrame *getFrame(const int32);
+	
+	virtual void draw(const Common::Rect &);
+	
+	uint32 getNumFrames() const { return _numFrames; }
+
+protected:
+	struct SpriteFrameRec {
+		SpriteFrame *frame;
+		tCoordType frameLeft;
+		tCoordType frameTop;
+	};
+
+	uint32 _numFrames;
+	uint32 _currentFrameNum;
+	SpriteFrameRec *_currentFrame;
+	Common::Array<SpriteFrameRec> _frameArray;
+};
+
+class SpriteSequence : public FrameSequence {
+public:
+	SpriteSequence(const tDisplayElementID id, const tDisplayElementID spriteID);
+	virtual ~SpriteSequence() {}
+
+	void useTransparent(bool transparent) { _transparent = transparent; }
+
+	virtual void openFrameSequence();
+	virtual void closeFrameSequence();
+
+	virtual void draw(const Common::Rect &);
+
+	virtual void setBounds(const Common::Rect &);
+
+protected:
+	virtual void newFrame(const uint16);
+
+	bool _transparent;
+	Sprite _sprite;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index d5d6350..a30b2c8 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -195,10 +195,7 @@ void GraphicsManager::invalRect(const Common::Rect &rect) {
 		_dirtyRect = rect;
 	} else {
 		// Expand our dirty rect to include rect
-		_dirtyRect.left = MIN<int>(_dirtyRect.left, rect.left);
-		_dirtyRect.top = MIN<int>(_dirtyRect.top, rect.top);
-		_dirtyRect.right = MAX<int>(_dirtyRect.right, rect.right);
-		_dirtyRect.bottom = MAX<int>(_dirtyRect.bottom, rect.bottom);
+		_dirtyRect.extend(rect);
 	}
 }
 
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 01c069e..5c77fac 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -16,6 +16,7 @@ MODULE_OBJS = \
 	overview.o \
 	pegasus.o \
 	sound.o \
+	surface.o \
 	timers.o \
 	transition.o \
 	util.o \
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
new file mode 100755
index 0000000..32a8aa0
--- /dev/null
+++ b/engines/pegasus/surface.cpp
@@ -0,0 +1,221 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/file.h"
+#include "common/macresman.h"
+#include "common/stream.h"
+#include "common/system.h"
+#include "graphics/pict.h"
+#include "graphics/surface.h"
+#include "video/video_decoder.h"
+
+#include "pegasus/pegasus.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+
+Surface::Surface() {
+	_ownsSurface = false;
+	_surface = 0;
+}
+
+Surface::~Surface() {
+	deallocateSurface();
+}
+
+void Surface::deallocateSurface() {
+	if (_surface) {
+		if (_ownsSurface) {
+			_surface->free();
+			delete _surface;
+		}
+
+		_surface = 0;
+		_bounds = Common::Rect();
+		_ownsSurface = false;
+	}
+}
+
+void Surface::shareSurface(Surface *surface) {
+	deallocateSurface();
+
+	if (surface) {
+		_ownsSurface = false;
+		_surface = surface->getSurface();
+		surface->getSurfaceBounds(_bounds);
+	}
+}
+
+void Surface::allocateSurface(const Common::Rect &bounds) {
+	deallocateSurface();
+
+	if (bounds.isEmpty())
+		return;
+
+	_bounds = bounds;
+	_surface = new Graphics::Surface();
+	_surface->create(bounds.width(), bounds.height(), g_system->getScreenFormat());
+	_ownsSurface = true;
+}
+
+void Surface::getImageFromPICTFile(const Common::String &fileName) {
+	Common::File pict;
+	if (!pict.open(fileName))
+		error("Could not open picture '%s'", fileName.c_str());
+
+	getImageFromPICTStream(&pict);
+}
+
+void Surface::getImageFromPICTResource(Common::MacResManager *resFork, uint16 id) {
+	Common::SeekableReadStream *res = resFork->getResource(MKTAG('P', 'I', 'C', 'T'), id);
+	if (!res)
+		error("Could not open PICT resource %d from '%s'", id, resFork->getBaseFileName().c_str());
+	
+	getImageFromPICTStream(res);
+	delete res;
+}
+
+void Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
+	Graphics::PictDecoder pict(g_system->getScreenFormat());
+	byte pal[256 * 3];
+
+	Graphics::Surface *surface = pict.decodeImage(stream, pal);
+
+	// Create the surface if not present
+	if (!_surface)
+		_surface = new Graphics::Surface();
+
+	// Update
+	if (surface->format.bytesPerPixel == 1) {
+		// Convert to true color
+		_surface->create(surface->w, surface->h, g_system->getScreenFormat());
+		
+		for (int y = 0; y < surface->h; y++) {
+			for (int x = 0; x < surface->w; x++) {
+				byte index = *((byte *)surface->getBasePtr(x, y));
+				uint32 color = _surface->format.RGBToColor(pal[index * 3], pal[index * 3 + 1], pal[index * 3 + 2]);
+				if (_surface->format.bytesPerPixel == 2)
+					*((uint16 *)_surface->getBasePtr(x, y)) = color;
+				else
+					*((uint32 *)_surface->getBasePtr(x, y)) = color;
+			}
+		}
+	} else {
+		// Just a copy
+		_surface->copyFrom(*surface);
+	}
+
+	_ownsSurface = true;
+	_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
+}
+
+void Surface::copyToCurrentPort() const {
+	copyToCurrentPort(_bounds);
+}
+
+void Surface::copyToCurrentPortTransparent() const {
+	copyToCurrentPortTransparent(_bounds);
+}
+
+void Surface::copyToCurrentPort(const Common::Rect &rect) const {
+	copyToCurrentPort(rect, rect);
+}
+
+void Surface::copyToCurrentPortTransparent(const Common::Rect &rect) const {
+	copyToCurrentPortTransparent(rect, rect);
+}
+
+void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
+	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
+
+	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
+
+	for (int y = 0; y < srcRect.height(); y++) {
+		memcpy(dst, src, lineSize);
+		src += _surface->pitch - lineSize;
+		dst += screen->pitch - lineSize;
+	}
+}
+
+void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
+	// HACK: Seems we're truncating some color data somewhere...
+	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
+	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
+
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
+	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
+
+	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
+
+	for (int y = 0; y < srcRect.height(); y++) {
+		for (int x = 0; x < srcRect.width(); x++) {
+			if (g_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = READ_UINT16(src);
+				if (color != transColor1 && color != transColor2)
+					memcpy(dst, src, 2);
+			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = READ_UINT32(src);
+				if (color != transColor1 && color != transColor2)
+					memcpy(dst, src, 4);
+			}
+
+			src += g_system->getScreenFormat().bytesPerPixel;
+			dst += g_system->getScreenFormat().bytesPerPixel;
+		}
+
+		src += _surface->pitch - lineSize;
+		dst += screen->pitch - lineSize;
+	}
+}
+
+PixelImage::PixelImage() {
+	_transparent = false;
+}
+
+void PixelImage::drawImage(const Common::Rect &sourceBounds, const Common::Rect &destBounds) {
+	if (!isSurfaceValid())
+		return;
+
+	// Draw from sourceBounds to destBounds based on _transparent
+	if (_transparent)
+		copyToCurrentPortTransparent(sourceBounds, destBounds);
+	else
+		copyToCurrentPort(sourceBounds, destBounds);
+}
+
+void Frame::initFromPICTFile(const Common::String &fileName, bool transparent) {
+	getImageFromPICTFile(fileName);
+	_transparent = transparent;
+}
+
+void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
+	getImageFromPICTResource(resFork, id);
+	_transparent = transparent;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
new file mode 100755
index 0000000..1b63702
--- /dev/null
+++ b/engines/pegasus/surface.h
@@ -0,0 +1,119 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_SURFACE_H
+#define PEGASUS_SURFACE_H
+
+#include "common/rect.h"
+#include "common/str.h"
+
+#include "pegasus/types.h"
+
+namespace Common {
+	class MacResManager;
+}
+
+namespace Graphics {
+	struct Surface;
+}
+
+namespace Video {
+	class SeekableVideoDecoder;
+}
+
+namespace Pegasus {
+
+// Surface bounds are always normalized.
+
+class Surface {
+public:
+	Surface();
+	virtual ~Surface();
+	
+	virtual void allocateSurface(const Common::Rect &);
+	virtual void deallocateSurface();
+	virtual void shareSurface(Surface *surface);
+	bool isSurfaceValid() const { return _surface != 0; }
+
+	Graphics::Surface *getSurface() const { return _surface; }
+	void getSurfaceBounds(Common::Rect &r) { r = _bounds; }
+
+	//	None of the CopyToCurrentPort functions do any sanity checks.
+	//	For speed, they just call CopyBits.
+	//	It's up to clients to make sure that the GWorld is valid.
+	void copyToCurrentPort() const;
+	void copyToCurrentPortTransparent() const;
+	void copyToCurrentPort(const Common::Rect &) const;
+	void copyToCurrentPortTransparent(const Common::Rect &) const;
+	void copyToCurrentPort(const Common::Rect &, const Common::Rect &) const;
+	void copyToCurrentPortTransparent(const Common::Rect &, const Common::Rect &) const;
+
+	virtual void getImageFromPICTFile(const Common::String &fileName);
+	virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
+
+protected:
+	bool _ownsSurface;
+	Graphics::Surface *_surface;
+	Common::Rect _bounds;
+
+private:
+	void getImageFromPICTStream(Common::SeekableReadStream *stream);
+};
+
+class PixelImage : public Surface {
+public:
+	PixelImage();
+	virtual ~PixelImage() {}
+
+	void drawImage(const Common::Rect &, const Common::Rect &);
+
+protected:
+	virtual void setTransparent(bool transparent) { _transparent = transparent; }
+	
+	bool _transparent;
+};
+
+class Frame : public PixelImage {
+public:
+	Frame() {}
+	virtual ~Frame() {}
+
+	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
+	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
+};
+
+class SpriteFrame : public Frame {
+friend class Sprite;
+public:
+	SpriteFrame() { _referenceCount = 0; }
+	virtual ~SpriteFrame() {}
+
+protected:
+	uint32 _referenceCount;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: d29e50504176c76b6f86cd5b6d6e43e923de170c
    https://github.com/scummvm/scummvm/commit/d29e50504176c76b6f86cd5b6d6e43e923de170c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T07:56:30-07:00

Commit Message:
PEGASUS: Update timer code a bit to make it friendlier for movies

Changed paths:
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 1699867..ab0e4da 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -223,17 +223,19 @@ void TimeBase::checkCallBacks() {
 
 	// TODO: Update the slaves?
 
+	Common::Rational time = getTime();
+
 	// Check if we've triggered any callbacks
 	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
 		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
-			if (_time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
+			if (time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
 				runner->callBack();
 		} else if (runner->_type == kCallBackAtExtremes) {
 			if (runner->_trigger == kTriggerAtStop) {
-				if (_time == stopTime)
+				if (time == stopTime)
 					runner->callBack();
 			} else if (runner->_trigger == kTriggerAtStart) {
-				if (_time == startTime)
+				if (time == startTime)
 					runner->callBack();
 			}
 		}
@@ -241,10 +243,10 @@ void TimeBase::checkCallBacks() {
 
 	// Loop if necessary
 	if (getFlags() & kLoopTimeBase) {
-		if (_time == startTime)
-			_time = stopTime;
-		else if (_time == stopTime)
-			_time = startTime;
+		if (time == startTime)
+			setTime(_stopTime, _stopScale);
+		else if (time == stopTime)
+			setTime(_startTime, _startScale);
 	}
 }
 
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 04dd235..a40a2c1 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -102,7 +102,7 @@ public:
 	void disposeAllCallBacks();
 
 	// ScummVM's API additions (to replace the need for actual timers)
-	void checkCallBacks();
+	virtual void checkCallBacks();
 
 protected:
 	void addCallBack(TimeBaseCallBack *);


Commit: 635c8aa370e78cfc74dc66dd7efad5924ba348d2
    https://github.com/scummvm/scummvm/commit/635c8aa370e78cfc74dc66dd7efad5924ba348d2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T07:56:51-07:00

Commit Message:
PEGASUS: Add first stab at the Movie class

Seems this means the end of the base classes -- onto actual game logic from here on out!

Changed paths:
  A engines/pegasus/movie.cpp
  A engines/pegasus/movie.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 5c77fac..97830fe 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS = \
 	hotspot.o \
 	input.o \
 	menu.o \
+	movie.o \
 	notification.o \
 	overview.o \
 	pegasus.o \
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
new file mode 100755
index 0000000..c341d0c
--- /dev/null
+++ b/engines/pegasus/movie.cpp
@@ -0,0 +1,156 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/system.h"
+#include "graphics/surface.h"
+#include "video/qt_decoder.h"
+#include "video/video_decoder.h"
+
+#include "pegasus/movie.h"
+
+namespace Pegasus {
+
+Movie::Movie(const tDisplayElementID id) : Animation(id) {
+	_video = 0;
+	_directDraw = false;
+	setScale(600);
+}
+
+Movie::~Movie() {
+	releaseMovie();
+}
+
+//	*** Make sure this will stop displaying the movie.
+
+void Movie::releaseMovie() {
+	if (_video) {
+		delete _video;
+		_video = 0;
+		disposeAllCallBacks();
+		deallocateSurface();
+		// TODO: Decrease global direct draw counter
+	}
+}
+
+void Movie::initFromMovieFile(const Common::String &fileName, bool transparent) {
+	_transparent = transparent;
+
+	releaseMovie();
+	_video = new Video::QuickTimeDecoder();
+	if (!_video->loadFile(fileName))	
+		error("Could not load video '%s'", fileName.c_str());
+
+	_video->pauseVideo(true);
+
+	Common::Rect bounds(0, 0, _video->getWidth(), _video->getHeight());
+	allocateSurface(bounds);
+	setBounds(bounds);
+
+	setStart(0, getScale());
+	setStop(_video->getDuration() * getScale() / 1000, getScale());
+}
+
+void Movie::setDirectDraw(const bool flag) {
+	_directDraw = flag;
+	// TODO: Increase/decrease the global direct draw counter
+}
+
+void Movie::redrawMovieWorld() {
+	if (_video && _video->needsUpdate()) {
+		const Graphics::Surface *frame = _video->decodeNextFrame();
+
+		if (_directDraw) {
+			// Copy to the screen
+			// TODO: Scaling
+			Common::Rect bounds;
+			getBounds(bounds);
+			g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, bounds.left, bounds.top, frame->w, frame->h);
+		} else {
+			// Just copy to our surface
+			_surface->copyFrom(*frame);
+		}
+	}
+}
+
+void Movie::draw(const Common::Rect &r) {
+	if (_transparent)
+		copyToCurrentPortTransparent(r);
+	else
+		copyToCurrentPort(r);
+}
+
+void Movie::setVolume(uint16 volume) {
+	// TODO
+}
+
+void Movie::setTime(const TimeValue time, const TimeScale scale) {
+	if (_video)
+		_video->seekToTime(Audio::Timestamp(0, time, ((scale == 0) ? getScale() : scale)));
+}
+
+TimeValue Movie::getTime(const TimeScale scale) {
+	if (_video) {
+		TimeScale actualScale = ((scale == 0) ? getScale() : scale);
+
+		uint32 startTime = _startTime * actualScale / _startScale;
+		uint32 stopTime = _stopTime * actualScale / _stopScale;
+		return CLIP<int>(_video->getElapsedTime() * actualScale / 1000, startTime, stopTime);
+	}
+
+	return 0;
+}
+
+void Movie::setRate(const Common::Rational rate) {
+	if (rate != 1 && rate != 0)
+		error("Cannot set movie rate");
+}
+
+void Movie::start() {
+	if (_video && _video->isPaused())
+		_video->pauseVideo(false);
+
+	TimeBase::start();
+}
+
+void Movie::stop() {
+	if (_video && !_video->isPaused())
+		_video->pauseVideo(true);
+
+	TimeBase::stop();
+}
+
+void Movie::resume() {
+	if (_video && _video->isPaused())
+		_video->pauseVideo(false);
+
+	TimeBase::resume();
+}
+
+void Movie::checkCallBacks() {
+	TimeBase::checkCallBacks();
+	redrawMovieWorld();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
new file mode 100755
index 0000000..551d8cd
--- /dev/null
+++ b/engines/pegasus/movie.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MOVIE_H
+#define PEGASUS_MOVIE_H
+
+#include "common/str.h"
+
+#include "pegasus/elements.h"
+#include "pegasus/surface.h"
+
+namespace Video {
+	class SeekableVideoDecoder;
+}
+
+namespace Pegasus {
+
+class Movie : public Animation, public PixelImage {
+public:
+	Movie(const tDisplayElementID);
+	virtual ~Movie();
+
+	virtual void initFromMovieFile(const Common::String &fileName, bool transparent);
+
+	bool isMovieValid() { return _video != 0; }
+	
+	virtual void releaseMovie();
+	
+	virtual void draw(const Common::Rect &);
+	virtual void redrawMovieWorld();
+	
+	void setDirectDraw(const bool);
+	
+	virtual void setTime(const TimeValue, const TimeScale = 0);
+	virtual TimeValue getTime(const TimeScale = 0);
+	
+	virtual void setRate(const Common::Rational);
+	
+	virtual void start();
+	virtual void stop();
+	virtual void resume();
+
+	// *** HACK ALERT
+	Video::SeekableVideoDecoder *getMovie() { return _video; }
+	void setVolume(uint16);
+
+	virtual void checkCallBacks();
+
+protected:
+	Video::SeekableVideoDecoder *_video;
+	bool _directDraw;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: fec7a123fd34bd167528b49ddb46a3123f31c416
    https://github.com/scummvm/scummvm/commit/fec7a123fd34bd167528b49ddb46a3123f31c416
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T08:49:20-07:00

Commit Message:
PEGASUS: Begin hooking the new code in as the main code

The first notification has been received!

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index b9b8540..89fdeef 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -27,6 +27,7 @@
 #define PEGASUS_CONSTANTS_H
 
 #include "common/endian.h"
+#include "common/rect.h"
 
 #include "pegasus/types.h"
 
@@ -264,6 +265,261 @@ const uint32 kPegasusPrimeVersion = 0x00009019;
 const char kNormalSave = 0;
 const char kContinueSave = 1;
 
+//	Display IDs.
+
+const tDisplayElementID kNavMovieID = 1;
+const tDisplayElementID kTurnPushID = 2;
+
+const tDisplayElementID kMaxGameShellDisplayID = kTurnPushID;
+
+//	Display ordering.
+
+const tDisplayOrder kNavLayer = 10000;
+const tDisplayOrder kNavMovieOrder = kNavLayer;
+const tDisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
+
+/////////////////////////////////////////////
+//
+//	Display IDs.
+
+const tDisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
+const tDisplayElementID kInterface1ID = kScreenDimmerID + 1;
+const tDisplayElementID kInterface2ID = kInterface1ID + 1;
+const tDisplayElementID kInterface3ID = kInterface2ID + 1;
+const tDisplayElementID kInterface4ID = kInterface3ID + 1;
+const tDisplayElementID kDateID = kInterface4ID + 1;
+const tDisplayElementID kCompassID = kDateID + 1;
+const tDisplayElementID kInventoryPushID = kCompassID + 1;
+const tDisplayElementID kInventoryLidID = kInventoryPushID + 1;
+const tDisplayElementID kBiochipPushID = kInventoryLidID + 1;
+const tDisplayElementID kBiochipLidID = kBiochipPushID + 1;
+const tDisplayElementID kEnergyBarID = kBiochipLidID + 1;
+const tDisplayElementID kWarningLightID = kEnergyBarID + 1;
+const tDisplayElementID kAILeftAreaID = kWarningLightID + 1;
+const tDisplayElementID kAIMiddleAreaID = kAILeftAreaID + 1;
+const tDisplayElementID kAIRightAreaID = kAIMiddleAreaID + 1;
+const tDisplayElementID kAIMovieID = kAIRightAreaID + 1;
+const tDisplayElementID kInventoryDropHighlightID = kAIMovieID + 1;
+const tDisplayElementID kBiochipDropHighlightID = kInventoryDropHighlightID + 1;
+
+const tDisplayElementID kDraggingSpriteID = 1000;
+
+const tDisplayElementID kCroppedMovieID = 2000;
+
+const tDisplayElementID kNeighborhoodDisplayID = 3000;
+
+const tDisplayElementID kItemPictureBaseID = 5000;
+
+const tCoordType kNavAreaLeft = 64;
+const tCoordType kNavAreaTop = 64;
+
+const tCoordType kBackground1Left = 0;
+const tCoordType kBackground1Top = 64;
+
+const tCoordType kBackground2Left = 0;
+const tCoordType kBackground2Top = 0;
+
+const tCoordType kBackground3Left = 576;
+const tCoordType kBackground3Top = 64;
+
+const tCoordType kBackground4Left = 0;
+const tCoordType kBackground4Top = 320;
+
+const tCoordType kOverviewControllerLeft = 540;
+const tCoordType kOverviewControllerTop = 348;
+
+const tCoordType kSwapLeft = 194;
+const tCoordType kSwapTop = 116;
+
+const tCoordType kSwapHiliteLeft = 200;
+const tCoordType kSwapHiliteTop = 206;
+
+const tCoordType kDateLeft = 136;
+const tCoordType kDateTop = 44;
+
+const tCoordType kCompassLeft = 222;
+const tCoordType kCompassTop = 42;
+const tCoordType kCompassWidth = 92;
+
+const tCoordType kInventoryPushLeft = 74;
+const tCoordType kInventoryPushTop = 92;
+
+const tCoordType kInventoryLidLeft = 74;
+const tCoordType kInventoryLidTop = 316;
+
+const tCoordType kBiochipPushLeft = 362;
+const tCoordType kBiochipPushTop = 192;
+
+const tCoordType kBiochipLidLeft = 362;
+const tCoordType kBiochipLidTop = 316;
+
+// TODO: Remove global variable needs
+//const Common::Rect kInventoryHiliteBounds(334, 76, 430, 172);
+//const Common::Rect kBiochipHiliteBounds (334, 364, 430, 460);
+
+const tCoordType kInventoryDropLeft = 0;
+const tCoordType kInventoryDropTop = 320;
+const tCoordType kInventoryDropRight = 232;
+const tCoordType kInventoryDropBottom = 480;
+
+const tCoordType kBiochipDropLeft = 302;
+const tCoordType kBiochipDropTop = 320;
+const tCoordType kBiochipDropRight = 640;
+const tCoordType kBiochipDropBottom = 480;
+
+const tCoordType kFinalMessageLeft = kInventoryPushLeft + 1;
+const tCoordType kFinalMessageTop = kInventoryPushTop + 24;
+
+/////////////////////////////////////////////
+//
+//	Notifications.
+
+const tNotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
+const tNotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
+const tNotificationID kAINotificationID = kInterfaceNotificationID + 1;
+const tNotificationID kNoradNotificationID = kAINotificationID + 1;
+const tNotificationID kNoradECRNotificationID = kNoradNotificationID + 1;
+const tNotificationID kNoradFillingStationNotificationID = kNoradECRNotificationID + 1;
+const tNotificationID kNoradPressureNotificationID = kNoradFillingStationNotificationID + 1;
+const tNotificationID kNoradUtilityNotificationID = kNoradPressureNotificationID + 1;
+const tNotificationID kNoradElevatorNotificationID = kNoradUtilityNotificationID + 1;
+const tNotificationID kNoradSubPlatformNotificationID = kNoradElevatorNotificationID + 1;
+const tNotificationID kSubControlNotificationID = kNoradSubPlatformNotificationID + 1;
+const tNotificationID kNoradGreenBallNotificationID = kSubControlNotificationID + 1;
+const tNotificationID kNoradGlobeNotificationID = kNoradGreenBallNotificationID + 1;
+const tNotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotificationID + 1;
+const tNotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
+const tNotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
+
+//	Sent to the shell by fShellNotification.
+const tNotificationFlags kGameStartingFlag = 1;
+const tNotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
+const tNotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
+
+const tNotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
+														kNeedNewJumpFlag |
+														kPlayerDiedFlag;
+
+//	Sent to the interface.
+const tNotificationFlags kInventoryLidOpenFlag = 1;
+const tNotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
+const tNotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
+const tNotificationFlags kInventoryDrawerDownFlag = kInventoryDrawerUpFlag << 1;
+const tNotificationFlags kBiochipLidOpenFlag = kInventoryDrawerDownFlag << 1;
+const tNotificationFlags kBiochipLidClosedFlag = kBiochipLidOpenFlag << 1;
+const tNotificationFlags kBiochipDrawerUpFlag = kBiochipLidClosedFlag << 1;
+const tNotificationFlags kBiochipDrawerDownFlag = kBiochipDrawerUpFlag << 1;
+
+const tNotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
+														kInventoryLidClosedFlag |
+														kInventoryDrawerUpFlag |
+														kInventoryDrawerDownFlag |
+														kBiochipLidOpenFlag |
+														kBiochipLidClosedFlag |
+														kBiochipDrawerUpFlag |
+														kBiochipDrawerDownFlag;
+
+//	Hot spots.
+
+//	Neighborhood hot spots.
+
+const tHotSpotID kFirstNeighborhoodSpotID = 5000;
+
+//	kShellSpotFlag is a flag which marks all hot spots which belong to the shell, like
+//	the current item and current biochip spots.
+const tHotSpotFlags kShellSpotFlag = 1;
+//	kNeighborhoodSpotFlag is a flag which marks all hot spots which belong to a
+//	neighborhood, like buttons on walls and so on.
+const tHotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
+//	kZoomInSpotFlag is a flag which marks all hot spots which indicate a zoom.
+const tHotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
+//	kZoomOutSpotFlag is a flag which marks all hot spots which indicate a zoom.
+const tHotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
+
+const tHotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
+const tHotSpotFlags kPlayExtraSpotFlag = kClickSpotFlag << 1;
+const tHotSpotFlags kPickUpItemSpotFlag = kPlayExtraSpotFlag << 1;
+const tHotSpotFlags kDropItemSpotFlag = kPickUpItemSpotFlag << 1;
+const tHotSpotFlags kOpenDoorSpotFlag = kDropItemSpotFlag << 1;
+
+const tHotSpotFlags kZoomSpotFlags = kZoomInSpotFlag | kZoomOutSpotFlag;
+
+const tHotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
+
+/////////////////////////////////////////////
+//
+//	Hot spots.
+
+//	Shell hot spots.
+//	The shell reserves all hot spot IDs from 0 to 999
+
+const tHotSpotID kCurrentItemSpotID = 0;
+const tHotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
+
+const tHotSpotID kInventoryDropSpotID = kCurrentBiochipSpotID + 1;
+const tHotSpotID kBiochipDropSpotID = kInventoryDropSpotID + 1;
+
+const tHotSpotID kInfoReturnSpotID = kBiochipDropSpotID + 1;
+
+const tHotSpotID kAIHint1SpotID = kInfoReturnSpotID + 1;
+const tHotSpotID kAIHint2SpotID = kAIHint1SpotID + 1;
+const tHotSpotID kAIHint3SpotID = kAIHint2SpotID + 1;
+const tHotSpotID kAISolveSpotID = kAIHint3SpotID + 1;
+const tHotSpotID kAIBriefingSpotID = kAISolveSpotID + 1;
+const tHotSpotID kAIScanSpotID = kAIBriefingSpotID + 1;
+
+const tHotSpotID kPegasusRecallSpotID = kAIScanSpotID + 1;
+
+const tHotSpotID kAriesSpotID = kPegasusRecallSpotID + 1;
+const tHotSpotID kMercurySpotID = kAriesSpotID + 1;
+const tHotSpotID kPoseidonSpotID = kMercurySpotID + 1;
+
+const tHotSpotID kAirMaskToggleSpotID = kPoseidonSpotID + 1;
+
+const tHotSpotID kShuttleEnergySpotID = kAirMaskToggleSpotID + 1;
+const tHotSpotID kShuttleGravitonSpotID = kShuttleEnergySpotID + 1;
+const tHotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
+const tHotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
+const tHotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
+
+//	Most of these are obsolete:
+
+//	kInventoryDropSpotFlag is a flag which marks hot spots which are valid drop spots
+//	for inventory items.
+//	const tHotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
+
+//	kBiochipDropSpotFlag is a flag which marks hot spots which are valid drop spots
+//	for biochips.
+//	const tHotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
+
+//	kInventorySpotFlag is a flag which marks hot spots which indicate inventory items
+//	in the environment.
+//	const tHotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
+
+//	kBiochipSpotFlag is a flag which marks hot spots which indicate biochips
+//	in the environment.
+const tHotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
+const tHotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
+
+const tHotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
+
+//	Biochip and inventory hot spot flags...
+
+const tHotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
+const tHotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
+const tHotSpotFlags kOpticalBiochipSpotFlag = kPegasusBiochipSpotFlag << 1;
+const tHotSpotFlags kAirMaskSpotFlag = kOpticalBiochipSpotFlag << 1;
+
+const tHotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
+											kPlayExtraSpotFlag |
+											kOpenDoorSpotFlag |
+											kInfoReturnSpotFlag |
+											kAIBiochipSpotFlag |
+											kPegasusBiochipSpotFlag |
+											kOpticalBiochipSpotFlag |
+											kAirMaskSpotFlag;
+
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 3a9c7d1..bc16297 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -44,6 +44,7 @@
 
 //#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
+//#define RUN_OLD_CODE
 
 #ifdef RUN_INTERFACE_TEST
 #include "pegasus/sound.h"
@@ -51,7 +52,8 @@
 
 namespace Pegasus {
 
-PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc) {
+PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
+		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID) {
 	_continuePoint = 0;
 	_saveAllowed = _loadAllowed = true;
 }
@@ -147,7 +149,7 @@ Common::Error PegasusEngine::run() {
 		
 		_system->delayMillis(10);
 	}
-#else
+#elif defined(RUN_OLD_CODE)
 	while (!shouldQuit()) {
 		switch (_gameMode) {
 		case kIntroMode:
@@ -170,6 +172,30 @@ Common::Error PegasusEngine::run() {
 			break;
 		}
 	}
+#else
+	// Set up input
+	InputHandler::setInputHandler(this);
+	allowInput(true);
+
+	// Set up inventories
+	_items.setWeightLimit(0);
+	_items.setOwnerID(kPlayerID);
+	_biochips.setWeightLimit(8);
+	_biochips.setOwnerID(kPlayerID);
+
+	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
+	_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
+
+	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
+	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
+	g_allHotspots.push_back(&_returnHotspot);
+
+	while (!shouldQuit()) {
+		checkNotifications();
+		InputHandler::pollForInput();
+		giveIdleTime();
+		_gfx->updateDisplay();
+	}
 #endif
 
 	return Common::kNoError;
@@ -488,4 +514,11 @@ Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc)
 	return valid ? Common::kNoError : Common::kUnknownError;
 }
 
+void PegasusEngine::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	if (&_shellNotification == notification) {
+		if (flags == kGameStartingFlag)
+			error("Notification test complete");
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 8d49050..a9984ea 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -33,8 +33,11 @@
 #include "engines/engine.h"
 
 #include "pegasus/graphics.h"
+#include "pegasus/hotspot.h"
 #include "pegasus/input.h"
+#include "pegasus/notification.h"
 #include "pegasus/video.h"
+#include "pegasus/items/inventory.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Video {
@@ -66,7 +69,7 @@ enum GameMode {
 	kQuitMode
 };
 
-class PegasusEngine : public ::Engine, public InputHandler {
+class PegasusEngine : public ::Engine, public InputHandler, public NotificationManager {
 friend class InputHandler;
 
 public:
@@ -101,6 +104,9 @@ protected:
 
 	Cursor *_cursor;
 
+	Notification _shellNotification;
+	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
+
 private:
 	// Intro
 	void runIntro();
@@ -152,6 +158,8 @@ private:
 	// Items
 	void createItems();
 	void createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction);
+	Inventory _items;
+	Inventory _biochips;
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;
@@ -163,6 +171,9 @@ private:
 	void loadFromContinuePoint();
 	Common::ReadStream *_continuePoint;
 	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
+
+	// Misc.
+	Hotspot _returnHotspot;
 };
 
 } // End of namespace Pegasus


Commit: e21224ff9a590144f2afee292ac342bc9769e2eb
    https://github.com/scummvm/scummvm/commit/e21224ff9a590144f2afee292ac342bc9769e2eb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T10:04:04-07:00

Commit Message:
PEGASUS: Fix copyToCurrentPort()

Changed paths:
    engines/pegasus/surface.cpp



diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 32a8aa0..7da5cd1 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -156,8 +156,8 @@ void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect
 
 	for (int y = 0; y < srcRect.height(); y++) {
 		memcpy(dst, src, lineSize);
-		src += _surface->pitch - lineSize;
-		dst += screen->pitch - lineSize;
+		src += _surface->pitch;
+		dst += screen->pitch;
 	}
 }
 


Commit: 2dbf379d11b4099b97e4ba6525609cc21535fe65
    https://github.com/scummvm/scummvm/commit/2dbf379d11b4099b97e4ba6525609cc21535fe65
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T10:04:27-07:00

Commit Message:
PEGASUS: Fix some movie bugs

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index c341d0c..8f79c03 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -91,6 +91,8 @@ void Movie::redrawMovieWorld() {
 			// Just copy to our surface
 			_surface->copyFrom(*frame);
 		}
+
+		triggerRedraw();
 	}
 }
 
@@ -125,6 +127,8 @@ TimeValue Movie::getTime(const TimeScale scale) {
 void Movie::setRate(const Common::Rational rate) {
 	if (rate != 1 && rate != 0)
 		error("Cannot set movie rate");
+
+	TimeBase::setRate(rate);
 }
 
 void Movie::start() {


Commit: dc0a98f655bb3cf0459085b6f84f29e7cb9eaa00
    https://github.com/scummvm/scummvm/commit/dc0a98f655bb3cf0459085b6f84f29e7cb9eaa00
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T10:11:00-07:00

Commit Message:
PEGASUS: Make movie transparency be off by default

Changed paths:
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 551d8cd..98d84b6 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -42,7 +42,7 @@ public:
 	Movie(const tDisplayElementID);
 	virtual ~Movie();
 
-	virtual void initFromMovieFile(const Common::String &fileName, bool transparent);
+	virtual void initFromMovieFile(const Common::String &fileName, bool transparent = false);
 
 	bool isMovieValid() { return _video != 0; }
 	


Commit: 0193d0d01948a0b2b24967be036fbcddfccc7fd6
    https://github.com/scummvm/scummvm/commit/0193d0d01948a0b2b24967be036fbcddfccc7fd6
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T10:23:16-07:00

Commit Message:
PEGASUS: Fix a regression in checkCallBacks()

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index ab0e4da..b462e42 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -223,7 +223,7 @@ void TimeBase::checkCallBacks() {
 
 	// TODO: Update the slaves?
 
-	Common::Rational time = getTime();
+	Common::Rational time = Common::Rational(getTime(), getScale());
 
 	// Check if we've triggered any callbacks
 	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {


Commit: 1c8213ad86b8cdda01785b4c7ec41376e46e0f7e
    https://github.com/scummvm/scummvm/commit/1c8213ad86b8cdda01785b4c7ec41376e46e0f7e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T10:28:41-07:00

Commit Message:
PEGASUS: Fix timebase looping

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index b462e42..b3dd3cf 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -243,9 +243,9 @@ void TimeBase::checkCallBacks() {
 
 	// Loop if necessary
 	if (getFlags() & kLoopTimeBase) {
-		if (time == startTime)
+		if (getRate() < 0 && time == startTime)
 			setTime(_stopTime, _stopScale);
-		else if (time == stopTime)
+		else if (getRate() > 0 && time == stopTime)
 			setTime(_startTime, _startScale);
 	}
 }


Commit: de23530a4eada1dd244bf5533479399b8747287a
    https://github.com/scummvm/scummvm/commit/de23530a4eada1dd244bf5533479399b8747287a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T11:21:54-07:00

Commit Message:
PEGASUS: Remove VideoManager code

It was originally from Mohawk and does not fit in with the new graphics management introduced. Movie will be used from here on out!

In addition, the intro code has been rewritten and now it properly starts from the new code.

Changed paths:
  R engines/pegasus/video.cpp
  R engines/pegasus/video.h
    engines/pegasus/credits.cpp
    engines/pegasus/menu.cpp
    engines/pegasus/module.mk
    engines/pegasus/overview.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/credits.cpp b/engines/pegasus/credits.cpp
index 4ef723e..6d683de 100644
--- a/engines/pegasus/credits.cpp
+++ b/engines/pegasus/credits.cpp
@@ -142,7 +142,9 @@ void PegasusEngine::drawCredits(int button, bool highlight, int frame, Video::Qu
 		_gfx->drawPictTransparent("Images/Credits/SelectS.pict", 40, s_creditsButtonY[button], _gfx->getColor(0xf8, 0xf8, 0xf8));
 
 	video->seekToTime(frame * 200);
-	_video->copyFrameToScreen(video->decodeNextFrame(), video->getWidth(), video->getHeight(), 288, 0);
+
+	const Graphics::Surface *surf = video->decodeNextFrame();
+	_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, 288, 0, video->getWidth(), video->getHeight());
 }
 
 void PegasusEngine::runDemoCredits() {
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 49d6014..12c987c 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -49,13 +49,10 @@ void PegasusEngine::runMainMenu() {
 	sound.initFromAIFFFile("Sounds/Main Menu.aiff");
 	sound.loopSound();
 
-	// Note down how long since the last click
-	uint32 lastClickTime = _system->getMillis();
-
 	int buttonSelected = 0;
 	drawMenu(buttonSelected);
 
-	while (!shouldQuit() && _system->getMillis() - lastClickTime < 60 * 1000) {
+	while (!shouldQuit()) {
 		Common::Event event;
 	
 		// Ignore events for now
@@ -105,8 +102,6 @@ void PegasusEngine::runMainMenu() {
 					break;
 				}
 
-				// Update our last press time too
-				lastClickTime = _system->getMillis();
 				break;
 			default:
 				break;
@@ -119,11 +114,6 @@ void PegasusEngine::runMainMenu() {
 
 	if (shouldQuit())
 		return;
-
-	// Too slow! Go back and show the intro again.
-	sound.stopSound();
-	_video->playMovie(_introDirectory + "/LilMovie.movie");
-	_gameMode = kIntroMode;
 }
 
 void PegasusEngine::drawMenu(int buttonSelected) {
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 97830fe..131ec1f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -21,7 +21,6 @@ MODULE_OBJS = \
 	timers.o \
 	transition.o \
 	util.o \
-	video.o \
 	items/inventory.o \
 	items/item.o \
 	items/itemlist.o \
diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
index 8e82708..90fa9a4 100644
--- a/engines/pegasus/overview.cpp
+++ b/engines/pegasus/overview.cpp
@@ -115,7 +115,8 @@ void PegasusEngine::drawInterfaceOverview(const OverviewHotspot &hotspot, Video:
 	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
 
 	video->seekToTime(hotspot.time);
-	_video->copyFrameToScreen(video->decodeNextFrame(), video->getWidth(), video->getHeight(), kViewScreenOffset, kViewScreenOffset);
+	const Graphics::Surface *surf = video->decodeNextFrame();
+	_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, kViewScreenOffset, kViewScreenOffset, video->getWidth(), video->getHeight());
 
 	if (hotspot.time == 530) {
 		// The keyboard is special
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index bc16297..0a4e066 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -32,17 +32,18 @@
 #include "base/plugins.h"
 #include "base/version.h"
 #include "gui/saveload.h"
+#include "video/qt_decoder.h"
 
 #include "pegasus/console.h"
 #include "pegasus/cursor.h"
 #include "pegasus/gamestate.h"
+#include "pegasus/movie.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
 #include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/items/inventory/inventoryitem.h"
 
-//#define RUN_SUB_MOVIE // :D :D :D :D :D :D
 //#define RUN_INTERFACE_TEST
 //#define RUN_OLD_CODE
 
@@ -59,11 +60,8 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 }
 
 PegasusEngine::~PegasusEngine() {
-	delete _video;
 	delete _gfx;
 	delete _resFork;
-	delete _inventoryLid;
-	delete _biochipLid;
 	delete _console;
 	delete _cursor;
 	delete _continuePoint;
@@ -72,10 +70,7 @@ PegasusEngine::~PegasusEngine() {
 Common::Error PegasusEngine::run() {
 	_console = new PegasusConsole(this);
 	_gfx = new GraphicsManager(this);
-	_video = new VideoManager(this);
 	_resFork = new Common::MacResManager();
-	_inventoryLid = new Common::MacResManager();
-	_biochipLid = new Common::MacResManager();
 	_cursor = new Cursor();
 	_gameMode = kIntroMode;
 	_adventureMode = true;
@@ -83,12 +78,6 @@ Common::Error PegasusEngine::run() {
 	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 		error("Could not load JMP PP Resources");
 
-	if (!_inventoryLid->open("Images/Lids/Inventory Lid Sequence") || !_inventoryLid->hasResFork())
-		error("Could not open Inventory Lid Sequence");
-
-	if (!_biochipLid->open("Images/Lids/Biochip Lid Sequence") || !_biochipLid->hasResFork())
-		error("Could not open Biochip Lid Sequence");
-
 	// Initialize items
 	createItems();
 
@@ -111,27 +100,7 @@ Common::Error PegasusEngine::run() {
 		return Common::kNoGameDataFoundError;
 	}
 
-#if 0
-	Common::MacResIDArray pictIds = _biochipLid->getResIDArray(MKID_BE('PICT'));
-	for (uint32 i = 0; i < pictIds.size(); i++) {
-		Common::String filename = Common::String::printf("PICT_%d.pict", pictIds[i]);
-		Common::DumpFile file;
-		assert(file.open(filename));
-		Common::SeekableReadStream *res = _biochipLid->getResource(MKID_BE('PICT'), pictIds[i]);
-		byte *data = new byte[res->size()];
-		res->read(data, res->size());
-		for (int j = 0; j < 512; j++)
-			file.writeByte(0);
-		file.write(data, res->size());
-		file.close();
-		delete res;
-		delete[] data;
-	}
-#endif
-
-#if defined(RUN_SUB_MOVIE)
-	_video->playMovie("Images/Norad Alpha/Sub Chase Movie");
-#elif defined(RUN_INTERFACE_TEST)
+#if defined(RUN_INTERFACE_TEST)
 	_cursor->setCurrentFrameIndex(0);
 	_cursor->show();
 	drawInterface();
@@ -183,6 +152,7 @@ Common::Error PegasusEngine::run() {
 	_biochips.setWeightLimit(8);
 	_biochips.setOwnerID(kPlayerID);
 
+	// Start up the first notification
 	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
 	_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
 
@@ -191,6 +161,7 @@ Common::Error PegasusEngine::run() {
 	g_allHotspots.push_back(&_returnHotspot);
 
 	while (!shouldQuit()) {
+		checkCallBacks();
 		checkNotifications();
 		InputHandler::pollForInput();
 		giveIdleTime();
@@ -280,10 +251,73 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 }
 
 void PegasusEngine::runIntro() {
-	_video->playMovieCentered(_introDirectory + "/BandaiLogo.movie");
-	VideoHandle handle = _video->playBackgroundMovie(_introDirectory + "/Big Movie.movie");
-	_video->seekToTime(handle, 10 * 600);
-	_video->waitUntilMovieEnds(handle);
+	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
+	if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
+		while (!shouldQuit() && !video->endOfVideo()) {
+			if (video->needsUpdate()) {
+				const Graphics::Surface *frame = video->decodeNextFrame();
+				_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
+				_system->updateScreen();
+			}
+
+			Common::Event event;
+			while (_eventMan->pollEvent(event))
+				;
+		}
+	}
+
+	delete video;
+
+	if (shouldQuit())
+		return;
+
+	video = new Video::QuickTimeDecoder();
+
+	if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
+		error("Could not load intro movie");
+
+	video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
+
+	while (!shouldQuit() && !video->endOfVideo()) {
+		if (video->needsUpdate()) {
+			const Graphics::Surface *frame = video->decodeNextFrame();
+
+			// Scale up the frame doing some simple scaling
+			Graphics::Surface scaledFrame;
+			scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
+			const byte *src = (const byte *)frame->pixels;
+			byte *dst1 = (byte *)scaledFrame.pixels;
+			byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
+
+			for (int y = 0; y < frame->h; y++) {
+				for (int x = 0; x < frame->w; x++) {
+					memcpy(dst1, src, frame->format.bytesPerPixel);
+					dst1 += frame->format.bytesPerPixel;
+					memcpy(dst1, src, frame->format.bytesPerPixel);
+					dst1 += frame->format.bytesPerPixel;
+					memcpy(dst2, src, frame->format.bytesPerPixel);
+					dst2 += frame->format.bytesPerPixel;
+					memcpy(dst2, src, frame->format.bytesPerPixel);
+					dst2 += frame->format.bytesPerPixel;
+					src += frame->format.bytesPerPixel;
+				}
+
+				src += frame->pitch - frame->format.bytesPerPixel * frame->w;
+				dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+				dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+			}
+
+			_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, 0, 0, scaledFrame.w, scaledFrame.h);
+			_system->updateScreen();
+			scaledFrame.free();
+		}
+
+		Common::Event event;
+		while (_eventMan->pollEvent(event))
+			;
+	}
+
+	delete video;
 }
 
 void PegasusEngine::drawInterface() {
@@ -296,14 +330,7 @@ void PegasusEngine::drawInterface() {
 }
 
 void PegasusEngine::mainGameLoop() {
-	// TODO: Yeah...
-	_system->fillScreen(0);
-	_video->playMovieCentered("Images/Caldoria/Pullback.movie");
-	drawInterface();
-
-	Common::String navMovie = Common::String::format("Images/%s/%s.movie", getTimeZoneFolder(GameState.getCurrentNeighborhood()).c_str(), getTimeZoneDesc(GameState.getCurrentNeighborhood()).c_str());
-	_video->playMovie(navMovie, kViewScreenOffset, kViewScreenOffset);
-
+	// TODO: Remove me
 	_gameMode = kQuitMode;
 }
 
@@ -496,7 +523,6 @@ Common::Error PegasusEngine::loadGameState(int slot) {
 		return Common::kUnknownError;
 
 	bool valid = loadFromStream(loadFile);
-	warning("pos = %d", loadFile->pos());
 	delete loadFile;
 
 	return valid ? Common::kNoError : Common::kUnknownError;
@@ -516,9 +542,48 @@ Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc)
 
 void PegasusEngine::receiveNotification(Notification *notification, const tNotificationFlags flags) {
 	if (&_shellNotification == notification) {
-		if (flags == kGameStartingFlag)
-			error("Notification test complete");
+		switch (flags) {
+		case kGameStartingFlag: {
+#if 0
+			// This is just some graphical test that I wrote; I'll
+			// keep it around for reference.
+			Movie opening(1);
+			opening.initFromMovieFile(_introDirectory + "/Big Movie.movie");
+			opening.setTime(10, 1);
+			opening.setStart(10, 1);
+			opening.startDisplaying();
+			opening.show();
+			opening.start();
+			opening.setFlags(kLoopTimeBase);
+
+			Input input;
+			InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+
+			while (opening.isRunning() && !shouldQuit()) {
+				checkCallBacks();
+				_gfx->updateDisplay();
+
+				InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+				if (input.anyInput())
+					break;
+
+				_system->delayMillis(10);
+			}
+#else
+			if (!isDemo())
+				runIntro();
+#endif
+			break;
+		}
+		default:
+			break;
+		}
 	}
 }
 
+void PegasusEngine::checkCallBacks() {
+	for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
+		(*it)->checkCallBacks();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index a9984ea..3e20ddc 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -36,12 +36,11 @@
 #include "pegasus/hotspot.h"
 #include "pegasus/input.h"
 #include "pegasus/notification.h"
-#include "pegasus/video.h"
 #include "pegasus/items/inventory.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Video {
-	class Video::QuickTimeDecoder;
+	class QuickTimeDecoder;
 }
 
 namespace Pegasus {
@@ -49,7 +48,6 @@ namespace Pegasus {
 class PegasusConsole;
 struct PegasusGameDescription;
 class SoundManager;
-class VideoManager;
 class GraphicsManager;
 class Idler;
 class Cursor;
@@ -86,9 +84,8 @@ public:
 	Common::Error saveGameState(int slot, const Common::String &desc);
 
 	// Base classes
-	VideoManager *_video;
 	GraphicsManager *_gfx;
-	Common::MacResManager *_resFork, *_inventoryLid, *_biochipLid;
+	Common::MacResManager *_resFork;
 
 	// Misc.
 	bool isDemo() const;
@@ -163,6 +160,7 @@ private:
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;
+	void checkCallBacks();
 
 	// Save/Load
 	bool loadFromStream(Common::ReadStream *stream);
diff --git a/engines/pegasus/video.cpp b/engines/pegasus/video.cpp
deleted file mode 100644
index 89884e0..0000000
--- a/engines/pegasus/video.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/pegasus.h"
-#include "pegasus/video.h"
-
-#include "common/events.h"
-#include "common/textconsole.h"
-#include "graphics/scaler.h"
-#include "video/qt_decoder.h"
-
-namespace Pegasus {
-	
-VideoManager::VideoManager(PegasusEngine *vm) : _vm(vm) {
-	_timeZoneVideo = 0;
-}
-	
-VideoManager::~VideoManager() {
-	stopVideos();
-	delete _timeZoneVideo;
-}
-
-bool VideoManager::loadTimeZoneVideo(const Common::String &filename) {
-	Video::QuickTimeDecoder *video = new Video::QuickTimeDecoder();
-
-	if (!video->loadFile(filename)) {
-		delete video;
-		return false;
-	}
-
-	delete _timeZoneVideo;
-	_timeZoneVideo = video;
-
-	// Set it on pause
-	_timeZoneVideo->pauseVideo(true);
-	return true;
-}
-
-void VideoManager::drawTimeZoneVideoFrame(uint32 time) {
-	assert(_timeZoneVideo);
-
-	if (!_timeZoneVideo->isPaused())
-		_timeZoneVideo->pauseVideo(true);
-
-	_timeZoneVideo->seekToTime(Audio::Timestamp(0, time, 600));
-
-	const Graphics::Surface *frame = _timeZoneVideo->decodeNextFrame();
-
-	if (!frame)	
-		error("Could not find frame at time %d", time);
-
-	copyFrameToScreen(frame, _timeZoneVideo->getWidth(), _timeZoneVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
-	_vm->_system->updateScreen();
-}
-
-void VideoManager::playTimeZoneVideoSegment(uint32 startTime, uint32 endTime) {
-	assert(_timeZoneVideo);
-
-	_timeZoneVideo->seekToTime(Audio::Timestamp(0, startTime, 600));
-
-	if (_timeZoneVideo->isPaused())
-		_timeZoneVideo->pauseVideo(false);
-
-	// Convert the end time to ms
-	endTime = Audio::Timestamp(0, endTime, 600).msecs();
-
-	bool continuePlaying = true;
-	while (!_timeZoneVideo->endOfVideo() && _timeZoneVideo->getElapsedTime() < endTime && !_vm->shouldQuit() && continuePlaying) {
-		if (_timeZoneVideo->needsUpdate()) {
-			const Graphics::Surface *frame = _timeZoneVideo->decodeNextFrame();
-
-			if (frame) {
-				copyFrameToScreen(frame, _timeZoneVideo->getWidth(), _timeZoneVideo->getHeight(), kViewScreenOffset, kViewScreenOffset);
-				_vm->_system->updateScreen();
-			}
-		}
-
-		Common::Event event;
-		while (_vm->_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RTL:
-			case Common::EVENT_QUIT:
-				continuePlaying = false;
-				break;
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_ESCAPE:
-					continuePlaying = false;
-					break;
-				default:
-					break;
-				}
-				break;
-			default:
-				break;
-			}
-		}
-
-		// Cut down on CPU usage
-		_vm->_system->delayMillis(10);
-	}
-
-	_timeZoneVideo->pauseVideo(true);
-}
-
-void VideoManager::pauseVideos() {
-	for (uint16 i = 0; i < _videoStreams.size(); i++)
-		_videoStreams[i]->pauseVideo(true);
-}
-
-void VideoManager::resumeVideos() {
-	for (uint16 i = 0; i < _videoStreams.size(); i++)
-		_videoStreams[i]->pauseVideo(false);
-}
-
-void VideoManager::stopVideos() {
-	for (uint16 i = 0; i < _videoStreams.size(); i++) {
-		delete _videoStreams[i].video;
-		_videoStreams[i].video = 0;
-	}
-}
-
-void VideoManager::playMovie(Common::String filename, uint16 x, uint16 y) {
-	VideoHandle videoHandle = playBackgroundMovie(filename, x, y, false);
-
-	if (videoHandle != NULL_VID_HANDLE)
-		waitUntilMovieEnds(videoHandle);
-}
-
-void VideoManager::playMovieCentered(Common::String filename) {
-	VideoHandle videoHandle = playBackgroundMovie(filename, 0, 0, false);
-
-	if (videoHandle == NULL_VID_HANDLE)
-		return;
-
-	_videoStreams[videoHandle].x = (_vm->_system->getWidth() - _videoStreams[videoHandle]->getWidth()) / 2;
-	_videoStreams[videoHandle].y = (_vm->_system->getHeight() - _videoStreams[videoHandle]->getHeight()) / 2;
-
-	waitUntilMovieEnds(videoHandle);
-}
-	
-void VideoManager::waitUntilMovieEnds(VideoHandle videoHandle) {
-	bool continuePlaying = true;
-
-	while (!_videoStreams[videoHandle]->endOfVideo() && !_vm->shouldQuit() && continuePlaying) {
-		if (updateBackgroundMovies())
-			_vm->_system->updateScreen();
-
-		Common::Event event;
-		while (_vm->_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RTL:
-			case Common::EVENT_QUIT:
-				continuePlaying = false;
-				break;
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_ESCAPE:
-					continuePlaying = false;
-					break;
-				default:
-					break;
-				}
-				break;
-			default:
-				break;
-			}
-		}
-
-		// Cut down on CPU usage
-		_vm->_system->delayMillis(10);
-	}
-
-	delete _videoStreams[videoHandle].video;
-	_videoStreams.clear();
-}
-
-bool VideoManager::updateBackgroundMovies() {
-	bool updateScreen = false;
-
-	for (uint32 i = 0; i < _videoStreams.size() && !_vm->shouldQuit(); i++) {
-		// Skip deleted videos
-		if (!_videoStreams[i].video)
-			continue;
-
-		// Remove any videos that are over
-		if (_videoStreams[i]->endOfVideo()) {
-			if (_videoStreams[i].loop) {
-				_videoStreams[i]->rewind();
-			} else {
-				delete _videoStreams[i].video;
-				memset(&_videoStreams[i], 0, sizeof(VideoEntry));
-				_videoStreams[i].video = NULL;
-				continue;
-			}
-		}
-
-		// Check if we need to draw a frame
-		if (_videoStreams[i]->needsUpdate()) {
-			const Graphics::Surface *frame = _videoStreams[i]->decodeNextFrame();
-
-			if (frame) {				
-				copyFrameToScreen(frame, _videoStreams[i]->getWidth(), _videoStreams[i]->getHeight(), _videoStreams[i].x, _videoStreams[i].y);
-
-				// We've drawn something to the screen, make sure we update it
-				updateScreen = true;
-			}
-		}
-	}
-
-	// Return true if we need to update the screen
-	return updateScreen;
-}
-
-VideoHandle VideoManager::playBackgroundMovie(Common::String filename, int x, int y, bool loop) {
-	// First, check to see if that video is already playing
-	for (uint32 i = 0; i < _videoStreams.size(); i++)
-		if (_videoStreams[i].filename == filename)
-			return i;
-
-	// Otherwise, create a new entry
-	VideoEntry entry;
-	entry.video = new Video::QuickTimeDecoder();
-	entry.x = x;
-	entry.y = y;
-	entry.filename = filename;
-	entry.loop = loop;
-	
-	if (!entry->loadFile(filename))
-		return NULL_VID_HANDLE;
-	
-	// Search for any deleted videos so we can take a formerly used slot
-	for (uint32 i = 0; i < _videoStreams.size(); i++)
-		if (!_videoStreams[i].video) {
-			_videoStreams[i] = entry;
-			return i;
-		}
-			
-	// Otherwise, just add it to the list
-	_videoStreams.push_back(entry);
-	return _videoStreams.size() - 1;
-}
-
-void VideoManager::seekToTime(VideoHandle handle, uint32 time) {
-	if (handle != NULL_VID_HANDLE)
-		_videoStreams[handle]->seekToTime(Audio::Timestamp(0, time, 600));
-}
-
-void VideoManager::copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y) {
-	if (frame->format.bytesPerPixel == 1)
-		error("Unhandled 8bpp frames"); // Cut out because Pegasus Prime shouldn't need this
-
-	// Clip the width/height to make sure we stay on the screen
-	width = MIN<int32>(width, _vm->_system->getWidth() - x);
-	height = MIN<int32>(height, _vm->_system->getHeight() - y);
-
-	if (width == 320 && height == 240) {
-		// TODO: Is this right? At least "Big Movie" and the "Sub Chase Movie" need to be scaled...
-		// FIXME: Normal2x is only compiled in when USE_SCALERS is defined
-		Graphics::Surface scaledSurf;
-		scaledSurf.create(frame->w * 2, frame->h * 2, frame->format);
-		Normal2x((byte *)frame->pixels, frame->pitch, (byte *)scaledSurf.pixels, scaledSurf.pitch, frame->w, frame->h);
-		_vm->_system->copyRectToScreen((byte *)scaledSurf.pixels, scaledSurf.pitch, 0, 0, width * 2, height * 2);
-		scaledSurf.free();
-	} else
-		_vm->_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, x, y, width, height);
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/video.h b/engines/pegasus/video.h
deleted file mode 100644
index 56339e4..0000000
--- a/engines/pegasus/video.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_VIDEO_H
-#define PEGASUS_VIDEO_H
-
-#include "common/array.h"
-
-namespace Common {
-	class String;
-}
-
-namespace Video {
-	class QuickTimeDecoder;
-}
-
-namespace Pegasus {
-
-class PegasusEngine;
-
-struct VideoEntry {
-	Video::QuickTimeDecoder *video;
-	uint16 x;
-	uint16 y;
-	bool loop;
-	Common::String filename;
-
-	Video::QuickTimeDecoder *operator->() const { assert(video); return video; }
-};
-
-typedef int32 VideoHandle;
-
-enum {
-	NULL_VID_HANDLE = -1
-};
-
-class VideoManager {
-public:
-	VideoManager(PegasusEngine *vm);
-	~VideoManager();
-
-	bool loadTimeZoneVideo(const Common::String &filename);
-	void drawTimeZoneVideoFrame(uint32 time);
-	void playTimeZoneVideoSegment(uint32 startTime, uint32 endTime);
-	
-	// Generic movie functions
-	void playMovie(Common::String filename, uint16 x = 0, uint16 y = 0);
-	void playMovieCentered(Common::String filename);
-	VideoHandle playBackgroundMovie(Common::String filename, int x = 0, int y = 0, bool loop = false);
-	bool updateBackgroundMovies();
-	void pauseVideos();
-	void resumeVideos();
-	void stopVideos();
-	void waitUntilMovieEnds(VideoHandle videoHandle);
-
-	void seekToTime(VideoHandle handle, uint32 time);
-
-	// Helper functions
-	void copyFrameToScreen(const Graphics::Surface *frame, int width, int height, int x, int y);
-
-private:
-	PegasusEngine *_vm;
-
-	Video::QuickTimeDecoder *_timeZoneVideo;
-
-	// Keep tabs on any videos playing
-	Common::Array<VideoEntry> _videoStreams;
-	uint32 _pauseStart;
-};
-
-} // End of namespace Pegasus
-
-#endif


Commit: 335a043bd06ab269c8c263fb86a2bc48f5ba9f7b
    https://github.com/scummvm/scummvm/commit/335a043bd06ab269c8c263fb86a2bc48f5ba9f7b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T18:45:39-07:00

Commit Message:
PEGASUS: Add picture class

Changed paths:
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h



diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 7da5cd1..48f9fa3 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -218,4 +218,20 @@ void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool
 	_transparent = transparent;
 }
 
+void Picture::draw(const Common::Rect &r) {
+	Common::Rect surfaceBounds;
+	getSurfaceBounds(surfaceBounds);
+	Common::Rect r1 = r;
+
+	Common::Rect bounds;
+	getBounds(bounds);
+	surfaceBounds.moveTo(bounds.left, bounds.top);
+	r1 = r1.findIntersectingRect(surfaceBounds);
+	getSurfaceBounds(surfaceBounds);
+
+	Common::Rect r2 = r1;
+	r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
+	drawImage(r2, r1);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index 1b63702..9493323 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -29,6 +29,7 @@
 #include "common/rect.h"
 #include "common/str.h"
 
+#include "pegasus/elements.h"
 #include "pegasus/types.h"
 
 namespace Common {
@@ -114,6 +115,14 @@ protected:
 	uint32 _referenceCount;
 };
 
+class Picture : public DisplayElement, public Frame {
+public:
+	Picture(const tDisplayElementID id) : DisplayElement(id) {}
+	virtual ~Picture() {}
+
+	virtual void draw(const Common::Rect &);
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: 6c47e909da0fb6d47c5e9105d4c44fdd0db1c7dc
    https://github.com/scummvm/scummvm/commit/6c47e909da0fb6d47c5e9105d4c44fdd0db1c7dc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T18:57:34-07:00

Commit Message:
PEGASUS: Remove remaining 'old' code

Changed paths:
  R engines/pegasus/credits.cpp
  R engines/pegasus/menu.cpp
  R engines/pegasus/overview.cpp
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/credits.cpp b/engines/pegasus/credits.cpp
deleted file mode 100644
index 6d683de..0000000
--- a/engines/pegasus/credits.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/events.h"
-#include "common/textconsole.h"
-#include "video/qt_decoder.h"
-
-#include "pegasus/pegasus.h"
-
-namespace Pegasus {
-
-enum {
-	kCreditsCore = 0,
-	kCreditsSupport,
-	kCreditsOriginal,
-	kCreditsTalent,
-	kCreditsOther,
-	kCreditsMainMenu
-};
-
-static const int s_startCreditsSegment[] = { 0, 16, 25, 37, 39 };
-
-static int findButtonForFrame(int frame) {
-	int button = kCreditsCore;
-	for (int i = kCreditsCore; i < kCreditsMainMenu; i++)
-		if (frame >= s_startCreditsSegment[i])
-			button = i;
-
-	return button;
-}
-
-void PegasusEngine::runCredits() {
-	Video::QuickTimeDecoder *creditsVideo = new Video::QuickTimeDecoder();
-	if (!creditsVideo->loadFile("Images/Credits/Credits.movie"))
-		error("Could not open credits movie");
-
-	// We're not playing, just retrieving frames
-	creditsVideo->pauseVideo(true);
-
-	int curButton = kCreditsCore;
-	int frame = 0;
-
-	drawCredits(curButton, false, frame, creditsVideo);
-	_system->updateScreen();
-
-	bool continueLooping = true;
-	while (!shouldQuit() && continueLooping) {
-		Common::Event event;
-		while (_eventMan->pollEvent(event)) {
-			bool needsUpdate = false;
-
-			switch (event.type) {
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_UP:
-					if (curButton != kCreditsCore)
-						curButton--;
-					frame = s_startCreditsSegment[curButton];
-					needsUpdate = true;
-					break;
-				case Common::KEYCODE_DOWN:
-					if (curButton != kCreditsMainMenu) {
-						curButton++;
-						if (curButton == kCreditsMainMenu)
-							frame = 43;
-						else
-							frame = s_startCreditsSegment[curButton];
-						needsUpdate = true;
-					}
-					break;
-				case Common::KEYCODE_LEFT:
-					if (frame > 0) {
-						frame--;
-						curButton = findButtonForFrame(frame);
-						needsUpdate = true;
-					}
-					break;
-				case Common::KEYCODE_RIGHT:
-					if (frame < 43) {
-						frame++;
-						curButton = findButtonForFrame(frame);
-						needsUpdate = true;
-					}
-					break;
-				case Common::KEYCODE_RETURN:
-					if (curButton == kCreditsMainMenu) {
-						drawCredits(curButton, true, frame, creditsVideo);
-						_system->updateScreen();
-						continueLooping = false;
-					}
-					break;
-				default:
-					break;
-				}
-				break;
-			default:
-				break;
-			}
-
-			if (needsUpdate) {
-				drawCredits(curButton, false, frame, creditsVideo);
-				_system->updateScreen();
-			}
-		}
-
-		_system->delayMillis(10);
-	}
-
-	delete creditsVideo;
-}
-
-void PegasusEngine::drawCredits(int button, bool highlight, int frame, Video::QuickTimeDecoder *video) {
-	static const int s_creditsButtonY[] = { 224, 260, 296, 332, 366, 407 };
-
-	_gfx->drawPict("Images/Credits/CredScrn.pict", 0, 0, false);
-
-	if (highlight)
-		_gfx->drawPict("Images/Credits/MainMenu.pict", 32, 412, false);
-
-	if (button == kCreditsMainMenu)
-		_gfx->drawPictTransparent("Images/Credits/SelectL.pict", 30, s_creditsButtonY[button], _gfx->getColor(0xf8, 0xf8, 0xf8));
-	else
-		_gfx->drawPictTransparent("Images/Credits/SelectS.pict", 40, s_creditsButtonY[button], _gfx->getColor(0xf8, 0xf8, 0xf8));
-
-	video->seekToTime(frame * 200);
-
-	const Graphics::Surface *surf = video->decodeNextFrame();
-	_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, 288, 0, video->getWidth(), video->getHeight());
-}
-
-void PegasusEngine::runDemoCredits() {
-	_gfx->drawPict("Images/Demo/DemoCredits.pict", 0, 0, true);
-
-	bool continueLooping = true;
-	while (!shouldQuit() && continueLooping) {
-		Common::Event event;
-		while (_eventMan->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_MOUSEMOVE:
-				_system->updateScreen();
-				break;
-			case Common::EVENT_KEYDOWN:
-				// Break on any keypress, but ignore the meta keys
-				// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
-				continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
-				break;
-			case Common::EVENT_LBUTTONDOWN:
-				continueLooping = false;
-				break;
-			default:
-				break;
-			}				
-		}
-
-		_system->delayMillis(10);
-	}
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
deleted file mode 100644
index 12c987c..0000000
--- a/engines/pegasus/menu.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/events.h"
-#include "common/textconsole.h"
-
-#include "pegasus/console.h"
-#include "pegasus/pegasus.h"
-#include "pegasus/sound.h"
-
-namespace Pegasus {
-
-enum {
-	kInterfaceOverviewButton = 0,
-	kStartButton = 1,
-	kRestoreButton = 2,
-	kDifficultyButton = 3,
-	kCreditsButton = 4,
-	kQuitButton = 5
-};
-
-enum {
-	kDemoStartButton = 0,
-	kDemoCreditsButton = 1,
-	kDemoQuitButton = 2
-};	
-
-void PegasusEngine::runMainMenu() {
-	Sound sound;
-	sound.initFromAIFFFile("Sounds/Main Menu.aiff");
-	sound.loopSound();
-
-	int buttonSelected = 0;
-	drawMenu(buttonSelected);
-
-	while (!shouldQuit()) {
-		Common::Event event;
-	
-		// Ignore events for now
-		while (_eventMan->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_UP:
-					if (buttonSelected > 0) {
-						buttonSelected--;
-						drawMenu(buttonSelected);
-					}
-					break;
-				case Common::KEYCODE_DOWN:
-					if ((isDemo() && buttonSelected < 2) || (!isDemo() && buttonSelected < 5)) {
-						buttonSelected++;
-						drawMenu(buttonSelected);
-					}
-					break;
-				case Common::KEYCODE_LEFT:
-				case Common::KEYCODE_RIGHT:
-					if (buttonSelected == kDifficultyButton) {
-						_adventureMode = !_adventureMode;
-						drawMenu(buttonSelected);
-					}
-					break;
-				case Common::KEYCODE_RETURN:
-					if (buttonSelected != kDifficultyButton) {
-						drawMenuButtonSelected(buttonSelected);
-						sound.stopSound();
-						setGameMode(buttonSelected);
-
-						if (_gameMode != kMainMenuMode)
-							return;
-						
-						drawMenu(buttonSelected);
-						sound.loopSound();
-					}
-					break;
-				case Common::KEYCODE_d:
-					if (event.kbd.flags & Common::KBD_CTRL) {
-						_console->attach();
-						_console->onFrame();
-					}
-					break;
-				default:
-					break;
-				}
-
-				break;
-			default:
-				break;
-			}
-		}
-		
-		//_system->updateScreen();
-		_system->delayMillis(10);
-	}
-
-	if (shouldQuit())
-		return;
-}
-
-void PegasusEngine::drawMenu(int buttonSelected) {
-	if (isDemo()) {
-		_gfx->drawPict("Images/Demo/DemoMenu.pict", 0, 0, false);
-	} else {
-		_gfx->drawPict("Images/Main Menu/MainMenu.mac", 0, 0, false);
-		if (!_adventureMode)
-			_gfx->drawPict("Images/Main Menu/BtnWlk.pict", 320, 340, false);
-	}
-
-	drawMenuButtonHighlighted(buttonSelected);
-}
-
-// FIXME: Most of these coordinates can use tweaking
-
-static const int kMainMenuButtonX = 152;
-static const char s_mainMenuButtonSuffix[] = { 'L', 'S', 'S', 'L', 'S', 'S' };
-static const int s_mainMenuButtonY[] = { 202, 252, 292, 337, 382, 422 };
-static const char s_demoMainMenuButtonSuffix[] = { 'S', 'S', 'L' }; // SSL!
-static const int s_demoMainMenuButtonX[] = { 38, 38, 28 };
-static const int s_demoMainMenuButtonY[] = { 332, 366, 408 };
-
-void PegasusEngine::drawMenuButtonHighlighted(int buttonSelected) {
-	if (isDemo())
-		_gfx->drawPictTransparent(Common::String("Images/Demo/Select") + s_demoMainMenuButtonSuffix[buttonSelected] + ".pict", s_demoMainMenuButtonX[buttonSelected], s_demoMainMenuButtonY[buttonSelected], _gfx->getColor(0xff, 0xff, 0xff), true);
-	else
-		_gfx->drawPictTransparent(Common::String("Images/Main Menu/Select") + s_mainMenuButtonSuffix[buttonSelected] + ".pict", kMainMenuButtonX, s_mainMenuButtonY[buttonSelected], _gfx->getColor(0xf8, 0xf8, 0xf8), true);
-}
-
-static const char *s_mainMenuButtonSelSuffix[] = { "Overvi", "Start", "Restor", "", "Credit", "Quit" };
-static const char *s_demoMainMenuButtonSel[] = { "Start", "Credits", "Quit" };
-static const int s_mainMenuSelButtonX[] = { 198, 210, 210, 0, 210, 210 };
-static const int s_demoMainMenuSelButtonX[] = { 43, 43, 34 };
-static const int s_demoMainMenuSelButtonY[] = { 338, 373, 410 };
-
-void PegasusEngine::drawMenuButtonSelected(int buttonSelected) {
-	if (isDemo())
-		_gfx->drawPict(Common::String("Images/Demo/") + s_demoMainMenuButtonSel[buttonSelected] + ".pict", s_demoMainMenuSelButtonX[buttonSelected], s_demoMainMenuSelButtonY[buttonSelected], false);
-	else
-		_gfx->drawPict(Common::String("Images/Main Menu/pb") + s_mainMenuButtonSelSuffix[buttonSelected] + ".pict", s_mainMenuSelButtonX[buttonSelected], s_mainMenuButtonY[buttonSelected] + 5, false);
-
-	drawMenuButtonHighlighted(buttonSelected);
-}
-
-void PegasusEngine::setGameMode(int buttonSelected) {
-	if (isDemo()) {
-		switch (buttonSelected) {
-		case kDemoStartButton:
-			_gameMode = kMainGameMode;
-			break;
-		case kDemoCreditsButton:
-			runDemoCredits();
-			break;
-		case kDemoQuitButton:
-			_gameMode = kQuitMode;
-			break;
-		}
-	} else {
-		switch (buttonSelected) {
-		case kInterfaceOverviewButton:
-			runInterfaceOverview();
-			break;
-		case kStartButton:
-			_gameMode = kMainGameMode;
-			break;
-		case kRestoreButton:
-			showLoadDialog();
-			break;
-		case kCreditsButton:
-			runCredits();
-			break;
-		case kQuitButton:
-			_gameMode = kQuitMode;
-			break;
-		}
-	}
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 131ec1f..7207e48 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -2,7 +2,6 @@ MODULE := engines/pegasus
 
 MODULE_OBJS = \
 	console.o \
-	credits.o \
 	cursor.o \
 	detection.o \
 	elements.o \
@@ -11,10 +10,8 @@ MODULE_OBJS = \
 	graphics.o \
 	hotspot.o \
 	input.o \
-	menu.o \
 	movie.o \
 	notification.o \
-	overview.o \
 	pegasus.o \
 	sound.o \
 	surface.o \
diff --git a/engines/pegasus/overview.cpp b/engines/pegasus/overview.cpp
deleted file mode 100644
index 90fa9a4..0000000
--- a/engines/pegasus/overview.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/events.h"
-#include "common/textconsole.h"
-#include "graphics/cursorman.h"
-#include "video/qt_decoder.h"
-
-#include "pegasus/cursor.h"
-#include "pegasus/pegasus.h"
-
-namespace Pegasus {
-
-void PegasusEngine::runInterfaceOverview() {
-	_cursor->setCurrentFrameIndex(3);
-	_cursor->show();
-
-	Video::QuickTimeDecoder *overviewVideo = new Video::QuickTimeDecoder();
-	if (!overviewVideo->loadFile("Images/Interface/Overview Mac.movie"))
-		error("Could not open overview video");
-
-	// Pause the video, we're only getting frames from it
-	overviewVideo->pauseVideo(true);
-	
-	static const OverviewHotspot overviewHotspots[] = {
-		{ Common::Rect(0, 0, 640, 480), 1000 },     // Main
-		{ Common::Rect(131, 39, 212, 63), 660 },    // Date
-		{ Common::Rect(210, 33, 326, 63), 330 },    // Compass
-		{ Common::Rect(324, 39, 448, 63), 800 },    // Energy Bar
-		{ Common::Rect(531, 35, 601, 57), 2330 },   // Energy Alert
-		{ Common::Rect(63, 63, 577, 321), 1730 },   // View Window
-		{ Common::Rect(69, 317, 355, 331), 1360 },  // Inventory Panel
-		{ Common::Rect(353, 317, 559, 331), 130 },  // BioChip Panel
-		{ Common::Rect(75, 333, 173, 431), 1460 },  // Inventory Box
-		{ Common::Rect(171, 333, 365, 431), 2060 }, // Inventory/BioChip Display
-		{ Common::Rect(363, 333, 461, 431), 1860 }, // BioChip Box
-		{ Common::Rect(540, 348, 640, 468), 530 },  // Keyboard
-	};
-
-	// Draw the rest of the interface
-	int curHotspot;
-	for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
-		if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
-			curHotspot = i;
-	drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
-	_system->updateScreen();
-
-	bool continueLooping = true;
-	while (!shouldQuit() && continueLooping) {
-		Common::Event event;
-		while (_eventMan->pollEvent(event)) {
-			bool updateScreen = false;
-
-			switch (event.type) {
-			case Common::EVENT_MOUSEMOVE:
-				updateScreen = true;
-				break;
-			case Common::EVENT_KEYDOWN:
-				// Break on any keypress, but ignore the meta keys
-				// Except for num lock! num lock on OS9 is 'clear' and we need that for the inventory panel (along with the tilde)
-				continueLooping = (event.kbd.keycode == Common::KEYCODE_INVALID || (event.kbd.keycode >= Common::KEYCODE_CAPSLOCK && event.kbd.keycode <= Common::KEYCODE_COMPOSE));
-				break;
-			case Common::EVENT_LBUTTONDOWN:
-				continueLooping = false;
-				break;
-			default:
-				break;
-			}
-
-			int oldHotspot = curHotspot;
-
-			for (int i = 0; i < ARRAYSIZE(overviewHotspots); i++)
-				if (overviewHotspots[i].rect.contains(_eventMan->getMousePos()))
-					curHotspot = i;
-
-			if (oldHotspot != curHotspot) {
-				drawInterfaceOverview(overviewHotspots[curHotspot], overviewVideo);
-				updateScreen = true;
-			}
-
-			if (updateScreen)
-				_system->updateScreen();
-		}
-
-		_system->delayMillis(10);
-	}
-
-	_cursor->hide();
-	delete overviewVideo;
-}
-
-void PegasusEngine::drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video) {
-	_gfx->drawPict("Images/Interface/OVTop.mac", 0, 0, false);
-	_gfx->drawPict("Images/Interface/OVLeft.mac", 0, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/OVRight.mac", 640 - kViewScreenOffset, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/OVBottom.mac", 0, kViewScreenOffset + 256, false);
-
-	video->seekToTime(hotspot.time);
-	const Graphics::Surface *surf = video->decodeNextFrame();
-	_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, kViewScreenOffset, kViewScreenOffset, video->getWidth(), video->getHeight());
-
-	if (hotspot.time == 530) {
-		// The keyboard is special
-		// Interesting how the file is "controller" and not keyboard. The PlayStation/Pippin versions probably
-		// had similar names...
-		_gfx->drawPict("Images/Interface/OVcontrollerHilite.mac", hotspot.rect.left, hotspot.rect.top, false);
-	} else if (hotspot.time != 1000) {
-		// Draw a yellow outline around the hotspot
-		Common::Rect rect = hotspot.rect;
-		uint32 color = _system->getScreenFormat().RGBToColor(232, 232, 0); // Yellow
-		Graphics::Surface *screen = _system->lockScreen();
-		screen->frameRect(rect, color);
-		rect.grow(1);
-		screen->frameRect(rect, color);
-		rect.grow(1);
-		screen->frameRect(rect, color);
-		screen->hLine(rect.left + 1, rect.top - 1, rect.right - 2, color);
-		screen->hLine(rect.left + 1, rect.bottom, rect.right - 2, color);
-		screen->vLine(rect.left - 1, rect.top + 1, rect.bottom - 2, color);
-		screen->vLine(rect.right, rect.top + 1, rect.bottom - 2, color);
-		_system->unlockScreen();
-	}
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 0a4e066..08ff821 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -23,7 +23,6 @@
 #include "common/config-manager.h"
 #include "common/error.h"
 #include "common/events.h"
-#include "common/file.h"
 #include "common/fs.h"
 #include "common/memstream.h"
 #include "common/savefile.h"
@@ -44,13 +43,6 @@
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/items/inventory/inventoryitem.h"
 
-//#define RUN_INTERFACE_TEST
-//#define RUN_OLD_CODE
-
-#ifdef RUN_INTERFACE_TEST
-#include "pegasus/sound.h"
-#endif
-
 namespace Pegasus {
 
 PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
@@ -72,8 +64,6 @@ Common::Error PegasusEngine::run() {
 	_gfx = new GraphicsManager(this);
 	_resFork = new Common::MacResManager();
 	_cursor = new Cursor();
-	_gameMode = kIntroMode;
-	_adventureMode = true;
 	
 	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 		error("Could not load JMP PP Resources");
@@ -100,48 +90,6 @@ Common::Error PegasusEngine::run() {
 		return Common::kNoGameDataFoundError;
 	}
 
-#if defined(RUN_INTERFACE_TEST)
-	_cursor->setCurrentFrameIndex(0);
-	_cursor->show();
-	drawInterface();
-	Sound sound;
-	sound.initFromAIFFFile("Sounds/Caldoria/Apartment Music.aiff");
-	sound.loopSound();
-
-	while (!shouldQuit()) {
-		Common::Event event;
-		// Ignore events for now
-		while (_eventMan->pollEvent(event)) {
-			if (event.type == Common::EVENT_MOUSEMOVE)
-				_system->updateScreen();
-		}
-		
-		_system->delayMillis(10);
-	}
-#elif defined(RUN_OLD_CODE)
-	while (!shouldQuit()) {
-		switch (_gameMode) {
-		case kIntroMode:
-			if (!isDemo())
-				runIntro();
-			_gameMode = kMainMenuMode;
-			break;
-		case kMainMenuMode:
-			runMainMenu();
-			break;
-		case kMainGameMode:
-			// NOTE: Prehistoric will be our testing location
-			changeLocation(kPrehistoricID);
-			mainGameLoop();
-			break;
-		case kQuitMode:
-			return Common::kNoError;
-		default:
-			_gameMode = kMainMenuMode;
-			break;
-		}
-	}
-#else
 	// Set up input
 	InputHandler::setInputHandler(this);
 	allowInput(true);
@@ -167,7 +115,6 @@ Common::Error PegasusEngine::run() {
 		giveIdleTime();
 		_gfx->updateDisplay();
 	}
-#endif
 
 	return Common::kNoError;
 }
@@ -320,29 +267,6 @@ void PegasusEngine::runIntro() {
 	delete video;
 }
 
-void PegasusEngine::drawInterface() {
-	_gfx->drawPict("Images/Interface/3DInterface Top", 0, 0, false);
-	_gfx->drawPict("Images/Interface/3DInterface Left", 0, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/3DInterface Right", 640 - kViewScreenOffset, kViewScreenOffset, false);
-	_gfx->drawPict("Images/Interface/3DInterface Bottom", 0, kViewScreenOffset + 256, false);
-	//drawCompass();
-	_system->updateScreen();
-}
-
-void PegasusEngine::mainGameLoop() {
-	// TODO: Remove me
-	_gameMode = kQuitMode;
-}
-
-void PegasusEngine::changeLocation(tNeighborhoodID neighborhood) {
-	GameState.setCurrentNeighborhood(neighborhood);
-
-	// Just a test...
-	Neighborhood *neighborhoodPtr = new Neighborhood(this, this, getTimeZoneDesc(neighborhood), neighborhood);
-	neighborhoodPtr->init();
-	delete neighborhoodPtr;
-}
-
 void PegasusEngine::showLoadDialog() {
 	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
 	slc.setSaveMode(false);
@@ -356,24 +280,11 @@ void PegasusEngine::showLoadDialog() {
 
 	if (slot >= 0) {
 		warning("TODO: Load game");
-		_gameMode = kMainGameMode;
 	}
 
 	slc.close();
 }
 
-Common::String PegasusEngine::getTimeZoneDesc(tNeighborhoodID neighborhood) {
-	static const char *names[] = { "Caldoria", "Full TSA", "Full TSA", "Tiny TSA", "Prehistoric", "Mars", "WSC", "Norad Alpha", "Norad Delta" };
-	return names[neighborhood];
-}
-
-Common::String PegasusEngine::getTimeZoneFolder(tNeighborhoodID neighborhood) {
-	if (neighborhood == kFullTSAID || neighborhood == kTinyTSAID || neighborhood == kFinalTSAID)
-		return "TSA";
-
-	return getTimeZoneDesc(neighborhood);
-}
-
 GUI::Debugger *PegasusEngine::getDebugger() {
 	return _console;
 }
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 3e20ddc..3a99ddb 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -53,20 +53,6 @@ class Idler;
 class Cursor;
 class TimeBase;
 
-static const int kViewScreenOffset = 64;
-
-struct OverviewHotspot {
-	Common::Rect rect;
-	uint32 time;
-};
-
-enum GameMode {
-	kIntroMode,
-	kMainMenuMode,
-	kMainGameMode,
-	kQuitMode
-};
-
 class PegasusEngine : public ::Engine, public InputHandler, public NotificationManager {
 friend class InputHandler;
 
@@ -105,46 +91,11 @@ protected:
 	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
 
 private:
-	// Intro
-	void runIntro();
-	void runMainMenu();
-	void drawMenu(int buttonSelected);
-	void drawMenuButtonHighlighted(int buttonSelected);
-	void drawMenuButtonSelected(int buttonSelected);
-	//void runInterfaceOverview();
-	void setGameMode(int buttonSelected);
-
-	// Interface
-	void drawInterface();
-	//void drawCompass();
-	//void runPauseMenu();
-	void showLoadDialog();
-
-	// Interface Overview
-	void runInterfaceOverview();
-	void drawInterfaceOverview(const OverviewHotspot &hotspot, Video::QuickTimeDecoder *video);
-
-	// Credits
-	void runCredits();
-	void drawCredits(int button, bool highlight, int frame, Video::QuickTimeDecoder *video);
-	void runDemoCredits();
-
-	// Main Game Functions
-	void mainGameLoop();
-	void changeLocation(tNeighborhoodID neighborhood);
-
-	// Misc Functions
-	static Common::String getTimeZoneFolder(tNeighborhoodID neighborhood);
-	static Common::String getTimeZoneDesc(tNeighborhoodID neighborhood);
-
-	// Game Variables
-	bool _adventureMode;
-	GameMode _gameMode;
-
 	// Console
 	PegasusConsole *_console;
 
-	// Intro Directory Code
+	// Intro
+	void runIntro();
 	bool detectOpeningClosingDirectory();
 	Common::String _introDirectory;
 
@@ -172,6 +123,7 @@ private:
 
 	// Misc.
 	Hotspot _returnHotspot;
+	void showLoadDialog();
 };
 
 } // End of namespace Pegasus


Commit: e310da1aa80123c1d558388fc345253daed7f63d
    https://github.com/scummvm/scummvm/commit/e310da1aa80123c1d558388fc345253daed7f63d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-20T19:05:09-07:00

Commit Message:
PEGASUS: Add new menu class

Changed paths:
  A engines/pegasus/menu.cpp
  A engines/pegasus/menu.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
new file mode 100755
index 0000000..f7ffbea
--- /dev/null
+++ b/engines/pegasus/menu.cpp
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/menu.h"
+#include "pegasus/pegasus.h"
+
+namespace Pegasus {
+
+GameMenu::GameMenu(const uint32 id) : IDObject(id), InputHandler((InputHandler *)((PegasusEngine *)g_engine)) {
+	_previousHandler = 0;
+	_lastCommand = kMenuCmdNoCommand;
+}
+
+void GameMenu::becomeCurrentHandler() {
+	_previousHandler = InputHandler::setInputHandler(this);
+}
+
+void GameMenu::restorePreviousHandler() {
+	InputHandler::setInputHandler(_previousHandler);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
new file mode 100755
index 0000000..ecb751a
--- /dev/null
+++ b/engines/pegasus/menu.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_MENU_H
+#define PEGASUS_MENU_H
+
+#include "pegasus/constants.h"
+#include "pegasus/input.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+class GameMenu : public IDObject, public InputHandler {
+public:
+	GameMenu(const uint32);
+	virtual ~GameMenu() {}
+	
+	virtual void becomeCurrentHandler();
+	virtual void restorePreviousHandler();
+	
+	tGameMenuCommand getLastCommand() { return _lastCommand; }
+	void clearLastCommand() { _lastCommand = kMenuCmdNoCommand; }
+
+protected:
+	void setLastCommand(const tGameMenuCommand command) { _lastCommand = command; }
+
+	InputHandler *_previousHandler;
+	tGameMenuCommand _lastCommand;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 7207e48..485b107 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -10,6 +10,7 @@ MODULE_OBJS = \
 	graphics.o \
 	hotspot.o \
 	input.o \
+	menu.o \
 	movie.o \
 	notification.o \
 	pegasus.o \


Commit: e3080fb251386687f592aae3f2777cf29a677e68
    https://github.com/scummvm/scummvm/commit/e3080fb251386687f592aae3f2777cf29a677e68
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T07:01:27-07:00

Commit Message:
PEGASUS: Add the JMPPPInput utility class

Changed paths:
    engines/pegasus/input.h



diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 4da0418..0672434 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -449,6 +449,29 @@ protected:
 	InputHandler *_savedHandler;
 };
 
+class JMPPPInput {
+public:
+	static bool isMenuButtonPressInput(const Input &input) { return input.twoButtonDown(); }
+
+	static tInputBits getClickInputFilter() { return kFilterTwoButton; }
+	static bool isClickInput(const Input &input) { return input.twoButtonDown(); }
+	static bool isDraggingInput(const Input &input) { return input.twoButtonAnyDown(); }
+	static bool isPressingInput(const Input &input) { return input.twoButtonAnyDown(); }
+
+	static bool isRaiseInventoryInput(const Input &input) { return input.leftFireButtonDown(); }
+	static bool isRaiseBiochipsInput(const Input &input) { return input.rightFireButtonDown(); }
+	static tInputBits getItemPanelsInputFilter() { return kFilterLeftFireButton | kFilterRightFireButton; }
+
+	static bool isToggleAIMiddleInput(const Input &input) { return input.threeButtonDown(); }
+
+	static bool isToggleInfoInput(const Input &input) { return input.fourButtonDown(); }
+
+	// Hmmmmm....
+	static bool isEasterEggModifierInput(const Input &input) { return input.mod2ButtonAnyDown(); }
+	
+	static bool isTogglePauseInput(const Input &input) { return input.mod3ButtonDown(); }
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: f9fff1809ce8f40706ded0f00b159e96b1989274
    https://github.com/scummvm/scummvm/commit/f9fff1809ce8f40706ded0f00b159e96b1989274
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T11:38:23-07:00

Commit Message:
PEGASUS: Fix auto bits setting in the input code

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 9ef369e..5ef1a14 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -111,10 +111,13 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 
 	// Update the mouse position too
 	input.setInputLocation(g_system->getEventManager()->getMousePos());
-	_lastRawBits = currentBits;
 
-	tInputBits filteredBits = currentBits & filter;
+	// Set the outgoing bits
+	tInputBits filteredBits = currentBits & filter;	
 	input.setInputBits((filteredBits & kAllButtonDownBits) | (filteredBits & _lastRawBits & kAllAutoBits));
+
+	// Update the last bits
+	_lastRawBits = currentBits;
 }
 
 //	Wait until the input device stops returning input allowed by filter...


Commit: 185f5fb05406f29650452c7d3915c4bbfb350684
    https://github.com/scummvm/scummvm/commit/185f5fb05406f29650452c7d3915c4bbfb350684
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T15:10:08-07:00

Commit Message:
PEGASUS: Only allow for keydown events

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 5ef1a14..4b1a8e4 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -46,10 +46,10 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
-		// We only care about two events here
+		// We only care about key down here
 		// We're mapping from ScummVM events to pegasus events, which
 		// are based on pippin events.
-		if (event.type == Common::EVENT_KEYDOWN || event.type == Common::EVENT_KEYUP) {
+		if (event.type == Common::EVENT_KEYDOWN) {
 			switch (event.kbd.keycode) {
 			case Common::KEYCODE_UP:
 			case Common::KEYCODE_KP8:


Commit: d4a731c0f3a529bb9376f7ee532877e642f7aa6b
    https://github.com/scummvm/scummvm/commit/d4a731c0f3a529bb9376f7ee532877e642f7aa6b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T16:21:08-07:00

Commit Message:
PEGASUS: Fix updating elements when the bounds change

Changed paths:
    engines/pegasus/elements.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index faf46f7..ea1ed84 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -71,10 +71,7 @@ void DisplayElement::stopDisplaying() {
 }
 
 void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
-	_bounds.left = left;
-	_bounds.top = top;
-	_bounds.right = right;
-	_bounds.bottom = bottom;
+	setBounds(Common::Rect(left, top, right, bottom));
 }
 
 void DisplayElement::getBounds(Common::Rect &r) const {
@@ -82,16 +79,22 @@ void DisplayElement::getBounds(Common::Rect &r) const {
 }
 
 void DisplayElement::sizeElement(const tCoordType h, const tCoordType v) {
-	_bounds.right = _bounds.left + h;
-	_bounds.bottom = _bounds.top + v;
+	Common::Rect newBounds = _bounds;
+	newBounds.right = _bounds.left + h;
+	newBounds.bottom = _bounds.top + v;
+	setBounds(newBounds);
 }
 
 void DisplayElement::moveElementTo(const tCoordType h, const tCoordType v) {
-	_bounds.moveTo(h, v);
+	Common::Rect newBounds = _bounds;
+	newBounds.moveTo(h, v);
+	setBounds(newBounds);
 }
 
 void DisplayElement::moveElement(const tCoordType dh, const tCoordType dv) {
-	_bounds.translate(dh, dv);
+	Common::Rect newBounds = _bounds;
+	newBounds.translate(dh, dv);
+	setBounds(newBounds);
 }
 
 void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
@@ -100,7 +103,9 @@ void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
 }
 
 void DisplayElement::centerElementAt(const tCoordType h, const tCoordType v) {
-	_bounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
+	Common::Rect newBounds = _bounds;
+	newBounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
+	setBounds(newBounds);
 }
 
 void DisplayElement::getCenter(tCoordType &h, tCoordType &v) const {


Commit: 64d0b6df58195fb42cfc813270b6d2107c3404c8
    https://github.com/scummvm/scummvm/commit/64d0b6df58195fb42cfc813270b6d2107c3404c8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T16:42:45-07:00

Commit Message:
PEGASUS: Fix bug with drawing dirty rects

Changed paths:
    engines/pegasus/graphics.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index a30b2c8..9431293 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -294,7 +294,7 @@ void GraphicsManager::updateDisplay() {
 		}
 
 		// Copy only the dirty rect to the screen
-		g_system->copyRectToScreen((byte *)_workArea.pixels, _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height());
+		g_system->copyRectToScreen((byte *)_workArea.getBasePtr(_dirtyRect.left, _dirtyRect.top), _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height());
 
 		// Mark the screen as dirty
 		screenDirty = true;


Commit: 46bc7e6c4d6ec9addccff397f1c8439d6a86bb20
    https://github.com/scummvm/scummvm/commit/46bc7e6c4d6ec9addccff397f1c8439d6a86bb20
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T16:44:42-07:00

Commit Message:
PEGASUS: Fix bounds of Pictures

Changed paths:
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h



diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 48f9fa3..fb64c92 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -234,4 +234,20 @@ void Picture::draw(const Common::Rect &r) {
 	drawImage(r2, r1);
 }
 
+void Picture::initFromPICTFile(const Common::String &fileName, bool transparent) {
+	Frame::initFromPICTFile(fileName, transparent);
+
+	Common::Rect surfaceBounds;
+	getSurfaceBounds(surfaceBounds);
+	setBounds(surfaceBounds);
+}
+
+void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
+	Frame::initFromPICTResource(resFork, id, transparent);
+
+	Common::Rect surfaceBounds;
+	getSurfaceBounds(surfaceBounds);
+	setBounds(surfaceBounds);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index 9493323..72d614f 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -120,6 +120,9 @@ public:
 	Picture(const tDisplayElementID id) : DisplayElement(id) {}
 	virtual ~Picture() {}
 
+	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
+	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
+
 	virtual void draw(const Common::Rect &);
 };
 


Commit: b4408d4527c05612aaabd86d52541d6def1485ab
    https://github.com/scummvm/scummvm/commit/b4408d4527c05612aaabd86d52541d6def1485ab
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T16:51:42-07:00

Commit Message:
PEGASUS: Implement main menu

Sound fading is not working yet, so it has been disabled in the meantime

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/menu.cpp
    engines/pegasus/menu.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 89fdeef..8d2a95b 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -519,6 +519,42 @@ const tHotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
 											kOpticalBiochipSpotFlag |
 											kAirMaskSpotFlag;
 
+const tMM32BitID kMainMenuID = 1;
+const tMM32BitID kPauseMenuID = 2;
+const tMM32BitID kCreditsMenuID = 3;
+const tMM32BitID kDeathMenuID = 4;
+
+/////////////////////////////////////////////
+//
+//	Menu commands.
+
+const tGameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
+const tGameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
+const tGameMenuCommand kMenuCmdStartWalkthrough = kMenuCmdStartAdventure + 1;
+const tGameMenuCommand kMenuCmdRestore = kMenuCmdStartWalkthrough + 1;
+const tGameMenuCommand kMenuCmdCredits = kMenuCmdRestore + 1;
+const tGameMenuCommand kMenuCmdQuit = kMenuCmdCredits + 1;
+
+const tGameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
+
+const tGameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
+const tGameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
+
+const tGameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathContinue + 1;
+const tGameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
+
+const tGameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
+const tGameMenuCommand kMenuCmdPauseContinue = kMenuCmdPauseSave + 1;
+const tGameMenuCommand kMenuCmdPauseRestore = kMenuCmdPauseContinue + 1;
+const tGameMenuCommand kMenuCmdPauseQuit = kMenuCmdPauseRestore + 1;
+
+const tGameMenuCommand kMenuCmdCreditsMainMenu = kMenuCmdPauseQuit + 1;
+
+const tGameMenuCommand kMenuCmdCancelRestart = kMenuCmdCreditsMainMenu + 1;
+const tGameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
+
+const TimeValue kMenuButtonHiliteTime = 20;
+const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index f7ffbea..335cfea 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -41,4 +41,335 @@ void GameMenu::restorePreviousHandler() {
 	InputHandler::setInputHandler(_previousHandler);
 }
 
+enum {
+	kMainMenuStartDemo = 0,
+	kMainMenuCreditsDemo,
+	kMainMenuQuitDemo,
+	kFirstSelectionDemo = kMainMenuStartDemo,
+	kLastSelectionDemo = kMainMenuQuitDemo,
+
+	kMainMenuOverview = 0,
+	kMainMenuStart,
+	kMainMenuRestore,
+	kMainMenuDifficulty,
+	kMainMenuCredits,
+	kMainMenuQuit,
+	kFirstSelection = kMainMenuOverview,
+	kLastSelection = kMainMenuQuit
+};
+
+static const tCoordType kStartLeftDemo = 44;
+static const tCoordType kStartTopDemo = 336;
+
+static const tCoordType kStartSelectLeftDemo = 40;
+static const tCoordType kStartSelectTopDemo = 331;
+
+static const tCoordType kCreditsLeftDemo = 44;
+static const tCoordType kCreditsTopDemo = 372;
+
+static const tCoordType kCreditsSelectLeftDemo = 40;
+static const tCoordType kCreditsSelectTopDemo = 367;
+
+static const tCoordType kMainMenuQuitLeftDemo = 32;
+static const tCoordType kMainMenuQuitTopDemo = 412;
+
+static const tCoordType kMainMenuQuitSelectLeftDemo = 28;
+static const tCoordType kMainMenuQuitSelectTopDemo = 408;
+
+static const tCoordType kOverviewLeft = 200;
+static const tCoordType kOverviewTop = 208;
+
+static const tCoordType kOverviewSelectLeft = 152;
+static const tCoordType kOverviewSelectTop = 204;
+
+static const tCoordType kStartLeft = 212;
+static const tCoordType kStartTop = 256;
+
+static const tCoordType kStartSelectLeft = 152;
+static const tCoordType kStartSelectTop = 252;
+
+static const tCoordType kRestoreLeft = 212;
+static const tCoordType kRestoreTop = 296;
+
+static const tCoordType kRestoreSelectLeft = 152;
+static const tCoordType kRestoreSelectTop = 292;
+
+static const tCoordType kDifficultyLeft = 320;
+static const tCoordType kDifficultyTop = 340;
+
+static const tCoordType kDifficultySelectLeft = 152;
+static const tCoordType kDifficultySelectTop = 336;
+
+static const tCoordType kCreditsLeft = 212;
+static const tCoordType kCreditsTop = 388;
+
+static const tCoordType kCreditsSelectLeft = 152;
+static const tCoordType kCreditsSelectTop = 384;
+
+static const tCoordType kMainMenuQuitLeft = 212;
+static const tCoordType kMainMenuQuitTop = 428;
+
+static const tCoordType kMainMenuQuitSelectLeft = 152;
+static const tCoordType kMainMenuQuitSelectTop = 424;
+
+//	Never set the current input handler to the MainMenu.
+MainMenu::MainMenu() : GameMenu(kMainMenuID), _menuBackground(0), _overviewButton(0),
+		_restoreButton(0), _adventureButton(0), _walkthroughButton(0), _startButton(0),
+		_creditsButton(0), _quitButton(0), _largeSelect(0), _smallSelect(0) {
+
+	bool isDemo = ((PegasusEngine *)g_engine)->isDemo();
+
+	if (isDemo)
+		_menuBackground.initFromPICTFile("Images/Demo/DemoMenu.pict");
+	else
+		_menuBackground.initFromPICTFile("Images/Main Menu/MainMenu.mac");
+	_menuBackground.setDisplayOrder(0);
+	_menuBackground.startDisplaying();
+	_menuBackground.show();
+
+	if (!isDemo) {
+		_overviewButton.initFromPICTFile("Images/Main Menu/pbOvervi.pict");
+		_overviewButton.setDisplayOrder(1);
+		_overviewButton.moveElementTo(kOverviewLeft, kOverviewTop);
+		_overviewButton.startDisplaying();
+
+		_restoreButton.initFromPICTFile("Images/Main Menu/pbRestor.pict");
+		_restoreButton.setDisplayOrder(1);
+		_restoreButton.moveElementTo(kRestoreLeft, kRestoreTop);
+		_restoreButton.startDisplaying();
+
+		_adventureButton.initFromPICTFile("Images/Main Menu/BtnAdv.pict");
+		_adventureButton.setDisplayOrder(1);
+		_adventureButton.moveElementTo(kDifficultyLeft, kDifficultyTop);
+		_adventureButton.startDisplaying();
+
+		_walkthroughButton.initFromPICTFile("Images/Main Menu/BtnWlk.pict");
+		_walkthroughButton.setDisplayOrder(1);
+		_walkthroughButton.moveElementTo(kDifficultyLeft, kDifficultyTop);
+		_walkthroughButton.startDisplaying();
+	}
+
+	if (isDemo)
+		_startButton.initFromPICTFile("Images/Demo/Start.pict");
+	else
+		_startButton.initFromPICTFile("Images/Main Menu/pbStart.pict");
+	_startButton.setDisplayOrder(1);
+	_startButton.moveElementTo(isDemo ? kStartLeftDemo : kStartLeft, isDemo ? kStartTopDemo : kStartTop);
+	_startButton.startDisplaying();
+
+	if (isDemo)
+		_creditsButton.initFromPICTFile("Images/Demo/Credits.pict");
+	else
+		_creditsButton.initFromPICTFile("Images/Main Menu/pbCredit.pict");
+	_creditsButton.setDisplayOrder(1);
+	_creditsButton.moveElementTo(isDemo ? kCreditsLeftDemo : kCreditsLeft, isDemo ? kCreditsTopDemo : kCreditsTop);
+	_creditsButton.startDisplaying();
+
+	if (isDemo)
+		_quitButton.initFromPICTFile("Images/Demo/Quit.pict");
+	else
+		_quitButton.initFromPICTFile("Images/Main Menu/pbQuit.pict");
+	_quitButton.setDisplayOrder(1);
+	_quitButton.moveElementTo(isDemo ? kMainMenuQuitLeftDemo : kMainMenuQuitLeft, isDemo ? kMainMenuQuitTopDemo : kMainMenuQuitTop);
+	_quitButton.startDisplaying();
+
+	if (isDemo)
+		_largeSelect.initFromPICTFile("Images/Demo/SelectL.pict", true);
+	else
+		_largeSelect.initFromPICTFile("Images/Main Menu/SelectL.pict", true);
+	_largeSelect.setDisplayOrder(1);
+	_largeSelect.startDisplaying();
+
+	if (isDemo)
+		_smallSelect.initFromPICTFile("Images/Demo/SelectS.pict", true);
+	else
+		_smallSelect.initFromPICTFile("Images/Main Menu/SelectS.pict", true);
+	_smallSelect.setDisplayOrder(1);
+	_smallSelect.startDisplaying();
+
+	_menuSelection = isDemo ? kFirstSelectionDemo : kFirstSelection;
+
+	_adventureMode = true;
+
+	//_menuLoop.attachFader(&_menuFader);
+	_menuLoop.initFromAIFFFile("Sounds/Main Menu.aiff");
+
+	updateDisplay();
+}
+
+MainMenu::~MainMenu() {
+	if (_menuLoop.isPlaying())
+		stopMainMenuLoop();
+}
+
+void MainMenu::startMainMenuLoop() {
+	FaderMoveSpec spec;
+
+	_menuLoop.loopSound();
+	spec.makeTwoKnotFaderSpec(30, 0, 0, 30, 255);
+	//_menuFader.startFaderSync(spec);
+}
+
+void MainMenu::stopMainMenuLoop() {
+	FaderMoveSpec spec;
+	
+	spec.makeTwoKnotFaderSpec(30, 0, 255, 30, 0);
+	//_menuFader.startFaderSync(spec);
+	_menuLoop.stopSound();
+}
+
+void MainMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	bool isDemo = vm->isDemo();
+
+	if (input.upButtonDown()) {
+		if (_menuSelection > (isDemo ? kFirstSelectionDemo : kFirstSelection)) {
+			_menuSelection--;
+			updateDisplay();
+		}
+	} else if (input.downButtonDown()) {
+		if (_menuSelection < (isDemo ? kLastSelectionDemo : kLastSelection)) {
+			_menuSelection++;
+			updateDisplay();
+		}
+	} else if (!isDemo && (input.leftButtonDown() || input.rightButtonDown())) {
+		if (_menuSelection == kMainMenuDifficulty) {
+			_adventureMode = !_adventureMode;
+			updateDisplay();
+		}
+	} else if (JMPPPInput::isMenuButtonPressInput(input)) {
+		if (isDemo) {
+			switch (_menuSelection) {
+			case kMainMenuCreditsDemo:
+				_creditsButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_creditsButton.hide();
+				setLastCommand(kMenuCmdCredits);
+				break;
+			case kMainMenuStartDemo:
+				_startButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_startButton.hide();
+				setLastCommand(kMenuCmdStartAdventure);
+				break;
+			case kMainMenuQuitDemo:
+				_quitButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_quitButton.hide();
+				setLastCommand(kMenuCmdQuit);
+				break;
+			}
+		} else {
+			switch (_menuSelection) {
+			case kMainMenuOverview:
+				_overviewButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_overviewButton.hide();
+				setLastCommand(kMenuCmdOverview);
+				break;
+			case kMainMenuRestore:
+				_restoreButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_restoreButton.hide();
+				setLastCommand(kMenuCmdRestore);
+				break;
+			case kMainMenuCredits:
+				_creditsButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_creditsButton.hide();
+				setLastCommand(kMenuCmdCredits);
+				break;
+			case kMainMenuStart:
+				_startButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_startButton.hide();
+				if (_adventureMode)
+					setLastCommand(kMenuCmdStartAdventure);
+				else
+					setLastCommand(kMenuCmdStartWalkthrough);
+				break;
+			case kMainMenuDifficulty:
+				_adventureMode = !_adventureMode;
+				updateDisplay();
+				break;
+			case kMainMenuQuit:
+				_quitButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_quitButton.hide();
+				setLastCommand(kMenuCmdQuit);
+				break;
+			}
+		}
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void MainMenu::updateDisplay() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	if (vm->isDemo()) {
+		switch (_menuSelection) {
+		case kMainMenuStartDemo:
+			_smallSelect.moveElementTo(kStartSelectLeftDemo, kStartSelectTopDemo);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kMainMenuCreditsDemo:
+			_smallSelect.moveElementTo(kCreditsSelectLeftDemo, kCreditsSelectTopDemo);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kMainMenuQuitDemo:
+			_largeSelect.moveElementTo(kMainMenuQuitSelectLeftDemo, kMainMenuQuitSelectTopDemo);
+			_largeSelect.show();
+			_smallSelect.hide();
+			break;
+		}
+	} else {
+		switch (_menuSelection) {
+		case kMainMenuOverview:
+			_largeSelect.moveElementTo(kOverviewSelectLeft, kOverviewSelectTop);
+			_largeSelect.show();
+			_smallSelect.hide();
+			break;
+		case kMainMenuRestore:
+			_smallSelect.moveElementTo(kRestoreSelectLeft, kRestoreSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kMainMenuDifficulty:
+			if (_adventureMode) {
+				_adventureButton.show();
+				_walkthroughButton.hide();
+			} else {
+				_walkthroughButton.show();
+				_adventureButton.hide();
+			}
+
+			_largeSelect.moveElementTo(kDifficultySelectLeft, kDifficultySelectTop);
+			_largeSelect.show();
+			_smallSelect.hide();
+			break;
+		case kMainMenuStart:
+			_smallSelect.moveElementTo(kStartSelectLeft, kStartSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kMainMenuCredits:
+			_smallSelect.moveElementTo(kCreditsSelectLeft, kCreditsSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kMainMenuQuit:
+			_smallSelect.moveElementTo(kMainMenuQuitSelectLeft, kMainMenuQuitSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		}
+
+		vm->resetIntroTimer();
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
index ecb751a..24e3785 100755
--- a/engines/pegasus/menu.h
+++ b/engines/pegasus/menu.h
@@ -27,7 +27,10 @@
 #define PEGASUS_MENU_H
 
 #include "pegasus/constants.h"
+#include "pegasus/fader.h"
 #include "pegasus/input.h"
+#include "pegasus/sound.h"
+#include "pegasus/surface.h"
 #include "pegasus/util.h"
 
 namespace Pegasus {
@@ -50,6 +53,41 @@ protected:
 	tGameMenuCommand _lastCommand;
 };
 
+class Hotspot;
+
+class MainMenu : public GameMenu {
+public:
+	MainMenu();
+	virtual ~MainMenu();
+
+	virtual void handleInput(const Input &input, const Hotspot *);
+	void startMainMenuLoop();
+	void stopMainMenuLoop();
+
+protected:
+	void updateDisplay();
+
+	uint32 _menuSelection;
+
+	// Full and Demo
+	Picture _menuBackground;
+	Picture _startButton;
+	Picture _creditsButton;
+	Picture _quitButton;
+	Picture _largeSelect;
+	Picture _smallSelect;
+
+	// Full only
+	bool _adventureMode;
+	Picture _overviewButton;
+	Picture _restoreButton;
+	Picture _adventureButton;
+	Picture _walkthroughButton;
+
+	Sound _menuLoop;
+	SoundFader _menuFader;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 08ff821..c79d519 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -36,6 +36,7 @@
 #include "pegasus/console.h"
 #include "pegasus/cursor.h"
 #include "pegasus/gamestate.h"
+#include "pegasus/menu.h"
 #include "pegasus/movie.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
@@ -49,6 +50,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID) {
 	_continuePoint = 0;
 	_saveAllowed = _loadAllowed = true;
+	_gameMenu = 0;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -57,6 +59,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _console;
 	delete _cursor;
 	delete _continuePoint;
+	delete _gameMenu;
 }
 
 Common::Error PegasusEngine::run() {
@@ -483,6 +486,14 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 #else
 			if (!isDemo())
 				runIntro();
+
+			if (shouldQuit())
+				return;
+
+			useMenu(new MainMenu());
+			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
+			_gfx->updateDisplay();
+			((MainMenu *)_gameMenu)->startMainMenuLoop();
 #endif
 			break;
 		}
@@ -497,4 +508,85 @@ void PegasusEngine::checkCallBacks() {
 		(*it)->checkCallBacks();
 }
 
+void PegasusEngine::resetIntroTimer() {
+	// TODO
+}
+
+void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
+	if (time == 0 || scale == 0)
+		return;
+
+	uint32 startTime = g_system->getMillis();
+	uint32 timeInMillis = time * 1000 / scale;
+
+	while (g_system->getMillis() < startTime + timeInMillis) {
+		checkCallBacks();
+		_gfx->updateDisplay();
+	}
+}
+
+void PegasusEngine::useMenu(GameMenu *newMenu) {
+	if (_gameMenu) {
+		_gameMenu->restorePreviousHandler();
+		delete _gameMenu;
+	}
+
+	_gameMenu = newMenu;
+
+	if (_gameMenu)
+		_gameMenu->becomeCurrentHandler();
+}
+
+bool PegasusEngine::checkGameMenu() {
+	tGameMenuCommand command = kMenuCmdNoCommand;
+
+	if (_gameMenu) {
+		command = _gameMenu->getLastCommand();
+		if (command != kMenuCmdNoCommand) {
+			_gameMenu->clearLastCommand();
+			doGameMenuCommand(command);
+		}
+	}
+
+	return command != kMenuCmdNoCommand;
+}
+
+void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
+	switch (command) {
+	case kMenuCmdStartAdventure:
+		GameState.setWalkthroughMode(false);
+		error("Start new game (adventure mode)");
+		break;
+	case kMenuCmdCredits:
+		error("Show credits");
+		break;
+	case kMenuCmdQuit:
+		_system->quit();
+		break;
+	case kMenuCmdOverview:
+		error("Show overview");
+		break;
+	case kMenuCmdStartWalkthrough:
+		GameState.setWalkthroughMode(true);
+		error("Start new game (walkthrough mode)");
+		break;
+	case kMenuCmdRestore:
+		error("Load game");
+		break;
+	case kMenuCmdNoCommand:
+		break;
+	default:
+		error("Unknown menu command %d", command);
+	}
+}
+
+void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (!checkGameMenu())
+		; // TODO: Other input
+
+	// TODO: Quit request
+	// TODO: Save request
+	// TODO: Load request
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 3a99ddb..e3965e6 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -52,6 +52,7 @@ class GraphicsManager;
 class Idler;
 class Cursor;
 class TimeBase;
+class GameMenu;
 
 class PegasusEngine : public ::Engine, public InputHandler, public NotificationManager {
 friend class InputHandler;
@@ -73,6 +74,10 @@ public:
 	GraphicsManager *_gfx;
 	Common::MacResManager *_resFork;
 
+	// Menu
+	void useMenu(GameMenu *menu);
+	bool checkGameMenu();
+
 	// Misc.
 	bool isDemo() const;
 	void addIdler(Idler *idler);
@@ -81,6 +86,8 @@ public:
 	void removeTimeBase(TimeBase *timeBase);
 	void swapSaveAllowed(bool allow) { _saveAllowed = allow; }
 	void swapLoadAllowed(bool allow) { _loadAllowed = allow; }
+	void delayShell(TimeValue time, TimeScale scale);
+	void resetIntroTimer();
 
 protected:
 	Common::Error run();
@@ -90,6 +97,8 @@ protected:
 	Notification _shellNotification;
 	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
 
+	void handleInput(const Input &input, const Hotspot *cursorSpot);
+
 private:
 	// Console
 	PegasusConsole *_console;
@@ -124,6 +133,10 @@ private:
 	// Misc.
 	Hotspot _returnHotspot;
 	void showLoadDialog();
+
+	// Menu
+	GameMenu *_gameMenu;
+	void doGameMenuCommand(const tGameMenuCommand);
 };
 
 } // End of namespace Pegasus


Commit: 02e7656b07061d0c8e5a7e79e731d5e01fc6210b
    https://github.com/scummvm/scummvm/commit/02e7656b07061d0c8e5a7e79e731d5e01fc6210b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T17:06:49-07:00

Commit Message:
PEGASUS: Allow for backquote to be used as a tilde too

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 4b1a8e4..76f5afa 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -87,6 +87,7 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 				currentBits |= (kRawButtonDown << kMod3ButtonShift);
 				break;
 			case Common::KEYCODE_TILDE:
+			case Common::KEYCODE_BACKQUOTE:
 			case Common::KEYCODE_NUMLOCK: // Yes, the original uses Num Lock/Clear on the Mac...
 				currentBits |= (kRawButtonDown << kLeftFireButtonShift);
 				break;


Commit: 2bba1d0c11d2ceb8a1ec1dc5a9f1910a90b5cf5a
    https://github.com/scummvm/scummvm/commit/2bba1d0c11d2ceb8a1ec1dc5a9f1910a90b5cf5a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T17:22:26-07:00

Commit Message:
PEGASUS: Allow redrawMovieWorld to be used without the video running

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 8f79c03..ba8f47d 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -78,7 +78,7 @@ void Movie::setDirectDraw(const bool flag) {
 }
 
 void Movie::redrawMovieWorld() {
-	if (_video && _video->needsUpdate()) {
+	if (_video) {
 		const Graphics::Surface *frame = _video->decodeNextFrame();
 
 		if (_directDraw) {
@@ -154,7 +154,11 @@ void Movie::resume() {
 
 void Movie::checkCallBacks() {
 	TimeBase::checkCallBacks();
-	redrawMovieWorld();
+
+	// The reason why we overrode TimeBase's checkCallBacks():
+	// Again, avoiding timers and handling it here
+	if (_video->needsUpdate())
+		redrawMovieWorld();
 }
 
 } // End of namespace Pegasus


Commit: 97072b5d4b6f789ee7bc8b7eb570fd93e0d14e82
    https://github.com/scummvm/scummvm/commit/97072b5d4b6f789ee7bc8b7eb570fd93e0d14e82
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T17:30:49-07:00

Commit Message:
PEGASUS: Remove scaling TODO

Video scaling is not done with this class

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index ba8f47d..d37a493 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -83,7 +83,6 @@ void Movie::redrawMovieWorld() {
 
 		if (_directDraw) {
 			// Copy to the screen
-			// TODO: Scaling
 			Common::Rect bounds;
 			getBounds(bounds);
 			g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, bounds.left, bounds.top, frame->w, frame->h);


Commit: cb500d147efa0c890d30f6be7aff286d5909b315
    https://github.com/scummvm/scummvm/commit/cb500d147efa0c890d30f6be7aff286d5909b315
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T18:09:58-07:00

Commit Message:
PEGASUS: Clamp the dirty rect to the screen size

Changed paths:
    engines/pegasus/graphics.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 9431293..2891f21 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -197,6 +197,10 @@ void GraphicsManager::invalRect(const Common::Rect &rect) {
 		// Expand our dirty rect to include rect
 		_dirtyRect.extend(rect);
 	}
+
+	// Sanity check: clip our rect to the screen
+	_dirtyRect.right = MIN<int>(640, _dirtyRect.right);
+	_dirtyRect.bottom = MIN<int>(480, _dirtyRect.bottom);
 }
 
 void GraphicsManager::addDisplayElement(DisplayElement *newElement) {


Commit: 0fd4a55492eb4c4cd77f2e3e160fd26b896f87c2
    https://github.com/scummvm/scummvm/commit/0fd4a55492eb4c4cd77f2e3e160fd26b896f87c2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T18:18:46-07:00

Commit Message:
PEGASUS: Fix DropHighlight

Changed paths:
    engines/pegasus/elements.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index ea1ed84..6f94fe5 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -178,6 +178,7 @@ void DropHighlight::draw(const Common::Rect &) {
 	// going to implement it in those two ways. Deal with it.
 
 	Common::Rect rect = _bounds;
+	rect.grow(-_thickness);
 	screen->frameRect(rect, _highlightColor);
 	rect.grow(1);
 	screen->frameRect(rect, _highlightColor);


Commit: 802fb1a97b04a1b6613dd00b700fb0a42b3eaef7
    https://github.com/scummvm/scummvm/commit/802fb1a97b04a1b6613dd00b700fb0a42b3eaef7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T18:33:33-07:00

Commit Message:
PEGASUS: Add very simple mouse movement update checking

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 2891f21..a25dd67 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include "common/events.h"
 #include "common/file.h"
 #include "common/textconsole.h"
 #include "engines/util.h"
@@ -49,6 +50,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_frontLayer = kMaxAvailableOrder;
 	_firstDisplayElement = _lastDisplayElement = 0;
 	_workArea.create(640, 480, _vm->_system->getScreenFormat());
+	_lastMousePosition = Common::Point(-1, -1);
 }
 	
 GraphicsManager::~GraphicsManager() {
@@ -282,10 +284,15 @@ void GraphicsManager::removeDisplayElement(DisplayElement *oldElement) {
 }
 
 void GraphicsManager::updateDisplay() {
-	// TODO: Check for cursor move/change
-
 	bool screenDirty = false;
 
+	// TODO: Check for cursor change
+	Common::Point mousePos = g_system->getEventManager()->getMousePos();
+	if (_lastMousePosition != mousePos) {
+		screenDirty = true;
+		_lastMousePosition = mousePos;
+	}
+
 	if (!_dirtyRect.isEmpty()) {
 		for (DisplayElement *runner = _firstDisplayElement; runner != 0; runner = runner->_nextElement) {
 			Common::Rect bounds;
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index d4f9628..b72137b 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -83,6 +83,7 @@ private:
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 	Graphics::Surface _workArea;
+	Common::Point _lastMousePosition;
 };
 
 } // End of namespace Pegasus


Commit: 5b23d33a29f501236b164ee7de3013ae41c289a0
    https://github.com/scummvm/scummvm/commit/5b23d33a29f501236b164ee7de3013ae41c289a0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T18:35:55-07:00

Commit Message:
PEGASUS: Remove old graphics API

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index a25dd67..e37150e 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -39,13 +39,6 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	if (_vm->_system->getScreenFormat().bytesPerPixel == 1)
 		error("No true color mode available");
 
-	// Old
-	_pictDecoder = new Graphics::PictDecoder(_vm->_system->getScreenFormat());
-
-	for (int i = 0; i < kImageCacheSize; i++)
-		_cache[i].surface = 0;
-
-	// New
 	_backLayer = kMinAvailableOrder;
 	_frontLayer = kMaxAvailableOrder;
 	_firstDisplayElement = _lastDisplayElement = 0;
@@ -54,140 +47,9 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 }
 	
 GraphicsManager::~GraphicsManager() {
-	// Old
-	delete _pictDecoder;
-
-	for (int i = 0; i < kImageCacheSize; i++) {
-		if (_cache[i].surface) {
-			_cache[i].surface->free();
-			delete _cache[i].surface;
-		}
-	}
-
-	// New
 	_workArea.free();
 }
 
-Graphics::Surface *GraphicsManager::decodeImage(const Common::String &filename) {
-	int imageSlot = getImageSlot(filename);
-
-	if (_cache[imageSlot].surface)
-		return _cache[imageSlot].surface;
-
-	Common::File file;
-	if (!file.open(filename))
-		error("Could not open \'%s\'", filename.c_str());
-
-	byte palette[256 * 3];
-	Graphics::Surface *image = _pictDecoder->decodeImage(&file, palette);
-
-	// For <= 8bpp, we need to convert
-	if (image->format.bytesPerPixel == 1) {
-		Graphics::PixelFormat format = _vm->_system->getScreenFormat();
-		Graphics::Surface *output = new Graphics::Surface();
-		output->create(image->w, image->h, format);
-
-		for (uint16 y = 0; y < image->h; y++) {
-			for (uint16 x = 0; x < image->w; x++) {
-				byte c = *((byte *)image->getBasePtr(x, y));
-				byte r = palette[c * 3];
-				byte g = palette[c * 3 + 1];
-				byte b = palette[c * 3 + 2];
-
-				if (format.bytesPerPixel == 2) {
-					uint16 color = format.RGBToColor(r, g, b);
-					memcpy(output->getBasePtr(x, y), &color, 2);
-				} else if (format.bytesPerPixel == 4) {
-					uint32 color = format.RGBToColor(r, g, b);
-					memcpy(output->getBasePtr(x, y), &color, 4);
-				}
-			}
-		}
-
-		image->free();
-		delete image;
-		image = output;
-	}
-
-	_cache[imageSlot].surface = image;
-	return image;
-}
-
-void GraphicsManager::drawPict(Common::String filename, int x, int y, bool updateScreen) {
-	Graphics::Surface *surface = decodeImage(filename);
-	
-	_vm->_system->copyRectToScreen((byte *)surface->pixels, surface->pitch, x, y, surface->w, surface->h);
-
-	if (updateScreen)
-		_vm->_system->updateScreen();
-}
-
-void GraphicsManager::drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen) {
-	if (_vm->_system->getScreenFormat().bytesPerPixel == 2)
-		transparency &= 0xffff;
-
-	Graphics::Surface *surface = decodeImage(filename);
-	Graphics::Surface *screen = _vm->_system->lockScreen();
-
-	for (uint16 i = 0; i < surface->h; i++) {
-		for (uint16 j = 0; j < surface->w; j++) {
-			if (_vm->_system->getScreenFormat().bytesPerPixel == 2) {
-				uint16 color = *((uint16 *)surface->getBasePtr(j, i));
-				if (color != transparency)
-					memcpy(screen->getBasePtr(j + x, i + y), &color, 2);
-			} else if (_vm->_system->getScreenFormat().bytesPerPixel == 4) {
-				uint32 color = *((uint32 *)surface->getBasePtr(j, i));
-				if (color != transparency)
-					memcpy(screen->getBasePtr(j + x, i + y), &color, 4);
-			}
-		}
-	}
-
-	_vm->_system->unlockScreen();
-
-	if (updateScreen)
-		_vm->_system->updateScreen();
-}
-
-uint32 GraphicsManager::getColor(byte r, byte g, byte b) {
-	return _vm->_system->getScreenFormat().RGBToColor(r, g, b);
-}
-
-int GraphicsManager::getImageSlot(const Common::String &filename) {
-	// Let's find a match, an open slot, or the oldest image slot
-	uint32 oldestAge = 0xffffffff;
-	int slot = 0;
-
-	for (int i = 0; i < kImageCacheSize; i++) {
-		if (_cache[i].filename.equalsIgnoreCase(filename)) {
-			//warning("Found image %s at slot %d", filename.c_str(), i);
-			_cache[i].lastUsed = _vm->_system->getMillis();
-			return i;
-		}
-
-		if (!_cache[i].surface) {
-			//warning("Putting image %s in empty slot %d", filename.c_str(), i);
-			_cache[i].filename = filename;
-			_cache[i].lastUsed = _vm->_system->getMillis();
-			return i;
-		}
-
-		if (_cache[i].lastUsed < oldestAge) {
-			oldestAge = _cache[i].lastUsed;
-			slot = i;
-		}
-	}
-
-	// Let's make sure that's cleaned out
-	//warning("Replacing old image %s with %s in slot %d", _cache[slot].filename.c_str(), filename.c_str(), slot);
-	_cache[slot].filename = filename;
-	_cache[slot].surface->free();
-	delete _cache[slot].surface;
-	_cache[slot].surface = 0;
-	_cache[slot].lastUsed = _vm->_system->getMillis();
-	return slot;
-}
-
 void GraphicsManager::invalRect(const Common::Rect &rect) {
 	// We're using a simpler algorithm for dirty rect handling than the original
 	// The original was way too overcomplicated for what we need here now.
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index b72137b..ebaaeb2 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -37,16 +37,6 @@
 
 namespace Pegasus {
 
-enum {
-	kImageCacheSize = 10
-};
-
-struct ImageCache {
-	Common::String filename;
-	Graphics::Surface *surface;
-	uint32 lastUsed;
-};
-
 class DisplayElement;
 class PegasusEngine;
 
@@ -55,12 +45,6 @@ public:
 	GraphicsManager(PegasusEngine *vm);
 	~GraphicsManager();
 
-	// Older "temporary" API
-	void drawPict(Common::String filename, int x, int y, bool updateScreen = true);
-	void drawPictTransparent(Common::String filename, int x, int y, uint32 transparency, bool updateScreen = true);
-	uint32 getColor(byte r, byte g, byte b);
-
-	// Newer "to-be-used" API
 	void addDisplayElement(DisplayElement *element);
 	void removeDisplayElement(DisplayElement *element);
 	void invalRect(const Common::Rect &rect);
@@ -72,13 +56,6 @@ public:
 private:		
 	PegasusEngine *_vm;
 
-	// Older "temporary" API
-	Graphics::PictDecoder *_pictDecoder;
-	Graphics::Surface *decodeImage(const Common::String &filename);
-	ImageCache _cache[kImageCacheSize];
-	int getImageSlot(const Common::String &filename);
-
-	// Newer "to-be-used" API
 	Common::Rect _dirtyRect;
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;


Commit: ea7ec2709469ed5311238542432db73c0ae2b180
    https://github.com/scummvm/scummvm/commit/ea7ec2709469ed5311238542432db73c0ae2b180
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-21T18:39:07-07:00

Commit Message:
PEGASUS: Fix drawing movies to positions other than the origin

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index d37a493..87ff872 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -96,10 +96,19 @@ void Movie::redrawMovieWorld() {
 }
 
 void Movie::draw(const Common::Rect &r) {
-	if (_transparent)
-		copyToCurrentPortTransparent(r);
-	else
-		copyToCurrentPort(r);
+	Common::Rect surfaceBounds;
+	getSurfaceBounds(surfaceBounds);
+	Common::Rect r1 = r;
+
+	Common::Rect bounds;
+	getBounds(bounds);
+	surfaceBounds.moveTo(bounds.left, bounds.top);
+	r1 = r1.findIntersectingRect(surfaceBounds);
+	getSurfaceBounds(surfaceBounds);
+
+	Common::Rect r2 = r1;
+	r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
+	drawImage(r2, r1);
 }
 
 void Movie::setVolume(uint16 volume) {


Commit: 35cc9b5d0f6d18629382e0af85c4eaf634cf3857
    https://github.com/scummvm/scummvm/commit/35cc9b5d0f6d18629382e0af85c4eaf634cf3857
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T06:07:41-07:00

Commit Message:
PEGASUS: Implement the overview code

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index c79d519..6ca2efb 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -564,7 +564,9 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		_system->quit();
 		break;
 	case kMenuCmdOverview:
-		error("Show overview");
+		// TODO: Stop intro timer
+		doInterfaceOverview();
+		resetIntroTimer();
 		break;
 	case kMenuCmdStartWalkthrough:
 		GameState.setWalkthroughMode(true);
@@ -589,4 +591,168 @@ void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	// TODO: Load request
 }
 
+void PegasusEngine::doInterfaceOverview() {
+	static const short kNumOverviewSpots = 11;
+	static const Common::Rect overviewSpots[kNumOverviewSpots] = {
+		Common::Rect(354, 318, 354 + 204, 318 + 12),
+		Common::Rect(211, 34, 211 + 114, 34 + 28),
+		Common::Rect(502, 344, 502 + 138, 344 + 120),
+		Common::Rect(132, 40, 132 + 79, 40 + 22),
+		Common::Rect(325, 40, 332 + 115, 40 + 22),
+		Common::Rect(70, 318, 70 + 284, 318 + 12),
+		Common::Rect(76, 334, 76 + 96, 334 + 96),
+		Common::Rect(64, 64, 64 + 512, 64 + 256),
+		Common::Rect(364, 334, 364 + 96, 334 + 96),
+		Common::Rect(172, 334, 172 + 192, 334 + 96),
+		Common::Rect(542, 36, 542 + 58, 36 + 20)
+	};
+
+	// TODO: fade out
+	useMenu(0);
+
+	Picture leftBackground(kNoDisplayElement);
+	leftBackground.initFromPICTFile("Images/Interface/OVLeft.mac");
+	leftBackground.setDisplayOrder(0);
+	leftBackground.moveElementTo(kBackground1Left, kBackground1Top);
+	leftBackground.startDisplaying();
+	leftBackground.show();
+
+	Picture topBackground(kNoDisplayElement);
+	topBackground.initFromPICTFile("Images/Interface/OVTop.mac");
+	topBackground.setDisplayOrder(0);
+	topBackground.moveElementTo(kBackground2Left, kBackground2Top);
+	topBackground.startDisplaying();
+	topBackground.show();
+
+	Picture rightBackground(kNoDisplayElement);
+	rightBackground.initFromPICTFile("Images/Interface/OVRight.mac");
+	rightBackground.setDisplayOrder(0);
+	rightBackground.moveElementTo(kBackground3Left, kBackground3Top);
+	rightBackground.startDisplaying();
+	rightBackground.show();
+
+	Picture bottomBackground(kNoDisplayElement);
+	bottomBackground.initFromPICTFile("Images/Interface/OVBottom.mac");
+	bottomBackground.setDisplayOrder(0);
+	bottomBackground.moveElementTo(kBackground4Left, kBackground4Top);
+	bottomBackground.startDisplaying();
+	bottomBackground.show();
+
+	Picture controllerHighlight(kNoDisplayElement);
+	controllerHighlight.initFromPICTFile("Images/Interface/OVcontrollerHilite.mac");
+	controllerHighlight.setDisplayOrder(0);
+	controllerHighlight.moveElementTo(kOverviewControllerLeft, kOverviewControllerTop);
+	controllerHighlight.startDisplaying();
+
+	Movie overviewText(kNoDisplayElement);
+	overviewText.initFromMovieFile("Images/Interface/Overview Mac.movie");
+	overviewText.setDisplayOrder(0);
+	overviewText.moveElementTo(kNavAreaLeft, kNavAreaTop);
+	overviewText.startDisplaying();
+	overviewText.show();
+	overviewText.redrawMovieWorld();
+
+	DropHighlight highlight(kNoDisplayElement);
+	highlight.setDisplayOrder(1);
+	highlight.startDisplaying();
+	highlight.setHighlightThickness(4);
+	highlight.setHighlightColor(g_system->getScreenFormat().RGBToColor(239, 239, 0));
+	highlight.setHighlightCornerDiameter(8);
+
+	Input input;
+	InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+
+	Common::Point cursorLoc;
+	input.getInputLocation(cursorLoc);
+
+	uint16 i;
+	for (i = 0; i < kNumOverviewSpots; ++i)
+		if (overviewSpots[i].contains(cursorLoc))
+			break;
+
+	TimeValue time;
+	if (i == kNumOverviewSpots)
+		time = 5;
+	else if (i > 4)
+		time = i + 1;
+	else
+		time = i;
+
+	if (time == 2) {
+		highlight.hide();
+		controllerHighlight.show();
+	} else if (i != kNumOverviewSpots) {
+		controllerHighlight.hide();
+		Common::Rect r = overviewSpots[i];
+		r.grow(5);
+		highlight.setBounds(r);
+		highlight.show();
+	} else {
+		highlight.hide();
+		controllerHighlight.hide();
+	}
+
+	overviewText.setTime(time * 3 + 2, 15);
+	overviewText.redrawMovieWorld();
+
+	_cursor->setCurrentFrameIndex(3);
+	_cursor->show();
+
+	_gfx->updateDisplay();
+	// TODO: Fade in
+
+	for (;;) {
+		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+
+		if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too
+			break;
+
+		input.getInputLocation(cursorLoc);
+		for (i = 0; i < kNumOverviewSpots; ++i)
+			if (overviewSpots[i].contains(cursorLoc))
+				break;
+
+		if (i == kNumOverviewSpots)
+			time = 5;
+		else if (i > 4)
+			time = i + 1;
+		else
+			time = i;
+
+		if (time == 2) {
+			highlight.hide();
+			controllerHighlight.show();
+		} else if (i != kNumOverviewSpots) {
+			controllerHighlight.hide();
+			Common::Rect r = overviewSpots[i];
+			r.grow(5);
+			highlight.setBounds(r);
+			highlight.show();
+		} else {
+			highlight.hide();
+			controllerHighlight.hide();
+		}
+
+		overviewText.setTime(time * 3 + 2, 15);
+		overviewText.redrawMovieWorld();
+
+		giveIdleTime();
+		_gfx->updateDisplay();
+	}
+
+	if (shouldQuit())
+		return;
+
+	highlight.hide();
+	_cursor->hide();
+
+	// TODO: Fade out
+	useMenu(new MainMenu());
+	_gfx->updateDisplay();
+	((MainMenu *)_gameMenu)->startMainMenuLoop();
+	// TODO: Fade in
+
+	// TODO: Cancel save/load requests?
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index e3965e6..d3fcae8 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -137,6 +137,7 @@ private:
 	// Menu
 	GameMenu *_gameMenu;
 	void doGameMenuCommand(const tGameMenuCommand);
+	void doInterfaceOverview();
 };
 
 } // End of namespace Pegasus


Commit: 17d6f74867994fd38809036602b24a2fc02ef987
    https://github.com/scummvm/scummvm/commit/17d6f74867994fd38809036602b24a2fc02ef987
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T06:24:14-07:00

Commit Message:
PEGASUS: Implement demo credits

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 6ca2efb..97ea63a 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -558,7 +558,14 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		error("Start new game (adventure mode)");
 		break;
 	case kMenuCmdCredits:
-		error("Show credits");
+		if (isDemo()) {
+			showTempScreen("Images/Demo/DemoCredits.pict");
+			// TODO: Fade out
+			_gfx->updateDisplay();
+			// TODO: Fade in
+		} else {
+			error("Show credits");
+		}
 		break;
 	case kMenuCmdQuit:
 		_system->quit();
@@ -755,4 +762,36 @@ void PegasusEngine::doInterfaceOverview() {
 	// TODO: Cancel save/load requests?
 }
 
+void PegasusEngine::showTempScreen(const Common::String &fileName) {
+	// TODO: Fade out
+
+	Picture picture(0);
+	picture.initFromPICTFile(fileName);
+	picture.setDisplayOrder(kMaxAvailableOrder);
+	picture.startDisplaying();
+	picture.show();
+	_gfx->updateDisplay();
+
+	// TODO: Fade in
+
+	// Wait for the next event
+	bool done = false;
+	while (!shouldQuit() && !done) {
+		Common::Event event;
+		while (_eventMan->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_LBUTTONUP:
+			case Common::EVENT_RBUTTONUP:
+			case Common::EVENT_KEYDOWN:
+				done = true;
+				break;
+			default:
+				break;
+			}
+		}
+
+		_system->delayMillis(10);
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index d3fcae8..7ad978d 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -133,6 +133,7 @@ private:
 	// Misc.
 	Hotspot _returnHotspot;
 	void showLoadDialog();
+	void showTempScreen(const Common::String &fileName);
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: b92476ecb17278ad04d75a69128fb5f5e3b9813c
    https://github.com/scummvm/scummvm/commit/b92476ecb17278ad04d75a69128fb5f5e3b9813c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T07:31:39-07:00

Commit Message:
PEGASUS: Don't update movies if they're paused

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 87ff872..9ddc091 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -165,7 +165,7 @@ void Movie::checkCallBacks() {
 
 	// The reason why we overrode TimeBase's checkCallBacks():
 	// Again, avoiding timers and handling it here
-	if (_video->needsUpdate())
+	if (!_video->isPaused() && _video->needsUpdate())
 		redrawMovieWorld();
 }
 


Commit: c88e33abd7ba8c282a6d2839c4b5cce57ad17773
    https://github.com/scummvm/scummvm/commit/c88e33abd7ba8c282a6d2839c4b5cce57ad17773
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T07:39:31-07:00

Commit Message:
PEGASUS: Make Movies use the normal TimeBase getTime()

getTime() shouldn't constantly update as the movie continues, only when I decide to update it (in checkCallBacks())

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 9ddc091..9d9c189 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -116,20 +116,10 @@ void Movie::setVolume(uint16 volume) {
 }
 
 void Movie::setTime(const TimeValue time, const TimeScale scale) {
-	if (_video)
-		_video->seekToTime(Audio::Timestamp(0, time, ((scale == 0) ? getScale() : scale)));
-}
-
-TimeValue Movie::getTime(const TimeScale scale) {
 	if (_video) {
-		TimeScale actualScale = ((scale == 0) ? getScale() : scale);
-
-		uint32 startTime = _startTime * actualScale / _startScale;
-		uint32 stopTime = _stopTime * actualScale / _stopScale;
-		return CLIP<int>(_video->getElapsedTime() * actualScale / 1000, startTime, stopTime);
+		_video->seekToTime(Audio::Timestamp(0, time, ((scale == 0) ? getScale() : scale)));
+		_time = Common::Rational(time, ((scale == 0) ? getScale() : scale));
 	}
-
-	return 0;
 }
 
 void Movie::setRate(const Common::Rational rate) {
@@ -165,8 +155,15 @@ void Movie::checkCallBacks() {
 
 	// The reason why we overrode TimeBase's checkCallBacks():
 	// Again, avoiding timers and handling it here
-	if (!_video->isPaused() && _video->needsUpdate())
-		redrawMovieWorld();
+	if (!_video->isPaused()) {
+		if (_video->needsUpdate())
+			redrawMovieWorld();
+
+		uint32 startTime = _startTime * getScale() / _startScale;
+		uint32 stopTime = _stopTime * getScale() / _stopScale;
+		uint32 actualTime = CLIP<int>(_video->getElapsedTime() * getScale() / 1000, startTime, stopTime);
+		_time = Common::Rational(actualTime, getScale());
+	}
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 98d84b6..54e57ae 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -54,7 +54,6 @@ public:
 	void setDirectDraw(const bool);
 	
 	virtual void setTime(const TimeValue, const TimeScale = 0);
-	virtual TimeValue getTime(const TimeScale = 0);
 	
 	virtual void setRate(const Common::Rational);
 	


Commit: 2e9c7b5342290005c92f30bcce35401c91fcd175
    https://github.com/scummvm/scummvm/commit/2e9c7b5342290005c92f30bcce35401c91fcd175
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T08:52:33-07:00

Commit Message:
PEGASUS: Don't allow for seeking beyond the ends of the movie

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 9d9c189..2bf852a 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -81,6 +81,9 @@ void Movie::redrawMovieWorld() {
 	if (_video) {
 		const Graphics::Surface *frame = _video->decodeNextFrame();
 
+		if (!frame)
+			return;
+
 		if (_directDraw) {
 			// Copy to the screen
 			Common::Rect bounds;
@@ -117,8 +120,16 @@ void Movie::setVolume(uint16 volume) {
 
 void Movie::setTime(const TimeValue time, const TimeScale scale) {
 	if (_video) {
-		_video->seekToTime(Audio::Timestamp(0, time, ((scale == 0) ? getScale() : scale)));
-		_time = Common::Rational(time, ((scale == 0) ? getScale() : scale));
+		// Don't go past the ends of the movie
+		Common::Rational timeFrac = Common::Rational(time, ((scale == 0) ? getScale() : scale));
+
+		if (timeFrac < Common::Rational(_startTime, _startScale))
+			timeFrac = Common::Rational(_startTime, _startScale);
+		else if (timeFrac >= Common::Rational(_stopTime, _stopScale))
+			return;
+
+		_video->seekToTime(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator()));
+		_time = timeFrac;
 	}
 }
 


Commit: 3417e39c7a7452f00c1f6d712e9fe04f4feba431
    https://github.com/scummvm/scummvm/commit/3417e39c7a7452f00c1f6d712e9fe04f4feba431
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T09:06:21-07:00

Commit Message:
PEGASUS: Implement the credits

Functionality is now back to where it was before switching to the updated API

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/menu.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 335cfea..3793a1f 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -372,4 +372,177 @@ void MainMenu::updateDisplay() {
 	}
 }
 
+enum {
+	kCreditsMenuCoreTeam,
+	kCreditsMenuSupportTeam,
+	kCreditsMenuOriginalTeam,
+	kCreditsMenuTalent,
+	kCreditsMenuOtherTitles,
+	kCreditsMenuMainMenu,
+	
+	kCreditsFirstSelection = kCreditsMenuCoreTeam,
+	kCreditsLastSelection = kCreditsMenuMainMenu
+};
+
+static const tCoordType kCreditsMovieLeft = 288;
+static const tCoordType kCreditsMovieTop = 0;
+
+static const tCoordType kCoreTeamSelectLeft = 40;
+static const tCoordType kCoreTeamSelectTop = 223;
+
+static const tCoordType kSupportTeamSelectLeft = 40;
+static const tCoordType kSupportTeamSelectTop = 259;
+
+static const tCoordType kOriginalTeamSelectLeft = 40;
+static const tCoordType kOriginalTeamSelectTop = 295;
+
+static const tCoordType kTalentSelectLeft = 40;
+static const tCoordType kTalentSelectTop = 331;
+
+static const tCoordType kOtherTitlesSelectLeft = 40;
+static const tCoordType kOtherTitlesSelectTop = 367;
+
+static const tCoordType kCreditsMainMenuLeft = 32;
+static const tCoordType kCreditsMainMenuTop = 412;
+
+static const tCoordType kCreditsMainMenuSelectLeft = 30;
+static const tCoordType kCreditsMainMenuSelectTop = 408;
+
+static const TimeValue kCoreTeamTime = 0;
+static const TimeValue kSupportTeamTime = 1920;
+static const TimeValue kOriginalTeamTime = 3000;
+static const TimeValue kTalentTime = 4440;
+static const TimeValue kOtherTitlesTime = 4680;
+
+static const TimeValue kFrameIncrement = 120;		//	Three frames...
+
+//	Never set the current input handler to the CreditsMenu.
+CreditsMenu::CreditsMenu() : GameMenu(kCreditsMenuID), _menuBackground(0), _creditsMovie(0),
+		_mainMenuButton(0), _largeSelect(0), _smallSelect(0) {
+
+	_menuBackground.initFromPICTFile("Images/Credits/CredScrn.pict");
+	_menuBackground.setDisplayOrder(0);
+	_menuBackground.startDisplaying();
+	_menuBackground.show();
+
+	_creditsMovie.initFromMovieFile("Images/Credits/Credits.movie");
+	_creditsMovie.setDisplayOrder(1);
+	_creditsMovie.moveElementTo(kCreditsMovieLeft, kCreditsMovieTop);
+	_creditsMovie.startDisplaying();
+	_creditsMovie.show();
+	_creditsMovie.redrawMovieWorld();
+
+	_mainMenuButton.initFromPICTFile("Images/Credits/MainMenu.pict");
+	_mainMenuButton.setDisplayOrder(1);
+	_mainMenuButton.moveElementTo(kCreditsMainMenuLeft, kCreditsMainMenuTop);
+	_mainMenuButton.startDisplaying();
+
+	_largeSelect.initFromPICTFile("Images/Credits/SelectL.pict", true);
+	_largeSelect.setDisplayOrder(2);
+	_largeSelect.moveElementTo(kCreditsMainMenuSelectLeft, kCreditsMainMenuSelectTop);
+	_largeSelect.startDisplaying();
+
+	_smallSelect.initFromPICTFile("Images/Credits/SelectS.pict", true);
+	_smallSelect.setDisplayOrder(2);
+	_smallSelect.show();
+	_smallSelect.startDisplaying();
+	
+	_menuSelection = -1;
+	
+	newMenuSelection(kCreditsMenuCoreTeam);
+}
+
+// Assumes the new selection is never more than one away from the old...
+void CreditsMenu::newMenuSelection(const int newSelection) {
+	if (newSelection != _menuSelection) {
+		switch (newSelection) {
+			case kCreditsMenuCoreTeam:
+				_smallSelect.moveElementTo(kCoreTeamSelectLeft, kCoreTeamSelectTop);
+				_creditsMovie.setTime(kCoreTeamTime);
+				_creditsMovie.redrawMovieWorld();
+				break;
+			case kCreditsMenuSupportTeam:
+				_smallSelect.moveElementTo(kSupportTeamSelectLeft, kSupportTeamSelectTop);
+				_creditsMovie.setTime(kSupportTeamTime);
+				_creditsMovie.redrawMovieWorld();
+				break;
+			case kCreditsMenuOriginalTeam:
+				_smallSelect.moveElementTo(kOriginalTeamSelectLeft, kOriginalTeamSelectTop);
+				_creditsMovie.setTime(kOriginalTeamTime);
+				_creditsMovie.redrawMovieWorld();
+				break;
+			case kCreditsMenuTalent:
+				_smallSelect.moveElementTo(kTalentSelectLeft, kTalentSelectTop);
+				_creditsMovie.setTime(kTalentTime);
+				_creditsMovie.redrawMovieWorld();
+				break;
+			case kCreditsMenuOtherTitles:
+				_smallSelect.moveElementTo(kOtherTitlesSelectLeft, kOtherTitlesSelectTop);
+				_smallSelect.show();
+				_largeSelect.hide();
+				_creditsMovie.setTime(kOtherTitlesTime);
+				_creditsMovie.redrawMovieWorld();
+				break;
+			case kCreditsMenuMainMenu:
+				_smallSelect.hide();
+				_largeSelect.show();
+				break;
+		}
+
+		_menuSelection = newSelection;
+	}
+}
+
+void CreditsMenu::newMovieTime(const TimeValue newTime) {
+	if (newTime < kSupportTeamTime) {
+		_smallSelect.moveElementTo(kCoreTeamSelectLeft, kCoreTeamSelectTop);
+		_menuSelection = kCreditsMenuCoreTeam;
+	} else if (newTime < kOriginalTeamTime) {
+		_smallSelect.moveElementTo(kSupportTeamSelectLeft, kSupportTeamSelectTop);
+		_menuSelection = kCreditsMenuSupportTeam;
+	} else if (newTime < kTalentTime) {
+		_smallSelect.moveElementTo(kOriginalTeamSelectLeft, kOriginalTeamSelectTop);
+		_menuSelection = kCreditsMenuOriginalTeam;
+	} else if (newTime < kOtherTitlesTime) {
+		_smallSelect.moveElementTo(kTalentSelectLeft, kTalentSelectTop);
+		_smallSelect.show();
+		_largeSelect.hide();
+		_menuSelection = kCreditsMenuTalent;
+	} else if ((int)newTime == -120) {
+		// HACK: Avoid getting sent to the bottom button in the default case
+		return;
+	} else {
+		_smallSelect.moveElementTo(kOtherTitlesSelectLeft, kOtherTitlesSelectTop);
+		_smallSelect.show();
+		_largeSelect.hide();
+		_menuSelection = kCreditsMenuOtherTitles;
+	}
+
+	_creditsMovie.setTime(newTime);
+	_creditsMovie.redrawMovieWorld();
+}
+
+void CreditsMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (input.upButtonDown()) {
+		if (_menuSelection > kCreditsFirstSelection)
+			newMenuSelection(_menuSelection - 1);
+	} else if (input.downButtonDown()) {
+		if (_menuSelection < kCreditsLastSelection)
+			newMenuSelection(_menuSelection + 1);
+	} else if (input.leftButtonDown()) {
+		newMovieTime(_creditsMovie.getTime() - kFrameIncrement);
+	} else if (input.rightButtonDown()) {
+		newMovieTime(_creditsMovie.getTime() + kFrameIncrement);
+	} else if (JMPPPInput::isMenuButtonPressInput(input)) {
+		if (_menuSelection == kCreditsMenuMainMenu) {
+			_mainMenuButton.show();
+			((PegasusEngine *)g_engine)->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+			_mainMenuButton.hide();
+			setLastCommand(kMenuCmdCreditsMainMenu);
+		}
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
index 24e3785..581fb5f 100755
--- a/engines/pegasus/menu.h
+++ b/engines/pegasus/menu.h
@@ -29,6 +29,7 @@
 #include "pegasus/constants.h"
 #include "pegasus/fader.h"
 #include "pegasus/input.h"
+#include "pegasus/movie.h"
 #include "pegasus/sound.h"
 #include "pegasus/surface.h"
 #include "pegasus/util.h"
@@ -88,6 +89,25 @@ protected:
 	SoundFader _menuFader;
 };
 
+class CreditsMenu : public GameMenu {
+public:
+	CreditsMenu(void);
+	virtual ~CreditsMenu() {}
+	
+	virtual void handleInput(const Input &input, const Hotspot *);
+
+protected:
+	void newMenuSelection(const int);
+	void newMovieTime(const TimeValue);
+	
+	int _menuSelection;
+	Picture _menuBackground;
+	Movie _creditsMovie;
+	Picture _mainMenuButton;
+	Picture _largeSelect;
+	Picture _smallSelect;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 97ea63a..b71295a 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -54,12 +54,12 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 }
 
 PegasusEngine::~PegasusEngine() {
-	delete _gfx;
 	delete _resFork;
 	delete _console;
 	delete _cursor;
 	delete _continuePoint;
 	delete _gameMenu;
+	delete _gfx;
 }
 
 Common::Error PegasusEngine::run() {
@@ -564,7 +564,11 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 			_gfx->updateDisplay();
 			// TODO: Fade in
 		} else {
-			error("Show credits");
+			// TODO: Stop intro timer
+			// TODO: Fade out
+			useMenu(new CreditsMenu());
+			_gfx->updateDisplay();
+			// TODO: Fade in
 		}
 		break;
 	case kMenuCmdQuit:
@@ -582,6 +586,14 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 	case kMenuCmdRestore:
 		error("Load game");
 		break;
+	case kMenuCmdCreditsMainMenu:
+		// TODO: Fade out
+		useMenu(new MainMenu());
+		_gfx->updateDisplay();
+		((MainMenu *)_gameMenu)->startMainMenuLoop();
+		// TODO: Fade in
+		resetIntroTimer();
+		break;
 	case kMenuCmdNoCommand:
 		break;
 	default:


Commit: 897c585f05b30d7431541f774383ace8f8f5201a
    https://github.com/scummvm/scummvm/commit/897c585f05b30d7431541f774383ace8f8f5201a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T11:50:24-07:00

Commit Message:
PEGASUS: Add the InventoryPicture class (and its derivatives)

Changed paths:
  A engines/pegasus/items/inventorypicture.cpp
  A engines/pegasus/items/inventorypicture.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
new file mode 100755
index 0000000..5c8010b
--- /dev/null
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -0,0 +1,367 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/transition.h"
+#include "pegasus/items/inventorypicture.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+InventoryPicture::InventoryPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+		InputHandler(nextHandler), Picture(id), _panelMovie(kNoDisplayElement){
+	_inventory = inventory;
+	_lastReferenceCount = 0xffffffff;
+
+	if (_inventory->getNumItems() > 0) {
+		_currentItemIndex = 0;
+		_currentItem = (Item *)_inventory->getItemAt(0);
+	} else {
+		_currentItemIndex = -1;
+		_currentItem = 0;
+	}
+
+	_active = false;
+	_shouldDrawHighlight = true;
+	_itemsPerRow = 1;
+	_numberOfRows = 1;
+	_itemWidth = 0;
+	_itemHeight = 0;
+	_itemX = 0;
+	_itemY = 0;
+}
+
+void InventoryPicture::initInventoryImage(Transition *transition) {
+	initFromPICTFile(_pictName, true);
+	_panelMovie.shareSurface(this);
+	_panelMovie.initFromMovieFile(_movieName);
+	_panelMovie.getBounds(_highlightBounds);
+	_panelMovie.setTriggeredElement(transition);
+	_highlightImage.initFromPICTFile(_highlightName, true);
+}
+
+void InventoryPicture::throwAwayInventoryImage() {
+	if (isSurfaceValid()) {
+		_panelMovie.releaseMovie();
+		_highlightImage.deallocateSurface();
+		deallocateSurface();
+	}
+}
+
+void InventoryPicture::getItemXY(uint32 index, tCoordType &x, tCoordType &y) {
+	x = (index % _itemsPerRow) * _itemWidth + _itemX;
+	y = (index / _itemsPerRow) * _itemHeight + _itemY;
+}
+
+void InventoryPicture::drawItemHighlight(const Common::Rect &r) {	
+	if (_highlightImage.isSurfaceValid()) {
+		Common::Rect r2 = _highlightBounds;
+		Common::Rect bounds;
+		getBounds(bounds);
+
+		r2.translate(bounds.left, bounds.top);
+		r2 = r2.findIntersectingRect(r);
+		if (!r2.isEmpty()) {
+			Common::Rect r1 = r2;
+			r1.translate(-bounds.left - _highlightBounds.left, -bounds.top - _highlightBounds.top);
+			_highlightImage.drawImage(r1, r2);
+		}
+	}
+}
+
+void InventoryPicture::draw(const Common::Rect &r) {
+	Picture::draw(r);
+	if (_inventory->getNumItems() != 0 && _shouldDrawHighlight)
+		drawItemHighlight(r);
+}
+
+// Assumes index >= 0.
+void InventoryPicture::setCurrentItemIndex(int32 index) {
+	if (index >= _inventory->getNumItems())
+		index = _inventory->getNumItems() - 1;
+
+	Item *currentItem = 0;
+	if (index >= 0)
+		currentItem = (Item *)_inventory->getItemAt(index);
+
+	if (currentItem != _currentItem) {
+		if (_currentItem) {
+			if (_currentItem->isSelected())
+				_currentItem->deselect();
+
+			if (_active)
+				unhighlightCurrentItem();
+		}
+
+		_currentItemIndex = index;
+		_currentItem = currentItem;
+		if (_currentItem) {
+			_currentItem->select();
+
+			if (_active)
+				highlightCurrentItem();
+		}
+
+		if (_active)
+			triggerRedraw();
+	}
+}
+
+void InventoryPicture::setCurrentItemID(tItemID id) {
+	int32 index = _inventory->findIndexOf(id);
+	if (index >= 0)
+		setCurrentItemIndex(index);
+}
+
+tInventoryResult InventoryPicture::addInventoryItem(Item *item) {
+	tInventoryResult result = _inventory->addItem(item);
+
+	if (result == kInventoryOK)
+		setCurrentItemIndex(_inventory->findIndexOf(item));
+
+	return result;
+}
+
+tInventoryResult InventoryPicture::removeInventoryItem(Item *item) {	
+	tInventoryResult result = _inventory->removeItem(item);
+
+	if (result == kInventoryOK)
+		setCurrentItemIndex(getCurrentItemIndex());
+
+	return result;
+}
+
+void InventoryPicture::removeAllItems() {
+	_inventory->removeAllItems();
+	setCurrentItemIndex(0);
+}
+
+bool InventoryPicture::itemInInventory(Item *item) {
+	return _inventory->itemInInventory(item);
+}
+
+bool InventoryPicture::itemInInventory(const tItemID id) {
+	return _inventory->itemInInventory(id);
+}
+
+void InventoryPicture::panelUp() {
+	allowInput(true);
+}
+
+//	Must ensure that the picture matches the _inventory member variable.
+void InventoryPicture::activateInventoryPicture() {
+	if (_active)
+		return;
+
+	allowInput(false);
+
+	if (_lastReferenceCount != _inventory->getReferenceCount()) {
+		uint32 numItems = _inventory->getNumItems();
+
+		tCoordType x, y;
+		getItemXY(0, x, y);
+		_panelMovie.moveElementTo(x, y);
+		_panelMovie.show();
+
+		for (uint32 i = 0; i < numItems; i++) {
+			Item *item = (Item *)_inventory->getItemAt(i);
+			if (item == _currentItem)
+				item->select();
+
+			getItemXY(i, x, y);
+			_panelMovie.moveElementTo(x, y);
+			_panelMovie.setTime(getItemPanelTime(item));
+			_panelMovie.redrawMovieWorld();
+		}
+
+		_panelMovie.setTime(0);
+		uint32 numSlots = _itemsPerRow * _numberOfRows;
+
+		for (uint32 i = numItems; i < numSlots; i++) {
+			getItemXY(i, x, y);
+			_panelMovie.moveElementTo(x, y);
+			_panelMovie.redrawMovieWorld();
+		}
+
+		_lastReferenceCount = _inventory->getReferenceCount();
+	}
+
+	show(); // *** Do we really need this?
+	if (_currentItem)
+		highlightCurrentItem();
+
+	_active = true;
+}
+
+void InventoryPicture::deactivateInventoryPicture() {
+	if (!_active)
+		return;
+
+	_active = false;
+	allowInput(false);
+	_panelMovie.hide();
+	hide();
+
+	if (_inventory->getNumItems() != 0)
+		if (!_currentItem->isActive())
+			_currentItem->activate();
+}
+
+void InventoryPicture::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_active) {
+		if (input.upButtonDown()) {
+			if (_currentItemIndex - _itemsPerRow >= 0)
+				setCurrentItemIndex(_currentItemIndex - _itemsPerRow);
+		} else if (input.downButtonDown()) {
+			if (_currentItemIndex + _itemsPerRow < _inventory->getNumItems())
+				setCurrentItemIndex(_currentItemIndex + _itemsPerRow);
+		} else if (input.leftButtonDown()) {
+			if ((_currentItemIndex % _itemsPerRow) != 0)
+				setCurrentItemIndex(_currentItemIndex - 1);
+		} else if (input.rightButtonDown()) {
+			if (((_currentItemIndex + 1) % _itemsPerRow) != 0 && _currentItemIndex + 1 < _inventory->getNumItems())
+				setCurrentItemIndex(_currentItemIndex + 1);
+		}
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void InventoryPicture::highlightCurrentItem() {
+	tCoordType x, y;
+	getItemXY(_currentItemIndex, x, y);
+	_highlightBounds.moveTo(x, y);
+}
+
+InventoryItemsPicture::InventoryItemsPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+		InventoryPicture(id, nextHandler, inventory) {
+	_pictName = "Images/Items/Inventory/Inventory Panel";
+	_movieName = "Images/Items/Inventory/Inventory Panel Movie";
+	_highlightName = "Images/Items/Inventory/Inventory Hilite";
+
+	_itemsPerRow = 3;
+	_numberOfRows = 3;
+	_itemWidth = 88;
+	_itemHeight = 64;
+	_itemX = 8;
+	_itemY = 26;
+	_isLooping = true;
+}
+
+void InventoryItemsPicture::loopCurrentItem() {
+	if (_isLooping) {
+		tCoordType x, y;
+		getItemXY(_currentItemIndex, x, y);
+		_panelMovie.moveElementTo(x, y);
+		_highlightBounds.moveTo(x, y);
+
+		TimeValue start, stop;
+		((InventoryItem *)_currentItem)->getPanelTimes(start, stop);
+		_panelMovie.stop();
+		_panelMovie.setFlags(0);
+		_panelMovie.setSegment(start, stop);
+		_panelMovie.setFlags(kLoopTimeBase);
+		_panelMovie.setTime(((InventoryItem *)_currentItem)->getAnimationTime());
+		_panelMovie.start();
+	}
+}
+
+void InventoryItemsPicture::highlightCurrentItem() {
+	InventoryPicture::highlightCurrentItem();
+	loopCurrentItem();
+}
+
+void InventoryItemsPicture::unhighlightCurrentItem() {
+	InventoryPicture::unhighlightCurrentItem();
+	_panelMovie.stop();
+	_panelMovie.setFlags(0);
+	((InventoryItem *)_currentItem)->setAnimationTime(_panelMovie.getTime());
+}
+
+TimeValue InventoryItemsPicture::getItemPanelTime(Item *item) {
+	TimeValue start, stop;
+	((InventoryItem *)item)->getPanelTimes(start, stop);
+	((InventoryItem *)item)->setAnimationTime(start);
+	return start;
+}
+
+void InventoryItemsPicture::deactivateInventoryPicture() {
+	if (_active) {
+		InventoryPicture::deactivateInventoryPicture();
+		_panelMovie.stop();
+		_panelMovie.setFlags(0);
+		_panelMovie.setSegment(0, _panelMovie.getDuration());
+		_isLooping = true;
+	}
+}
+
+void InventoryItemsPicture::playEndMessage(DisplayElement *pushElement) {
+	Movie endMessage(0);
+
+	_shouldDrawHighlight = false;
+	endMessage.shareSurface(this);
+	endMessage.initFromMovieFile("Images/Caldoria/A56 Congrats");
+	endMessage.moveElementTo(kFinalMessageLeft - kInventoryPushLeft, kFinalMessageTop - kInventoryPushTop);
+	endMessage.setTriggeredElement(pushElement);
+	endMessage.start();
+
+	while (endMessage.isRunning()) {
+		((PegasusEngine *)g_engine)->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	endMessage.stop();
+}
+
+BiochipPicture::BiochipPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+		InventoryPicture(id, nextHandler, inventory) {
+	_pictName = "Images/Items/Biochips/Biochip Panel";
+	_movieName = "Images/Items/Biochips/Biochip Panel Movie";
+	_highlightName = "Images/Items/Biochips/BioChip Hilite";
+
+	_itemsPerRow = 4;
+	_numberOfRows = 2;
+	_itemWidth = 46;
+	_itemHeight = 46;
+	_itemX = 4;
+	_itemY = 24;
+}
+
+void BiochipPicture::unhighlightCurrentItem() {
+	InventoryPicture::unhighlightCurrentItem();
+	tCoordType x, y;
+	getItemXY(_currentItemIndex, x, y);
+	_panelMovie.show();
+	_panelMovie.moveElementTo(x, y);
+	_panelMovie.setTime(getItemPanelTime(_currentItem));
+	_panelMovie.redrawMovieWorld();
+}
+
+TimeValue BiochipPicture::getItemPanelTime(Item *item) {
+	return ((BiochipItem *)item)->getPanelTime();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventorypicture.h b/engines/pegasus/items/inventorypicture.h
new file mode 100755
index 0000000..034354d
--- /dev/null
+++ b/engines/pegasus/items/inventorypicture.h
@@ -0,0 +1,125 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORYPICTURE_H
+#define PEGASUS_ITEMS_INVENTORYPICTURE_H
+
+#include "pegasus/input.h"
+#include "pegasus/movie.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+
+class Inventory;
+class Item;
+class Input;
+class Transition;
+
+class InventoryPicture : public InputHandler, public Picture {
+public:
+	InventoryPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	virtual ~InventoryPicture() {}
+	
+	void initInventoryImage(Transition *);
+	void throwAwayInventoryImage();
+	
+	void panelUp();
+	void activateInventoryPicture();
+	void deactivateInventoryPicture();
+	void handleInput(const Input &, const Hotspot *);
+	bool wantsCursor() { return false; }
+	
+	tInventoryResult addInventoryItem(Item *);
+	tInventoryResult removeInventoryItem(Item *);
+	void removeAllItems();
+	Item *getCurrentItem() { return _currentItem; }
+	void setCurrentItemIndex(int32);
+	void setCurrentItemID(tItemID);
+	int32 getCurrentItemIndex() { return _currentItemIndex; }
+	bool itemInInventory(Item *);
+	bool itemInInventory(const tItemID);
+
+protected:
+	void getItemXY(uint32, tCoordType &, tCoordType &);
+	void draw(const Common::Rect &);
+	void drawItemHighlight(const Common::Rect &);
+	virtual void highlightCurrentItem();
+	virtual void unhighlightCurrentItem() {}
+	virtual TimeValue getItemPanelTime(Item *) = 0;
+	
+	Inventory *_inventory;
+	uint32 _lastReferenceCount;
+	Frame _highlightImage;
+	Movie _panelMovie;
+	int32 _currentItemIndex;
+	Item *_currentItem;
+	Common::Rect _highlightBounds;
+	bool _active, _shouldDrawHighlight;
+
+	Common::String _pictName;
+	Common::String _movieName;
+	Common::String _highlightName;
+	uint16 _itemsPerRow;
+	uint16 _numberOfRows;
+	uint16 _itemWidth;
+	uint16 _itemHeight;
+	uint16 _itemX;
+	uint16 _itemY;
+};
+
+class InventoryItemsPicture : public InventoryPicture {
+public:
+	InventoryItemsPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	virtual ~InventoryItemsPicture() {}
+
+	void deactivateInventoryPicture();
+
+	void disableLooping() { _isLooping = false; }
+
+	void playEndMessage(DisplayElement *);
+
+protected:
+	virtual void highlightCurrentItem();
+	virtual void unhighlightCurrentItem();
+	virtual TimeValue getItemPanelTime(Item *);
+	void loopCurrentItem();
+
+	InputHandler *_previousHandler;
+	bool _isLooping;
+};
+
+class BiochipPicture : public InventoryPicture {
+public:
+	BiochipPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	virtual ~BiochipPicture() {}
+	
+protected:
+	virtual void unhighlightCurrentItem();
+	virtual TimeValue getItemPanelTime(Item *);
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 485b107..cc0b3ec 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS = \
 	transition.o \
 	util.o \
 	items/inventory.o \
+	items/inventorypicture.o \
 	items/item.o \
 	items/itemlist.o \
 	items/biochips/biochipitem.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index b71295a..f125136 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -115,8 +115,7 @@ Common::Error PegasusEngine::run() {
 		checkCallBacks();
 		checkNotifications();
 		InputHandler::pollForInput();
-		giveIdleTime();
-		_gfx->updateDisplay();
+		refreshDisplay();
 	}
 
 	return Common::kNoError;
@@ -755,8 +754,7 @@ void PegasusEngine::doInterfaceOverview() {
 		overviewText.setTime(time * 3 + 2, 15);
 		overviewText.redrawMovieWorld();
 
-		giveIdleTime();
-		_gfx->updateDisplay();
+		refreshDisplay();
 	}
 
 	if (shouldQuit())
@@ -806,4 +804,9 @@ void PegasusEngine::showTempScreen(const Common::String &fileName) {
 	}
 }
 
+void PegasusEngine::refreshDisplay() {
+	giveIdleTime();
+	_gfx->updateDisplay();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 7ad978d..73a95c9 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -88,6 +88,7 @@ public:
 	void swapLoadAllowed(bool allow) { _loadAllowed = allow; }
 	void delayShell(TimeValue time, TimeScale scale);
 	void resetIntroTimer();
+	void refreshDisplay();
 
 protected:
 	Common::Error run();


Commit: c8752bb1d3fadc760c723c3f3b9db7a7f2ab225d
    https://github.com/scummvm/scummvm/commit/c8752bb1d3fadc760c723c3f3b9db7a7f2ab225d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T12:26:09-07:00

Commit Message:
PEGASUS: Implement Item::getDragSprite()

Changed paths:
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h



diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index 126bbfe..e4f1b71 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -27,7 +27,9 @@
 #include "common/stream.h"
 
 #include "pegasus/constants.h"
+#include "pegasus/elements.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/surface.h"
 #include "pegasus/items/item.h"
 #include "pegasus/items/itemlist.h"
 
@@ -266,4 +268,22 @@ ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
 	return info;
 }
 
+Sprite *Item::getDragSprite(const tDisplayElementID id) const {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	Sprite *result = new Sprite(id);
+	SpriteFrame *frame = new SpriteFrame();
+
+	frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteNormalID);
+	result->addFrame(frame, 0, 0);
+
+	if (_itemInfo.dragSpriteNormalID != _itemInfo.dragSpriteUsedID) {
+		frame = new SpriteFrame();
+		frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteUsedID);
+	}
+
+	result->addFrame(frame, 0, 0);
+	result->setCurrentFrameIndex(0);
+	return result;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index f623df5..1373913 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -274,6 +274,8 @@ enum tItemType {
 	kBiochipItemType
 };
 
+class Sprite;
+
 /*
 
 	Item is an object which can be picked up and carried around.
@@ -313,8 +315,7 @@ public:
 	void getInfoRightTimes(TimeValue&, TimeValue&) const;
 	TimeValue getSharedAreaTime() const;
 
-	//TODO
-	//MMSprite*						GetDragSprite(const tDisplayElementID) const;
+	Sprite *getDragSprite(const tDisplayElementID) const;
 	
 	/*
 		select		--	called when this item becomes current. Also called when the inventory


Commit: dc463816af1073a8dae80bec1b56ea39d317819d
    https://github.com/scummvm/scummvm/commit/dc463816af1073a8dae80bec1b56ea39d317819d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T12:28:01-07:00

Commit Message:
PEGASUS: Remove unused EnergyBar class

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 6f94fe5..99f3fbd 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -193,59 +193,6 @@ void DropHighlight::draw(const Common::Rect &) {
 	}
 }
 
-EnergyBar::EnergyBar(const tDisplayElementID id) : DisplayElement(id) {
-	_maxEnergy = 0;
-	_energyLevel = 0;
-	_barColor = 0;
-}
-
-void EnergyBar::checkRedraw() {	
-	if (_elementIsVisible) {
-		Common::Rect r;
-		calcLevelRect(r);
-		if (r != _levelRect)
-			triggerRedraw();
-	}
-}
-
-void EnergyBar::setEnergyLevel(const uint32 newLevel) {
-	if (_energyLevel != newLevel) {
-		_energyLevel = newLevel;
-		checkRedraw();
-	}
-}
-
-void EnergyBar::setMaxEnergy(const uint32 newMax) {
-	if (_maxEnergy != newMax) {
-		if (_energyLevel > newMax)
-			_energyLevel = newMax;
-		_maxEnergy = newMax;
-		checkRedraw();
-	}
-}
-
-void EnergyBar::setBounds(const Common::Rect &r) {
-	DisplayElement::setBounds(r);
-	checkRedraw();
-}
-
-void EnergyBar::draw(const Common::Rect &r) {
-	Common::Rect levelRect;
-	calcLevelRect(levelRect);
-
-	if (r.intersects(levelRect))
-		((PegasusEngine *)g_engine)->_gfx->getWorkArea()->fillRect(levelRect, _barColor);
-}
-
-void EnergyBar::calcLevelRect(Common::Rect &r) const {
-	if (_maxEnergy > 0) {
-		r = _bounds;
-		r.left = r.right - _bounds.width() * _energyLevel / _maxEnergy;
-	} else {
-		r = Common::Rect(0, 0, 0, 0);
-	}
-}
-
 IdlerAnimation::IdlerAnimation(const tDisplayElementID id) : Animation(id) {
 	_lastTime = 0xffffffff;
 }
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 97f982a..46b3bc5 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -111,34 +111,6 @@ protected:
 	uint16 _cornerDiameter;
 };
 
-class EnergyBar : public DisplayElement {
-public:
-	EnergyBar(const tDisplayElementID);
-	virtual ~EnergyBar() {}
-	
-	void getBarColor(uint32 &color) const { color = _barColor; }
-	void setBarColor(const uint32 &color) { _barColor = color; }
-	
-	long getEnergyLevel() const { return _energyLevel; }
-	void setEnergyLevel(const uint32);
-	
-	long getMaxEnergy() const { return _maxEnergy; }
-	void setMaxEnergy(const uint32);
-	
-	virtual void setBounds(const Common::Rect&);
-	
-	virtual void draw(const Common::Rect&);
-
-protected:
-	void calcLevelRect(Common::Rect&) const;
-	void checkRedraw();
-	
-	uint32 _energyLevel;
-	uint32 _maxEnergy;
-	Common::Rect _levelRect;
-	uint32 _barColor;
-};
-
 class Animation : public DisplayElement, public DynamicElement {
 public:
 	Animation(const tDisplayElementID id) : DisplayElement(id) {}


Commit: ea36ec452e9274985b550dc14d1fc33b0438ffba
    https://github.com/scummvm/scummvm/commit/ea36ec452e9274985b550dc14d1fc33b0438ffba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T12:37:12-07:00

Commit Message:
PEGASUS: Add support for the console back

Changed paths:
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 76f5afa..08bc22b 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -43,6 +43,7 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 	// TODO: Save/Load keys
 
 	tInputBits currentBits = 0;
+	bool consoleRequested = false;
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -94,6 +95,10 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 			case Common::KEYCODE_DELETE:
 				currentBits |= (kRawButtonDown << kRightFireButtonShift);
 				break;
+			case Common::KEYCODE_d:
+				if (event.kbd.flags & Common::KBD_CTRL) // Console!
+					consoleRequested = true;
+				break;
 			default:
 				break;
 			}
@@ -119,6 +124,9 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 
 	// Update the last bits
 	_lastRawBits = currentBits;
+
+	// Set the console to be requested or not
+	input.setConsoleRequested(consoleRequested);
 }
 
 //	Wait until the input device stops returning input allowed by filter...
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 0672434..d70a573 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -353,19 +353,24 @@ public:
 	void getInputLocation(Common::Point &where) const { where = _inputLocation; }
 	
 	bool anyInputBitSet(const tInputBits bits) const { return (_inputState & bits) != 0; }
-	
+
+	bool isConsoleRequested() const { return _consoleRequested; }
+
 	void clearInput() {
 		_inputState = kAllUpBits;
 		_inputLocation.x = 0;
 		_inputLocation.y = 0;
+		_consoleRequested = false;
 	}
 
 protected:
 	void setInputBits(const tInputBits state) { _inputState = state; }
 	void setInputLocation(const Common::Point &where) { _inputLocation = where; }
+	void setConsoleRequested(bool consoleRequested) { _consoleRequested = consoleRequested; }
 	
 	tInputBits _inputState;
 	Common::Point _inputLocation;
+	bool _consoleRequested;
 };
 
 class InputHandler {
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index f125136..5870854 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -604,6 +604,12 @@ void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	if (!checkGameMenu())
 		; // TODO: Other input
 
+	// Handle the console here
+	if (input.isConsoleRequested()) {
+		_console->attach();
+		_console->onFrame();
+	}
+
 	// TODO: Quit request
 	// TODO: Save request
 	// TODO: Load request


Commit: cde643cc17ed60840f51def25e249ff75cf456f2
    https://github.com/scummvm/scummvm/commit/cde643cc17ed60840f51def25e249ff75cf456f2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T12:41:05-07:00

Commit Message:
PEGASUS: Allow for skipping the intro

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5870854..368dc29 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -200,24 +200,29 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 }
 
 void PegasusEngine::runIntro() {
+	bool skipped = false;
+
 	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 	if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
-		while (!shouldQuit() && !video->endOfVideo()) {
+		while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 			if (video->needsUpdate()) {
 				const Graphics::Surface *frame = video->decodeNextFrame();
 				_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
 				_system->updateScreen();
 			}
 
-			Common::Event event;
-			while (_eventMan->pollEvent(event))
-				;
+			Input input;
+			InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+			if (input.anyInput())
+				skipped = true;
+
+			_system->delayMillis(10);
 		}
 	}
 
 	delete video;
 
-	if (shouldQuit())
+	if (shouldQuit() || skipped)
 		return;
 
 	video = new Video::QuickTimeDecoder();
@@ -261,9 +266,12 @@ void PegasusEngine::runIntro() {
 			scaledFrame.free();
 		}
 
-		Common::Event event;
-		while (_eventMan->pollEvent(event))
-			;
+		Input input;
+		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+		if (input.anyInput())
+			break;
+
+		_system->delayMillis(10);
 	}
 
 	delete video;


Commit: 84731ef872ee3e704e0ed6d6ca2e88509c859d7b
    https://github.com/scummvm/scummvm/commit/84731ef872ee3e704e0ed6d6ca2e88509c859d7b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-22T17:17:09-07:00

Commit Message:
PEGASUS: Add the EnergyMonitor class

Changed paths:
  A engines/pegasus/energymonitor.cpp
  A engines/pegasus/energymonitor.h
    engines/pegasus/constants.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 8d2a95b..519e97e 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -556,6 +556,133 @@ const tGameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
 const TimeValue kMenuButtonHiliteTime = 20;
 const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
 
+//	PICT resources:
+
+//	Warning light PICTs:
+
+const tResIDType kLightOffID = 128;
+const tResIDType kLightYellowID = 129;
+const tResIDType kLightOrangeID = 130;
+const tResIDType kLightRedID = 131;
+
+//	Date PICTs:
+
+const tResIDType kDatePrehistoricID = 138;
+const tResIDType kDate2112ID = 139;
+const tResIDType kDate2185ID = 140;
+const tResIDType kDate2310ID = 141;
+const tResIDType kDate2318ID = 142;
+
+/////////////////////////////////////////////
+//
+//	Display Order
+
+const tDisplayOrder kCroppedMovieLayer = 11000;
+
+const tDisplayOrder kMonitorLayer = 12000;
+
+const tDisplayOrder kDragSpriteLayer = 15000;
+const tDisplayOrder kDragSpriteOrder = kDragSpriteLayer;
+
+const tDisplayOrder kInterfaceLayer = 20000;
+const tDisplayOrder kBackground1Order = kInterfaceLayer;
+const tDisplayOrder kBackground2Order = kBackground1Order + 1;
+const tDisplayOrder kBackground3Order = kBackground2Order + 1;
+const tDisplayOrder kBackground4Order = kBackground3Order + 1;
+const tDisplayOrder kDateOrder = kBackground4Order + 1;
+const tDisplayOrder kCompassOrder = kDateOrder + 1;
+const tDisplayOrder kEnergyBarOrder = kCompassOrder + 1;
+const tDisplayOrder kEnergyLightOrder = kEnergyBarOrder + 1;
+
+const tDisplayOrder kAILayer = 22000;
+const tDisplayOrder kAILeftAreaOrder = kAILayer;
+const tDisplayOrder kAIMiddleAreaOrder = kAILeftAreaOrder + 1;
+const tDisplayOrder kAIRightAreaOrder = kAIMiddleAreaOrder + 1;
+const tDisplayOrder kAIMovieOrder = kAIRightAreaOrder + 1;
+
+const tDisplayOrder kHilitesLayer = 23000;
+const tDisplayOrder kInventoryHiliteOrder = kHilitesLayer;
+const tDisplayOrder kBiochipHiliteOrder = kInventoryHiliteOrder + 1;
+
+const tDisplayOrder kPanelsLayer = 25000;
+const tDisplayOrder kInventoryPushOrder = kPanelsLayer;
+const tDisplayOrder kInventoryLidOrder = kInventoryPushOrder + 1;
+const tDisplayOrder kBiochipPushOrder = kInventoryLidOrder + 1;
+const tDisplayOrder kBiochipLidOrder = kBiochipPushOrder + 1;
+const tDisplayOrder kFinalMessageOrder = kBiochipLidOrder + 1;
+
+const tDisplayOrder kInfoLayer = 26000;
+const tDisplayOrder kInfoBackgroundOrder = kInfoLayer;
+const tDisplayOrder kInfoSpinOrder = kInfoBackgroundOrder + 1;
+
+const tDisplayOrder kScreenDimmerOrder = 30000;
+
+const tDisplayOrder kPauseScreenLayer = 31000;
+const tDisplayOrder kPauseMenuOrder = kPauseScreenLayer;
+const tDisplayOrder kSaveGameOrder = kPauseMenuOrder + 1;
+const tDisplayOrder kContinueOrder = kSaveGameOrder + 1;
+const tDisplayOrder kRestoreOrder = kContinueOrder + 1;
+const tDisplayOrder kSoundFXOrder = kRestoreOrder + 1;
+const tDisplayOrder kAmbienceOrder = kSoundFXOrder + 1;
+const tDisplayOrder kWalkthruOrder = kAmbienceOrder + 1;
+const tDisplayOrder kQuitToMainMenuOrder = kWalkthruOrder + 1;
+const tDisplayOrder kPauseLargeHiliteOrder = kQuitToMainMenuOrder + 1;
+const tDisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
+
+/////////////////////////////////////////////
+//
+//	Death reasons.
+enum {
+	// Caldoria
+	kDeathUncreatedInCaldoria = 1,
+	kDeathCardBomb,
+	kDeathShotBySinclair,
+	kDeathSinclairShotDelegate,
+	kDeathNuclearExplosion,
+
+	// TSA
+	kDeathUncreatedInTSA,
+	kDeathShotByTSARobots,
+
+	// Prehistoric
+	kDeathFallOffCliff,
+	kDeathEatenByDinosaur,
+	kDeathStranded,
+
+	// Norad
+	kDeathGassedInNorad,
+	kDeathArrestedInNorad,
+	kDeathWokeUpNorad,
+	kDeathSubDestroyed, // Unused
+	kDeathRobotThroughNoradDoor,
+	kDeathRobotSubControlRoom,
+
+	// Mars
+	kDeathWrongShuttleLock,
+	kDeathArrestedInMars,
+	kDeathRunOverByPod,
+	kDeathDidntGetOutOfWay,
+	kDeathReactorBurn,
+	kDeathDidntFindMarsBomb,
+	kDeathDidntDisarmMarsBomb,
+	kDeathNoMaskInMaze,
+	kDeathNoAirInMaze,
+	kDeathGroundByMazebot,
+	kDeathMissedOreBucket,
+	kDeathDidntLeaveBucket,
+	kDeathRanIntoCanyonWall, // Unused
+	kDeathRanIntoSpaceJunk,
+
+	// WSC
+	kDeathDidntStopPoison,
+	kDeathArrestedInWSC,
+	kDeathHitByPlasma,
+	kDeathShotOnCatwalk,
+
+	// Winning
+	kPlayerWonGame
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
new file mode 100755
index 0000000..fc22a32
--- /dev/null
+++ b/engines/pegasus/energymonitor.cpp
@@ -0,0 +1,291 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+
+Blinker::Blinker() {
+	_sprite = 0;
+	_frame1 = -1;
+	_frame2 = -1;
+	_blinkDuration = 0;
+}
+
+void Blinker::startBlinking(Sprite *sprite, int32 frame1, int32 frame2, uint32 numBlinks, TimeValue blinkDuration, TimeScale blinkScale) {
+	stopBlinking();
+	_sprite = sprite;
+	_frame1 = frame1;
+	_frame2 = frame2;
+	_blinkDuration = blinkDuration;
+	setScale(blinkScale);
+	setSegment(0, blinkDuration * numBlinks * 2, blinkScale);
+	setTime(0);
+	start();
+}
+
+void Blinker::stopBlinking() {
+	if (_sprite) {
+		_sprite->setCurrentFrameIndex(_frame2);
+		_sprite = 0;
+		stop();
+	}
+}
+
+void Blinker::timeChanged(const TimeValue time) {
+	if (_sprite && _blinkDuration != 0) {
+		if (((time / _blinkDuration) & 1) != 0 || time == getDuration()) {
+			_sprite->setCurrentFrameIndex(_frame2);
+			if (!isRunning())
+				stopBlinking();
+		} else {
+			_sprite->setCurrentFrameIndex(_frame1);
+		}
+	}
+}
+
+static const tNotificationFlags kEnergyExpiredFlag = 1;
+
+EnergyMonitor *g_energyMonitor = 0;
+
+EnergyMonitor::EnergyMonitor() : IdlerAnimation(kEnergyBarID), _energyLight(kWarningLightID) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	_stage = kStageNoStage;
+
+	_calibrating = false;
+	_dontFlash = false;
+
+	setBounds(338, 48, 434, 54);
+
+	setDisplayOrder(kEnergyBarOrder);
+	startDisplaying();
+
+	SpriteFrame *frame = new SpriteFrame();
+	frame->initFromPICTResource(vm->_resFork, kLightOffID);
+	_energyLight.addFrame(frame, 0, 0);
+
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(vm->_resFork, kLightYellowID);
+	_energyLight.addFrame(frame, 0, 0);
+
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(vm->_resFork, kLightOrangeID);
+	_energyLight.addFrame(frame, 0, 0);
+
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(vm->_resFork, kLightRedID);
+	_energyLight.addFrame(frame, 0, 0);
+
+	_energyLight.setBounds(540, 35, 600, 59);
+	_energyLight.setDisplayOrder(kEnergyLightOrder);
+	_energyLight.startDisplaying();
+
+	setScale(1);
+	setSegment(0, kMaxJMPEnergy);
+
+	setEnergyValue(kCasualEnergy);
+
+	g_energyMonitor = this;
+}
+
+EnergyMonitor::~EnergyMonitor() {
+	g_energyMonitor = 0;
+}
+
+void EnergyMonitor::setEnergyValue(const uint32 value) {
+	if (isRunning()) {
+		stop();
+		setTime(getStop() - value);
+		start();
+	} else {
+		setTime(getStop() - value);
+	}
+}
+
+void EnergyMonitor::startEnergyDraining() {
+	if (!isRunning()) {
+		_energyLight.show();
+		start();
+		show();
+	}
+}
+
+void EnergyMonitor::setEnergyDrainRate(Common::Rational rate) {
+	setRate(rate);
+}
+
+Common::Rational EnergyMonitor::getEnergyDrainRate() {
+	return getRate();
+}
+
+void EnergyMonitor::stopEnergyDraining() {
+	if (isRunning()) {
+		stop();
+		_energyLight.hide();
+		hide();
+	}
+}
+
+void EnergyMonitor::drainEnergy(const int32 delta) {
+	setTime(getTime() + delta);
+}
+
+int32 EnergyMonitor::getCurrentEnergy() {
+	return kMaxJMPEnergy - getTime();
+}
+
+void EnergyMonitor::timeChanged(const TimeValue currentTime) {
+	if (currentTime == getStop()) {
+		// TODO: Die :P
+		if (((PegasusEngine *)g_engine)->getEnergyDeathReason() != -1)
+			error("You're dead");
+	} else {
+		uint32 currentEnergy = kMaxJMPEnergy - currentTime;
+
+		tEnergyStage newStage;
+		if (currentEnergy > kWorriedEnergy)
+			newStage = kStageCasual;
+		else if (currentEnergy > kNervousEnergy)
+			newStage = kStageWorried;
+		else if (currentEnergy > kPanicStrickenEnergy)
+			newStage = kStageNervous;
+		else
+			newStage = kStagePanicStricken;
+
+		if (_stage != newStage) {
+			uint32 newFrame;
+
+			switch (newStage) {
+			case kStageCasual:
+				_barColor = g_system->getScreenFormat().RGBToColor(0x48, 0xB0, 0xD8);
+				newFrame = kFrameLightOff;
+				break;
+			case kStageWorried:
+				_barColor = g_system->getScreenFormat().RGBToColor(0xD8, 0xC0, 0x30);
+				newFrame = kFrameLightYellow;
+				break;
+			case kStageNervous:
+				_barColor = g_system->getScreenFormat().RGBToColor(0xD8, 0x78, 0x38);
+				newFrame = kFrameLightOrange;
+				break;
+			case kStagePanicStricken:
+				_barColor = g_system->getScreenFormat().RGBToColor(0xD8, 0x40, 0x38);
+				newFrame = kFrameLightRed;
+				break;
+			default:
+				error("no stage in energy monitor?");
+				break;
+			}
+
+			_stage = newStage;
+			uint32 oldFrame = _energyLight.getCurrentFrameIndex();
+
+			if (!_calibrating) {
+				if (oldFrame > newFrame || oldFrame == 0xffffffff || _dontFlash) {
+					_energyLight.setCurrentFrameIndex(newFrame);
+					_dontFlash = false;
+				} else {
+					_lightBlinker.startBlinking(&_energyLight, oldFrame, newFrame, 4, 1, 3);
+					triggerRedraw();
+				}
+			}
+		}
+
+		Common::Rect r;
+		calcLevelRect(r);
+		if (r != _levelRect) {
+			_levelRect = r;
+			triggerRedraw();
+		}
+	}
+}
+
+void EnergyMonitor::calcLevelRect(Common::Rect &r) {
+	if (getStop() == 0) {
+		r = Common::Rect();
+	} else {
+		getBounds(r);
+		r.left = r.right - r.width() * (kMaxJMPEnergy - getTime()) / getStop();
+	}
+}
+
+void EnergyMonitor::draw(const Common::Rect &r) {
+	Common::Rect r2 = r.findIntersectingRect(_levelRect);
+
+	if (!r2.isEmpty()) {
+		Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+		screen->fillRect(r2, _barColor);
+	}
+}
+
+void EnergyMonitor::calibrateEnergyBar() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	
+	_calibrating = true;
+
+	// TODO: set death reason to -1
+
+	uint32 numFrames = _energyLight.getNumFrames();
+	for (uint32 i = 1; i < numFrames; i++) {
+		_energyLight.setCurrentFrameIndex(i);
+		_energyLight.show();
+		vm->delayShell(1, 3);
+		_energyLight.hide();
+		vm->delayShell(1, 3);
+	}
+
+	_energyLight.setCurrentFrameIndex(0);
+	_energyLight.hide();
+	show();
+	setEnergyValue(0);
+	setEnergyDrainRate(-kMaxJMPEnergy / 2);
+
+	//	Make sure warning light is hidden...
+	_energyLight.hide();
+	while (getCurrentEnergy() != (int32)kMaxJMPEnergy)
+		vm->refreshDisplay();
+
+	vm->refreshDisplay();
+	setEnergyDrainRate(0);
+	hide();
+
+	_calibrating = false;
+}
+
+void EnergyMonitor::restoreLastEnergyValue() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	_dontFlash = true;
+	setEnergyValue(vm->getSavedEnergyValue());
+	vm->resetEnergyDeathReason();
+}
+
+void EnergyMonitor::saveCurrentEnergyValue() {
+	((PegasusEngine *)g_engine)->setLastEnergyValue(getCurrentEnergy());
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
new file mode 100755
index 0000000..cb5d449
--- /dev/null
+++ b/engines/pegasus/energymonitor.h
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ENERGYMONITOR_H
+#define PEGASUS_ENERGYMONITOR_H
+
+#include "pegasus/elements.h"
+
+namespace Pegasus {
+
+class Sprite;
+
+class Blinker : private IdlerTimeBase {
+public:
+	Blinker();
+	virtual ~Blinker() {}
+
+	void startBlinking(Sprite *sprite, int32 frame1, int32 frame2, uint32 numBlinks, TimeValue blinkDuration, TimeScale blinkScale);
+	void stopBlinking();
+
+protected:
+	virtual void timeChanged(const TimeValue);
+
+	Sprite *_sprite;
+	int32 _frame1;
+	int32 _frame2;
+	TimeValue _blinkDuration;
+};
+
+//	Energy monitor constants.
+
+//	These are in seconds.
+//	Max is two hours
+static const uint32 kMaxJMPEnergy = 7200;
+
+static const uint32 kCasualEnergy = kMaxJMPEnergy * 100 / 100;      // 100%
+static const uint32 kWorriedEnergy = kMaxJMPEnergy * 50 / 100;      // 50%
+static const uint32 kNervousEnergy = kMaxJMPEnergy * 25 / 100;      // 25%
+static const uint32 kPanicStrickenEnergy = kMaxJMPEnergy * 5 / 100; // 5%
+
+static const uint32 kFullEnergy = kCasualEnergy;
+
+static const uint32 kFrameLightOff = 0;
+static const uint32 kFrameLightYellow = 1;
+static const uint32 kFrameLightOrange = 2;
+static const uint32 kFrameLightRed = 3;
+
+static const int kEnergyDrainNormal = 1;
+static const int kMarsReactorEnergyDrainNoShield = 6;
+static const int kMarsReactorEnergyDrainWithShield = 3;
+static const int kWSCPoisonEnergyDrainWithDart = 20;
+static const int kWSCPoisonEnergyDrainNoDart = 10;
+
+class EnergyMonitor : private IdlerAnimation {
+public:
+	EnergyMonitor();
+	virtual ~EnergyMonitor();
+
+	void setEnergyValue(const uint32);
+	void startEnergyDraining();
+	void setEnergyDrainRate(Common::Rational);
+	Common::Rational getEnergyDrainRate();
+	void stopEnergyDraining();
+	void drainEnergy(const int32);
+	int32 getCurrentEnergy();
+
+	void restoreLastEnergyValue();
+	void saveCurrentEnergyValue();
+
+	void calibrateEnergyBar();
+
+protected:
+	void timeChanged(const TimeValue);
+	void calcLevelRect(Common::Rect &);
+	void draw(const Common::Rect &);
+
+	uint32 _barColor;
+	Common::Rect _levelRect;
+	tEnergyStage _stage;
+	Sprite _energyLight;
+	Blinker _lightBlinker;
+	bool _calibrating, _dontFlash;
+};
+
+extern EnergyMonitor *g_energyMonitor;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index cc0b3ec..2909a22 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS = \
 	cursor.o \
 	detection.o \
 	elements.o \
+	energymonitor.o \
 	fader.o \
 	gamestate.o \
 	graphics.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 368dc29..816d01c 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -51,6 +51,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_continuePoint = 0;
 	_saveAllowed = _loadAllowed = true;
 	_gameMenu = 0;
+	_deathReason = kDeathStranded;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -359,11 +360,11 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	// Game State
 	GameState.readGameState(stream);
 
-	// TODO: Energy
-	stream->readUint32BE();
+	// Energy
+	setLastEnergyValue(stream->readUint32BE() >> 16);
 
-	// TODO: Death reason
-	stream->readByte();
+	// Death reason
+	setEnergyDeathReason(stream->readByte());
 
 	// TODO: This is as far as we can go right now
 	return true;
@@ -403,11 +404,11 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	// Game State
 	GameState.writeGameState(stream);
 
-	// TODO: Energy
-	stream->writeUint32BE(0);
+	// Energy
+	stream->writeUint32BE(getSavedEnergyValue() << 16);
 
-	// TODO: Death reason
-	stream->writeByte(0);
+	// Death reason
+	stream->writeByte(getEnergyDeathReason());
 
 	// Items
 	g_allItems.writeToStream(stream);
@@ -823,4 +824,9 @@ void PegasusEngine::refreshDisplay() {
 	_gfx->updateDisplay();
 }
 
+void PegasusEngine::resetEnergyDeathReason() {
+	// TODO!
+	_deathReason = kDeathStranded;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 73a95c9..2990811 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -90,6 +90,15 @@ public:
 	void resetIntroTimer();
 	void refreshDisplay();
 
+	// Energy
+	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
+	int32 getSavedEnergyValue() { return _savedEnergyValue; }
+
+	// Death
+	void setEnergyDeathReason(const tDeathReason reason) { _deathReason = reason; } 
+	tDeathReason getEnergyDeathReason() { return _deathReason; }
+	void resetEnergyDeathReason();
+
 protected:
 	Common::Error run();
 
@@ -140,6 +149,12 @@ private:
 	GameMenu *_gameMenu;
 	void doGameMenuCommand(const tGameMenuCommand);
 	void doInterfaceOverview();
+
+	// Energy
+	int32 _savedEnergyValue;
+
+	// Death
+	tDeathReason _deathReason;
 };
 
 } // End of namespace Pegasus


Commit: 97af18a5a3a69392d0b71d88e43dd0b801a1a98d
    https://github.com/scummvm/scummvm/commit/97af18a5a3a69392d0b71d88e43dd0b801a1a98d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-23T10:44:40-07:00

Commit Message:
PEGASUS: Allow for movies to be offset on a surface

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 2bf852a..e102c70 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -67,6 +67,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 	Common::Rect bounds(0, 0, _video->getWidth(), _video->getHeight());
 	allocateSurface(bounds);
 	setBounds(bounds);
+	_movieBox = bounds;
 
 	setStart(0, getScale());
 	setStop(_video->getDuration() * getScale() / 1000, getScale());
@@ -90,8 +91,12 @@ void Movie::redrawMovieWorld() {
 			getBounds(bounds);
 			g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, bounds.left, bounds.top, frame->w, frame->h);
 		} else {
-			// Just copy to our surface
-			_surface->copyFrom(*frame);
+			// Copy to the surface using _movieBox
+			uint16 width = MIN<int>(MIN<int>(frame->w, _movieBox.width()), _surface->w - _movieBox.left);
+			uint16 height = MIN<int>(MIN<int>(frame->h, _movieBox.height()), _surface->h - _movieBox.top);
+
+			for (uint16 y = 0; y < height; y++)
+				memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
 		}
 
 		triggerRedraw();
@@ -114,6 +119,10 @@ void Movie::draw(const Common::Rect &r) {
 	drawImage(r2, r1);
 }
 
+void Movie::moveMovieBoxTo(const tCoordType h, const tCoordType v) {
+	_movieBox.moveTo(h, v);
+}
+
 void Movie::setVolume(uint16 volume) {
 	// TODO
 }
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 54e57ae..a724914 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -61,6 +61,8 @@ public:
 	virtual void stop();
 	virtual void resume();
 
+	virtual void moveMovieBoxTo(const tCoordType, const tCoordType);
+
 	// *** HACK ALERT
 	Video::SeekableVideoDecoder *getMovie() { return _video; }
 	void setVolume(uint16);
@@ -70,6 +72,7 @@ public:
 protected:
 	Video::SeekableVideoDecoder *_video;
 	bool _directDraw;
+	Common::Rect _movieBox;
 };
 
 } // End of namespace Pegasus


Commit: ddcdcb67b55a5813d375f70c50d2c7ff63bc4ba4
    https://github.com/scummvm/scummvm/commit/ddcdcb67b55a5813d375f70c50d2c7ff63bc4ba4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-23T10:56:44-07:00

Commit Message:
PEGASUS: Should use moveMovieBoxTo instead of moveElementTo here

Changed paths:
    engines/pegasus/items/inventorypicture.cpp



diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 5c8010b..33f497e 100755
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -183,7 +183,7 @@ void InventoryPicture::activateInventoryPicture() {
 
 		tCoordType x, y;
 		getItemXY(0, x, y);
-		_panelMovie.moveElementTo(x, y);
+		_panelMovie.moveMovieBoxTo(x, y);
 		_panelMovie.show();
 
 		for (uint32 i = 0; i < numItems; i++) {
@@ -192,7 +192,7 @@ void InventoryPicture::activateInventoryPicture() {
 				item->select();
 
 			getItemXY(i, x, y);
-			_panelMovie.moveElementTo(x, y);
+			_panelMovie.moveMovieBoxTo(x, y);
 			_panelMovie.setTime(getItemPanelTime(item));
 			_panelMovie.redrawMovieWorld();
 		}
@@ -202,7 +202,7 @@ void InventoryPicture::activateInventoryPicture() {
 
 		for (uint32 i = numItems; i < numSlots; i++) {
 			getItemXY(i, x, y);
-			_panelMovie.moveElementTo(x, y);
+			_panelMovie.moveMovieBoxTo(x, y);
 			_panelMovie.redrawMovieWorld();
 		}
 
@@ -324,7 +324,7 @@ void InventoryItemsPicture::playEndMessage(DisplayElement *pushElement) {
 	_shouldDrawHighlight = false;
 	endMessage.shareSurface(this);
 	endMessage.initFromMovieFile("Images/Caldoria/A56 Congrats");
-	endMessage.moveElementTo(kFinalMessageLeft - kInventoryPushLeft, kFinalMessageTop - kInventoryPushTop);
+	endMessage.moveMovieBoxTo(kFinalMessageLeft - kInventoryPushLeft, kFinalMessageTop - kInventoryPushTop);
 	endMessage.setTriggeredElement(pushElement);
 	endMessage.start();
 
@@ -355,7 +355,7 @@ void BiochipPicture::unhighlightCurrentItem() {
 	tCoordType x, y;
 	getItemXY(_currentItemIndex, x, y);
 	_panelMovie.show();
-	_panelMovie.moveElementTo(x, y);
+	_panelMovie.moveMovieBoxTo(x, y);
 	_panelMovie.setTime(getItemPanelTime(_currentItem));
 	_panelMovie.redrawMovieWorld();
 }


Commit: e5a2dec9c803f75f7aa0f695235e0c08a6d5e7eb
    https://github.com/scummvm/scummvm/commit/e5a2dec9c803f75f7aa0f695235e0c08a6d5e7eb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-23T11:07:18-07:00

Commit Message:
PEGASUS: Disable the alt key for now

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 08bc22b..993af63 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -103,8 +103,13 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 				break;
 			}
 
-			if (event.kbd.flags & Common::KBD_ALT) // Alt, option, same thing!
+#if 0
+			// FIXME: This is disabled for now because it interferes with
+			// the ScummVM alt combinations. It's only used for one easter egg
+			// anyway, so I'll come up with something when I get around to that.
+			if (event.kbd.flags & Common::KBD_ALT)
 				currentBits |= (kRawButtonDown << kMod2ButtonShift);
+#endif
 		}
 	}
 


Commit: 59f7e1deeaa15c87adbe073105ea512d1972cde0
    https://github.com/scummvm/scummvm/commit/59f7e1deeaa15c87adbe073105ea512d1972cde0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T11:10:54-07:00

Commit Message:
PEGASUS: Import AI code and relevant items

Changed paths:
  A engines/pegasus/ai/ai_action.cpp
  A engines/pegasus/ai/ai_action.h
  A engines/pegasus/ai/ai_area.cpp
  A engines/pegasus/ai/ai_area.h
  A engines/pegasus/ai/ai_condition.cpp
  A engines/pegasus/ai/ai_condition.h
  A engines/pegasus/ai/ai_rule.cpp
  A engines/pegasus/ai/ai_rule.h
  A engines/pegasus/items/biochips/aichip.cpp
  A engines/pegasus/items/biochips/aichip.h
  A engines/pegasus/items/biochips/opticalchip.cpp
  A engines/pegasus/items/biochips/opticalchip.h
  A engines/pegasus/items/biochips/pegasuschip.cpp
  A engines/pegasus/items/biochips/pegasuschip.h
  A engines/pegasus/items/inventory/airmask.cpp
  A engines/pegasus/items/inventory/airmask.h
    engines/pegasus/constants.h
    engines/pegasus/gamestate.h
    engines/pegasus/input.h
    engines/pegasus/items/biochips/biochipitem.cpp
    engines/pegasus/items/inventory/inventoryitem.cpp
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h
    engines/pegasus/items/itemlist.cpp
    engines/pegasus/items/itemlist.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/timers.h
    engines/pegasus/util.h



diff --git a/engines/pegasus/ai/ai_action.cpp b/engines/pegasus/ai/ai_action.cpp
new file mode 100755
index 0000000..36367eb
--- /dev/null
+++ b/engines/pegasus/ai/ai_action.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/ai/ai_action.h"
+#include "pegasus/ai/ai_area.h"
+
+namespace Pegasus {
+
+AICompoundAction::~AICompoundAction() {
+	for (AIActionList::iterator it = _compoundActions.begin(); it != _compoundActions.end(); it++)
+		delete *it;
+}
+
+void AICompoundAction::performAIAction(AIRule *rule) {
+	for (AIActionList::iterator it = _compoundActions.begin(); it != _compoundActions.end(); it++)
+		(*it)->performAIAction(rule);
+}
+
+AIPlayMessageAction::AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const tInputBits interruptionFilter) {
+	_movieName = movieName;
+	_keepLastFrame = keepLastFrame;
+	_interruptionFilter = interruptionFilter;
+}
+
+void AIPlayMessageAction::performAIAction(AIRule *) {
+	if (g_AIArea) {
+		g_AIArea->checkMiddleArea();
+		g_AIArea->playAIMovie(kRightAreaSignature, _movieName, _keepLastFrame, _interruptionFilter);
+	}
+}
+
+AIStartTimerAction::AIStartTimerAction(AITimerCondition *timerCondition) {
+	_timerCondition = timerCondition;
+}
+
+void AIStartTimerAction::performAIAction(AIRule *) {
+	_timerCondition->startTimer();
+}
+
+AIActivateRuleAction::AIActivateRuleAction(AIRule *rule) {
+	_rule = rule;
+}
+
+void AIActivateRuleAction::performAIAction(AIRule *) {
+	_rule->activateRule();
+}
+
+AIDeactivateRuleAction::AIDeactivateRuleAction(AIRule *rule) {
+	_rule = rule;
+}
+
+void AIDeactivateRuleAction::performAIAction(AIRule *) {
+	_rule->deactivateRule();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/ai/ai_action.h b/engines/pegasus/ai/ai_action.h
new file mode 100755
index 0000000..09a1d13
--- /dev/null
+++ b/engines/pegasus/ai/ai_action.h
@@ -0,0 +1,136 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_AI_AIACTION_H
+#define PEGASUS_AI_AIACTION_H
+
+#include "common/list.h"
+
+#include "pegasus/input.h"
+#include "pegasus/types.h"
+
+namespace Pegasus {
+
+class AIRule;
+class AITimerCondition;
+
+/////////////////////////////////////////////
+//
+//	AIAction
+
+class AIAction {
+friend class AIRule;
+public:
+	AIAction() { _actionCount = 1; }
+	virtual ~AIAction() {}
+
+	virtual void performAIAction(AIRule *) = 0;
+
+	void setActionCount(const uint32 count) { _actionCount = count; }
+
+protected:
+	uint32 _actionCount;
+};
+
+typedef Common::List<AIAction *> AIActionList;
+
+/////////////////////////////////////////////
+//
+//	AICompoundAction
+
+class AICompoundAction : public AIAction {
+public:
+	AICompoundAction() {}
+	virtual ~AICompoundAction();
+
+	void addAction(AIAction *action) { _compoundActions.push_back(action); }
+
+	virtual void performAIAction(AIRule *);
+
+protected:
+	AIActionList _compoundActions;
+};
+
+/////////////////////////////////////////////
+//
+//	AIPlayMessageAction
+
+class AIPlayMessageAction : public AIAction {
+public:
+	AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const tInputBits = kWarningInterruption);
+
+	virtual void performAIAction(AIRule *);
+
+protected:
+	Common::String _movieName;
+	tInputBits _interruptionFilter;
+	bool _keepLastFrame;
+};
+
+/////////////////////////////////////////////
+//
+//	AIStartTimerAction
+
+class AIStartTimerAction : public AIAction {
+public:
+	AIStartTimerAction(AITimerCondition *);
+
+	virtual void performAIAction(AIRule *);
+
+protected:
+	AITimerCondition *_timerCondition;
+};
+
+/////////////////////////////////////////////
+//
+//	AIActivateRuleAction
+
+class AIActivateRuleAction : public AIAction {
+public:
+	AIActivateRuleAction(AIRule *);
+
+	virtual void performAIAction(AIRule *);
+
+protected:
+	AIRule *_rule;
+};
+
+/////////////////////////////////////////////
+//
+//	AIDeactivateRuleAction
+
+class AIDeactivateRuleAction : public AIAction {
+public:
+	AIDeactivateRuleAction(AIRule *rule);
+
+	virtual void performAIAction(AIRule *);
+
+protected:
+	AIRule *_rule;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
new file mode 100755
index 0000000..0b7e435
--- /dev/null
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -0,0 +1,589 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/cursor.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/aichip.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/items/biochips/pegasuschip.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+AIArea *g_AIArea = 0;
+
+AIArea::AIArea(InputHandler *nextHandler) : InputHandler(nextHandler), _leftAreaMovie(kAILeftAreaID),
+		_middleAreaMovie(kAIMiddleAreaID), _rightAreaMovie(kAIRightAreaID), _AIMovie(kAIMovieID) {
+	g_AIArea = this;
+	_leftAreaOwner = kNoClientSignature;
+	_middleAreaOwner = kNoClientSignature;
+	_rightAreaOwner = kNoClientSignature;
+	_leftInventoryTime = 0xffffffff;
+	_middleInventoryTime = 0xffffffff;
+	_middleBiochipTime = 0xffffffff;
+	_rightBiochipTime = 0xffffffff;
+	_lockCount = 0;
+	startIdling();
+}
+
+AIArea::~AIArea() {	
+	if (_middleAreaOwner == kBiochipSignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+		if (currentBiochip && currentBiochip->isSelected())
+			currentBiochip->giveUpSharedArea();
+	} else if (_middleAreaOwner == kInventorySignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+		if (currentItem && currentItem->isSelected())
+			currentItem->giveUpSharedArea();
+	}
+
+	stopIdling();
+
+	for (AIRuleList::iterator it = _AIRules.begin(); it != _AIRules.end(); it++)
+		delete *it;
+
+	g_AIArea = 0;
+}
+
+//	Save last state of AI rules...
+void AIArea::saveAIState() {
+	// TODO
+}
+	
+void AIArea::restoreAIState() {
+	// TODO
+}
+
+void AIArea::initAIArea() {
+	allocateSurface(Common::Rect(0, 0, 384, 96));
+	
+	_leftAreaMovie.shareSurface(this);
+	_leftAreaMovie.initFromMovieFile("Images/Items/Left Area Movie");
+	_leftAreaMovie.moveElementTo(kAILeftAreaLeft, kAILeftAreaTop);
+	_leftAreaMovie.setDisplayOrder(kAILeftAreaOrder);
+	_leftAreaMovie.startDisplaying();
+	_leftAreaMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
+	
+	_middleAreaMovie.shareSurface(this);
+	_middleAreaMovie.initFromMovieFile("Images/Items/Middle Area Movie");
+	_middleAreaMovie.moveElementTo(kAIMiddleAreaLeft, kAIMiddleAreaTop);
+	_middleAreaMovie.moveMovieBoxTo(kAIMiddleAreaLeft - kAILeftAreaLeft, 0);
+	_middleAreaMovie.setDisplayOrder(kAIMiddleAreaOrder);
+	_middleAreaMovie.startDisplaying();
+	_middleAreaMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
+	
+	_rightAreaMovie.shareSurface(this);
+	_rightAreaMovie.initFromMovieFile("Images/Items/Right Area Movie");
+	_rightAreaMovie.moveElementTo(kAIRightAreaLeft, kAIRightAreaTop);
+	_rightAreaMovie.moveMovieBoxTo(kAIRightAreaLeft - kAILeftAreaLeft, 0);
+	_rightAreaMovie.setDisplayOrder(kAIRightAreaOrder);
+	_rightAreaMovie.startDisplaying();
+	_rightAreaMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
+	
+	_AIMovie.setDisplayOrder(kAIMovieOrder);
+}
+
+void AIArea::setAIVolume(const uint16 volume) {
+	_leftAreaMovie.setVolume(volume);
+	_middleAreaMovie.setVolume(volume);
+	_rightAreaMovie.setVolume(volume);
+}
+
+// There are only so many legal combinations of client/area.
+// Here is the list of supported pairs:
+//      kInventorySignature     kLeftAreaSignature
+//      kInventorySignature     kMiddleAreaSignature
+//      kBiochipSignature       kMiddleAreaSignature
+//      kBiochipSignature       kRightAreaSignature
+//      kAISignature            kLeftAreaSignature
+// Further, the kAISignature never sets a static frame time in the left area,
+// but only plays a sequence.
+
+// If this function is called while a sequence is playing, it will just "remember"
+// the time value, so that when the sequence finishes, the new time is asserted.
+
+void AIArea::setAIAreaToTime(const tLowerClientSignature client, const tLowerAreaSignature area, const TimeValue time) {
+	switch (area) {
+	case kLeftAreaSignature:
+		// Only support kInventorySignature client, since AI never calls SetAIAreaToTime.
+		_leftAreaMovie.setSegment(0, _leftAreaMovie.getDuration());
+
+		if (time == 0xffffffff) {
+			_leftAreaMovie.hide();
+			_leftAreaOwner = kNoClientSignature;
+		} else {
+			setLeftMovieTime(time);
+		}
+		break;
+	case kMiddleAreaSignature:
+		// Only support kInventorySignature and kBiochipSignature clients.
+		_middleAreaMovie.stop();
+		_middleAreaMovie.setFlags(0);
+		_middleAreaMovie.setSegment(0, _middleAreaMovie.getDuration());
+
+		if (time == 0xffffffff) {
+			if (client == kInventorySignature) {
+				if (_middleBiochipTime != 0xffffffff) {
+					setMiddleMovieTime(kBiochipSignature, _middleBiochipTime);
+				} else {
+					_middleAreaMovie.hide();
+					_middleAreaOwner = kNoClientSignature;
+				}
+			} else {	// client == kBiochipSignature
+				if (_middleInventoryTime != 0xffffffff) {
+					setMiddleMovieTime(kInventorySignature, _middleInventoryTime);
+				} else {
+					_middleAreaMovie.hide();
+					_middleAreaOwner = kNoClientSignature;
+				}
+			}
+		} else {
+			setMiddleMovieTime(client, time);
+		}
+		break;
+	case kRightAreaSignature:
+		// Only support kBiochipSignature client.
+		_rightAreaMovie.setSegment(0, _rightAreaMovie.getDuration());
+
+		if (time == 0xffffffff) {
+			_rightAreaMovie.hide();
+			_rightAreaOwner = kNoClientSignature;
+		} else {
+			setRightMovieTime(time);
+		}
+		break;
+	}
+}
+
+//	Plays a sequence on an area. When the sequence ends, the previous image
+//	is restored.
+//	Also, is input disabled or not?
+//	Easy answer: yes.
+
+//	There are only so many legal combinations of client/area.
+//	Here is the list of supported pairs:
+//		kBiochipSignature		kMiddleAreaSignature
+//		kBiochipSignature		kRightAreaSignature
+//		kInventorySignature		kMiddleAreaSignature
+
+void AIArea::playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature area, const TimeValue start, const TimeValue stop) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	lockAIOut();
+
+	switch (area) {
+	case kLeftAreaSignature:
+		break;
+	case kMiddleAreaSignature:
+		if (_middleAreaOwner == kInventorySignature)
+			_middleInventoryTime = _middleAreaMovie.getTime();
+		else if (_middleAreaOwner == kBiochipSignature)
+			_middleBiochipTime = _middleAreaMovie.getTime();
+
+		_middleAreaMovie.stop();
+		_middleAreaMovie.setFlags(0);
+		_middleAreaMovie.setSegment(start, stop);
+		_middleAreaMovie.setTime(start);
+		_middleAreaMovie.show();
+		_middleAreaMovie.start();
+		vm->_cursor->hide();
+
+		while (_middleAreaMovie.isRunning()) {
+			vm->refreshDisplay();
+			g_system->delayMillis(10);
+		}
+
+		_middleAreaMovie.stop();
+		vm->_cursor->hideUntilMoved();
+
+		if (_middleAreaOwner == kInventorySignature)
+			setAIAreaToTime(_middleAreaOwner, kMiddleAreaSignature, _middleInventoryTime);
+		else if (_middleAreaOwner == kBiochipSignature)
+			setAIAreaToTime(_middleAreaOwner, kMiddleAreaSignature, _middleBiochipTime);
+		else
+			setAIAreaToTime(_middleAreaOwner, kMiddleAreaSignature, 0xffffffff);
+		break;
+	case kRightAreaSignature:
+		_rightBiochipTime = _rightAreaMovie.getTime();
+		_rightAreaMovie.setSegment(start, stop);
+		_rightAreaMovie.setTime(start);
+		_rightAreaMovie.show();
+		_rightAreaMovie.start();
+		vm->_cursor->hide();
+
+		while (_rightAreaMovie.isRunning()) {
+			vm->refreshDisplay();
+			g_system->delayMillis(10);
+		}
+
+		_rightAreaMovie.stop();
+		vm->_cursor->hideUntilMoved();
+		setAIAreaToTime(_rightAreaOwner, kRightAreaSignature, _rightBiochipTime);
+		break;
+	}
+
+	unlockAI();
+}
+
+bool AIArea::playAIMovie(const tLowerAreaSignature area, const Common::String &movieName, bool keepLastFrame, const tInputBits interruptFilter) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	
+	lockAIOut();
+
+	InputHandler::getCurrentInputDevice()->waitInput(interruptFilter);
+	if (_AIMovie.isMovieValid())
+		_AIMovie.releaseMovie();
+
+	_AIMovie.shareSurface(this);
+	_AIMovie.initFromMovieFile(movieName);
+
+	if (area == kLeftAreaSignature) {
+		_AIMovie.moveElementTo(kAILeftAreaLeft, kAILeftAreaTop);
+		_leftAreaMovie.hide();
+	} else {
+		_AIMovie.moveElementTo(kAIRightAreaLeft, kAIRightAreaTop);
+		_rightAreaMovie.hide();
+	}
+
+	_AIMovie.setTime(0);
+	_AIMovie.startDisplaying();
+	_AIMovie.show();
+	_AIMovie.redrawMovieWorld();
+	_AIMovie.setVolume(vm->getSoundFXLevel());
+	_AIMovie.start();
+	vm->_cursor->hide();
+
+	bool result = true;
+	bool saveAllowed = vm->swapSaveAllowed(false);
+	bool openAllowed = vm->swapLoadAllowed(false);
+
+	while (_AIMovie.isRunning()) {
+		Input input;
+		InputHandler::getCurrentInputDevice()->getInput(input, interruptFilter);
+
+		if (input.anyInput() || vm->shouldQuit()) {
+			result = false;
+			break;
+		}
+
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	_AIMovie.stop();
+
+	vm->swapSaveAllowed(saveAllowed);
+	vm->swapLoadAllowed(openAllowed);
+
+	// This used to keep the last frame up even if the movie was interrupted.
+	// However, this only occurs in the recalibration, where interruption means skip the
+	// whole thing, so skipping causes the AI to go away even when keepLastFrame is true.
+
+	if (!(result && keepLastFrame)) {
+		_AIMovie.stopDisplaying();
+		_AIMovie.releaseMovie();
+
+		if (area == kLeftAreaSignature) {
+			_leftAreaMovie.setTime(_leftInventoryTime);
+			_leftAreaMovie.show();
+			_leftAreaMovie.redrawMovieWorld();
+		} else {
+			_rightAreaMovie.setTime(_rightBiochipTime);
+			_rightAreaMovie.show();
+			_rightAreaMovie.redrawMovieWorld();
+		}
+	}
+
+	vm->_cursor->hideUntilMoved();
+	unlockAI();
+	return result;
+}
+
+//	Only implemented for kMiddleAreaSignature, kInventorySignature
+void AIArea::loopAIAreaSequence(const tLowerClientSignature owner, const tLowerAreaSignature area, const TimeValue start, const TimeValue stop) {
+	if (area == kMiddleAreaSignature && owner == kInventorySignature && owner == _middleAreaOwner) {
+		_middleAreaMovie.stop();
+		_middleAreaMovie.setFlags(0);
+		_middleAreaMovie.setSegment(start, stop);
+		_middleAreaMovie.setFlags(kLoopTimeBase);
+		_middleAreaMovie.setTime(start);
+		_middleAreaMovie.show();
+		_middleAreaMovie.start();
+	}
+}
+
+// Only called by kInventorySignature.
+void AIArea::setLeftMovieTime(const TimeValue time) {
+	if (!_AIMovie.isSurfaceValid()) {
+		_leftAreaMovie.setTime(time);
+		_leftAreaMovie.show();
+		_leftAreaMovie.redrawMovieWorld();
+	}
+
+	_leftAreaOwner = kInventorySignature;
+	_leftInventoryTime = time;
+}
+
+void AIArea::setMiddleMovieTime(const tLowerClientSignature client, const TimeValue time) {	
+	if (client == kInventorySignature) {
+		_middleInventoryTime = time;
+		if (_middleAreaOwner == kBiochipSignature) {
+			BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+			if (currentBiochip && currentBiochip->isSelected())
+				currentBiochip->giveUpSharedArea();
+		}
+	} else {
+		_middleBiochipTime = time;
+		if (_middleAreaOwner == kInventorySignature) {
+			InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+			if (currentItem && currentItem->isSelected())
+				currentItem->giveUpSharedArea();
+		}
+	}
+
+	_middleAreaMovie.setSegment(0, _middleAreaMovie.getDuration());
+	_middleAreaMovie.stop();
+	_middleAreaMovie.setFlags(0);
+	_middleAreaMovie.setTime(time);
+	_middleAreaMovie.show();
+	_middleAreaMovie.redrawMovieWorld();
+	_middleAreaOwner = client;
+}
+
+//	Only called by kBiochipSignature.
+void AIArea::setRightMovieTime(const TimeValue time) {
+	if (!_AIMovie.isSurfaceValid()) {
+		// Can't do it when the AI movie is up...
+		_rightAreaMovie.setTime(time);
+		_rightAreaMovie.show();
+		_rightAreaMovie.redrawMovieWorld();
+	}
+
+	_rightAreaOwner = kBiochipSignature;
+	_rightBiochipTime = time;
+}
+
+void AIArea::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (JMPPPInput::isToggleAIMiddleInput(input))
+		toggleMiddleAreaOwner();
+	else
+		InputHandler::handleInput(input, cursorSpot);
+}
+
+void AIArea::toggleMiddleAreaOwner() {	
+	if (_middleAreaOwner == kInventorySignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+		if (currentBiochip) {
+			setMiddleMovieTime(kBiochipSignature, currentBiochip->getSharedAreaTime());
+			currentBiochip->takeSharedArea();
+		}
+	} else if (_middleAreaOwner == kBiochipSignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+		if (currentItem) {
+			setMiddleMovieTime(kInventorySignature, currentItem->getSharedAreaTime());
+			currentItem->takeSharedArea();
+		}
+	}
+}
+
+void AIArea::activateHotspots() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	
+	if (_middleAreaOwner == kBiochipSignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+		if (currentBiochip)
+			switch (currentBiochip->getObjectID()) {
+			case kAIBiochip:
+				((AIChip *)currentBiochip)->activateAIHotspots();
+				break;
+			case kPegasusBiochip:
+				if (!vm->isDemo())
+					((PegasusChip *)currentBiochip)->activatePegasusHotspots();
+				break;
+			case kOpticalBiochip:
+				((OpticalChip *)currentBiochip)->activateOpticalHotspots();
+				break;
+			}
+	} else if (_middleAreaOwner == kInventorySignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+		if (currentItem && currentItem->getObjectID() == kAirMask)
+			((AirMask *)currentItem)->activateAirMaskHotspots();
+	}
+
+	InputHandler::activateHotspots();
+}
+
+void AIArea::clickInHotspot(const Input &input, const Hotspot *hotspot) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	bool handled = false;
+
+	if (_middleAreaOwner == kBiochipSignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+
+		if (currentBiochip) {
+			switch (currentBiochip->getObjectID()) {
+			case kAIBiochip:
+				if ((hotspot->getHotspotFlags() & kAIBiochipSpotFlag) != 0) {
+					((AIChip *)currentBiochip)->clickInAIHotspot(hotspot->getObjectID());
+					handled = true;
+				}
+				break;
+			case kPegasusBiochip:
+				if (!vm->isDemo() && ((hotspot->getHotspotFlags() & kPegasusBiochipSpotFlag) != 0)) {
+					((PegasusChip *)currentBiochip)->clickInPegasusHotspot();
+					handled = true;
+				}
+				break;
+			case kOpticalBiochip:
+				if ((hotspot->getHotspotFlags() & kOpticalBiochipSpotFlag) != 0) {
+					((OpticalChip *)currentBiochip)->clickInOpticalHotspot(hotspot->getObjectID());
+					handled = true;
+				}
+				break;
+			}
+		}
+	} else if (_middleAreaOwner == kInventorySignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+
+		if (currentItem) {
+			switch (currentItem->getObjectID()) {
+			case kAirMask:
+				if ((hotspot->getHotspotFlags() & kAirMaskSpotFlag) != 0) {
+					((AirMask *)currentItem)->clickInAirMaskHotspot();
+					handled = true;
+				}
+				break;
+			}
+		}
+	}
+
+	if (!handled)
+		InputHandler::clickInHotspot(input, hotspot);
+}
+
+void AIArea::lockAIOut() {
+	if (_lockCount == 0)
+		stopIdling();
+
+	_lockCount++;
+}
+
+void AIArea::unlockAI() {
+	if (_lockCount > 0) {
+		_lockCount--;
+		if (_lockCount == 0)
+			startIdling();
+	}
+}
+
+void AIArea::forceAIUnlocked() {
+	if (_lockCount > 0) {
+		_lockCount = 1;
+		unlockAI();
+	}
+}
+
+void AIArea::checkRules() {
+	if (_lockCount == 0 && ((PegasusEngine *)g_engine)->playerAlive())
+		for (AIRuleList::iterator it = _AIRules.begin(); it != _AIRules.end(); it++)
+			if ((*it)->fireRule())
+				break;
+}
+
+void AIArea::useIdleTime() {
+	checkRules();
+}
+
+void AIArea::addAIRule(AIRule *rule) {
+	_AIRules.push_back(rule);
+}
+
+void AIArea::removeAllRules() {
+	for (AIRuleList::iterator it = _AIRules.begin(); it != _AIRules.end(); it++)
+		delete *it;
+
+	_AIRules.clear();
+}
+
+void AIArea::checkMiddleArea() {
+	BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+
+	if (currentBiochip) {
+		if (_middleAreaOwner == kBiochipSignature) {
+			switch (currentBiochip->getObjectID()) {
+			case kAIBiochip:
+				((AIChip *)currentBiochip)->setUpAIChip();
+				break;
+			case kPegasusBiochip:
+				((PegasusChip *)currentBiochip)->setUpPegasusChip();
+				break;
+			}
+		} else {
+			switch (currentBiochip->getObjectID()) {
+			case kAIBiochip:
+				((AIChip *)currentBiochip)->setUpAIChipRude();
+				break;
+			case kPegasusBiochip:
+				((PegasusChip *)currentBiochip)->setUpPegasusChipRude();
+				break;
+			}
+		}
+	}
+}
+
+TimeValue AIArea::getBigInfoTime() {
+	if (_middleAreaOwner == kInventorySignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+		return currentItem->getInfoLeftTime();
+	} else if (_middleAreaOwner == kBiochipSignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+		return currentBiochip->getInfoLeftTime();
+	}
+
+	return 0xffffffff;
+}
+
+void AIArea::getSmallInfoSegment(TimeValue &start, TimeValue &stop) {	
+	if (_middleAreaOwner == kInventorySignature) {
+		InventoryItem *currentItem = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+		currentItem->getInfoRightTimes(start, stop);
+	} else if (_middleAreaOwner == kBiochipSignature) {
+		BiochipItem *currentBiochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+		currentBiochip->getInfoRightTimes(start, stop);
+	} else {
+		start = 0xffffffff;
+		stop = 0xffffffff;
+	}
+}
+
+tLowerClientSignature AIArea::getMiddleAreaOwner() {
+	return _middleAreaOwner;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/ai/ai_area.h b/engines/pegasus/ai/ai_area.h
new file mode 100755
index 0000000..0338f2b
--- /dev/null
+++ b/engines/pegasus/ai/ai_area.h
@@ -0,0 +1,164 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_AI_AIAREA_H
+#define PEGASUS_AI_AIAREA_H
+
+#include "pegasus/input.h"
+#include "pegasus/movie.h"
+#include "pegasus/timers.h"
+#include "pegasus/ai/ai_rule.h"
+
+/*
+
+	The AI area is the area at the bottom of the screen. There are three areas within
+	the AI area:
+	1)	the inventory/AI help area
+	2)	the middle area
+	3)	the biochip display area
+	
+	Area 1 is used for displaying the current inventory item. When the player changes the
+	current item, either by selecting a new one in the inventory list or by picking
+	up a new item, area 1 updates to show the new item.
+	
+	If the AI decides to give a message, the AI's head temporarily takes over area 1
+	for the duration of the message, then goes away, returning the area to the current
+	inventory item.
+	
+	Area 2 is used to display the current inventory item's state, the current biochip's
+	state, and any extra information from the AI. The contention for this area is
+	resolved as follows:
+	--	If the AI needs to use the area while giving a message in area 1, it takes over
+		area 2 for the duration of its message.
+*** This is not true.
+	--	If the player selects a new inventory item, the inventory item's state gets
+		displayed immediately.
+	--	If the player selects a new biochip, the biochip's state info gets displayed
+		immediately.
+	--	If any auto drawing is to occur, it seizes the area as soon as the drawing is
+		to occur. For example, the mapping biochip does auto drawing every time the
+		player takes a step. The only exception to this rule is if the AI is presenting
+		a warning. When the AI seizes areas 1 and 2, it preempts all other uses.
+	Some inventory items and biochips can cause arbitrary drawing to occur in this area
+	at arbitrary times. The map biochip is one example which causes drawing when the
+	player takes a step. Another example is the poison gas canister, which flashes in
+	this area to indicate a dangerous compound.
+	
+	Area 3 is used to display the current biochip. When the player changes the current
+	biochip, either by selecting a new one from the biochip list or by picking up a
+	new one, area 3 updates to show the new item. In addition, some biochips can play
+	animation in this area.
+
+*/
+
+namespace Pegasus {
+
+class AIArea : public Surface, public Idler, public InputHandler {
+public:
+	AIArea(InputHandler *);
+	virtual ~AIArea();
+
+	void initAIArea();
+
+	void saveAIState();
+	void restoreAIState();
+	
+	void handleInput(const Input &, const Hotspot *);
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	
+	void setAIVolume(const uint16);
+	
+	// There are only so many legal combinations of client/area.
+	// Here is the list of supported pairs:
+	//      kInventorySignature     kLeftAreaSignature
+	//      kInventorySignature     kMiddleAreaSignature
+	//      kBiochipSignature       kMiddleAreaSignature
+	//      kBiochipSignature       kRightAreaSignature
+	//      kAISignature            kLeftAreaSignature
+	// Further, the kAISignature never sets a static frame time in the left area,
+	// but only plays a sequence from the AI movie.
+	void setAIAreaToTime(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue);
+	
+	// The "Play" functions play the requested sequence synchronously.
+	void playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue, const TimeValue);
+
+	// For PlayAIMovie, it is assumed that the client is the AI itself.
+	// This is used to play AI messages as well as Optical Memory video.
+	// Returns true if the movie played all the way through, false if it was interrupted.
+	bool playAIMovie(const tLowerAreaSignature, const Common::String &movieName, bool keepLastFrame, const tInputBits);
+
+	// Loop the requested sequence indefinitely.
+	void loopAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue, const TimeValue);
+
+	void addAIRule(AIRule *);
+
+	// Remove and delete all rules.
+	void removeAllRules();
+
+	void lockAIOut();
+	void unlockAI();
+	void forceAIUnlocked();
+
+	void checkMiddleArea();
+	void checkRules();
+
+	tLowerClientSignature getMiddleAreaOwner();
+	void toggleMiddleAreaOwner();
+
+	TimeValue getBigInfoTime();
+	void getSmallInfoSegment(TimeValue &, TimeValue &);
+
+protected:	
+	void useIdleTime();
+
+	void setLeftMovieTime(const TimeValue);
+	void setMiddleMovieTime(const tLowerClientSignature, const TimeValue);
+	void setRightMovieTime(const TimeValue);
+
+	Movie _leftAreaMovie;
+	Movie _middleAreaMovie;
+	Movie _rightAreaMovie;
+	Movie _AIMovie;
+
+	tLowerClientSignature _leftAreaOwner;
+	tLowerClientSignature _middleAreaOwner;
+	tLowerClientSignature _rightAreaOwner;
+
+	TimeValue _leftInventoryTime;
+	TimeValue _middleInventoryTime;
+	TimeValue _middleBiochipTime;
+	TimeValue _rightBiochipTime;
+
+	AIRuleList _AIRules;
+
+	uint _lockCount;
+};
+
+extern AIArea *g_AIArea;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/ai/ai_condition.cpp b/engines/pegasus/ai/ai_condition.cpp
new file mode 100755
index 0000000..dbb66dd
--- /dev/null
+++ b/engines/pegasus/ai/ai_condition.cpp
@@ -0,0 +1,293 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/stream.h"
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/ai/ai_condition.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+AIOneChildCondition::AIOneChildCondition(AICondition *child) {
+	_child = child;
+}
+
+AIOneChildCondition::~AIOneChildCondition() {
+	delete _child;
+}
+
+void AIOneChildCondition::writeAICondition(Common::WriteStream *stream) {
+	if (_child)
+		_child->writeAICondition(stream);
+}
+
+void AIOneChildCondition::readAICondition(Common::ReadStream *stream) {
+	if (_child)
+		_child->readAICondition(stream);
+}
+
+AITwoChildrenCondition::AITwoChildrenCondition(AICondition *leftChild, AICondition *rightChild) {
+	_leftChild = leftChild;
+	_rightChild = rightChild;
+}
+
+AITwoChildrenCondition::~AITwoChildrenCondition() {
+	delete _leftChild;
+	delete _rightChild;
+}
+
+void AITwoChildrenCondition::writeAICondition(Common::WriteStream *stream) {
+	if (_leftChild)
+		_leftChild->writeAICondition(stream);
+
+	if (_rightChild) 
+		_rightChild->writeAICondition(stream);
+}
+
+void AITwoChildrenCondition::readAICondition(Common::ReadStream *stream) {
+	if (_leftChild)
+		_leftChild->readAICondition(stream);
+
+	if (_rightChild)
+		_rightChild->readAICondition(stream);
+}
+
+AINotCondition::AINotCondition(AICondition* child) : AIOneChildCondition(child) {
+}
+	
+bool AINotCondition::fireCondition() {
+	return _child && !_child->fireCondition();
+}
+
+AIAndCondition::AIAndCondition(AICondition *leftChild, AICondition *rightChild) : AITwoChildrenCondition(leftChild, rightChild) {
+}
+	
+bool AIAndCondition::fireCondition() {
+	return _leftChild && _leftChild->fireCondition() && _rightChild && _rightChild->fireCondition();
+}
+
+AIOrCondition::AIOrCondition(AICondition *leftChild, AICondition *rightChild) : AITwoChildrenCondition(leftChild, rightChild) {
+}
+
+bool AIOrCondition::fireCondition() {
+	return (_leftChild && _leftChild->fireCondition()) || (_rightChild && _rightChild->fireCondition());
+}
+
+AITimerCondition::AITimerCondition(const TimeValue time, const TimeScale scale, const bool shouldStartTimer) {
+	_timerFuse.primeFuse(time, scale);
+	_timerFuse.setFunctionPtr((tFunctionPtr)&AITimerFunction, (void *)this);
+	_fired = false;
+
+	if (shouldStartTimer)
+		startTimer();
+}
+
+void AITimerCondition::startTimer() {
+	_fired = false;
+	_timerFuse.lightFuse();
+}
+
+void AITimerCondition::stopTimer() {
+	_timerFuse.stopFuse();
+}
+
+void AITimerCondition::writeAICondition(Common::WriteStream *stream) {
+	stream->writeByte(_timerFuse.isFuseLit());
+	stream->writeByte(_fired);
+	stream->writeUint32BE(_timerFuse.getTimeRemaining());
+	stream->writeUint32BE(_timerFuse.getFuseScale());
+}
+
+void AITimerCondition::readAICondition(Common::ReadStream *stream) {
+	bool running = stream->readByte();
+	_fired = stream->readByte();
+	TimeValue time = stream->readUint32BE();
+	TimeScale scale = stream->readUint32BE();
+
+	_timerFuse.stopFuse();
+	_timerFuse.primeFuse(time, scale);
+
+	if (running)
+		_timerFuse.lightFuse();
+}
+
+void AITimerCondition::AITimerFunction(FunctionPtr *, AITimerCondition *condition) {
+	condition->_fired = true;
+}
+
+bool AITimerCondition::fireCondition() {
+	return _fired;
+}
+
+AILocationCondition::AILocationCondition(uint32 maxLocations) {
+	_numLocations = 0;
+	_maxLocations = maxLocations;
+	_locations = new tRoomViewID[maxLocations];
+}
+
+AILocationCondition::~AILocationCondition() {
+	delete[] _locations;
+}
+
+void AILocationCondition::addLocation(const tRoomViewID location) {
+	if (_numLocations < _maxLocations)
+		_locations[_numLocations++] = location;
+}
+
+bool AILocationCondition::fireCondition() {
+	tRoomViewID test = GameState.getCurrentRoomAndView(), *p;
+	uint32 i;
+
+	for (i = 0, p = _locations; i < _numLocations; i++, p++) {
+		if (test == *p) {
+			*p = MakeRoomView(kNoRoomID, kNoDirection);
+			return true;
+		}
+	}
+
+	return false;
+}
+
+void AILocationCondition::writeAICondition(Common::WriteStream *stream) {
+	stream->writeUint32BE(_maxLocations);
+	stream->writeUint32BE(_numLocations);
+
+	uint32 i;
+	tRoomViewID *p;
+	for (i = 0, p = _locations; i < _numLocations; i++, p++)
+		stream->writeUint32BE(*p);
+}
+
+void AILocationCondition::readAICondition(Common::ReadStream *stream) {
+	uint32 maxLocations = stream->readUint32BE();
+
+	if (_maxLocations != maxLocations) {
+		delete[] _locations;
+		_locations = new tRoomViewID[maxLocations];
+		_maxLocations = maxLocations;
+	}
+
+	_numLocations = stream->readUint32BE();
+
+	uint32 i;
+	tRoomViewID *p;
+	for (i = 0, p = _locations; i < _numLocations; i++, p++)
+		*p = stream->readUint32BE();
+}
+
+AIDoorOpenedCondition::AIDoorOpenedCondition(tRoomViewID doorLocation) {
+	_doorLocation = doorLocation;
+}
+
+bool AIDoorOpenedCondition::fireCondition() {
+	return GameState.getCurrentRoomAndView() == _doorLocation && GameState.isCurrentDoorOpen();
+}
+
+AIHasItemCondition::AIHasItemCondition(const tItemID item) {
+	_item = item;
+}
+
+bool AIHasItemCondition::fireCondition() {
+	return _item == kNoItemID || GameState.isTakenItemID(_item);
+}
+
+AIDoesntHaveItemCondition::AIDoesntHaveItemCondition(const tItemID item) {
+	_item = item;
+}
+
+bool AIDoesntHaveItemCondition::fireCondition() {
+	return _item == kNoItemID || !GameState.isTakenItemID(_item);
+}
+
+AICurrentItemCondition::AICurrentItemCondition(const tItemID item) {
+	_item = item;
+}
+	
+bool AICurrentItemCondition::fireCondition() {
+	// TODO
+	//InventoryItem *item = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
+	InventoryItem *item = 0;
+
+	if (_item == kNoItemID)
+		return item == 0;
+
+	return item != 0 && item->getObjectID() == _item;
+}
+
+AICurrentBiochipCondition::AICurrentBiochipCondition(const tItemID biochip)  {
+	_biochip = biochip;
+}
+
+bool AICurrentBiochipCondition::fireCondition() {
+	// TODO
+	///BiochipItem *biochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
+	BiochipItem *biochip = 0;
+	
+	if (_biochip == kNoItemID)
+		return biochip == 0;
+
+	return biochip != 0 && biochip->getObjectID() == _biochip;
+}
+
+AIItemStateCondition::AIItemStateCondition(const tItemID item, const tItemState state) {
+	_item = item;
+	_state = state;
+}
+
+bool AIItemStateCondition::fireCondition() {
+	Item *item = g_allItems.findItemByID(_item);
+	return item != 0 && item->getItemState() == _state;
+}
+
+AIEnergyMonitorCondition::AIEnergyMonitorCondition(const int32 energyThreshold) {
+	_energyThreshold = energyThreshold;
+}
+
+bool AIEnergyMonitorCondition::fireCondition() {
+	return g_energyMonitor != 0 && g_energyMonitor->getCurrentEnergy() < _energyThreshold;
+}
+
+AILastExtraCondition::AILastExtraCondition(const tExtraID lastExtra) {
+	_lastExtra = lastExtra;
+}
+
+bool AILastExtraCondition::fireCondition() {
+	// TODO
+	return false;
+}
+
+AICondition *makeLocationAndDoesntHaveItemCondition(const tRoomID room, const tDirectionConstant direction, const tItemID item) {
+	AILocationCondition *location = new AILocationCondition(1);
+	location->addLocation(MakeRoomView(room, direction));
+	
+	AIDoesntHaveItemCondition *doesntHaveItem = new AIDoesntHaveItemCondition(item);
+
+	return new AIAndCondition(location, doesntHaveItem);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/ai/ai_condition.h b/engines/pegasus/ai/ai_condition.h
new file mode 100755
index 0000000..559ec55
--- /dev/null
+++ b/engines/pegasus/ai/ai_condition.h
@@ -0,0 +1,287 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_AI_AICONDITION_H
+#define PEGASUS_AI_AICONDITION_H
+
+#include "pegasus/timers.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+/////////////////////////////////////////////
+//
+//	AICondition
+
+class AICondition {
+public:
+	AICondition() {}
+	virtual ~AICondition() {}
+
+	virtual bool fireCondition() = 0;
+
+	// Only need these for conditions that are dynamic, like timer conditions...
+	// other conditions, like item related conditions, which don't change during
+	// the run of an environment, are completely initted when the environment
+	// is created.
+	virtual void writeAICondition(Common::WriteStream *) {}
+	virtual void readAICondition(Common::ReadStream *) {}
+};
+
+/////////////////////////////////////////////
+//
+//	AIOneChildCondition
+
+class AIOneChildCondition : public AICondition {
+public:
+	AIOneChildCondition(AICondition *);
+	virtual ~AIOneChildCondition();
+	
+	virtual void writeAICondition(Common::WriteStream *);
+	virtual void readAICondition(Common::ReadStream *);
+
+protected:
+	AICondition *_child;
+};
+
+/////////////////////////////////////////////
+//
+//	AITwoChildrenCondition
+
+class AITwoChildrenCondition : public AICondition {
+public:
+	AITwoChildrenCondition(AICondition *, AICondition *);
+	virtual ~AITwoChildrenCondition();
+	
+	virtual void writeAICondition(Common::WriteStream *);
+	virtual void readAICondition(Common::ReadStream *);
+
+protected:
+	AICondition *_leftChild, *_rightChild;
+};
+
+/////////////////////////////////////////////
+//
+//	AINotCondition
+
+class AINotCondition : public AIOneChildCondition {
+public:
+	AINotCondition(AICondition *);
+
+	virtual bool fireCondition();
+};
+
+/////////////////////////////////////////////
+//
+//	AIAndCondition
+
+class AIAndCondition : public AITwoChildrenCondition {
+public:
+	AIAndCondition(AICondition *, AICondition *);
+
+	virtual bool fireCondition();
+};
+
+/////////////////////////////////////////////
+//
+//	AIOrCondition
+
+class AIOrCondition : public AITwoChildrenCondition {
+public:
+	AIOrCondition(AICondition *, AICondition *);
+
+	virtual bool fireCondition();
+};
+
+/////////////////////////////////////////////
+//
+//	AITimerCondition
+
+class AITimerCondition : public AICondition {
+public:
+	AITimerCondition(const TimeValue, const TimeScale, const bool);
+
+	void startTimer();
+	void stopTimer();
+
+	virtual bool fireCondition();
+	
+	virtual void writeAICondition(Common::WriteStream *);
+	virtual void readAICondition(Common::ReadStream *);
+
+protected:
+	static void AITimerFunction(FunctionPtr *, AITimerCondition *);
+
+	FuseFunction _timerFuse;
+	bool _fired;
+};
+
+/////////////////////////////////////////////
+//
+//	AILocationCondition
+
+class AILocationCondition : public AICondition {
+public:
+	AILocationCondition(uint32);
+	virtual ~AILocationCondition();
+
+	void addLocation(tRoomViewID);
+	virtual bool fireCondition();
+
+	virtual void					writeAICondition(Common::WriteStream *);
+	virtual void					readAICondition(Common::ReadStream *);
+
+protected:
+	uint32 _numLocations, _maxLocations;
+	tRoomViewID *_locations;
+};
+
+/////////////////////////////////////////////
+//
+//	AIDoorOpenedCondition
+
+class AIDoorOpenedCondition : public AICondition {
+public:
+	AIDoorOpenedCondition(tRoomViewID);
+	virtual ~AIDoorOpenedCondition() {}
+
+	virtual bool fireCondition();
+
+protected:
+	tRoomViewID _doorLocation;
+};
+
+/////////////////////////////////////////////
+//
+//	AIHasItemCondition
+
+class AIHasItemCondition : public AICondition {
+public:
+	AIHasItemCondition(const tItemID);
+
+	virtual bool fireCondition();
+
+protected:
+	tItemID _item;
+};
+
+/////////////////////////////////////////////
+//
+//	AIDoesntHaveItemCondition
+
+class AIDoesntHaveItemCondition : public AICondition {
+public:
+	AIDoesntHaveItemCondition(const tItemID);
+
+	virtual bool fireCondition();
+
+protected:
+	tItemID _item;
+};
+
+/////////////////////////////////////////////
+//
+//	AICurrentItemCondition
+
+class AICurrentItemCondition : public AICondition {
+public:
+	AICurrentItemCondition(const tItemID);
+
+	virtual bool fireCondition();
+
+protected:
+	tItemID _item;
+};
+
+/////////////////////////////////////////////
+//
+//	AICurrentBiochipCondition
+
+class AICurrentBiochipCondition : public AICondition {
+public:
+	AICurrentBiochipCondition(const tItemID);
+
+	virtual bool fireCondition();
+
+protected:
+	tItemID _biochip;
+};
+
+/////////////////////////////////////////////
+//
+//	AIItemStateCondition
+
+class AIItemStateCondition : public AICondition {
+public:
+	AIItemStateCondition(const tItemID, const tItemState);
+
+	virtual bool fireCondition();
+
+protected:
+	tItemID _item;
+	tItemState _state;
+};
+
+/////////////////////////////////////////////
+//
+//	AIEnergyMonitorCondition
+
+class AIEnergyMonitorCondition : public AICondition {
+public:
+	AIEnergyMonitorCondition(const int32);
+
+	virtual bool fireCondition();
+
+protected:
+	int32 _energyThreshold;
+};
+
+/////////////////////////////////////////////
+//
+//	AILastExtraCondition
+
+class AILastExtraCondition : public AICondition {
+public:
+	AILastExtraCondition(const tExtraID);
+
+	virtual bool fireCondition();
+
+protected:
+	tExtraID _lastExtra;
+};
+
+/////////////////////////////////////////////
+//
+//	Helper functions
+
+AICondition *makeLocationAndDoesntHaveItemCondition(const tRoomID room, const tDirectionConstant direction, const tItemID item);
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/ai/ai_rule.cpp b/engines/pegasus/ai/ai_rule.cpp
new file mode 100755
index 0000000..3aaa530
--- /dev/null
+++ b/engines/pegasus/ai/ai_rule.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/stream.h"
+
+#include "pegasus/ai/ai_action.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/ai/ai_condition.h"
+#include "pegasus/ai/ai_rule.h"
+
+namespace Pegasus {
+
+bool AIRule::fireRule() {
+	if (_ruleActive && _ruleCondition && _ruleAction && _ruleCondition->fireCondition()) {
+		if (g_AIArea)
+			g_AIArea->lockAIOut();
+
+		_ruleAction->performAIAction(this);
+
+		if (--_ruleAction->_actionCount <= 0)
+			deactivateRule();
+
+		if (g_AIArea)
+			g_AIArea->unlockAI();
+
+		return true;
+	}
+
+	return false;
+}
+
+void AIRule::writeAIRule(Common::WriteStream *stream) {
+	stream->writeByte(_ruleActive);
+
+	if (_ruleCondition)
+		_ruleCondition->writeAICondition(stream);
+}
+
+void AIRule::readAIRule(Common::ReadStream *stream) {
+	_ruleActive = stream->readByte();
+
+	if (_ruleCondition)
+		_ruleCondition->readAICondition(stream);
+}
+
+void AIRuleList::writeAIRules(Common::WriteStream *stream) {
+	for (AIRuleList::iterator it = begin(); it != end(); it++)
+		(*it)->writeAIRule(stream);
+}
+
+void AIRuleList::readAIRules(Common::ReadStream *stream) {
+	for (AIRuleList::iterator it = begin(); it != end(); it++)
+		(*it)->readAIRule(stream);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/ai/ai_rule.h b/engines/pegasus/ai/ai_rule.h
new file mode 100755
index 0000000..bccd4ec
--- /dev/null
+++ b/engines/pegasus/ai/ai_rule.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_AI_AIRULE_H
+#define PEGASUS_AI_AIRULE_H
+
+#include "common/list.h"
+
+#include "pegasus/ai/ai_action.h"
+#include "pegasus/ai/ai_condition.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class AICondition;
+class AIAction;
+
+class AIRule {
+public:
+	AIRule(AICondition *condition, AIAction *rule) {
+		_ruleCondition = condition;
+		_ruleAction = rule;
+		_ruleActive = true;
+	}
+	
+	~AIRule() {
+		if (_ruleCondition)
+			delete _ruleCondition;
+
+		if (_ruleAction)
+			delete _ruleAction;
+	}
+
+	bool fireRule();
+
+	void activateRule() { _ruleActive = true; }
+	void deactivateRule() { _ruleActive = false; }
+	bool isRuleActive() { return _ruleActive; }
+
+	void writeAIRule(Common::WriteStream *);
+	void readAIRule(Common::ReadStream *);
+
+protected:
+	AICondition *_ruleCondition;
+	AIAction *_ruleAction;
+	bool _ruleActive;
+};
+
+class AIRuleList : public Common::List<AIRule *> {
+public:
+	AIRuleList() {}
+	~AIRuleList() {}
+
+	void writeAIRules(Common::WriteStream *);
+	void readAIRules(Common::ReadStream *);
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 519e97e..4af10bf 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -33,6 +33,8 @@
 
 namespace Pegasus {
 
+// TODO: Organize these
+
 const tGameID kGameIDNothing = -1;
 
 const tActorID kNoActorID = kGameIDNothing;
@@ -683,6 +685,53 @@ enum {
 	kPlayerWonGame
 };
 
+static const tCoordType kAILeftAreaLeft = 76;
+static const tCoordType kAILeftAreaTop = 334;
+
+static const tCoordType kAILeftAreaWidth = 96;
+static const tCoordType kAILeftAreaHeight = 96;
+
+static const tCoordType kAIMiddleAreaLeft = 172;
+static const tCoordType kAIMiddleAreaTop = 334;
+
+static const tCoordType kAIMiddleAreaWidth = 192;
+static const tCoordType kAIMiddleAreaHeight = 96;
+
+static const tCoordType kAIRightAreaLeft = 364;
+static const tCoordType kAIRightAreaTop = 334;
+
+static const tCoordType kAIRightAreaWidth = 96;
+static const tCoordType kAIRightAreaHeight = 96;
+
+enum {
+	kTSAPlayerNotArrived,				//	initial state, must be zero
+	kTSAPlayerForcedReview,				//	Player must watch TBP before rip occurs.
+	kTSAPlayerDetectedRip,				//	Player finished TBP, rip alarm just went off.
+	kTSAPlayerNeedsHistoricalLog,		//	Player is instructed to get historical log
+	kTSAPlayerGotHistoricalLog,
+	kTSAPlayerInstalledHistoricalLog,
+	kTSABossSawHistoricalLog,
+	kRobotsAtCommandCenter,
+	kRobotsAtFrontDoor,
+	kRobotsAtReadyRoom,
+	kPlayerLockedInPegasus,
+	kPlayerOnWayToPrehistoric,
+	kPlayerWentToPrehistoric,
+	kPlayerOnWayToNorad,
+	kPlayerOnWayToMars,
+	kPlayerOnWayToWSC,
+	kPlayerFinishedWithTSA
+};
+
+static const tDirectionConstant kNorth = 0;
+static const tDirectionConstant kSouth = 1;
+static const tDirectionConstant kEast = 2;
+static const tDirectionConstant kWest = 3;
+
+// TODO: Remove me
+const tRoomID kTSA37 = 42;
+const tRoomID kTinyTSA37 = 0;
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index f356829..b95a5d7 100755
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -30,6 +30,7 @@
 #include "common/util.h"
 
 #include "pegasus/types.h"
+#include "pegasus/util.h"
 #include "pegasus/items/item.h"
 
 namespace Common {
@@ -853,60 +854,6 @@ private:
 	tDirectionConstant _openDoorDirection;
 
 	// Pegasus Prime
-	#define NUM_FLAGS (sizeof(Unit) * 8)
-	#define BIT_INDEX_SHIFT (sizeof(Unit) + 2 - (sizeof(Unit)) / 3)
-	#define BIT_INDEX_MASK (NUM_FLAGS - 1)
-	template <typename Unit, uint32 kNumFlags>
-	class FlagsArray {
-	public:
-		FlagsArray() { clearAllFlags(); }
-		void clearAllFlags() { memset(_flags, 0, sizeof(_flags)); }
-		void setAllFlags() { memset(_flags, ~((Unit)0), sizeof(_flags)); }
-		void setFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] |= 1 << (flag & BIT_INDEX_MASK); }
-		void clearFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] &= ~(1 << (flag & BIT_INDEX_MASK)); }
-		void setFlag(uint32 flag, bool val) { if (val) setFlag(flag); else clearFlag(flag); }
-		bool getFlag(uint32 flag) { return (_flags[flag >> BIT_INDEX_SHIFT] & (1 << (flag & BIT_INDEX_MASK))) != 0; }
-		bool anyFlagSet() {
-			for (uint32 i = 0; i < sizeof(_flags); i++)
-				if (_flags[i] != 0)
-					return true;
-			return false;
-		}
-
-		void readFromStream(Common::ReadStream *stream) {
-			// Shortcut
-			if (sizeof(Unit) == 1) {
-				stream->read(_flags, sizeof(_flags));
-				return;
-			}
-
-			for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
-				if (sizeof(Unit) == 2)
-					_flags[i] = stream->readUint16BE();
-				else /* if (sizeof(Unit) == 4) */
-					_flags[i] = stream->readUint32BE();
-			}
-		}
-
-		void writeToStream(Common::WriteStream *stream) {
-			// Shortcut
-			if (sizeof(Unit) == 1) {
-				stream->write(_flags, sizeof(_flags));
-				return;
-			}
-
-			for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
-				if (sizeof(Unit) == 2)
-					stream->writeUint16BE(_flags[i]);
-				else /* if (sizeof(Unit) == 4) */
-					stream->writeUint32BE(_flags[i]);
-			}
-		}
-
-	private:
-		Unit _flags[(kNumFlags - 1) / NUM_FLAGS + 1];
-	};
-
 	FlagsArray<byte, kNumGlobalFlags> _globalFlags;
 	FlagsArray<byte, kNumScoringFlags> _scoringFlags;
 	FlagsArray<uint32, kNumItems> _itemTakenFlags;
@@ -934,6 +881,6 @@ private:
 
 } // End of namespace Pegasus
 
-#define GameState	(::Pegasus::GameStateManager::instance())
+#define GameState (::Pegasus::GameStateManager::instance())
 
 #endif
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index d70a573..298a78f 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -267,6 +267,10 @@ enum {
 								kFilterMod3Button
 };
 
+static const tInputBits kHintInterruption = kFilterAllInputNoAuto;
+static const tInputBits kWarningInterruption = kFilterNoInput;
+static const tInputBits kOpticalInterruption = kFilterAllInputNoAuto;
+
 /*
 
 	Buttons are defined as:
diff --git a/engines/pegasus/items/biochips/aichip.cpp b/engines/pegasus/items/biochips/aichip.cpp
new file mode 100755
index 0000000..d4e4259
--- /dev/null
+++ b/engines/pegasus/items/biochips/aichip.cpp
@@ -0,0 +1,279 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/aichip.h"
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+// indexed by [number of hints][number of solves (0, 1, or 2)][which button to highlight]
+static const tItemState s_highlightState[4][3][7] = {
+	{
+		{kAI000,	-1,			-1,			-1,			-1,			kAI005,		kAI006},
+		{kAI010,	-1,			-1,			-1,			-1,			kAI015,		kAI016},
+		{kAI020,	-1,			-1,			-1,			kAI024,		-1,			-1}
+	},
+	{
+		{kAI100,	kAI101,		-1,			-1,			-1,			kAI105,		kAI106},
+		{kAI110,	kAI111,		-1,			-1,			-1,			kAI115,		kAI116},
+		{kAI120,	kAI121,		-1,			-1,			kAI124,		kAI125,		kAI126}
+	},
+	{
+		{kAI200,	kAI201,		kAI202,		-1,			-1,			kAI205,		kAI206},
+		{kAI210,	kAI211,		kAI212,		-1,			-1,			kAI215,		kAI216},
+		{kAI220,	kAI221,		kAI222,		-1,			kAI224,		kAI225,		kAI226}
+	},
+	{
+		{kAI300,	kAI301,		kAI302,		kAI303,		-1,			kAI305,		kAI306},
+		{kAI310,	kAI311,		kAI312,		kAI313,		-1,			kAI315,		kAI316},
+		{kAI320,	kAI321,		kAI322,		kAI323,		kAI324,		kAI325,		kAI326}
+	}
+};
+
+AIChip *g_AIChip = 0;
+
+AIChip::AIChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction), _briefingSpot(kAIBriefingSpotID), _scanSpot(kAIScanSpotID),
+		_hint1Spot(kAIHint1SpotID), _hint2Spot(kAIHint2SpotID), _hint3Spot(kAIHint3SpotID), _solveSpot(kAISolveSpotID) {
+	_briefingSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 10, kAIMiddleAreaTop + 27, kAIMiddleAreaLeft + 10 + 81, kAIMiddleAreaTop + 27 + 31));
+	_briefingSpot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_briefingSpot);
+	
+	_scanSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 100, kAIMiddleAreaTop + 27, kAIMiddleAreaLeft + 100 + 81, kAIMiddleAreaTop + 27 + 31));
+	_scanSpot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_scanSpot);
+	
+	_hint1Spot.setArea(Common::Rect(kAIMiddleAreaLeft + 70, kAIMiddleAreaTop + 67, kAIMiddleAreaLeft + 70 + 21, kAIMiddleAreaTop + 67 + 21));
+	_hint1Spot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_hint1Spot);
+	
+	_hint2Spot.setArea(Common::Rect(kAIMiddleAreaLeft + 91, kAIMiddleAreaTop + 67, kAIMiddleAreaLeft + 91 + 20, kAIMiddleAreaTop + 67 + 21));
+	_hint2Spot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_hint2Spot);
+	
+	_hint3Spot.setArea(Common::Rect(kAIMiddleAreaLeft + 111, kAIMiddleAreaTop + 67, kAIMiddleAreaLeft + 111 + 20, kAIMiddleAreaTop + 67 + 21));
+	_hint3Spot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_hint3Spot);
+	
+	_solveSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 131, kAIMiddleAreaTop + 67, kAIMiddleAreaLeft + 131 + 50, kAIMiddleAreaTop + 67 + 21));
+	_solveSpot.setHotspotFlags(kAIBiochipSpotFlag);
+	g_allHotspots.push_back(&_solveSpot);
+	
+	_playingMovie = false;
+	setItemState(kAI000);
+	
+	g_AIChip = this;
+}
+
+AIChip::~AIChip() {
+	g_AIChip = NULL;
+	
+	g_allHotspots.removeOneHotspot(kAIBriefingSpotID);
+	g_allHotspots.removeOneHotspot(kAIScanSpotID);
+	g_allHotspots.removeOneHotspot(kAIHint1SpotID);
+	g_allHotspots.removeOneHotspot(kAIHint2SpotID);
+	g_allHotspots.removeOneHotspot(kAIHint3SpotID);
+	g_allHotspots.removeOneHotspot(kAISolveSpotID);
+}
+
+void AIChip::select() {
+	BiochipItem::select();
+	setUpAIChip();
+}
+
+void AIChip::takeSharedArea() {
+	setUpAIChip();
+}
+
+void AIChip::setUpAIChip() {	
+	if (!_playingMovie) {
+		PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+		uint numSolves;
+		if (GameState.getWalkthroughMode()) {
+			if (vm->canSolve())
+				numSolves = 2;
+			else
+				numSolves = 1;
+		} else {
+			numSolves = 0;
+		}
+
+		setItemState(s_highlightState[vm->getNumHints()][numSolves][0]);
+	}
+}
+
+// Only does something when there are hints or solves available.
+void AIChip::setUpAIChipRude() {	
+	if (!_playingMovie) {
+		PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+		uint numSolves;
+		if (GameState.getWalkthroughMode()) {
+			if (vm->canSolve())
+				numSolves = 2;
+			else
+				numSolves = 1;
+		} else {
+			numSolves = 0;
+		}
+
+		uint numHints = vm->getNumHints();
+		if (numSolves == 2 || numHints != 0)
+			setItemState(s_highlightState[numHints][numSolves][0]);
+	}
+}
+
+void AIChip::activateAIHotspots() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	_briefingSpot.setActive();
+	_scanSpot.setActive();
+
+	switch (vm->getNumHints()) {
+	case 3:
+		_hint3Spot.setActive();
+		// fall through
+	case 2:
+		_hint2Spot.setActive();
+		// fall through
+	case 1:
+		_hint1Spot.setActive();
+		break;
+	}
+
+	if (GameState.getWalkthroughMode() && vm->canSolve())
+		_solveSpot.setActive();
+}
+
+void AIChip::showBriefingClicked() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	_playingMovie = true;
+
+	uint numSolves;
+	if (GameState.getWalkthroughMode()) {
+		if (vm->canSolve())
+			numSolves = 2;
+		else
+			numSolves = 1;
+	} else {
+		numSolves = 0;
+	}
+
+	tItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIBriefingSpotID - kAIHint1SpotID + 1];
+	if (newState != -1)
+		setItemState(newState);
+}
+
+void AIChip::showEnvScanClicked() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	_playingMovie = true;
+
+	uint numSolves;
+	if (GameState.getWalkthroughMode()) {
+		if (vm->canSolve())
+			numSolves = 2;
+		else
+			numSolves = 1;
+	} else {
+		numSolves = 0;
+	}
+
+	tItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIScanSpotID - kAIHint1SpotID + 1];
+
+	if (newState != -1)
+		setItemState(newState);
+}
+
+void AIChip::clearClicked() {
+	_playingMovie = false;
+	setUpAIChip();
+}
+
+void AIChip::clickInAIHotspot(tHotSpotID id) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	Common::String movieName;
+
+	switch (id) {
+	case kAIBriefingSpotID:
+		movieName = vm->getBriefingMovie();
+		break;
+	case kAIScanSpotID:
+		movieName = vm->getEnvScanMovie();
+		break;
+	case kAIHint1SpotID:
+		movieName = vm->getHintMovie(1);
+		break;
+	case kAIHint2SpotID:
+		movieName = vm->getHintMovie(2);
+		break;
+	case kAIHint3SpotID:
+		movieName = vm->getHintMovie(3);
+		break;
+	case kAISolveSpotID:
+		g_neighborhood->doSolve();
+		break;
+	}
+
+	tItemState state = getItemState();
+
+	if (!movieName.empty()) {
+		_playingMovie = true;
+
+		uint numSolves;
+		if (GameState.getWalkthroughMode()) {
+			if (vm->canSolve())
+				numSolves = 2;
+			else
+				numSolves = 1;
+		} else {
+			numSolves = 0;
+		}
+
+		tItemState newState = s_highlightState[vm->getNumHints()][numSolves][id - kAIHint1SpotID + 1];
+
+		if (newState != -1)
+			setItemState(newState);
+
+		if (g_AIArea) {
+			vm->prepareForAIHint(movieName);
+			g_AIArea->playAIMovie(kRightAreaSignature, movieName, false, kHintInterruption);
+			vm->cleanUpAfterAIHint(movieName);
+		}
+
+		if (newState != -1)
+			setItemState(state);
+
+		_playingMovie = false;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/aichip.h b/engines/pegasus/items/biochips/aichip.h
new file mode 100755
index 0000000..96d2fb2
--- /dev/null
+++ b/engines/pegasus/items/biochips/aichip.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_AICHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_AICHIP_H
+
+#include "pegasus/hotspot.h"
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+class AIChip : public BiochipItem {
+public:
+	AIChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~AIChip();
+
+	void select();
+
+	void setUpAIChip();
+
+	// Called to set up the AI chip when the AI chip is the current chip but does not
+	// own the center area.
+	void setUpAIChipRude();
+	void activateAIHotspots();
+	void clickInAIHotspot(tHotSpotID);
+
+	void takeSharedArea();
+
+	void showBriefingClicked();
+	void showEnvScanClicked();
+	void clearClicked();
+
+protected:
+	Hotspot _briefingSpot;
+	Hotspot _scanSpot;
+	Hotspot _hint1Spot;
+	Hotspot _hint2Spot;
+	Hotspot _hint3Spot;
+	Hotspot _solveSpot;
+	bool _playingMovie;
+};
+
+extern AIChip *g_AIChip;
+
+} // End of namespace Pegasus
+
+#endif
\ No newline at end of file
diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
index 71065f1..99e6050 100755
--- a/engines/pegasus/items/biochips/biochipitem.cpp
+++ b/engines/pegasus/items/biochips/biochipitem.cpp
@@ -27,6 +27,7 @@
 #include "common/stream.h"
 
 #include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
 #include "pegasus/items/biochips/biochipitem.h"
 
 namespace Pegasus {
@@ -80,13 +81,15 @@ TimeValue BiochipItem::getRightAreaTime() const {
 void BiochipItem::select() {
 	Item::select();
 
-	// TODO: AI
+	if (g_AIArea)
+		g_AIArea->setAIAreaToTime(kBiochipSignature, kRightAreaSignature, getRightAreaTime());
 }
 
 void BiochipItem::deselect() {
 	Item::deselect();
 
-	// TODO: AI
+	if (g_AIArea)
+		g_AIArea->setAIAreaToTime(kBiochipSignature, kRightAreaSignature, 0xffffffff);
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/opticalchip.cpp b/engines/pegasus/items/biochips/opticalchip.cpp
new file mode 100755
index 0000000..f6519c7
--- /dev/null
+++ b/engines/pegasus/items/biochips/opticalchip.cpp
@@ -0,0 +1,189 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/opticalchip.h"
+
+namespace Pegasus {
+
+OpticalChip *g_opticalChip = 0;
+
+OpticalChip::OpticalChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction), _ariesHotspot(kAriesSpotID), _mercuryHotspot(kMercurySpotID),
+		_poseidonHotspot(kPoseidonSpotID) {
+	_ariesHotspot.setArea(Common::Rect(kAIMiddleAreaLeft + 60, kAIMiddleAreaTop + 27, kAIMiddleAreaLeft + 60 + 121, kAIMiddleAreaTop + 27 + 20));
+	_ariesHotspot.setHotspotFlags(kOpticalBiochipSpotFlag);
+	g_allHotspots.push_back(&_ariesHotspot);
+
+	_mercuryHotspot.setArea(Common::Rect(kAIMiddleAreaLeft + 60, kAIMiddleAreaTop + 47, kAIMiddleAreaLeft + 60 + 121, kAIMiddleAreaTop + 47 + 20));
+	_mercuryHotspot.setHotspotFlags(kOpticalBiochipSpotFlag);
+	g_allHotspots.push_back(&_mercuryHotspot);
+
+	_poseidonHotspot.setArea(Common::Rect(kAIMiddleAreaLeft + 60, kAIMiddleAreaTop + 67, kAIMiddleAreaLeft + 60 + 121, kAIMiddleAreaTop + 67 + 20));
+	_poseidonHotspot.setHotspotFlags(kOpticalBiochipSpotFlag);
+	g_allHotspots.push_back(&_poseidonHotspot);
+
+	setItemState(kOptical000);
+
+	g_opticalChip = this;
+}
+
+OpticalChip::~OpticalChip() {
+	g_allHotspots.removeOneHotspot(kAriesSpotID);
+	g_allHotspots.removeOneHotspot(kMercurySpotID);
+	g_allHotspots.removeOneHotspot(kPoseidonSpotID);
+}
+
+void OpticalChip::writeToStream(Common::WriteStream *stream) {
+	BiochipItem::writeToStream(stream);
+	_opticalFlags.writeToStream(stream);
+}
+
+void OpticalChip::readFromStream(Common::ReadStream *stream) {
+	BiochipItem::readFromStream(stream);
+	_opticalFlags.readFromStream(stream);
+}
+
+void OpticalChip::addAries() {
+	_opticalFlags.setFlag(kOpticalAriesExposed, true);
+	setUpOpticalChip();
+}
+
+void OpticalChip::addMercury() {
+	_opticalFlags.setFlag(kOpticalMercuryExposed, true);
+	setUpOpticalChip();
+}
+
+void OpticalChip::addPoseidon() {
+	_opticalFlags.setFlag(kOpticalPoseidonExposed, true);
+	setUpOpticalChip();
+}
+
+void OpticalChip::setUpOpticalChip() {
+	if (_opticalFlags.getFlag(kOpticalAriesExposed)) {
+		if (_opticalFlags.getFlag(kOpticalMercuryExposed)) {
+			if (_opticalFlags.getFlag(kOpticalPoseidonExposed))
+				setItemState(kOptical111);
+			else
+				setItemState(kOptical011);
+		} else {
+			if (_opticalFlags.getFlag(kOpticalPoseidonExposed))
+				setItemState(kOptical101);
+			else
+				setItemState(kOptical001);
+		}
+	} else {
+		if (_opticalFlags.getFlag(kOpticalMercuryExposed)) {
+			if (_opticalFlags.getFlag(kOpticalPoseidonExposed))
+				setItemState(kOptical110);
+			else
+				setItemState(kOptical010);
+		} else {
+			if (_opticalFlags.getFlag(kOpticalPoseidonExposed))
+				setItemState(kOptical100);
+			else
+				setItemState(kOptical000);
+		}
+	}
+}
+
+void OpticalChip::activateOpticalHotspots() {
+	if (_opticalFlags.getFlag(kOpticalAriesExposed))
+		_ariesHotspot.setActive();
+	if (_opticalFlags.getFlag(kOpticalMercuryExposed))
+		_mercuryHotspot.setActive();
+	if (_opticalFlags.getFlag(kOpticalPoseidonExposed))
+		_poseidonHotspot.setActive();
+}
+
+void OpticalChip::clickInOpticalHotspot(tHotSpotID id) {
+	playOpMemMovie(id);
+}
+
+void OpticalChip::playOpMemMovie(tHotSpotID id) {
+	Common::String movieName;
+	switch (id) {
+	case kAriesSpotID:
+		movieName = "Images/AI/Globals/OMAI";
+		break;
+	case kMercurySpotID:
+		movieName = "Images/AI/Globals/OMMI";
+		break;
+	case kPoseidonSpotID:
+		movieName = "Images/AI/Globals/OMPI";
+		break;
+	}
+
+	tItemState state = getItemState(), newState;
+	switch (state) {
+	case kOptical000:
+		// Can never happen.
+		break;
+	case kOptical001:
+		newState = kOptical002;
+		break;
+	case kOptical010:
+		newState = kOptical020;
+		break;
+	case kOptical011:
+		if (id == kAriesSpotID)
+			newState = kOptical012;
+		else
+			newState = kOptical021;
+		break;
+	case kOptical100:
+		newState = kOptical200;
+		break;
+	case kOptical101:
+		if (id == kAriesSpotID)
+			newState = kOptical102;
+		else
+			newState = kOptical201;
+		break;
+	case kOptical110:
+		if (id == kMercurySpotID)
+			newState = kOptical120;
+		else
+			newState = kOptical210;
+		break;
+	case kOptical111:
+		if (id == kAriesSpotID)
+			newState = kOptical112;
+		else if (id == kMercurySpotID)
+			newState = kOptical121;
+		else
+			newState = kOptical211;
+		break;
+	}
+
+	setItemState(newState);
+
+	if (g_AIArea)
+		g_AIArea->playAIMovie(kRightAreaSignature, movieName, false, kOpticalInterruption);
+
+	setItemState(state);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/opticalchip.h b/engines/pegasus/items/biochips/opticalchip.h
new file mode 100755
index 0000000..c44a5ea
--- /dev/null
+++ b/engines/pegasus/items/biochips/opticalchip.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_OPTICALCHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_OPTICALCHIP_H
+
+#include "pegasus/hotspot.h"
+#include "pegasus/util.h"
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+class OpticalChip : public BiochipItem {
+public:
+	OpticalChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~OpticalChip();
+
+	virtual void writeToStream(Common::WriteStream *);
+	virtual void readFromStream(Common::ReadStream *);
+
+	void addAries();
+	void addMercury();
+	void addPoseidon();
+
+	void activateOpticalHotspots();
+	void clickInOpticalHotspot(tHotSpotID);
+	void playOpMemMovie(tHotSpotID);
+
+protected:
+	enum {
+		kOpticalAriesExposed,
+		kOpticalMercuryExposed,
+		kOpticalPoseidonExposed,
+		kNumOpticalChipFlags
+	};
+	
+	void setUpOpticalChip();
+	
+	FlagsArray<byte, kNumOpticalChipFlags> _opticalFlags;
+	Hotspot _ariesHotspot;
+	Hotspot _mercuryHotspot;
+	Hotspot _poseidonHotspot;
+};
+
+extern OpticalChip *g_opticalChip;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
new file mode 100755
index 0000000..5d0c991
--- /dev/null
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -0,0 +1,178 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/items/biochips/pegasuschip.h"
+
+namespace Pegasus {
+
+PegasusChip::PegasusChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction), _recallSpot(kPegasusRecallSpotID) {
+	_recallSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 116, kAIMiddleAreaTop + 63, kAIMiddleAreaLeft + 184, kAIMiddleAreaTop + 91));
+	_recallSpot.setHotspotFlags(kPegasusBiochipSpotFlag);
+	g_allHotspots.push_back(&_recallSpot);
+	setItemState(kPegasusTSA00);
+}
+
+PegasusChip::~PegasusChip() {
+	g_allHotspots.removeOneHotspot(kPegasusRecallSpotID);
+}
+
+void PegasusChip::select() {
+	BiochipItem::select();
+	setUpPegasusChip();
+}
+
+void PegasusChip::setUpPegasusChip() {
+	switch (GameState.getCurrentNeighborhood()) {
+	case kCaldoriaID:
+		setItemState(kPegasusCaldoria);
+		break;
+	case kFullTSAID:
+	case kFinalTSAID:
+	case kTinyTSAID:
+		setItemState(kPegasusTSA10);
+		break;
+	case kPrehistoricID:
+		if (((PegasusEngine *)g_engine)->playerHasItemID(kHistoricalLog))
+			setItemState(kPegasusPrehistoric00);
+		else
+			setItemState(kPegasusPrehistoric10);
+		break;
+	case kMarsID:
+		if (GameState.getMarsFinished())
+			setItemState(kPegasusMars00);
+		else
+			setItemState(kPegasusMars10);
+		break;
+	case kWSCID:
+		if (GameState.getWSCFinished())
+			setItemState(kPegasusWSC00);
+		else
+			setItemState(kPegasusWSC10);
+		break;
+	case kNoradAlphaID:
+	case kNoradDeltaID:
+		if (GameState.getNoradFinished())
+			setItemState(kPegasusNorad00);
+		else
+			setItemState(kPegasusNorad10);
+		break;
+	}
+}
+
+// Only does something if the chip should be announcing that the time zone is finished...
+void PegasusChip::setUpPegasusChipRude() {
+	switch (GameState.getCurrentNeighborhood()) {
+	case kPrehistoricID:
+		if (((PegasusEngine *)g_engine)->playerHasItemID(kHistoricalLog))
+			setItemState(kPegasusPrehistoric00);
+		break;
+	case kMarsID:
+		if (GameState.getMarsFinished())
+			setItemState(kPegasusMars00);
+		break;
+	case kWSCID:
+		if (GameState.getWSCFinished())
+			setItemState(kPegasusWSC00);
+		break;
+	case kNoradAlphaID:
+	case kNoradDeltaID:
+		if (GameState.getNoradFinished())
+			setItemState(kPegasusNorad00);
+		break;
+	}
+}
+
+void PegasusChip::activatePegasusHotspots() {
+	switch (GameState.getCurrentNeighborhood()) {
+	case kPrehistoricID:
+	case kMarsID:
+	case kWSCID:
+	case kNoradAlphaID:
+	case kNoradDeltaID:
+		_recallSpot.setActive();
+		break;
+	}
+}
+
+void PegasusChip::clickInPegasusHotspot() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	tItemState thisState = getItemState();
+	tItemState hiliteState;
+
+	switch (thisState) {
+	case kPegasusPrehistoric00:
+		hiliteState = kPegasusPrehistoric01;
+		break;
+	case kPegasusPrehistoric10:
+		hiliteState = kPegasusPrehistoric11;
+		break;
+	case kPegasusMars00:
+		hiliteState = kPegasusMars01;
+		break;
+	case kPegasusMars10:
+		hiliteState = kPegasusMars11;
+		break;
+	case kPegasusNorad00:
+		hiliteState = kPegasusNorad01;
+		break;
+	case kPegasusNorad10:
+		hiliteState = kPegasusNorad11;
+		break;
+	case kPegasusWSC00:
+		hiliteState = kPegasusWSC01;
+		break;
+	case kPegasusWSC10:
+		hiliteState = kPegasusWSC11;
+		break;
+	}
+
+	setItemState(hiliteState);
+
+	uint32 time = g_system->getMillis();
+	while (g_system->getMillis() < time + 500) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	setItemState(thisState);
+
+	if (!((Neighborhood *)g_neighborhood)->okayToJump())
+		return;
+
+	if (g_energyMonitor)
+		g_energyMonitor->stopEnergyDraining();
+	
+	if (GameState.getTSAState() == kPlayerWentToPrehistoric || GameState.allTimeZonesFinished())
+		vm->jumpToNewEnvironment(kFullTSAID, kTSA37, kNorth);
+	else
+		vm->jumpToNewEnvironment(kTinyTSAID, kTinyTSA37, kNorth);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/pegasuschip.h b/engines/pegasus/items/biochips/pegasuschip.h
new file mode 100755
index 0000000..1ee35b7
--- /dev/null
+++ b/engines/pegasus/items/biochips/pegasuschip.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_PEGASUSCHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_PEGASUSCHIP_H
+
+#include "pegasus/hotspot.h"
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+class PegasusChip : public BiochipItem {
+public:
+	PegasusChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~PegasusChip();
+
+	void select();
+
+	void setUpPegasusChip();
+
+	// Called to set up the Pegasus chip when the Pegasus chip is the current chip but does not
+	// own the center area.
+	void setUpPegasusChipRude();
+	void activatePegasusHotspots();
+	void clickInPegasusHotspot();
+
+protected:
+	Hotspot _recallSpot;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/inventory/airmask.cpp b/engines/pegasus/items/inventory/airmask.cpp
new file mode 100755
index 0000000..682927d
--- /dev/null
+++ b/engines/pegasus/items/inventory/airmask.cpp
@@ -0,0 +1,248 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+AirMask *g_airMask = 0;
+
+//	Based on full == 100, which is scale used by GetAirLeft().
+static const TimeValue kOxygenLowThreshold = 25;
+
+void AirMask::airMaskTimerExpired(FunctionPtr *, void *) {
+	if (g_neighborhood)
+		g_neighborhood->checkAirMask();
+}
+
+AirMask::AirMask(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		InventoryItem(id, neighborhood, room, direction), _toggleSpot(kAirMaskToggleSpotID) {
+	g_airMask = this;
+	_toggleSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 10, kAIMiddleAreaTop + 17, kAIMiddleAreaLeft + 110, kAIMiddleAreaTop + 57));
+	_toggleSpot.setHotspotFlags(kAirMaskSpotFlag);
+	g_allHotspots.push_back(&_toggleSpot);
+	setItemState(kAirMaskEmptyOff);
+	_oxygenTimer.primeFuse(0);
+	_oxygenTimer.setFunctionPtr(&airMaskTimerExpired, 0);
+}
+
+AirMask::~AirMask() {
+	g_allHotspots.removeOneHotspot(kAirMaskToggleSpotID);
+	g_airMask = 0;
+}
+
+void AirMask::writeToStream(Common::WriteStream *stream) {
+	InventoryItem::writeToStream(stream);
+	stream->writeUint32BE(_oxygenTimer.getTimeRemaining());
+}
+
+void AirMask::readFromStream(Common::ReadStream *stream) {	
+	_oxygenTimer.stopFuse();
+	InventoryItem::readFromStream(stream);
+	_oxygenTimer.primeFuse(stream->readUint32BE());
+}
+
+void AirMask::putMaskOn() {
+	tAirQuality airQuality;
+
+	if (g_neighborhood)
+		airQuality = g_neighborhood->getAirQuality(GameState.getCurrentRoom());
+	else
+		airQuality = kAirQualityGood;
+
+	uint airLevel = getAirLeft();
+	tItemState newState = getItemState();
+	tItemState oldState = newState;
+
+	if (airLevel == 0) {
+		newState = kAirMaskEmptyFilter;
+	} else if (airLevel <= kOxygenLowThreshold) {
+		if (airQuality == kAirQualityVacuum)
+			newState = kAirMaskLowOn;
+		else
+			newState = kAirMaskLowFilter;
+	} else {
+		if (airQuality == kAirQualityVacuum)
+			newState = kAirMaskFullOn;
+		else
+			newState = kAirMaskFullFilter;
+	}
+
+	if (newState != oldState)
+		setItemState(newState);
+}
+
+void AirMask::takeMaskOff() {	
+	uint airLevel = getAirLeft();
+	tItemState newState = getItemState();
+	tItemState oldState = newState;
+
+	if (airLevel == 0)
+		newState = kAirMaskEmptyOff;
+	else if (airLevel <= kOxygenLowThreshold)
+		newState = kAirMaskLowOff;
+	else
+		newState = kAirMaskFullOff;
+
+	if (newState != oldState)
+		setItemState(newState);
+}
+
+void AirMask::toggleItemState() {
+	if (isAirMaskInUse())
+		takeMaskOff();
+	else
+		putMaskOn();
+}
+
+void AirMask::airQualityChanged() {
+	if (isAirMaskInUse())
+		putMaskOn();
+	else
+		takeMaskOff();
+}
+
+void AirMask::setItemState(const tItemState newState) {
+	if (newState != getItemState()) {
+		InventoryItem::setItemState(newState);
+
+		switch (newState) {
+		case kAirMaskFullOn:
+		case kAirMaskLowOn:
+			if (!_oxygenTimer.isFuseLit()) {
+				_oxygenTimer.lightFuse();
+				startIdling();
+			}
+			break;
+		default:
+			if (_oxygenTimer.isFuseLit()) {
+				_oxygenTimer.stopFuse();
+				stopIdling();
+			}
+			break;
+		}
+
+		if (g_neighborhood)
+			g_neighborhood->checkAirMask();
+
+		g_AIArea->checkMiddleArea();
+	}
+}
+
+void AirMask::useIdleTime() {
+	if (getAirLeft() == 0)
+		setItemState(kAirMaskEmptyOff);
+	else if (getAirLeft() <= kOxygenLowThreshold)
+		setItemState(kAirMaskLowOn);
+}
+
+void AirMask::refillAirMask() {
+	switch (getItemState()) {
+		case kAirMaskEmptyOff:
+		case kAirMaskLowOff:
+			setItemState(kAirMaskFullOff);
+			break;
+		case kAirMaskEmptyFilter:
+		case kAirMaskLowFilter:
+			setItemState(kAirMaskFullFilter);
+			break;
+		case kAirMaskLowOn:
+			setItemState(kAirMaskFullOn);
+			break;
+	}
+
+	if (_oxygenTimer.isFuseLit()) {
+		_oxygenTimer.stopFuse();
+		_oxygenTimer.primeFuse(kOxyMaskFullTime);
+		_oxygenTimer.lightFuse();
+	} else {
+		_oxygenTimer.primeFuse(kOxyMaskFullTime);
+	}
+}
+
+//	Doesn't return 0 until the timer is actually at 0.
+uint AirMask::getAirLeft() {
+	return CLIP<int>(((_oxygenTimer.getTimeRemaining() * 100) + kOxyMaskFullTime - 1) / kOxyMaskFullTime, 0, 100);
+}
+
+bool AirMask::isAirMaskInUse() {
+	switch (getItemState()) {
+	case kAirMaskEmptyOff:
+	case kAirMaskLowOff:
+	case kAirMaskFullOff:
+		return false;
+		break;
+	default:
+		return true;
+		break;
+	}
+}
+
+bool AirMask::isAirMaskOn() {
+	switch (getItemState()) {
+	case kAirMaskLowOn:
+	case kAirMaskFullOn:
+		return true;
+		break;
+	default:
+		return false;
+		break;
+	}
+}
+
+bool AirMask::isAirFilterOn() {
+	switch (getItemState()) {
+	case kAirMaskEmptyFilter:
+	case kAirMaskLowFilter:
+	case kAirMaskFullFilter:
+		return true;
+		break;
+	default:
+		return false;
+		break;
+	}
+}
+
+void AirMask::addedToInventory() {
+	GameState.setMarsMaskOnFiller(false);
+}
+
+void AirMask::removedFromInventory() {
+	if (isAirMaskInUse())
+		toggleItemState();
+}
+
+void AirMask::activateAirMaskHotspots() {
+	_toggleSpot.setActive();
+}
+
+void AirMask::clickInAirMaskHotspot() {
+	toggleItemState();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventory/airmask.h b/engines/pegasus/items/inventory/airmask.h
new file mode 100755
index 0000000..0e71380
--- /dev/null
+++ b/engines/pegasus/items/inventory/airmask.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORY_AIRMASK_H
+#define PEGASUS_ITEMS_INVENTORY_AIRMASK_H
+
+#include "pegasus/hotspot.h"
+#include "pegasus/timers.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+class AirMask : public InventoryItem, private Idler {
+public:
+	AirMask(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~AirMask();
+
+	virtual void writeToStream(Common::WriteStream *);
+	virtual void readFromStream(Common::ReadStream *);
+
+	virtual void setItemState(const tItemState);
+	void putMaskOn();
+	void takeMaskOff();
+	void toggleItemState();
+	void airQualityChanged();
+
+	bool isAirMaskInUse();
+	bool isAirMaskOn();
+	bool isAirFilterOn();
+
+	void refillAirMask();
+
+	// Returns a percentage
+	uint getAirLeft();
+
+	void activateAirMaskHotspots();
+	void clickInAirMaskHotspot();
+
+protected:
+	static void airMaskTimerExpired(FunctionPtr *, void *);
+
+	virtual void removedFromInventory();
+	virtual void addedToInventory();
+	void useIdleTime();
+
+	Hotspot _toggleSpot;
+	FuseFunction _oxygenTimer;
+};
+
+extern AirMask *g_airMask;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
index ffa745a..17f0705 100755
--- a/engines/pegasus/items/inventory/inventoryitem.cpp
+++ b/engines/pegasus/items/inventory/inventoryitem.cpp
@@ -26,6 +26,7 @@
 #include "common/stream.h"
 
 #include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
 #include "pegasus/items/inventory/inventoryitem.h"
 
 namespace Pegasus {
@@ -90,13 +91,15 @@ TimeValue InventoryItem::getAnimationTime() const {
 void InventoryItem::select() {
 	Item::select();
 
-	// TODO: AI
+	if (g_AIArea)
+		g_AIArea->setAIAreaToTime(kInventorySignature, kLeftAreaSignature, getLeftAreaTime());
 }
 
 void InventoryItem::deselect() {
 	Item::deselect();
 
-	// TODO: AI
+	if (g_AIArea)
+		g_AIArea->setAIAreaToTime(kInventorySignature, kLeftAreaSignature, 0xffffffff);
 }
 
 void InventoryItem::getPanelTimes(TimeValue &start, TimeValue &stop) const {
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index e4f1b71..aba9741 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -30,8 +30,11 @@
 #include "pegasus/elements.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/surface.h"
+#include "pegasus/ai/ai_area.h"
 #include "pegasus/items/item.h"
 #include "pegasus/items/itemlist.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
 
 namespace Pegasus {
 
@@ -128,30 +131,20 @@ Item::~Item() {
 	delete[] _itemExtras.entries;
 }
 
-Common::Error Item::writeToStream(Common::WriteStream *stream) {
+void Item::writeToStream(Common::WriteStream *stream) {
 	stream->writeUint16BE(_itemNeighborhood);
 	stream->writeUint16BE(_itemRoom);
 	stream->writeByte(_itemDirection);
 	stream->writeUint16BE(_itemOwnerID);
 	stream->writeUint16BE(_itemState);
-
-	if (stream->err())
-		return Common::kWritingFailed;
-	
-	return Common::kNoError;
 }
 
-Common::Error Item::readFromStream(Common::ReadStream *stream) {
+void Item::readFromStream(Common::ReadStream *stream) {
 	_itemNeighborhood = stream->readUint16BE();
 	_itemRoom = stream->readUint16BE();
 	_itemDirection = stream->readByte();
 	_itemOwnerID = stream->readUint16BE();
 	_itemState = stream->readUint16BE();
-	
-	if (stream->err())
-		return Common::kReadingFailed;
-	
-	return Common::kNoError;
 }
 
 tActorID Item::getItemOwner() const {
@@ -181,7 +174,11 @@ tItemState Item::getItemState() const {
 void Item::setItemState(const tItemState state) {
 	if (state != _itemState) {
 		_itemState = state;
-		// TODO: Selection
+
+		if (getItemType() == kInventoryItemType && ((PegasusEngine *)g_engine)->getCurrentInventoryItem() == (InventoryItem *)this)
+			select();
+		else if (getItemType() == kBiochipItemType && ((PegasusEngine *)g_engine)->getCurrentBiochip() == (BiochipItem *)this)
+			select();
 	}
 }
 
@@ -224,14 +221,24 @@ TimeValue Item::getSharedAreaTime() const {
 void Item::select() {
 	_isSelected = true;
 
-	// TODO: AI
+	if (g_AIArea) {
+		if (getItemType() == kInventoryItemType)
+			g_AIArea->setAIAreaToTime(kInventorySignature, kMiddleAreaSignature, getSharedAreaTime());
+		else
+			g_AIArea->setAIAreaToTime(kBiochipSignature, kMiddleAreaSignature, getSharedAreaTime());
+	}
 }
 
 void Item::deselect() {
 	_isActive = false;
 	_isSelected = false;
 
-	// TODO: AI
+	if (g_AIArea) {
+		if (getItemType() == kInventoryItemType)
+			g_AIArea->setAIAreaToTime(kInventorySignature, kMiddleAreaSignature, 0xffffffff);
+		else
+			g_AIArea->setAIAreaToTime(kBiochipSignature, kMiddleAreaSignature, 0xffffffff);
+	}
 }
 
 void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state, TimeValue &time) {	
@@ -286,4 +293,13 @@ Sprite *Item::getDragSprite(const tDisplayElementID id) const {
 	return result;
 }
 
+TimeValue Item::getInfoLeftTime() const {
+	return _itemInfo.infoLeftTime;
+}
+
+void Item::getInfoRightTimes(TimeValue &start, TimeValue &stop) const {
+	start = _itemInfo.infoRightStart;
+	stop = _itemInfo.infoRightStop;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index 1373913..b74dfc4 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -294,8 +294,8 @@ public:
 	
 	// WriteToStream writes everything EXCEPT the item's ID.
 	// It is assumed that the calling function will write and read the ID.
-	virtual Common::Error writeToStream(Common::WriteStream *stream);
-	virtual Common::Error readFromStream(Common::ReadStream *stream);
+	virtual void writeToStream(Common::WriteStream *stream);
+	virtual void readFromStream(Common::ReadStream *stream);
 	
 	virtual tActorID getItemOwner() const;
 	virtual void setItemOwner(const tActorID owner);
@@ -312,7 +312,7 @@ public:
 	virtual tItemType getItemType() = 0;
 	
 	TimeValue getInfoLeftTime() const;
-	void getInfoRightTimes(TimeValue&, TimeValue&) const;
+	void getInfoRightTimes(TimeValue &, TimeValue &) const;
 	TimeValue getSharedAreaTime() const;
 
 	Sprite *getDragSprite(const tDisplayElementID) const;
diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
index 2b980d6..cbe4828 100755
--- a/engines/pegasus/items/itemlist.cpp
+++ b/engines/pegasus/items/itemlist.cpp
@@ -40,32 +40,22 @@ ItemList::ItemList() {
 ItemList::~ItemList() {
 }
 
-Common::Error ItemList::writeToStream(Common::WriteStream *stream) {
+void ItemList::writeToStream(Common::WriteStream *stream) {
 	stream->writeUint32BE(size());
 
 	for (ItemIterator it = begin(); it != end(); it++) {
 		stream->writeUint16BE((*it)->getObjectID());
 		(*it)->writeToStream(stream);
 	}
-
-	if (stream->err())
-		return Common::kWritingFailed;
-	
-	return Common::kNoError;
 }
 
-Common::Error ItemList::readFromStream(Common::ReadStream *stream) {
+void ItemList::readFromStream(Common::ReadStream *stream) {
 	uint32 itemCount = stream->readUint32BE();
 
 	for (uint32 i = 0; i < itemCount; i++) {
 		tItemID itemID = stream->readUint16BE();
 		g_allItems.findItemByID(itemID)->readFromStream(stream);
 	}
-
-	if (stream->err())
-		return Common::kReadingFailed;
-	
-	return Common::kNoError;
 }
 
 Item *ItemList::findItemByID(const tItemID id) {
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
index dd9a4ba..df31b5c 100755
--- a/engines/pegasus/items/itemlist.h
+++ b/engines/pegasus/items/itemlist.h
@@ -44,8 +44,8 @@ public:
 	ItemList();
 	virtual ~ItemList();
 	
-	virtual Common::Error writeToStream(Common::WriteStream *stream);
-	virtual Common::Error readFromStream(Common::ReadStream *stream);
+	virtual void writeToStream(Common::WriteStream *stream);
+	virtual void readFromStream(Common::ReadStream *stream);
 	
 	Item *findItemByID(const tItemID id);
 };
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2909a22..3af207f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -20,11 +20,19 @@ MODULE_OBJS = \
 	timers.o \
 	transition.o \
 	util.o \
+	ai/ai_action.o \
+	ai/ai_area.o \
+	ai/ai_condition.o \
+	ai/ai_rule.o \
 	items/inventory.o \
 	items/inventorypicture.o \
 	items/item.o \
 	items/itemlist.o \
+	items/biochips/aichip.o \
 	items/biochips/biochipitem.o \
+	items/biochips/opticalchip.o \
+	items/biochips/pegasuschip.o \
+	items/inventory/airmask.o \
 	items/inventory/inventoryitem.o \
 	neighborhood/door.o \
 	neighborhood/exit.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 75a8df9..6f0bf79 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -33,10 +33,13 @@
 
 namespace Pegasus {
 
+Neighborhood *g_neighborhood = 0;
+
 Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 	_interruptionFilter = kFilterAllInput;
+	g_neighborhood = this;
 }
 
 Neighborhood::~Neighborhood() {
@@ -44,6 +47,7 @@ Neighborhood::~Neighborhood() {
 		g_allHotspots.remove(*it);
 
 	_neighborhoodHotspots.deleteHotspots();
+	g_neighborhood = 0;
 }
 
 void Neighborhood::init() {
@@ -389,4 +393,46 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2) {
 	return !operator==(arg1, arg2);
 }
 
+Common::String Neighborhood::getBriefingMovie() {
+	// TODO: Interaction check
+
+	return Common::String();
+}
+
+Common::String Neighborhood::getEnvScanMovie() {
+	// TODO: Interaction check
+
+	return Common::String();
+}
+
+uint Neighborhood::getNumHints() {
+	// TODO: Interaction check
+
+	return 0;
+}
+
+Common::String Neighborhood::getHintMovie(uint hintNum) {
+	// TODO: Interaction check
+
+	return Common::String();
+}
+
+bool Neighborhood::canSolve() {
+	// TODO: Interaction check
+
+	return false;
+}
+
+void Neighborhood::doSolve() {
+	// TODO: Interaction check
+}
+
+bool Neighborhood::okayToJump() {
+	return !_vm->playerHasItemID(kGasCanister) && !_vm->playerHasItemID(kMachineGun);
+}
+
+tAirQuality Neighborhood::getAirQuality(const tRoomID) {
+	return kAirQualityGood;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index d294ffe..f421718 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -113,6 +113,20 @@ public:
 
 	virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
 
+	virtual Common::String getBriefingMovie();
+	virtual Common::String getEnvScanMovie();
+	virtual uint getNumHints();
+	virtual Common::String getHintMovie(uint);
+	virtual bool canSolve();
+	virtual void prepareForAIHint(const Common::String &) {}
+	virtual void cleanUpAfterAIHint(const Common::String &) {}
+	virtual void doSolve();
+
+	virtual bool okayToJump();
+
+	virtual tAirQuality getAirQuality(const tRoomID);
+	virtual void checkAirMask() {}
+
 protected:
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
 
@@ -146,6 +160,8 @@ protected:
 	tInputBits _interruptionFilter;
 };
 
+extern Neighborhood *g_neighborhood;
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 816d01c..1db0dc6 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -41,8 +41,13 @@
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
 #include "pegasus/items/itemlist.h"
+#include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/items/biochips/pegasuschip.h"
+#include "pegasus/items/inventory/airmask.h"
 #include "pegasus/items/inventory/inventoryitem.h"
+#include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
 
@@ -52,6 +57,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_saveAllowed = _loadAllowed = true;
 	_gameMenu = 0;
 	_deathReason = kDeathStranded;
+	_neighborhood = 0;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -178,16 +184,24 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 	case kInterfaceBiochip:
 		// Unused in game, but still in the data - no need to load it
 		break;
-	case kMapBiochip:
 	case kAIBiochip:
+		new AIChip(itemID, neighborhoodID, roomID, direction);
+		break;
 	case kPegasusBiochip:
+		new PegasusChip(itemID, neighborhoodID, roomID, direction);
+		break;
+	case kOpticalBiochip:
+		new OpticalChip(itemID, neighborhoodID, roomID, direction);
+		break;
+	case kMapBiochip:
 	case kRetinalScanBiochip:
 	case kShieldBiochip:
-	case kOpticalBiochip:
-		// TODO: Specialized biochip classes
+		// TODO: Rest of specialized biochip classes
 		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kAirMask:
+		new AirMask(itemID, neighborhoodID, roomID, direction);
+		break;
 	case kKeyCard:
 	case kGasCanister:
 		// TODO: Specialized inventory item classes
@@ -829,4 +843,97 @@ void PegasusEngine::resetEnergyDeathReason() {
 	_deathReason = kDeathStranded;
 }
 
+uint16 PegasusEngine::getSoundFXLevel() {
+	// TODO
+	return 0x100;
+}
+
+bool PegasusEngine::playerHasItem(const Item *item) {
+	return playerHasItemID(item->getObjectID());
+}
+
+bool PegasusEngine::playerHasItemID(const tItemID itemID) {
+	return itemInInventory(itemID) || itemInBiochips(itemID);
+}
+
+InventoryItem *PegasusEngine::getCurrentInventoryItem() {
+	// TODO
+	return 0;
+}
+
+bool PegasusEngine::itemInInventory(InventoryItem *item) {
+	return _items.itemInInventory(item);
+}
+
+bool PegasusEngine::itemInInventory(tItemID id) {
+	return _items.itemInInventory(id);
+}
+
+BiochipItem *PegasusEngine::getCurrentBiochip() {
+	// TODO
+	return 0;
+}
+
+bool PegasusEngine::itemInBiochips(BiochipItem *item) {
+	return _biochips.itemInInventory(item);
+}
+
+bool PegasusEngine::itemInBiochips(tItemID id) {
+	return _biochips.itemInInventory(id);
+}
+
+bool PegasusEngine::playerAlive() {
+	return (_shellNotification.getNotificationFlags() & kPlayerDiedFlag) == 0;
+}
+
+Common::String PegasusEngine::getBriefingMovie() {
+	if (_neighborhood)
+		return _neighborhood->getBriefingMovie();
+
+	return Common::String();
+}
+
+Common::String PegasusEngine::getEnvScanMovie() {
+	if (_neighborhood)
+		return _neighborhood->getEnvScanMovie();
+
+	return Common::String();
+}
+
+uint PegasusEngine::getNumHints() {
+	if (_neighborhood)
+		return _neighborhood->getNumHints();
+
+	return 0;
+}
+
+Common::String PegasusEngine::getHintMovie(uint hintNum) {
+	if (_neighborhood)
+		return _neighborhood->getHintMovie(hintNum);
+
+	return Common::String();
+}
+
+bool PegasusEngine::canSolve() {
+	if (_neighborhood)
+		return _neighborhood->canSolve();
+
+	return false;
+}
+
+void PegasusEngine::prepareForAIHint(const Common::String &movieName) {
+	if (g_neighborhood)
+		g_neighborhood->prepareForAIHint(movieName);
+}
+
+void PegasusEngine::cleanUpAfterAIHint(const Common::String &movieName) {
+	if (g_neighborhood)
+		g_neighborhood->cleanUpAfterAIHint(movieName);
+}
+
+void PegasusEngine::jumpToNewEnvironment(const tNeighborhoodID neighborhoodID, const tRoomID roomID, const tDirectionConstant direction) {
+	GameState.setNextLocation(neighborhoodID, roomID, direction);
+	_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 2990811..e6902bf 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -53,6 +53,9 @@ class Idler;
 class Cursor;
 class TimeBase;
 class GameMenu;
+class InventoryItem;
+class BiochipItem;
+class Neighborhood;
 
 class PegasusEngine : public ::Engine, public InputHandler, public NotificationManager {
 friend class InputHandler;
@@ -73,6 +76,7 @@ public:
 	// Base classes
 	GraphicsManager *_gfx;
 	Common::MacResManager *_resFork;
+	Cursor *_cursor;
 
 	// Menu
 	void useMenu(GameMenu *menu);
@@ -84,11 +88,20 @@ public:
 	void removeIdler(Idler *idler);
 	void addTimeBase(TimeBase *timeBase);
 	void removeTimeBase(TimeBase *timeBase);
-	void swapSaveAllowed(bool allow) { _saveAllowed = allow; }
-	void swapLoadAllowed(bool allow) { _loadAllowed = allow; }
+	bool swapSaveAllowed(bool allow) {
+		bool old = _saveAllowed;
+		_saveAllowed = allow;
+		return old;
+	}
+	bool swapLoadAllowed(bool allow) {
+		bool old = _loadAllowed;
+		_loadAllowed = allow;
+		return old;
+	}
 	void delayShell(TimeValue time, TimeScale scale);
 	void resetIntroTimer();
 	void refreshDisplay();
+	bool playerAlive();
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
@@ -99,11 +112,38 @@ public:
 	tDeathReason getEnergyDeathReason() { return _deathReason; }
 	void resetEnergyDeathReason();
 
+	// Volume
+	uint16 getSoundFXLevel();
+
+	// Items
+	bool playerHasItem(const Item *);
+	bool playerHasItemID(const tItemID);
+
+	// Inventory Items
+	InventoryItem *getCurrentInventoryItem();
+	bool itemInInventory(InventoryItem *);
+	bool itemInInventory(tItemID);
+
+	// Biochips
+	BiochipItem *getCurrentBiochip();
+	bool itemInBiochips(BiochipItem *);
+	bool itemInBiochips(tItemID);
+
+	// AI
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+	bool canSolve();
+	void prepareForAIHint(const Common::String &);
+	void cleanUpAfterAIHint(const Common::String &);
+
+	// Neighborhood
+	void jumpToNewEnvironment(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+
 protected:
 	Common::Error run();
 
-	Cursor *_cursor;
-
 	Notification _shellNotification;
 	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
 
@@ -155,6 +195,9 @@ private:
 
 	// Death
 	tDeathReason _deathReason;
+
+	// Neighborhood
+	Neighborhood *_neighborhood;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index a40a2c1..4ad2df0 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -241,8 +241,8 @@ protected:
 
 class FuseFunction : public Fuse, public FunctionPtr {
 public:
-	FuseFunction();
-	virtual ~FuseFunction();
+	FuseFunction() {}
+	virtual ~FuseFunction() {}
 
 protected:
 	virtual void invokeAction() { callFunction(); }
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index 459c138..6369c49 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -23,8 +23,10 @@
  *
  */
 
-#ifndef PEGASUS_MMSHELL_MMIDOBJECT_H
-#define PEGASUS_MMSHELL_MMIDOBJECT_H
+#ifndef PEGASUS_UTIL_H
+#define PEGASUS_UTIL_H
+
+#include "common/stream.h"
 
 #include "pegasus/types.h"
 
@@ -63,6 +65,65 @@ protected:
 	void *_functionArg;
 };
 
+#define NUM_FLAGS (sizeof(Unit) * 8)
+#define BIT_INDEX_SHIFT (sizeof(Unit) + 2 - (sizeof(Unit)) / 3)
+#define BIT_INDEX_MASK (NUM_FLAGS - 1)
+
+template <typename Unit, uint32 kNumFlags>
+class FlagsArray {
+public:
+	FlagsArray() { clearAllFlags(); }
+	void clearAllFlags() { memset(_flags, 0, sizeof(_flags)); }
+	void setAllFlags() { memset(_flags, ~((Unit)0), sizeof(_flags)); }
+	void setFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] |= 1 << (flag & BIT_INDEX_MASK); }
+	void clearFlag(uint32 flag) { _flags[flag >> BIT_INDEX_SHIFT] &= ~(1 << (flag & BIT_INDEX_MASK)); }
+	void setFlag(uint32 flag, bool val) { if (val) setFlag(flag); else clearFlag(flag); }
+	bool getFlag(uint32 flag) { return (_flags[flag >> BIT_INDEX_SHIFT] & (1 << (flag & BIT_INDEX_MASK))) != 0; }
+	bool anyFlagSet() {
+		for (uint32 i = 0; i < sizeof(_flags); i++)
+			if (_flags[i] != 0)
+				return true;
+		return false;
+	}
+
+	void readFromStream(Common::ReadStream *stream) {
+		// Shortcut
+		if (sizeof(Unit) == 1) {
+			stream->read(_flags, sizeof(_flags));
+			return;
+		}
+
+		for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
+			if (sizeof(Unit) == 2)
+				_flags[i] = stream->readUint16BE();
+			else /* if (sizeof(Unit) == 4) */
+				_flags[i] = stream->readUint32BE();
+		}
+	}
+
+	void writeToStream(Common::WriteStream *stream) {
+		// Shortcut
+		if (sizeof(Unit) == 1) {
+			stream->write(_flags, sizeof(_flags));
+			return;
+		}
+
+		for (uint32 i = 0; i < ARRAYSIZE(_flags); i++) {
+			if (sizeof(Unit) == 2)
+				stream->writeUint16BE(_flags[i]);
+			else /* if (sizeof(Unit) == 4) */
+				stream->writeUint32BE(_flags[i]);
+		}
+	}
+
+private:
+	Unit _flags[(kNumFlags - 1) / NUM_FLAGS + 1];
+};
+
+#undef NUM_FLAGS;
+#undef BIT_INDEX_SHIFT
+#undef BIT_INDEX_MASK
+
 int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2);
 
 void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random);


Commit: 5275e16849d4c8da65ec6a6f9b900c8b2b4ed0be
    https://github.com/scummvm/scummvm/commit/5275e16849d4c8da65ec6a6f9b900c8b2b4ed0be
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T12:29:42-07:00

Commit Message:
PEGASUS: Add remaining specialized inventory items

Changed paths:
  A engines/pegasus/items/inventory/gascanister.cpp
  A engines/pegasus/items/inventory/gascanister.h
  A engines/pegasus/items/inventory/keycard.cpp
  A engines/pegasus/items/inventory/keycard.h
    engines/pegasus/items/item.cpp
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/inventory/gascanister.cpp b/engines/pegasus/items/inventory/gascanister.cpp
new file mode 100755
index 0000000..b6cd883
--- /dev/null
+++ b/engines/pegasus/items/inventory/gascanister.cpp
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/inventory/gascanister.h"
+
+namespace Pegasus {
+
+GasCanister::GasCanister(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		InventoryItem(id, neighborhood, room, direction) {
+}
+
+void GasCanister::select() {
+	InventoryItem::select();
+	takeSharedArea();
+}
+
+void GasCanister::takeSharedArea() {
+	ItemExtraEntry entry;
+	findItemExtra(kGasCanLoop, entry);
+	g_AIArea->loopAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventory/gascanister.h b/engines/pegasus/items/inventory/gascanister.h
new file mode 100755
index 0000000..437df12
--- /dev/null
+++ b/engines/pegasus/items/inventory/gascanister.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORY_GASCANISTER_H
+#define PEGASUS_ITEMS_INVENTORY_GASCANISTER_H
+
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+class GasCanister : public InventoryItem {
+public:
+	GasCanister(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~GasCanister() {}
+	
+	void select();
+	void takeSharedArea();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/inventory/keycard.cpp b/engines/pegasus/items/inventory/keycard.cpp
new file mode 100755
index 0000000..53a3f67
--- /dev/null
+++ b/engines/pegasus/items/inventory/keycard.cpp
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/items/inventory/keycard.h"
+
+namespace Pegasus {
+
+KeyCard::KeyCard(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+			InventoryItem(id, neighborhood, room, direction) {
+	setItemState(kFlashlightOff);
+}
+
+void KeyCard::toggleItemState() {
+	if (getItemState() == kFlashlightOff)
+		setItemState(kFlashlightOn);
+	else
+		setItemState(kFlashlightOff);
+}
+
+void KeyCard::setItemState(const tItemState newState) {
+	if (newState != getItemState()) {
+		InventoryItem::setItemState(newState);
+		((PegasusEngine *)g_engine)->checkFlashlight();
+	}
+}
+
+bool KeyCard::isFlashlightOn() {
+	return getItemState() == kFlashlightOn;
+}
+
+void KeyCard::removedFromInventory() {
+	if (isFlashlightOn())
+		setItemState(kFlashlightOff);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/inventory/keycard.h b/engines/pegasus/items/inventory/keycard.h
new file mode 100755
index 0000000..7fdb905
--- /dev/null
+++ b/engines/pegasus/items/inventory/keycard.h
@@ -0,0 +1,48 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_INVENTORY_KEYCARD_H
+#define PEGASUS_ITEMS_INVENTORY_KEYCARD_H
+
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+class KeyCard : public InventoryItem {
+public:
+	KeyCard(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~KeyCard() {}
+	
+	virtual void toggleItemState();
+	virtual void setItemState(const tItemState);
+	bool isFlashlightOn();
+
+protected:
+	virtual void removedFromInventory();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index aba9741..e20549e 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -302,4 +302,13 @@ void Item::getInfoRightTimes(TimeValue &start, TimeValue &stop) const {
 	stop = _itemInfo.infoRightStop;
 }
 
+void Item::findItemExtra(const uint32 extraID, ItemExtraEntry &entry) {
+	for (uint32 i = 0; i < _itemExtras.numEntries; i++) {
+		if (_itemExtras.entries[i].extraID == extraID) {
+			entry = _itemExtras.entries[i];
+			return;
+		}
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 3af207f..0bac02d 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -33,7 +33,9 @@ MODULE_OBJS = \
 	items/biochips/opticalchip.o \
 	items/biochips/pegasuschip.o \
 	items/inventory/airmask.o \
+	items/inventory/gascanister.o \
 	items/inventory/inventoryitem.o \
+	items/inventory/keycard.o \
 	neighborhood/door.o \
 	neighborhood/exit.o \
 	neighborhood/extra.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index f421718..cf5abfb 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -126,6 +126,7 @@ public:
 
 	virtual tAirQuality getAirQuality(const tRoomID);
 	virtual void checkAirMask() {}
+	virtual void checkFlashlight() {}
 
 protected:
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 1db0dc6..045c9f8 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -46,7 +46,9 @@
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/items/biochips/pegasuschip.h"
 #include "pegasus/items/inventory/airmask.h"
+#include "pegasus/items/inventory/gascanister.h"
 #include "pegasus/items/inventory/inventoryitem.h"
+#include "pegasus/items/inventory/keycard.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
@@ -203,9 +205,10 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 		new AirMask(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kKeyCard:
+		new KeyCard(itemID, neighborhoodID, roomID, direction);
+		break;
 	case kGasCanister:
-		// TODO: Specialized inventory item classes
-		new InventoryItem(itemID, neighborhoodID, roomID, direction);
+		new GasCanister(itemID, neighborhoodID, roomID, direction);
 		break;
 	default:
 		// Everything else is a normal inventory item
@@ -936,4 +939,9 @@ void PegasusEngine::jumpToNewEnvironment(const tNeighborhoodID neighborhoodID, c
 	_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
 }
 
+void PegasusEngine::checkFlashlight() {
+	if (_neighborhood)
+		_neighborhood->checkFlashlight();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index e6902bf..4bd81f4 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -118,6 +118,7 @@ public:
 	// Items
 	bool playerHasItem(const Item *);
 	bool playerHasItemID(const tItemID);
+	void checkFlashlight();
 
 	// Inventory Items
 	InventoryItem *getCurrentInventoryItem();


Commit: 8de524b073aa5895b662a54e4430e77fbe491d60
    https://github.com/scummvm/scummvm/commit/8de524b073aa5895b662a54e4430e77fbe491d60
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T12:31:32-07:00

Commit Message:
PEGASUS: Create the Interface biochip even if it's not used

Still needed for saves

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 045c9f8..22d2d86 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -184,7 +184,9 @@ void PegasusEngine::createItems() {
 void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction) {
 	switch (itemID) {
 	case kInterfaceBiochip:
-		// Unused in game, but still in the data - no need to load it
+		// Unused in game, but still in the data and we need to create
+		// it because it's saved/loaded from save files.
+		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kAIBiochip:
 		new AIChip(itemID, neighborhoodID, roomID, direction);


Commit: 5f0f9dae357505d29acd349597646a510f184f2c
    https://github.com/scummvm/scummvm/commit/5f0f9dae357505d29acd349597646a510f184f2c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T13:19:03-07:00

Commit Message:
PEGASUS: Add retscan/shield biochips

Changed paths:
  A engines/pegasus/items/biochips/retscanchip.cpp
  A engines/pegasus/items/biochips/retscanchip.h
  A engines/pegasus/items/biochips/shieldchip.cpp
  A engines/pegasus/items/biochips/shieldchip.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/items/biochips/retscanchip.cpp b/engines/pegasus/items/biochips/retscanchip.cpp
new file mode 100755
index 0000000..e990405
--- /dev/null
+++ b/engines/pegasus/items/biochips/retscanchip.cpp
@@ -0,0 +1,49 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/retscanchip.h"
+
+namespace Pegasus {
+
+RetScanChip::RetScanChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction) {
+}
+
+void RetScanChip::searchForLaser() {
+	ItemExtraEntry entry;
+	findItemExtra(kRetinalScanSearching, entry);
+
+	if (g_AIArea)
+		g_AIArea->playAIAreaSequence(kBiochipSignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
+
+	findItemExtra(kRetinalScanActivated, entry);
+	if (g_AIArea)
+		g_AIArea->playAIAreaSequence(kBiochipSignature, kRightAreaSignature, entry.extraStart, entry.extraStop);
+
+	setItemState(kRetinalSimulating);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/retscanchip.h b/engines/pegasus/items/biochips/retscanchip.h
new file mode 100755
index 0000000..7d8fe6d
--- /dev/null
+++ b/engines/pegasus/items/biochips/retscanchip.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_RETSCANCHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_RETSCANCHIP_H
+
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+class RetScanChip : public BiochipItem {
+public:
+	RetScanChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~RetScanChip() {}
+	
+	void searchForLaser();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/biochips/shieldchip.cpp b/engines/pegasus/items/biochips/shieldchip.cpp
new file mode 100755
index 0000000..4bd0572
--- /dev/null
+++ b/engines/pegasus/items/biochips/shieldchip.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/items/biochips/shieldchip.h"
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+ShieldChip *g_shield = 0;
+
+ShieldChip::ShieldChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction) {
+	g_shield = this;
+}
+
+void ShieldChip::select() {
+	BiochipItem::select();
+	GameState.setShieldOn(true);
+	if (g_neighborhood)
+		g_neighborhood->shieldOn();
+}
+
+void ShieldChip::deselect() {
+	BiochipItem::deselect();
+	GameState.setShieldOn(false);
+	if (g_neighborhood)
+		g_neighborhood->shieldOff();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/shieldchip.h b/engines/pegasus/items/biochips/shieldchip.h
new file mode 100755
index 0000000..c0b9cc5
--- /dev/null
+++ b/engines/pegasus/items/biochips/shieldchip.h
@@ -0,0 +1,46 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_SHIELDCHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_SHIELDCHIP_H
+
+#include "pegasus/items/biochips/biochipitem.h"
+
+namespace Pegasus {
+
+class ShieldChip : public BiochipItem {
+public:
+	ShieldChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~ShieldChip() {}
+
+	void select();
+	void deselect();
+};
+
+extern ShieldChip *g_shield;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 0bac02d..2636b6c 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -32,6 +32,8 @@ MODULE_OBJS = \
 	items/biochips/biochipitem.o \
 	items/biochips/opticalchip.o \
 	items/biochips/pegasuschip.o \
+	items/biochips/retscanchip.o \
+	items/biochips/shieldchip.o \
 	items/inventory/airmask.o \
 	items/inventory/gascanister.o \
 	items/inventory/inventoryitem.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index cf5abfb..fcfc833 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -30,6 +30,7 @@
 #include "common/str.h"
 
 #include "pegasus/hotspot.h"
+#include "pegasus/input.h"
 #include "pegasus/notification.h"
 #include "pegasus/sound.h"
 #include "pegasus/util.h"
@@ -127,6 +128,8 @@ public:
 	virtual tAirQuality getAirQuality(const tRoomID);
 	virtual void checkAirMask() {}
 	virtual void checkFlashlight() {}
+	virtual void shieldOn() {}
+	virtual void shieldOff() {}
 
 protected:
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 22d2d86..9198f37 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -45,6 +45,8 @@
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/items/biochips/pegasuschip.h"
+#include "pegasus/items/biochips/retscanchip.h"
+#include "pegasus/items/biochips/shieldchip.h"
 #include "pegasus/items/inventory/airmask.h"
 #include "pegasus/items/inventory/gascanister.h"
 #include "pegasus/items/inventory/inventoryitem.h"
@@ -198,11 +200,15 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 		new OpticalChip(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kMapBiochip:
-	case kRetinalScanBiochip:
-	case kShieldBiochip:
-		// TODO: Rest of specialized biochip classes
+		// TODO: Implement this biochip
 		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 		break;
+	case kRetinalScanBiochip:
+		new RetScanChip(itemID, neighborhoodID, roomID, direction);
+		break;
+	case kShieldBiochip:
+		new ShieldChip(itemID, neighborhoodID, roomID, direction);
+		break;		
 	case kAirMask:
 		new AirMask(itemID, neighborhoodID, roomID, direction);
 		break;


Commit: 0b83e0c4911bfbddac394df2da2fe3e221bb350c
    https://github.com/scummvm/scummvm/commit/0b83e0c4911bfbddac394df2da2fe3e221bb350c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T19:54:54-07:00

Commit Message:
PEGASUS: Add the compass class

Changed paths:
  A engines/pegasus/compass.cpp
  A engines/pegasus/compass.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/compass.cpp b/engines/pegasus/compass.cpp
new file mode 100755
index 0000000..3772827
--- /dev/null
+++ b/engines/pegasus/compass.cpp
@@ -0,0 +1,82 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/compass.h"
+
+namespace Pegasus {
+
+Compass *g_compass = 0;
+
+Compass::Compass() : FaderAnimation(kCompassID) {
+	// Initialize it to east...
+	setFaderValue(90);
+	g_compass = this;
+}
+
+Compass::~Compass() {
+	g_compass = 0;
+}
+
+void Compass::initCompass() {
+	if (!isCompassValid()) {
+		Common::Rect r;
+		_compassImage.initFromPICTFile("Images/Compass/Compass");
+		_compassImage.getSurfaceBounds(r);
+		r.right = kCompassWidth;
+		setBounds(r);
+	}
+}
+
+void Compass::deallocateCompass() {
+	_compassImage.deallocateSurface();
+}
+
+void Compass::setFaderValue(const uint32 angle) {
+	int16 a = (int32)angle % 360;
+
+	if (a < 0)
+		a += 360;
+
+	FaderAnimation::setFaderValue(a);
+}
+
+void Compass::draw(const Common::Rect &r1) {	
+	if (_compassImage.isSurfaceValid()) {
+		Common::Rect bounds;
+		getBounds(bounds);
+
+		Common::Rect r2;
+		_compassImage.getSurfaceBounds(r2);
+
+		tCoordType width = r2.width();
+		tCoordType offsetH = width / 10 - bounds.width() / 2 + (getFaderValue() * width) / 450 - bounds.left;
+		tCoordType offsetV = -bounds.top;
+		r2 = r1;
+		r2.translate(offsetH, offsetV);
+		_compassImage.drawImage(r2, r1);
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/compass.h b/engines/pegasus/compass.h
new file mode 100755
index 0000000..f669dd3
--- /dev/null
+++ b/engines/pegasus/compass.h
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_COMPASS_H
+#define PEGASUS_COMPASS_H
+
+#include "pegasus/fader.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+ 
+// Compass is defined with 0 as north, 90 east, 180 south, 270 west.
+// Clockwise rotation increases the angle, counterclockwise rotation decreases the angle.
+
+class Compass : public FaderAnimation {
+public:
+	Compass();
+	virtual ~Compass();
+	
+	void initCompass();
+	void deallocateCompass();
+	bool isCompassValid() const { return _compassImage.isSurfaceValid(); }
+	
+	void setFaderValue(const uint32);
+
+protected:
+	void draw(const Common::Rect &);
+
+	Frame _compassImage;
+};
+
+extern Compass *g_compass;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2636b6c..2c784cd 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -1,6 +1,7 @@
 MODULE := engines/pegasus
 
 MODULE_OBJS = \
+	compass.o \
 	console.o \
 	cursor.o \
 	detection.o \


Commit: 647c83b514f1c942eaf71f838c0afd848c547b91
    https://github.com/scummvm/scummvm/commit/647c83b514f1c942eaf71f838c0afd848c547b91
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-24T21:42:33-07:00

Commit Message:
PEGASUS: Add the interface class

Changed paths:
  A engines/pegasus/interface.cpp
  A engines/pegasus/interface.h
    engines/pegasus/fader.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
index 5ca1a5c..fe5b1ae 100755
--- a/engines/pegasus/fader.h
+++ b/engines/pegasus/fader.h
@@ -71,7 +71,7 @@ protected:
 	FaderKnot _knots[kMaxFaderKnots];
 };
 
-class Fader : private IdlerTimeBase {
+class Fader : public IdlerTimeBase {
 public:
 	Fader();
 	virtual ~Fader() {}
diff --git a/engines/pegasus/interface.cpp b/engines/pegasus/interface.cpp
new file mode 100755
index 0000000..10a1042
--- /dev/null
+++ b/engines/pegasus/interface.cpp
@@ -0,0 +1,659 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/compass.h"
+#include "pegasus/energymonitor.h"
+#include "pegasus/interface.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/inventory/inventoryitem.h"
+
+namespace Pegasus {
+
+Interface *g_interface = 0;
+
+Interface::Interface() : InputHandler(0), _interfaceNotification(kInterfaceNotificationID, (NotificationManager *)((PegasusEngine *)g_engine)),
+			_currentItemSpot(kCurrentItemSpotID), _currentBiochipSpot(kCurrentBiochipSpotID),
+			_background1(kInterface1ID), _background2(kInterface2ID), _background3(kInterface3ID),
+			_background4(kInterface4ID), _datePicture(kDateID), _inventoryPush(kInventoryPushID),
+			_inventoryLid(kInventoryLidID, kNoDisplayElement),
+			_inventoryPanel(kNoDisplayElement, (InputHandler *)((PegasusEngine *)g_engine), ((PegasusEngine *)g_engine)->getItemsInventory()),
+			_biochipPush(kBiochipPushID), _biochipLid(kBiochipLidID, kNoDisplayElement),
+			_biochipPanel(kNoDisplayElement, (InputHandler *)((PegasusEngine *)g_engine), ((PegasusEngine *)g_engine)->getBiochipsInventory()) {
+	g_energyMonitor = 0;
+	_previousHandler = 0;
+	_inventoryRaised = false;
+	_biochipRaised = false;
+	_playingEndMessage = false;
+	g_interface = this;
+}
+
+Interface::~Interface() {
+	throwAwayInterface();
+	g_interface = 0;
+}
+
+void Interface::throwAwayInterface() {
+	g_allHotspots.removeOneHotspot(kCurrentItemSpotID);
+	g_allHotspots.removeOneHotspot(kCurrentBiochipSpotID);
+
+	throwAwayBackground();
+	throwAwayDateMonitor();
+	throwAwayEnergyMonitor();
+	throwAwayAIArea();
+	throwAwayCompass();
+	throwAwayNotifications();
+	throwAwayInventoryPanel();
+	throwAwayBiochipPanel();
+}
+
+void Interface::validateBackground() {
+	if (!_background1.isSurfaceValid()) {
+		_background1.initFromPICTFile("Images/Interface/3DInterface Left");
+		_background2.initFromPICTFile("Images/Interface/3DInterface Top");
+		_background3.initFromPICTFile("Images/Interface/3DInterface Right");
+		_background4.initFromPICTFile("Images/Interface/3DInterface Bottom");
+
+		_background1.setDisplayOrder(kBackground1Order);
+		_background1.startDisplaying();
+		_background1.moveElementTo(kBackground1Left, kBackground1Top);
+
+		_background2.setDisplayOrder(kBackground2Order);
+		_background2.startDisplaying();
+		_background2.moveElementTo(kBackground2Left, kBackground2Top);
+
+		_background3.setDisplayOrder(kBackground2Order);
+		_background3.startDisplaying();
+		_background3.moveElementTo(kBackground3Left, kBackground3Top);
+
+		_background4.setDisplayOrder(kBackground4Order);
+		_background4.startDisplaying();
+		_background4.moveElementTo(kBackground4Left, kBackground4Top);
+
+		_background1.show();
+		_background2.show();
+		_background3.show();
+		_background4.show();
+	}
+}
+
+void Interface::throwAwayBackground() {
+	_background1.stopDisplaying();
+	_background1.deallocateSurface();
+	_background2.stopDisplaying();
+	_background2.deallocateSurface();
+	_background3.stopDisplaying();
+	_background3.deallocateSurface();
+	_background4.stopDisplaying();
+	_background4.deallocateSurface();
+}
+
+void Interface::validateDateMonitor() {
+	if (!_datePicture.isSurfaceValid()) {
+		_datePicture.setDisplayOrder(kDateOrder);
+		_datePicture.startDisplaying();
+		_datePicture.moveElementTo(kDateLeft, kDateTop);
+		_datePicture.show();
+	}
+}
+
+void Interface::throwAwayDateMonitor() {
+	_datePicture.stopDisplaying();
+	_datePicture.deallocateSurface();
+}
+
+void Interface::setDate(const uint16 dateResID) {
+	validateDateMonitor();
+	_datePicture.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, dateResID);
+	_datePicture.triggerRedraw();
+}
+
+void Interface::validateCompass() {
+	if (g_compass) {
+		new Compass();
+		g_compass->initCompass();
+		g_compass->setDisplayOrder(kCompassOrder);
+		g_compass->startDisplaying();
+		g_compass->moveElementTo(kCompassLeft, kCompassTop);
+		g_compass->show();
+	}
+}
+
+void Interface::throwAwayCompass() {
+	delete g_compass;
+}
+
+void Interface::validateNotifications() {
+	_interfaceNotification.notifyMe(this, kInterfaceNotificationFlags, kInterfaceNotificationFlags);
+	_inventoryLidCallBack.setNotification(&_interfaceNotification);
+	_inventoryPushCallBack.setNotification(&_interfaceNotification);
+	_biochipLidCallBack.setNotification(&_interfaceNotification);
+	_biochipPushCallBack.setNotification(&_interfaceNotification);
+}
+
+void Interface::throwAwayNotifications() {
+	_interfaceNotification.cancelNotification(this);
+}
+
+void Interface::validateAIArea() {
+	if (!g_AIArea) {
+		new AIArea((InputHandler *)((PegasusEngine *)g_engine));
+		if (g_AIArea)
+			g_AIArea->initAIArea();
+	}
+}
+
+void Interface::throwAwayAIArea() {
+	delete g_AIArea;
+}
+
+void Interface::validateInventoryPanel() {	
+	if (!_inventoryPanel.isSurfaceValid()) {
+		_inventoryPanel.initInventoryImage(&_inventoryPush);
+		_inventoryPanel.moveElementTo(kInventoryPushLeft, kInventoryPushTop);
+		_inventoryPush.setSlideDirection(kSlideUpMask);
+		_inventoryPush.setInAndOutElements(&_inventoryPanel, 0);
+		_inventoryPush.setDisplayOrder(kInventoryPushOrder);
+		_inventoryPush.startDisplaying();
+
+		_inventoryLid.useFileName("Images/Lids/Inventory Lid Sequence");
+		_inventoryLid.useTransparent(true);
+		_inventoryLid.openFrameSequence();
+		_inventoryLid.moveElementTo(kInventoryLidLeft, kInventoryLidTop);
+		_inventoryLid.setDisplayOrder(kInventoryLidOrder);
+		_inventoryLid.startDisplaying();
+
+		_inventoryPushCallBack.initCallBack(&_inventoryPush, kCallBackAtExtremes);
+		_inventoryLidCallBack.initCallBack(&_inventoryLid, kCallBackAtExtremes);
+
+		_inventoryUp = false;
+		_inventoryRaised = false;
+
+		Item *item = getCurrentInventoryItem();
+		if (item)
+			item->select();
+	}
+}
+
+void Interface::throwAwayInventoryPanel() {
+	_inventoryPanel.stopDisplaying();
+	_inventoryPanel.throwAwayInventoryImage();
+	_inventoryPush.stopDisplaying();
+	_inventoryLid.stopDisplaying();
+	_inventoryLid.closeFrameSequence();
+	_inventoryPushCallBack.releaseCallBack();
+	_inventoryLidCallBack.releaseCallBack();
+
+	Item *item = getCurrentInventoryItem();
+	if (item)
+		item->deselect();
+
+	_inventoryUp = false;
+	_inventoryRaised = false;
+}
+
+void Interface::validateBiochipPanel() {	
+	if (!_biochipPanel.isSurfaceValid()) {
+		_biochipPanel.initInventoryImage(&_biochipPush);
+		_biochipPanel.moveElementTo(kBiochipPushLeft, kBiochipPushTop);
+		_biochipPush.setSlideDirection(kSlideUpMask);
+		_biochipPush.setInAndOutElements(&_biochipPanel, 0);
+		_biochipPush.setDisplayOrder(kBiochipPushOrder);
+		_biochipPush.startDisplaying();
+
+		_biochipLid.useFileName("Images/Lids/Biochip Lid Sequence");
+		_biochipLid.useTransparent(true);
+		_biochipLid.openFrameSequence();
+		_biochipLid.moveElementTo(kBiochipLidLeft, kBiochipLidTop);
+		_biochipLid.setDisplayOrder(kBiochipLidOrder);
+		_biochipLid.startDisplaying();
+
+		_biochipPushCallBack.initCallBack(&_biochipPush, kCallBackAtExtremes);
+		_biochipLidCallBack.initCallBack(&_biochipLid, kCallBackAtExtremes);
+
+		_biochipUp = false;
+		_biochipRaised = false;
+
+		Item *item = getCurrentBiochip();
+		if (item)
+			item->select();
+	}
+}
+
+void Interface::throwAwayBiochipPanel() {	
+	_biochipPanel.stopDisplaying();
+	_biochipPanel.throwAwayInventoryImage();
+	_biochipPush.stopDisplaying();
+	_biochipLid.stopDisplaying();
+	_biochipLid.closeFrameSequence();
+	_biochipPushCallBack.releaseCallBack();
+	_biochipLidCallBack.releaseCallBack();
+	
+	Item *item = getCurrentBiochip();
+	if (item)
+		item->deselect();
+	
+	_biochipUp = false;
+	_biochipRaised = false;
+}
+
+void Interface::validateEnergyMonitor() {
+	if (!g_energyMonitor)
+		new EnergyMonitor();
+}
+
+void Interface::throwAwayEnergyMonitor() {
+	delete g_energyMonitor;
+}
+
+void Interface::createInterface() {
+	validateBackground();
+	validateDateMonitor();
+	validateCompass();
+	validateNotifications();
+	validateAIArea();
+	validateBiochipPanel();
+	validateInventoryPanel();
+	validateEnergyMonitor();
+
+	if (!g_allHotspots.findHotspotByID(kCurrentItemSpotID)) {
+		_currentItemSpot.setArea(Common::Rect(76, 334, 172, 430));
+		_currentItemSpot.setHotspotFlags(kShellSpotFlag);
+		_currentItemSpot.setActive();
+		g_allHotspots.push_back(&_currentItemSpot);
+	}
+
+	if (!g_allHotspots.findHotspotByID(kCurrentBiochipSpotID)) {
+		_currentBiochipSpot.setArea(Common::Rect(364, 334, 460, 430));
+		_currentBiochipSpot.setHotspotFlags(kShellSpotFlag);
+		_currentBiochipSpot.setActive();
+		g_allHotspots.push_back(&_currentBiochipSpot);
+	}
+}
+
+tInventoryResult Interface::addInventoryItem(InventoryItem *item) {
+	return _inventoryPanel.addInventoryItem(item);
+}
+
+tInventoryResult Interface::removeInventoryItem(InventoryItem *item) {
+	return _inventoryPanel.removeInventoryItem(item);
+}
+
+void Interface::removeAllItemsFromInventory() {
+	_inventoryPanel.removeAllItems();
+}
+
+InventoryItem *Interface::getCurrentInventoryItem() {
+	return (InventoryItem *)_inventoryPanel.getCurrentItem();
+}
+
+void Interface::setCurrentInventoryItem(InventoryItem *item) {
+	setCurrentInventoryItemID(item->getObjectID());
+}
+
+void Interface::setCurrentInventoryItemID(tItemID id) {
+	_inventoryPanel.setCurrentItemID(id);
+}
+
+tInventoryResult Interface::addBiochip(BiochipItem *item) {
+	return _biochipPanel.addInventoryItem(item);
+}
+
+void Interface::removeAllItemsFromBiochips() {
+	_biochipPanel.removeAllItems();
+}
+
+BiochipItem *Interface::getCurrentBiochip() {
+	return (BiochipItem *)_biochipPanel.getCurrentItem();
+}
+
+void Interface::setCurrentBiochip(BiochipItem *item) {
+	setCurrentBiochipID(item->getObjectID());
+}
+
+void Interface::setCurrentBiochipID(tItemID id) {
+	_biochipPanel.setCurrentItemID(id);
+}
+
+void Interface::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	if (notification == &_interfaceNotification) {
+		switch (flags) {
+		case kInventoryLidOpenFlag:
+			inventoryLidOpen(true);
+			break;
+		case kInventoryLidClosedFlag:
+			inventoryLidClosed();
+			break;
+		case kInventoryDrawerUpFlag:
+			inventoryDrawerUp();
+			break;
+		case kInventoryDrawerDownFlag:
+			inventoryDrawerDown(true);
+			break;
+		case kBiochipLidOpenFlag:
+			biochipLidOpen(true);
+			break;
+		case kBiochipLidClosedFlag:
+			biochipLidClosed();
+			break;
+		case kBiochipDrawerUpFlag:
+			biochipDrawerUp();
+			break;
+		case kBiochipDrawerDownFlag:
+			biochipDrawerDown(true);
+			break;
+		}
+	}
+}
+
+void Interface::raiseInventoryDrawer(const bool doCallBacks) {	
+	if (!_biochipUp)
+		_previousHandler = InputHandler::getCurrentHandler();
+
+	InputHandler::setInputHandler(&_inventoryPanel);
+	_inventoryUp = true;
+	_inventoryPanel.activateInventoryPicture();
+
+	if (doCallBacks) {
+		_inventoryLidCallBack.setCallBackFlag(kInventoryLidOpenFlag);
+		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	_inventoryLid.show();
+	_inventoryPush.show();
+	_inventoryLid.start();
+}
+
+void Interface::playEndMessage() {
+	raiseInventoryDrawerForMessage();
+	_playingEndMessage = true;
+	_inventoryPanel.playEndMessage(&_inventoryPush);
+	lowerInventoryDrawerForMessage();
+	_playingEndMessage = false;
+}
+
+void Interface::raiseInventoryDrawerForMessage() {
+	_inventoryPanel.disableLooping();
+	raiseInventoryDrawerSync();
+}
+
+void Interface::lowerInventoryDrawerForMessage() {
+	lowerInventoryDrawerSync();
+}
+
+void Interface::inventoryLidOpen(const bool doCallBacks) {
+	_inventoryLid.stop();
+
+	if (doCallBacks) {
+		_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerUpFlag);
+		_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 15, 1000);
+	_inventoryPush.startFader(moveSpec);
+}
+
+void Interface::inventoryDrawerUp() {
+	_inventoryPush.stopFader();
+	_inventoryPanel.panelUp();
+	_inventoryRaised = true;
+}
+
+bool Interface::isInventoryUp() {
+	return _inventoryRaised;
+}
+
+bool Interface::isInventoryDown() {
+	return !_inventoryUp;
+}
+
+void Interface::lowerInventoryDrawer(const bool doCallBacks) {	
+	if (_inventoryRaised) {
+		_inventoryRaised = false;
+
+		if (!_playingEndMessage)
+			_inventoryPanel.deactivateInventoryPicture();
+
+		if (doCallBacks) {
+			_inventoryPushCallBack.setCallBackFlag(kInventoryDrawerDownFlag);
+			_inventoryPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		}
+
+		FaderMoveSpec moveSpec;
+		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 15, 0);
+		_inventoryPush.startFader(moveSpec);
+	}
+}
+
+void Interface::inventoryDrawerDown(const bool doCallBacks) {
+	_inventoryPush.stopFader();
+
+	if (doCallBacks) {
+		_inventoryLidCallBack.setCallBackFlag(kInventoryLidClosedFlag);
+		_inventoryLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
+	}
+
+	_inventoryLid.setRate(-1);
+}
+
+void Interface::inventoryLidClosed() {
+	_inventoryLid.stop();
+
+	if (!_biochipUp)
+		InputHandler::setInputHandler(_previousHandler);
+
+	_inventoryLid.hide();
+	_inventoryPush.hide();
+	_inventoryUp = false;
+}
+
+void Interface::raiseBiochipDrawer(const bool doCallBacks) {	
+	if (!_inventoryUp)
+		_previousHandler = InputHandler::getCurrentHandler();
+
+	InputHandler::setInputHandler(&_biochipPanel);
+	_biochipUp = true;
+	_biochipPanel.activateInventoryPicture();
+
+	if (doCallBacks) {
+		_biochipLidCallBack.setCallBackFlag(kBiochipLidOpenFlag);
+		_biochipLidCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	_biochipLid.show();
+	_biochipPush.show();
+	_biochipLid.start();
+}
+
+void Interface::biochipLidOpen(const bool doCallBacks) {
+	_biochipLid.stop();
+
+	if (doCallBacks) {
+		_biochipPushCallBack.setCallBackFlag(kBiochipDrawerUpFlag);
+		_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 9, 1000);
+	_biochipPush.startFader(moveSpec);
+}
+
+void Interface::biochipDrawerUp() {
+	_biochipPush.stopFader();
+	_biochipPanel.panelUp();
+	_biochipRaised = true;
+}
+
+void Interface::lowerBiochipDrawer(const bool doCallBacks) {	
+	if (_biochipRaised) {
+		_biochipRaised = false;
+		_biochipPanel.deactivateInventoryPicture();
+
+		if (doCallBacks) {
+			_biochipPushCallBack.setCallBackFlag(kBiochipDrawerDownFlag);
+			_biochipPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		}
+
+		FaderMoveSpec moveSpec;
+		moveSpec.makeTwoKnotFaderSpec(60, 0, 1000, 9, 0);
+		_biochipPush.startFader(moveSpec);
+	}
+}
+
+void Interface::biochipDrawerDown(const bool doCallBacks) {
+	_biochipPush.stopFader();
+
+	if (doCallBacks) {
+		_biochipLidCallBack.setCallBackFlag(kBiochipLidClosedFlag);
+		_biochipLidCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
+	}
+
+	_biochipLid.setRate(-1);
+}
+
+void Interface::biochipLidClosed() {
+	_biochipLid.stop();
+
+	if (!_inventoryUp)
+		InputHandler::setInputHandler(_previousHandler);
+
+	_biochipLid.hide();
+	_biochipPush.hide();
+	_biochipUp = false;
+}
+
+void Interface::calibrateCompass() {
+	uint32 currentValue = g_compass->getFaderValue();
+	FaderMoveSpec compassMove;
+	compassMove.makeTwoKnotFaderSpec(15, 0, currentValue, 30, currentValue + 360);
+
+	g_compass->startFader(compassMove);
+
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	while (g_compass->isFading()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	g_compass->setFaderValue(currentValue);
+}
+
+void Interface::calibrateEnergyBar() {
+	g_energyMonitor->calibrateEnergyBar();
+}
+
+void Interface::raiseInventoryDrawerSync() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	raiseInventoryDrawer(false);
+
+	while (_inventoryLid.isRunning()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	inventoryLidOpen(false);
+
+	while (_inventoryPush.isFading()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	inventoryDrawerUp();
+}
+
+void Interface::lowerInventoryDrawerSync() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	lowerInventoryDrawer(false);
+
+	while (_inventoryPush.isFading()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	inventoryDrawerDown(false);
+
+	while (_inventoryLid.isRunning()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	inventoryLidClosed();
+}
+
+void Interface::raiseBiochipDrawerSync() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	raiseBiochipDrawer(false);
+
+	while (_biochipLid.isRunning()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	biochipLidOpen(false);
+
+	while (_biochipPush.isFading()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	biochipDrawerUp();
+}
+
+void Interface::lowerBiochipDrawerSync() {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	lowerBiochipDrawer(false);
+
+	while (_biochipPush.isFading()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+	
+	vm->refreshDisplay();
+	biochipDrawerDown(false);
+
+	while (_biochipLid.isRunning()) {
+		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
+
+	vm->refreshDisplay();
+	biochipLidClosed();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/interface.h b/engines/pegasus/interface.h
new file mode 100755
index 0000000..f8ad714
--- /dev/null
+++ b/engines/pegasus/interface.h
@@ -0,0 +1,148 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_INTERFACE_H
+#define PEGASUS_INTERFACE_H
+
+#include "pegasus/hotspot.h"
+#include "pegasus/input.h"
+#include "pegasus/notification.h"
+#include "pegasus/surface.h"
+#include "pegasus/transition.h"
+#include "pegasus/items/inventorypicture.h"
+
+namespace Pegasus {
+
+class BiochipItem;
+class InventoryItem;
+
+class Interface : public InputHandler, public NotificationReceiver {
+public:
+	Interface();
+	virtual ~Interface();
+
+	void createInterface();
+
+	// Recalibration functions...
+	void calibrateCompass();
+	void calibrateEnergyBar();
+	void raiseInventoryDrawerSync();
+	void lowerInventoryDrawerSync();
+	void raiseBiochipDrawerSync();
+	void lowerBiochipDrawerSync();
+
+	void raiseInventoryDrawer(const bool doCallBacks = true);
+	void raiseBiochipDrawer(const bool doCallBacks = true);
+	void lowerInventoryDrawer(const bool doCallBacks = true);
+	void lowerBiochipDrawer(const bool doCallBacks = true);
+
+	void raiseInventoryDrawerForMessage();
+	void lowerInventoryDrawerForMessage();
+	bool isInventoryUp();
+	bool isInventoryDown();
+
+	tInventoryResult addInventoryItem(InventoryItem*);
+	tInventoryResult removeInventoryItem(InventoryItem*);
+	void removeAllItemsFromInventory();
+	InventoryItem *getCurrentInventoryItem();
+	void setCurrentInventoryItem(InventoryItem*);
+	void setCurrentInventoryItemID(tItemID);
+	tInventoryResult addBiochip(BiochipItem*);
+	void removeAllItemsFromBiochips();
+	BiochipItem *getCurrentBiochip();
+	void setCurrentBiochip(BiochipItem*);
+	void setCurrentBiochipID(tItemID);
+
+	void setDate(const uint16);
+
+	void playEndMessage();
+
+	void throwAwayInterface();
+
+protected:
+	void validateBackground();
+	void validateDateMonitor();
+	void validateCompass();
+	void validateNotifications();
+	void validateAIArea();
+	void validateInventoryPanel();
+	void validateBiochipPanel();
+	void validateEnergyMonitor();
+
+	void throwAwayBackground();
+	void throwAwayDateMonitor();
+	void throwAwayCompass();
+	void throwAwayNotifications();
+	void throwAwayAIArea();
+	void throwAwayInventoryPanel();
+	void throwAwayBiochipPanel();
+	void throwAwayEnergyMonitor();
+
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void inventoryLidOpen(const bool doCallBacks);
+	void inventoryLidClosed();
+	void inventoryDrawerUp();
+	void inventoryDrawerDown(const bool doCallBacks);
+	void biochipLidOpen(const bool doCallBacks);
+	void biochipLidClosed();
+	void biochipDrawerUp();
+	void biochipDrawerDown(const bool doCallBacks);
+
+	Picture _background1;
+	Picture _background2;
+	Picture _background3;
+	Picture _background4;
+
+	Picture _datePicture;
+
+	InputHandler *_previousHandler;
+
+	Push _inventoryPush;
+	SpriteSequence _inventoryLid;
+	NotificationCallBack _inventoryPushCallBack;
+	NotificationCallBack _inventoryLidCallBack;
+	InventoryItemsPicture _inventoryPanel;
+	bool _inventoryUp, _inventoryRaised;
+
+	Push _biochipPush;
+	SpriteSequence _biochipLid;
+	NotificationCallBack _biochipPushCallBack;
+	NotificationCallBack _biochipLidCallBack;
+	BiochipPicture _biochipPanel;
+	bool _biochipUp, _biochipRaised;
+
+	Hotspot _currentItemSpot;
+	Hotspot _currentBiochipSpot;
+
+	Notification _interfaceNotification;
+
+	bool _playingEndMessage;
+};
+
+extern Interface *g_interface;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2c784cd..d0b661a 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS = \
 	graphics.o \
 	hotspot.o \
 	input.o \
+	interface.o \
 	menu.o \
 	movie.o \
 	notification.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 9198f37..14e7ff4 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -36,6 +36,7 @@
 #include "pegasus/console.h"
 #include "pegasus/cursor.h"
 #include "pegasus/gamestate.h"
+#include "pegasus/interface.h"
 #include "pegasus/menu.h"
 #include "pegasus/movie.h"
 #include "pegasus/pegasus.h"
@@ -868,7 +869,9 @@ bool PegasusEngine::playerHasItemID(const tItemID itemID) {
 }
 
 InventoryItem *PegasusEngine::getCurrentInventoryItem() {
-	// TODO
+	if (g_interface)
+		return g_interface->getCurrentInventoryItem();
+
 	return 0;
 }
 
@@ -881,7 +884,9 @@ bool PegasusEngine::itemInInventory(tItemID id) {
 }
 
 BiochipItem *PegasusEngine::getCurrentBiochip() {
-	// TODO
+	if (g_interface)
+		g_interface->getCurrentBiochip();
+
 	return 0;
 }
 
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 4bd81f4..6a5913d 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -124,11 +124,13 @@ public:
 	InventoryItem *getCurrentInventoryItem();
 	bool itemInInventory(InventoryItem *);
 	bool itemInInventory(tItemID);
+	Inventory *getItemsInventory() { return &_items; }
 
 	// Biochips
 	BiochipItem *getCurrentBiochip();
 	bool itemInBiochips(BiochipItem *);
 	bool itemInBiochips(tItemID);
+	Inventory *getBiochipsInventory() { return &_biochips; }
 
 	// AI
 	Common::String getBriefingMovie();


Commit: 4aed723368b9a4e82205bc3ed950a4e04ba3d8dc
    https://github.com/scummvm/scummvm/commit/4aed723368b9a4e82205bc3ed950a4e04ba3d8dc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T09:23:19-07:00

Commit Message:
PEGASUS: Fix startFaderSync

Since we're not running in multiple threads anymore, we cannot have the fader hold the main thread to itself.

Changed paths:
    engines/pegasus/fader.cpp
    engines/pegasus/fader.h



diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
index c3cfe9d..3d8305b 100755
--- a/engines/pegasus/fader.cpp
+++ b/engines/pegasus/fader.cpp
@@ -31,6 +31,7 @@ namespace Pegasus {
 Fader::Fader() {
 	_currentValue = 0;
 	_currentFaderMove._numKnots = 0;
+	_syncMode = false;
 }
 
 void Fader::setFaderValue(const uint32 newValue) {
@@ -85,19 +86,13 @@ void Fader::startFader(const FaderMoveSpec &spec) {
 
 void Fader::startFaderSync(const FaderMoveSpec &spec) {
 	if (initFaderMove(spec)) {
+		_syncMode = true;
+	
 		setFlags(0);
 		setScale(spec._faderScale);
 		setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
 		setTime(spec._knots[0].knotTime);
-		start();
-
-		while (isFading())
-			useIdleTime();
-
-		// Once more, for good measure, to make sure that there are no boundary
-		// condition problems.
-		useIdleTime();
-		stopFader();
+		start();		
 	}
 }
 
@@ -144,6 +139,18 @@ void Fader::timeChanged(const TimeValue newTime) {
 	}
 }
 
+void Fader::checkCallBacks() {
+	IdlerTimeBase::checkCallBacks();
+
+	if (_syncMode && !isRunning()) {
+		// Once more, for good measure, to make sure that there are no boundary
+		// condition problems.
+		useIdleTime();
+		stopFader();
+		_syncMode = false;
+	}
+}
+
 void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
 	_numKnots = 1;
 	_knots[0].knotTime = 0;
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
index fe5b1ae..83f5a81 100755
--- a/engines/pegasus/fader.h
+++ b/engines/pegasus/fader.h
@@ -89,12 +89,15 @@ public:
 
 	void getCurrentFaderMove(FaderMoveSpec &spec) { spec = _currentFaderMove; }
 
+	virtual void checkCallBacks();
+
 protected:
 	bool initFaderMove(const FaderMoveSpec &);
 	virtual void timeChanged(const TimeValue);
 	
 	uint32 _currentValue;
 	FaderMoveSpec _currentFaderMove;
+	bool _syncMode;
 };
 
 class FaderAnimation : public DisplayElement, public Fader {


Commit: e97ddf24495b0eaa7296113e5425f7d9cdc9a204
    https://github.com/scummvm/scummvm/commit/e97ddf24495b0eaa7296113e5425f7d9cdc9a204
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T09:25:16-07:00

Commit Message:
PEGASUS: Enable main menu sound fading now that it works

Changed paths:
    engines/pegasus/menu.cpp



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 3793a1f..f4ec150 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -191,7 +191,7 @@ MainMenu::MainMenu() : GameMenu(kMainMenuID), _menuBackground(0), _overviewButto
 
 	_adventureMode = true;
 
-	//_menuLoop.attachFader(&_menuFader);
+	_menuLoop.attachFader(&_menuFader);
 	_menuLoop.initFromAIFFFile("Sounds/Main Menu.aiff");
 
 	updateDisplay();
@@ -207,14 +207,14 @@ void MainMenu::startMainMenuLoop() {
 
 	_menuLoop.loopSound();
 	spec.makeTwoKnotFaderSpec(30, 0, 0, 30, 255);
-	//_menuFader.startFaderSync(spec);
+	_menuFader.startFaderSync(spec);
 }
 
 void MainMenu::stopMainMenuLoop() {
 	FaderMoveSpec spec;
 	
 	spec.makeTwoKnotFaderSpec(30, 0, 255, 30, 0);
-	//_menuFader.startFaderSync(spec);
+	_menuFader.startFaderSync(spec);
 	_menuLoop.stopSound();
 }
 


Commit: 09051449851fea84f094c3a21809c2bc6313e209
    https://github.com/scummvm/scummvm/commit/09051449851fea84f094c3a21809c2bc6313e209
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T16:44:20-07:00

Commit Message:
GRAPHICS: Rewrite PictDecoder's opcode handling

In preparation for adding support for multiple CompressedQuickTime opcodes

Changed paths:
    graphics/pict.cpp
    graphics/pict.h



diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index 80bcb7a..f768ecd 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -45,10 +45,164 @@ PictDecoder::~PictDecoder() {
 	delete _jpeg;
 }
 
+#define OPCODE(a, b, c) _opcodes.push_back(PICTOpcode(a, &PictDecoder::b, c))
+
+void PictDecoder::setupOpcodesCommon() {
+	OPCODE(0x0000, o_nop, "NOP");
+	OPCODE(0x0001, o_clip, "Clip");
+	OPCODE(0x0003, o_txFont, "TxFont");
+	OPCODE(0x0004, o_txFace, "TxFace");
+	OPCODE(0x0007, o_pnSize, "PnSize");
+	OPCODE(0x000D, o_txSize, "TxSize");
+	OPCODE(0x0010, o_txRatio, "TxRatio");
+	OPCODE(0x0011, o_versionOp, "VersionOp");
+	OPCODE(0x001E, o_nop, "DefHilite");
+	OPCODE(0x0028, o_longText, "LongText");
+	OPCODE(0x00A1, o_longComment, "LongComment");
+	OPCODE(0x00FF, o_opEndPic, "OpEndPic");
+	OPCODE(0x0C00, o_headerOp, "HeaderOp");
+}
+
+void PictDecoder::setupOpcodesNormal() {
+	setupOpcodesCommon();
+	OPCODE(0x0098, on_packBitsRect, "PackBitsRect");
+	OPCODE(0x009A, on_directBitsRect, "DirectBitsRect");
+	OPCODE(0x8200, on_compressedQuickTime, "CompressedQuickTime");
+}
+
+void PictDecoder::setupOpcodesQuickTime() {
+	setupOpcodesCommon();
+	OPCODE(0x0098, oq_packBitsRect, "PackBitsRect");
+	OPCODE(0x009A, oq_directBitsRect, "DirectBitsRect");
+	OPCODE(0x8200, oq_compressedQuickTime, "CompressedQuickTime");
+}
+
+#undef OPCODE
+
+void PictDecoder::o_nop(Common::SeekableReadStream *) {
+	// Nothing to do
+}
+
+void PictDecoder::o_clip(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->skip(stream->readUint16BE() - 2);
+}
+
+void PictDecoder::o_txFont(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+}
+
+void PictDecoder::o_txFace(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readByte();
+}
+
+void PictDecoder::o_pnSize(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+	stream->readUint16BE();
+}
+
+void PictDecoder::o_txSize(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+}
+
+void PictDecoder::o_txRatio(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+	stream->readUint16BE();
+	stream->readUint16BE();
+	stream->readUint16BE();
+}
+
+void PictDecoder::o_versionOp(Common::SeekableReadStream *stream) {
+	// We only support v2 extended
+	if (stream->readUint16BE() != 0x02FF)
+		error("Unknown PICT version");
+}
+
+void PictDecoder::o_longText(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+	stream->readUint16BE();
+	stream->skip(stream->readByte());
+}
+
+void PictDecoder::o_longComment(Common::SeekableReadStream *stream) {
+	// Ignore
+	stream->readUint16BE();
+	stream->skip(stream->readUint16BE());
+}
+
+void PictDecoder::o_opEndPic(Common::SeekableReadStream *stream) {
+	// We've reached the end of the picture
+	_continueParsing = false;
+}
+
+void PictDecoder::o_headerOp(Common::SeekableReadStream *stream) {
+	// Read the basic header, but we don't really have to do anything with it
+	/* uint16 version = */ stream->readUint16BE();
+	stream->readUint16BE(); // Reserved
+	/* uint32 hRes = */ stream->readUint32BE();
+	/* uint32 vRes = */ stream->readUint32BE();
+	Common::Rect origResRect;
+	origResRect.top = stream->readUint16BE();
+	origResRect.left = stream->readUint16BE();
+	origResRect.bottom = stream->readUint16BE();
+	origResRect.right = stream->readUint16BE();
+	stream->readUint32BE(); // Reserved
+}
+
+void PictDecoder::on_packBitsRect(Common::SeekableReadStream *stream) {
+	// Unpack data (8bpp or lower)
+	unpackBitsRect(stream, true);
+}
+
+void PictDecoder::on_directBitsRect(Common::SeekableReadStream *stream) {
+	// Unpack data (16bpp or higher)
+	unpackBitsRect(stream, false);
+}
+
+void PictDecoder::on_compressedQuickTime(Common::SeekableReadStream *stream) {
+	// OK, here's the fun. We get to completely change how QuickDraw draws
+	// the data in PICT files.
+
+	// Swap out the opcodes to the new ones
+	_opcodes.clear();
+	setupOpcodesQuickTime();
+
+	// We'll decode the first QuickTime data from here, but the QuickTime-specific
+	// opcodes will take over from here on out. Normal opcodes, signing off.
+	decodeCompressedQuickTime(stream);
+}
+
+void PictDecoder::oq_packBitsRect(Common::SeekableReadStream *stream) {
+	// Skip any data here (8bpp or lower)
+	skipBitsRect(stream, true);
+}
+
+void PictDecoder::oq_directBitsRect(Common::SeekableReadStream *stream) {
+	// Skip any data here (16bpp or higher)
+	skipBitsRect(stream, false);
+}
+
+void PictDecoder::oq_compressedQuickTime(Common::SeekableReadStream *stream) {
+	// Just pass the data along
+	decodeCompressedQuickTime(stream);
+}
+
 Surface *PictDecoder::decodeImage(Common::SeekableReadStream *stream, byte *palette) {
 	assert(stream);
 
+	// Initialize opcodes to their normal state
+	_opcodes.clear();
+	setupOpcodesNormal();
+
 	_outputSurface = 0;
+	_continueParsing = true;
+	memset(_palette, 0, sizeof(_palette));
 
 	uint16 fileSize = stream->readUint16BE();
 
@@ -63,70 +217,41 @@ Surface *PictDecoder::decodeImage(Common::SeekableReadStream *stream, byte *pale
 	_imageRect.bottom = stream->readUint16BE();
 	_imageRect.right = stream->readUint16BE();
 	_imageRect.debugPrint(0, "PICT Rect:");
-	_isPaletted = false;
 
 	// NOTE: This is only a subset of the full PICT format.
-	//     - Only V2 Images Supported
+	//     - Only V2 (Extended) Images Supported
 	//     - CompressedQuickTime (JPEG) compressed data is supported
 	//     - DirectBitsRect/PackBitsRect compressed data is supported
-	for (uint32 opNum = 0; !stream->eos() && !stream->err() && stream->pos() < stream->size(); opNum++) {
+	for (uint32 opNum = 0; !stream->eos() && !stream->err() && stream->pos() < stream->size() && _continueParsing; opNum++) {
+		// PICT v2 opcodes are two bytes
 		uint16 opcode = stream->readUint16BE();
-		debug(2, "Found PICT opcode %04x", opcode);
 
 		if (opNum == 0 && opcode != 0x0011)
-			error ("Cannot find PICT version opcode");
+			error("Cannot find PICT version opcode");
 		else if (opNum == 1 && opcode != 0x0C00)
-			error ("Cannot find PICT header opcode");
-
-		if (opcode == 0x0000) {        // Nop
-			stream->readUint16BE(); // Unknown
-		} else if (opcode == 0x0001) { // Clip
-			// Ignore
-			uint16 clipSize = stream->readUint16BE();
-			stream->seek(clipSize - 2, SEEK_CUR);
-		} else if (opcode == 0x0007) { // PnSize
-			// Ignore
-			stream->readUint16BE();
-			stream->readUint16BE();
-		} else if (opcode == 0x0011) { // VersionOp
-			uint16 version = stream->readUint16BE();
-			if (version != 0x02FF)
-				error ("Unknown PICT version");
-		} else if (opcode == 0x001E) { // DefHilite
-			// Ignore, Contains no Data
-		} else if (opcode == 0x0098) { // PackBitsRect
-			decodeDirectBitsRect(stream, true);
-			_isPaletted = true;
-		} else if (opcode == 0x009A) { // DirectBitsRect
-			decodeDirectBitsRect(stream, false);
-		} else if (opcode == 0x00A1) { // LongComment
-			stream->readUint16BE();
-			uint16 dataSize = stream->readUint16BE();
-			stream->seek(dataSize, SEEK_CUR);
-		} else if (opcode == 0x00FF) { // OpEndPic
-			stream->readUint16BE();
-			break;
-		} else if (opcode == 0x0C00) { // HeaderOp
-			/* uint16 version = */ stream->readUint16BE();
-			stream->readUint16BE(); // Reserved
-			/* uint32 hRes = */ stream->readUint32BE();
-			/* uint32 vRes = */ stream->readUint32BE();
-			Common::Rect origResRect;
-			origResRect.top = stream->readUint16BE();
-			origResRect.left = stream->readUint16BE();
-			origResRect.bottom = stream->readUint16BE();
-			origResRect.right = stream->readUint16BE();
-			stream->readUint32BE(); // Reserved
-		} else if (opcode == 0x8200) { // CompressedQuickTime
-			decodeCompressedQuickTime(stream);
-			break;
-		} else {
-			warning("Unknown PICT opcode %04x", opcode);
+			error("Cannot find PICT header opcode");
+
+		// Since opcodes are word-aligned, we need to mark our starting
+		// position here.
+		uint32 startPos = stream->pos();
+
+		for (uint32 i = 0; i < _opcodes.size(); i++) {
+			if (_opcodes[i].op == opcode) {
+				debug(4, "Running PICT opcode %04x '%s'", opcode, _opcodes[i].desc);
+				(this->*(_opcodes[i].proc))(stream);
+				break;
+			} else if (i == _opcodes.size() - 1) {
+				// Unknown opcode; attempt to continue forward
+				warning("Unknown PICT opcode %04x", opcode);
+			}
 		}
+
+		// Align
+		stream->skip((stream->pos() - startPos) & 1);
 	}
 
 	// If we got a palette throughout this nonsense, go and grab it
-	if (palette && _isPaletted)
+	if (palette)
 		memcpy(palette, _palette, 256 * 3);
 
 	return _outputSurface;
@@ -155,21 +280,18 @@ PictDecoder::PixMap PictDecoder::readPixMap(Common::SeekableReadStream *stream,
 	return pixMap;
 }
 
-struct DirectBitsRectData {
+struct PackBitsRectData {
 	PictDecoder::PixMap pixMap;
 	Common::Rect srcRect;
 	Common::Rect dstRect;
 	uint16 mode;
 };
 
-void PictDecoder::decodeDirectBitsRect(Common::SeekableReadStream *stream, bool hasPalette) {
+void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPalette) {
 	static const PixelFormat directBitsFormat16 = PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
 
-	// Clear the palette
-	memset(_palette, 0, sizeof(_palette));
-
-	DirectBitsRectData directBitsData;
-	directBitsData.pixMap = readPixMap(stream, !hasPalette);
+	PackBitsRectData packBitsData;
+	packBitsData.pixMap = readPixMap(stream, !hasPalette);
 
 	// Read in the palette if there is one present
 	if (hasPalette) {
@@ -186,47 +308,47 @@ void PictDecoder::decodeDirectBitsRect(Common::SeekableReadStream *stream, bool
 		}
 	}
 
-	directBitsData.srcRect.top = stream->readUint16BE();
-	directBitsData.srcRect.left = stream->readUint16BE();
-	directBitsData.srcRect.bottom = stream->readUint16BE();
-	directBitsData.srcRect.right = stream->readUint16BE();
-	directBitsData.dstRect.top = stream->readUint16BE();
-	directBitsData.dstRect.left = stream->readUint16BE();
-	directBitsData.dstRect.bottom = stream->readUint16BE();
-	directBitsData.dstRect.right = stream->readUint16BE();
-	directBitsData.mode = stream->readUint16BE();
+	packBitsData.srcRect.top = stream->readUint16BE();
+	packBitsData.srcRect.left = stream->readUint16BE();
+	packBitsData.srcRect.bottom = stream->readUint16BE();
+	packBitsData.srcRect.right = stream->readUint16BE();
+	packBitsData.dstRect.top = stream->readUint16BE();
+	packBitsData.dstRect.left = stream->readUint16BE();
+	packBitsData.dstRect.bottom = stream->readUint16BE();
+	packBitsData.dstRect.right = stream->readUint16BE();
+	packBitsData.mode = stream->readUint16BE();
 
-	uint16 width = directBitsData.srcRect.width();
-	uint16 height = directBitsData.srcRect.height();
+	uint16 width = packBitsData.srcRect.width();
+	uint16 height = packBitsData.srcRect.height();
 
 	byte bytesPerPixel = 0;
 
-	if (directBitsData.pixMap.pixelSize <= 8)
+	if (packBitsData.pixMap.pixelSize <= 8)
 		bytesPerPixel = 1;
-	else if (directBitsData.pixMap.pixelSize == 32)
+	else if (packBitsData.pixMap.pixelSize == 32)
 		bytesPerPixel = 3;
 	else
-		bytesPerPixel = directBitsData.pixMap.pixelSize / 8;
+		bytesPerPixel = packBitsData.pixMap.pixelSize / 8;
 
 	_outputSurface = new Graphics::Surface();
 	_outputSurface->create(width, height, (bytesPerPixel == 1) ? PixelFormat::createFormatCLUT8() : _pixelFormat);
 	byte *buffer = new byte[width * height * bytesPerPixel];
 
 	// Read in amount of data per row
-	for (uint16 i = 0; i < directBitsData.pixMap.bounds.height(); i++) {
+	for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) {
 		// NOTE: Compression 0 is "default". The format in SCI games is packed when 0.
 		// In the future, we may need to have something to set the  "default" packing
 		// format, but this is good for now.
 
-		if (directBitsData.pixMap.packType == 1 || directBitsData.pixMap.rowBytes < 8) { // Unpacked, Pad-Byte (on 24-bit)
+		if (packBitsData.pixMap.packType == 1 || packBitsData.pixMap.rowBytes < 8) { // Unpacked, Pad-Byte (on 24-bit)
 			// TODO: Finish this. Hasn't been needed (yet).
 			error("Unpacked DirectBitsRect data (padded)");
-		} else if (directBitsData.pixMap.packType == 2) { // Unpacked, No Pad-Byte (on 24-bit)
+		} else if (packBitsData.pixMap.packType == 2) { // Unpacked, No Pad-Byte (on 24-bit)
 			// TODO: Finish this. Hasn't been needed (yet).
 			error("Unpacked DirectBitsRect data (not padded)");
-		} else if (directBitsData.pixMap.packType == 0 || directBitsData.pixMap.packType > 2) { // Packed
-			uint16 byteCount = (directBitsData.pixMap.rowBytes > 250) ? stream->readUint16BE() : stream->readByte();
-			decodeDirectBitsLine(buffer + i * _outputSurface->w * bytesPerPixel, directBitsData.pixMap.rowBytes, stream->readStream(byteCount), directBitsData.pixMap.pixelSize, bytesPerPixel);
+		} else if (packBitsData.pixMap.packType == 0 || packBitsData.pixMap.packType > 2) { // Packed
+			uint16 byteCount = (packBitsData.pixMap.rowBytes > 250) ? stream->readUint16BE() : stream->readByte();
+			unpackBitsLine(buffer + i * _outputSurface->w * bytesPerPixel, packBitsData.pixMap.rowBytes, stream->readStream(byteCount), packBitsData.pixMap.pixelSize, bytesPerPixel);
 		}
 	}
 
@@ -264,7 +386,7 @@ void PictDecoder::decodeDirectBitsRect(Common::SeekableReadStream *stream, bool
 	delete[] buffer;
 }
 
-void PictDecoder::decodeDirectBitsLine(byte *out, uint32 length, Common::SeekableReadStream *data, byte bitsPerPixel, byte bytesPerPixel) {
+void PictDecoder::unpackBitsLine(byte *out, uint32 length, Common::SeekableReadStream *data, byte bitsPerPixel, byte bytesPerPixel) {
 	uint32 dataDecoded = 0;
 	byte bytesPerDecode = (bytesPerPixel == 2) ? 2 : 1;
 
@@ -299,11 +421,16 @@ void PictDecoder::decodeDirectBitsLine(byte *out, uint32 length, Common::Seekabl
 		dataDecoded += length / 4;
 
 	if (length != dataDecoded)
-		warning("Mismatched DirectBits read (%d/%d)", dataDecoded, length);
+		warning("Mismatched PackBits read (%d/%d)", dataDecoded, length);
 
 	delete data;
 }
 
+void PictDecoder::skipBitsRect(Common::SeekableReadStream *stream, bool hasPalette) {
+	// TODO
+	error("TODO: PICT-QuickTime mode: skip PackBitsRect/DirectBitsRect");
+}
+
 void PictDecoder::outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel) {
 	switch (bitsPerPixel) {
 	case 1:
diff --git a/graphics/pict.h b/graphics/pict.h
index 485c88b..b426c6e 100644
--- a/graphics/pict.h
+++ b/graphics/pict.h
@@ -23,6 +23,7 @@
 #ifndef GRAPHICS_PICT_H
 #define GRAPHICS_PICT_H
 
+#include "common/array.h"
 #include "common/rect.h"
 #include "common/scummsys.h"
 
@@ -37,6 +38,8 @@ namespace Graphics {
 class JPEG;
 struct Surface;
 
+#define DECLARE_OPCODE(x) void x(Common::SeekableReadStream *stream)
+
 class PictDecoder {
 public:
 	PictDecoder(Graphics::PixelFormat pixelFormat);
@@ -70,13 +73,56 @@ private:
 	byte _palette[256 * 3];
 	bool _isPaletted;
 	Graphics::Surface *_outputSurface;
+	bool _continueParsing;
 
-	void decodeDirectBitsRect(Common::SeekableReadStream *stream, bool hasPalette);
-	void decodeDirectBitsLine(byte *out, uint32 length, Common::SeekableReadStream *data, byte bitsPerPixel, byte bytesPerPixel);
+	// Utility Functions
+	void unpackBitsRect(Common::SeekableReadStream *stream, bool hasPalette);
+	void unpackBitsLine(byte *out, uint32 length, Common::SeekableReadStream *data, byte bitsPerPixel, byte bytesPerPixel);
+	void skipBitsRect(Common::SeekableReadStream *stream, bool hasPalette);
 	void decodeCompressedQuickTime(Common::SeekableReadStream *stream);
 	void outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel);
+
+	// Opcodes
+	typedef void (PictDecoder::*OpcodeProcPICT)(Common::SeekableReadStream *stream);
+	struct PICTOpcode {
+		PICTOpcode() { op = 0; proc = 0; desc = 0; }
+		PICTOpcode(uint16 o, OpcodeProcPICT p, const char *d) { op = o; proc = p; desc = d; }
+		uint16 op;
+		OpcodeProcPICT proc;
+		const char *desc;
+	};
+	Common::Array<PICTOpcode> _opcodes;
+
+	// Common Opcodes
+	void setupOpcodesCommon();
+	DECLARE_OPCODE(o_nop);
+	DECLARE_OPCODE(o_clip);
+	DECLARE_OPCODE(o_txFont);
+	DECLARE_OPCODE(o_txFace);
+	DECLARE_OPCODE(o_pnSize);
+	DECLARE_OPCODE(o_txSize);
+	DECLARE_OPCODE(o_txRatio);
+	DECLARE_OPCODE(o_versionOp);
+	DECLARE_OPCODE(o_longText);
+	DECLARE_OPCODE(o_longComment);
+	DECLARE_OPCODE(o_opEndPic);
+	DECLARE_OPCODE(o_headerOp);
+
+	// Regular-mode Opcodes
+	void setupOpcodesNormal();
+	DECLARE_OPCODE(on_packBitsRect);
+	DECLARE_OPCODE(on_directBitsRect);
+	DECLARE_OPCODE(on_compressedQuickTime);
+
+	// QuickTime-mode Opcodes
+	void setupOpcodesQuickTime();
+	DECLARE_OPCODE(oq_packBitsRect);
+	DECLARE_OPCODE(oq_directBitsRect);
+	DECLARE_OPCODE(oq_compressedQuickTime);
 };
 
+#undef DECLARE_OPCODE
+
 } // End of namespace Graphics
 
 #endif


Commit: 161b4c9f2ba245249c16401bb0b0099e01b2273f
    https://github.com/scummvm/scummvm/commit/161b4c9f2ba245249c16401bb0b0099e01b2273f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T17:17:33-07:00

Commit Message:
GRAPHICS: Properly parse the CompressQuickTime header

Changed paths:
    graphics/pict.cpp



diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index f768ecd..718214c 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -453,13 +453,36 @@ void PictDecoder::outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel) {
 // Compressed QuickTime details can be found here:
 // http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/B-Chapter/2TheImageCompression.html
 // http://developer.apple.com/legacy/mac/library/#documentation/QuickTime/Rm/CompressDecompress/ImageComprMgr/F-Chapter/6WorkingwiththeImage.html
-// I'm just ignoring that because Myst ME uses none of that extra stuff. The offset is always the same.
 
 void PictDecoder::decodeCompressedQuickTime(Common::SeekableReadStream *stream) {
+	// First, read all the fields from the opcode
 	uint32 dataSize = stream->readUint32BE();
 	uint32 startPos = stream->pos();
 
-	Common::SeekableReadStream *jpegStream = new Common::SeekableSubReadStream(stream, stream->pos() + 156, stream->pos() + dataSize);
+	/* uint16 version = */ stream->readUint16BE();
+
+	uint32 matrix[3][3];
+	for (uint32 i = 0; i < 3; i++)
+		for (uint32 j = 0; j < 3; j++)
+			matrix[i][j] = stream->readUint32BE();
+
+	uint32 matteSize = stream->readUint32BE();
+	stream->skip(8); // matte rect
+	/* uint16 transferMode = */ stream->readUint16BE();
+	stream->skip(8); // src rect
+	/* uint32 accuracy = */ stream->readUint32BE();
+	uint32 maskSize = stream->readUint32BE();
+	
+	stream->skip(matteSize + maskSize);
+	
+	// Now we've reached the image descriptor, so read the relevant data from that
+	uint32 idStart = stream->pos();
+	uint32 idSize = stream->readUint32BE();
+	stream->skip(40);
+	uint32 jpegSize = stream->readUint32BE();
+	stream->skip(idSize - (stream->pos() - idStart));
+
+	Common::SeekableReadStream *jpegStream = new Common::SeekableSubReadStream(stream, stream->pos(), stream->pos() + jpegSize);
 
 	if (!_jpeg->read(jpegStream))
 		error("PictDecoder::decodeCompressedQuickTime(): Could not decode JPEG data");


Commit: 8897c17884c846f225f751f4b2838dd0e15c7faa
    https://github.com/scummvm/scummvm/commit/8897c17884c846f225f751f4b2838dd0e15c7faa
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T17:55:33-07:00

Commit Message:
GRAPHICS: Add support for multiple CompressedQuickTime calls

Several pegasus demos now show up correctly. Yay! :)

Changed paths:
    graphics/pict.cpp



diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index 718214c..a4cc67f 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -173,6 +173,11 @@ void PictDecoder::on_compressedQuickTime(Common::SeekableReadStream *stream) {
 	_opcodes.clear();
 	setupOpcodesQuickTime();
 
+	// We set up the surface for JPEG here too
+	if (!_outputSurface)
+		_outputSurface = new Graphics::Surface();
+	_outputSurface->create(_imageRect.width(), _imageRect.height(), _pixelFormat);
+
 	// We'll decode the first QuickTime data from here, but the QuickTime-specific
 	// opcodes will take over from here on out. Normal opcodes, signing off.
 	decodeCompressedQuickTime(stream);
@@ -427,8 +432,50 @@ void PictDecoder::unpackBitsLine(byte *out, uint32 length, Common::SeekableReadS
 }
 
 void PictDecoder::skipBitsRect(Common::SeekableReadStream *stream, bool hasPalette) {
-	// TODO
-	error("TODO: PICT-QuickTime mode: skip PackBitsRect/DirectBitsRect");
+	// Step through a PackBitsRect/DirectBitsRect function
+
+	if (!hasPalette)
+		stream->readUint32BE();
+
+	uint16 rowBytes = stream->readUint16BE();
+	uint16 height = stream->readUint16BE();
+	stream->readUint16BE();
+	height = stream->readUint16BE() - height;
+	stream->readUint16BE();
+
+	uint16 packType;
+	uint16 pixelSize;
+
+	// Top two bits signify PixMap vs BitMap
+	if (rowBytes & 0xC000) {
+		// PixMap
+		stream->readUint16BE();
+		packType = stream->readUint16BE();
+		stream->skip(14);
+		pixelSize = stream->readUint16BE();
+		stream->skip(16);
+
+		if (hasPalette) {
+			stream->readUint32BE();
+			stream->readUint16BE();
+			stream->skip((stream->readUint16BE() + 1) * 8);
+		}
+
+		rowBytes &= 0x3FFF;
+	} else {
+		// BitMap
+		packType = 0;
+		pixelSize = 1;
+	}
+
+	stream->skip(18);
+
+	for (uint16 i = 0; i < height; i++) {
+		if (packType == 1 || packType == 2 || rowBytes < 8)
+			error("Unpacked PackBitsRect data");
+		else if (packType == 0 || packType > 2)
+			stream->skip((rowBytes > 250) ? stream->readUint16BE() : stream->readByte());
+	}
 }
 
 void PictDecoder::outputPixelBuffer(byte *&out, byte value, byte bitsPerPixel) {
@@ -461,33 +508,42 @@ void PictDecoder::decodeCompressedQuickTime(Common::SeekableReadStream *stream)
 
 	/* uint16 version = */ stream->readUint16BE();
 
+	// Read in the display matrix
 	uint32 matrix[3][3];
 	for (uint32 i = 0; i < 3; i++)
 		for (uint32 j = 0; j < 3; j++)
 			matrix[i][j] = stream->readUint32BE();
 
+	// We currently only support offseting images vertically from the matrix
+	uint16 xOffset = 0;
+	uint16 yOffset = matrix[2][1] >> 16;
+
 	uint32 matteSize = stream->readUint32BE();
 	stream->skip(8); // matte rect
 	/* uint16 transferMode = */ stream->readUint16BE();
 	stream->skip(8); // src rect
 	/* uint32 accuracy = */ stream->readUint32BE();
 	uint32 maskSize = stream->readUint32BE();
-	
+
+	// Skip the matte and mask
 	stream->skip(matteSize + maskSize);
 	
 	// Now we've reached the image descriptor, so read the relevant data from that
 	uint32 idStart = stream->pos();
 	uint32 idSize = stream->readUint32BE();
-	stream->skip(40);
+	stream->skip(40); // miscellaneous stuff
 	uint32 jpegSize = stream->readUint32BE();
-	stream->skip(idSize - (stream->pos() - idStart));
+	stream->skip(idSize - (stream->pos() - idStart)); // more useless stuff
 
 	Common::SeekableReadStream *jpegStream = new Common::SeekableSubReadStream(stream, stream->pos(), stream->pos() + jpegSize);
 
 	if (!_jpeg->read(jpegStream))
 		error("PictDecoder::decodeCompressedQuickTime(): Could not decode JPEG data");
 
-	_outputSurface = _jpeg->getSurface(_pixelFormat);
+	Graphics::Surface *jpegSurface = _jpeg->getSurface(_pixelFormat);
+
+	for (uint16 y = 0; y < jpegSurface->h; y++)
+		memcpy(_outputSurface->getBasePtr(0 + xOffset, y + yOffset), jpegSurface->getBasePtr(0, y), jpegSurface->w * _pixelFormat.bytesPerPixel);
 
 	stream->seek(startPos + dataSize);
 	delete jpegStream;


Commit: 515b2501a7eaf875172fcdde910b061da843c96d
    https://github.com/scummvm/scummvm/commit/515b2501a7eaf875172fcdde910b061da843c96d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T18:06:51-07:00

Commit Message:
PEGASUS: Show the demo quit/splash screens

They work now with all the PICT changes ;)

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 14e7ff4..be5a22e 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -520,6 +520,8 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 #else
 			if (!isDemo())
 				runIntro();
+			else
+				showTempScreen("Images/Demo/NGsplashScrn.pict");
 
 			if (shouldQuit())
 				return;
@@ -606,6 +608,8 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		}
 		break;
 	case kMenuCmdQuit:
+		if (isDemo())
+			showTempScreen("Images/Demo/NGquitScrn.pict");
 		_system->quit();
 		break;
 	case kMenuCmdOverview:


Commit: 85e7d2d9a99a0b7663881c6b5e1ce066d2efc49c
    https://github.com/scummvm/scummvm/commit/85e7d2d9a99a0b7663881c6b5e1ce066d2efc49c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T21:17:21-07:00

Commit Message:
PEGASUS: Update the GraphicsManager a bit

- Only update the screen if we drew something to it, not if a dirty rect was present.
- Add ability to clear the screen.

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index e37150e..05217fa 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -44,6 +44,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_firstDisplayElement = _lastDisplayElement = 0;
 	_workArea.create(640, 480, _vm->_system->getScreenFormat());
 	_lastMousePosition = Common::Point(-1, -1);
+	_modifiedScreen = false;
 }
 	
 GraphicsManager::~GraphicsManager() {
@@ -162,22 +163,31 @@ void GraphicsManager::updateDisplay() {
 
 			// TODO: Better logic; it does a bit more work than it probably needs to
 			// but it should work fine for now.
-			if (bounds.intersects(_dirtyRect) && runner->validToDraw(_backLayer, _frontLayer))
+			if (bounds.intersects(_dirtyRect) && runner->validToDraw(_backLayer, _frontLayer)) {
 				runner->draw(bounds);
+				screenDirty = true;
+			}
 		}
 
 		// Copy only the dirty rect to the screen
-		g_system->copyRectToScreen((byte *)_workArea.getBasePtr(_dirtyRect.left, _dirtyRect.top), _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height());
-
-		// Mark the screen as dirty
-		screenDirty = true;
+		if (screenDirty)
+			g_system->copyRectToScreen((byte *)_workArea.getBasePtr(_dirtyRect.left, _dirtyRect.top), _workArea.pitch, _dirtyRect.left, _dirtyRect.top, _dirtyRect.width(), _dirtyRect.height());
 
 		// Clear the dirty rect
 		_dirtyRect = Common::Rect();
 	}
 
-	if (screenDirty)
+	if (screenDirty || _modifiedScreen)
 		g_system->updateScreen();
+
+	_modifiedScreen = false;
+}
+
+void GraphicsManager::clearScreen() {
+	Graphics::Surface *screen = g_system->lockScreen();
+	screen->fillRect(Common::Rect(0, 0, 640, 480), g_system->getScreenFormat().RGBToColor(0, 0, 0));
+	g_system->unlockScreen();
+	_modifiedScreen = true;
 }
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index ebaaeb2..90d0f33 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -52,10 +52,12 @@ public:
 	tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
 	void updateDisplay();
 	Graphics::Surface *getWorkArea() { return &_workArea; }
+	void clearScreen();
 
 private:		
 	PegasusEngine *_vm;
 
+	bool _modifiedScreen;
 	Common::Rect _dirtyRect;
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;


Commit: 24cc9568cbefe6570dd846874c0681f3c09521bd
    https://github.com/scummvm/scummvm/commit/24cc9568cbefe6570dd846874c0681f3c09521bd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-25T21:30:44-07:00

Commit Message:
PEGASUS: Implement the death menu

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/menu.cpp
    engines/pegasus/menu.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 4af10bf..6678b70 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -542,7 +542,7 @@ const tGameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
 const tGameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
 const tGameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
 
-const tGameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathContinue + 1;
+const tGameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathMainMenuDemo + 1;
 const tGameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
 
 const tGameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index f4ec150..fb6af17 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -23,8 +23,10 @@
  *
  */
 
+#include "pegasus/gamestate.h"
 #include "pegasus/menu.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/scoring.h"
 
 namespace Pegasus {
 
@@ -41,6 +43,34 @@ void GameMenu::restorePreviousHandler() {
 	InputHandler::setInputHandler(_previousHandler);
 }
 
+void GameMenu::drawScore(tGameScoreType score, tGameScoreType total, const Common::Rect &scoreBounds, Surface *numbers) {
+	tCoordType x = scoreBounds.right;
+	drawNumber(total, x, scoreBounds.top, numbers);
+
+	x -= 12;
+	Common::Rect r1(120, 0, 132, 12); // The slash.
+	Common::Rect r2 = r1;
+	r2.moveTo(x, scoreBounds.top);
+	numbers->copyToCurrentPort(r1, r2);
+	drawNumber(score, x, scoreBounds.top, numbers);
+}
+
+void GameMenu::drawNumber(tGameScoreType number, tCoordType &x, tCoordType y, Surface *numbers) {
+	Common::Rect r1(0, 0, 12, 12); // Width, height of one digit
+	Common::Rect r2 = r1;
+	r2.moveTo(x - 12, y);
+
+	do {
+		uint16 digit = number % 10;
+		number /= 10;
+		r1.moveTo(digit * 12, 0);
+		numbers->copyToCurrentPort(r1, r2);
+		r2.translate(-12, 0);
+	} while (number != 0);
+
+	x = r2.right;
+}
+
 enum {
 	kMainMenuStartDemo = 0,
 	kMainMenuCreditsDemo,
@@ -545,4 +575,340 @@ void CreditsMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	InputHandler::handleInput(input, cursorSpot);
 }
 
+static const tCoordType kContinueLeft = 44;
+static const tCoordType kContinueTop = 336;
+
+static const tCoordType kContinueSelectLeft = 40;
+static const tCoordType kContinueSelectTopDemo = 331;
+static const tCoordType kContinueSelectTop = 332;
+
+static const tCoordType kMainMenuLeftDemo = 44;
+static const tCoordType kMainMenuTopDemo = 372;
+
+static const tCoordType kMainMenuSelectLeftDemo = 40;
+static const tCoordType kMainMenuSelectTopDemo = 367;
+
+static const tCoordType kQuitLeftDemo = 32;
+static const tCoordType kQuitTopDemo = 412;
+
+static const tCoordType kQuitSelectLeftDemo = 28;
+static const tCoordType kQuitSelectTopDemo = 408;
+
+static const tCoordType kRestoreLeftDeath = 44;
+static const tCoordType kRestoreTopDeath = 372;
+
+static const tCoordType kRestoreSelectLeftDeath = 40;
+static const tCoordType kRestoreSelectTopDeath = 368;
+
+static const tCoordType kMainMenuLeft = 32;
+static const tCoordType kMainMenuTop = 412;
+
+static const tCoordType kMainMenuSelectLeft = 28;
+static const tCoordType kMainMenuSelectTop = 408;
+
+enum {
+	kDeathScreenContinueDemo = 0,
+	kDeathScreenMainMenuDemo,
+	kDeathScreenQuitDemo,
+	
+	kFirstDeathSelectionDemo = kDeathScreenContinueDemo,
+	kLastDeathSelectionDemo = kDeathScreenQuitDemo,
+
+	kDeathScreenContinue = 0,
+	kDeathScreenRestore,
+	kDeathScreenMainMenu,
+	
+	kFirstDeathSelection = kDeathScreenContinue,
+	kLastDeathSelection = kDeathScreenMainMenu
+};
+
+// Never set the current input handler to the DeathMenu.
+DeathMenu::DeathMenu(const tDeathReason deathReason) : GameMenu(kDeathMenuID), _deathBackground(0), _continueButton(0),
+		_mainMenuButton(0), _quitButton(0), _restoreButton(0), _largeSelect(0), _smallSelect(0) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+	bool isDemo = vm->isDemo();
+
+	_playerWon = (deathReason == kPlayerWonGame);
+
+	Common::String prefix = "Images/";
+	Common::String imageName;
+	if (isDemo) {
+		prefix += "Demo/";
+		imageName = prefix;
+
+		switch (deathReason) {
+		case kDeathFallOffCliff:
+			imageName += "dPfall";
+			break;
+		case kDeathEatenByDinosaur:
+			imageName += "dPdino";
+			break;
+		case kDeathStranded:
+			imageName += "dPstuck";
+			break;
+		default:
+			imageName += "dPdemowin";
+			break;
+		}
+
+		imageName += ".pict";
+	} else {
+		prefix += "Death Screens/";
+		imageName = prefix;
+
+		static const char *fileNames[] = {
+			"dAunmade", "dAbombed", "dAshot", "dAassass", "dAnuked",
+			"dTunmade", "dTshot", "dPfall", "dPdino", "dPstuck",
+			"dNchoke", "dNcaught", "dNcaught", "dNsub", "dNrobot1",
+			"dNrobot2", "dMfall", "dMcaught", "dMtracks", "dMrobot",
+			"dMtoast", "dMexplo1", "dMexplo2", "dMchoke1", "dMchoke2",
+			"dMdroid", "dMfall", "dMgears", "dMshutt1", "dMshutt2",
+			"dWpoison", "dWcaught", "dWplasma", "dWshot", "dAfinale"
+		};
+
+		imageName += fileNames[deathReason - 1];
+		imageName += ".pict";
+	}
+
+	_deathBackground.initFromPICTFile(imageName);
+	_deathReason = deathReason;
+
+	if (!isDemo)
+		drawAllScores();
+
+	_deathBackground.setDisplayOrder(0);
+	_deathBackground.startDisplaying();
+	_deathBackground.show();
+
+	if (isDemo) {
+		if (_playerWon) // Make credits button...
+			_continueButton.initFromPICTFile(prefix + "Credits.pict");
+		else            // Make continue button...
+			_continueButton.initFromPICTFile(prefix + "Continue.pict");
+
+		_mainMenuButton.initFromPICTFile(prefix + "MainMenu.pict");
+		_mainMenuButton.setDisplayOrder(1);
+		_mainMenuButton.moveElementTo(kMainMenuLeftDemo, kMainMenuTopDemo);
+		_mainMenuButton.startDisplaying();
+
+		_quitButton.initFromPICTFile(prefix + "Quit.pict");
+		_quitButton.setDisplayOrder(1);
+		_quitButton.moveElementTo(kQuitLeftDemo, kQuitTopDemo);
+		_quitButton.startDisplaying();
+
+		_menuSelection = kDeathScreenContinueDemo;
+	} else {
+		if (!_playerWon) {
+			_mainMenuButton.initFromPICTFile(prefix + "MainMenu.pict");
+			_mainMenuButton.setDisplayOrder(1);
+			_mainMenuButton.moveElementTo(kMainMenuLeft, kMainMenuTop);
+			_mainMenuButton.startDisplaying();
+
+			_restoreButton.initFromPICTFile(prefix + "Restore.pict");
+			_restoreButton.setDisplayOrder(1);
+			_restoreButton.moveElementTo(kRestoreLeftDeath, kRestoreTopDeath);
+			_restoreButton.startDisplaying();
+		}
+
+		_continueButton.initFromPICTFile(prefix + "Continue.pict");
+
+		_menuSelection = kDeathScreenContinue;
+	}
+
+	_smallSelect.initFromPICTFile(prefix + "SelectS.pict", true);
+	_smallSelect.setDisplayOrder(2);
+	_smallSelect.startDisplaying();
+
+	_continueButton.setDisplayOrder(1);
+	_continueButton.moveElementTo(kContinueLeft, kContinueTop);
+	_continueButton.startDisplaying();
+
+	if (isDemo || !_playerWon) {
+		_largeSelect.initFromPICTFile(prefix + "SelectL.pict", true);
+		_largeSelect.setDisplayOrder(2);
+		_largeSelect.startDisplaying();
+	} else {
+		_triumphSound.initFromQuickTime("Sounds/Caldoria/Galactic Triumph");
+		_triumphSound.playSound();
+	}
+
+	updateDisplay();
+}
+
+void DeathMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	if (input.upButtonDown()) {
+		if (_menuSelection > (vm->isDemo() ? kFirstDeathSelectionDemo : kFirstDeathSelection)) {
+			_menuSelection--;
+			updateDisplay();
+		}
+	} else if (input.downButtonDown() && (vm->isDemo() || !_playerWon)) {
+		if (_menuSelection < (vm->isDemo() ? kLastDeathSelectionDemo : kLastDeathSelection)) {
+			_menuSelection++;
+			updateDisplay();
+		}
+	} else if (JMPPPInput::isMenuButtonPressInput(input)) {
+		if (vm->isDemo()) {
+			switch (_menuSelection) {
+			case kDeathScreenContinueDemo:
+				_continueButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_continueButton.hide();
+				setLastCommand(kMenuCmdDeathContinue);
+				break;
+			case kDeathScreenQuitDemo:
+				_quitButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_quitButton.hide();
+				setLastCommand(kMenuCmdDeathQuitDemo);
+				break;
+			case kDeathScreenMainMenuDemo:
+				_mainMenuButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_mainMenuButton.hide();
+				setLastCommand(kMenuCmdDeathMainMenuDemo);
+				break;
+			}
+		} else {
+			switch (_menuSelection) {
+			case kDeathScreenContinue:
+				_continueButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_continueButton.hide();
+				setLastCommand(kMenuCmdDeathContinue);
+				break;
+			case kDeathScreenRestore:
+				_restoreButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_restoreButton.hide();
+				setLastCommand(kMenuCmdDeathRestore);
+				break;
+			case kDeathScreenMainMenu:
+				_mainMenuButton.show();
+				vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+				_mainMenuButton.hide();
+				setLastCommand(kMenuCmdDeathMainMenu);
+				break;
+			}
+		}
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void DeathMenu::updateDisplay() {
+	if (((PegasusEngine *)g_engine)->isDemo()) {
+		switch (_menuSelection) {
+		case kDeathScreenContinueDemo:
+			_smallSelect.moveElementTo(kContinueSelectLeft, kContinueSelectTopDemo);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kDeathScreenQuitDemo:
+			_largeSelect.moveElementTo(kQuitSelectLeftDemo, kQuitSelectTopDemo);
+			_largeSelect.show();
+			_smallSelect.hide();
+			break;
+		case kDeathScreenMainMenuDemo:
+			_smallSelect.moveElementTo(kMainMenuSelectLeftDemo, kMainMenuSelectTopDemo);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		}
+	} else {
+		switch (_menuSelection) {
+		case kDeathScreenContinue:
+			_smallSelect.moveElementTo(kContinueSelectLeft, kContinueSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kDeathScreenRestore:
+			_smallSelect.moveElementTo(kRestoreSelectLeftDeath, kRestoreSelectTopDeath);
+			_smallSelect.show();
+			_largeSelect.hide();
+			break;
+		case kDeathScreenMainMenu:
+			_largeSelect.moveElementTo(kMainMenuSelectLeft, kMainMenuSelectTop);
+			_largeSelect.show();
+			_smallSelect.hide();
+			break;
+		}
+	}
+}
+
+void DeathMenu::drawAllScores() {
+	Surface numbers;
+	numbers.getImageFromPICTFile("Images/Death Screens/Numbers.pict");
+
+	Common::Rect scoreBounds;
+	tGameScoreType caldoriaTotal = 0;
+
+	switch (_deathReason) {
+	case kDeathCardBomb:
+	case kDeathShotBySinclair:
+	case kDeathSinclairShotDelegate:
+	case kDeathNuclearExplosion:
+	case kDeathGassedInNorad:
+	case kDeathWokeUpNorad:
+	case kDeathArrestedInNorad:
+	case kDeathSubDestroyed:
+	case kDeathRobotThroughNoradDoor:
+	case kDeathRobotSubControlRoom:
+	case kDeathWrongShuttleLock:
+	case kDeathArrestedInMars:
+	case kDeathRunOverByPod:
+	case kDeathDidntGetOutOfWay:
+	case kDeathReactorBurn:
+	case kDeathDidntFindMarsBomb:
+	case kDeathDidntDisarmMarsBomb:
+	case kDeathNoMaskInMaze:
+	case kDeathNoAirInMaze:
+	case kDeathGroundByMazebot:
+	case kDeathMissedOreBucket:
+	case kDeathDidntLeaveBucket:
+	case kDeathRanIntoCanyonWall:
+	case kDeathRanIntoSpaceJunk:
+	case kDeathDidntStopPoison:
+	case kDeathArrestedInWSC:
+	case kDeathHitByPlasma:
+	case kDeathShotOnCatwalk:
+	case kPlayerWonGame:
+		caldoriaTotal += kMaxCaldoriaTSAScoreAfter;
+		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5,
+				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5 + kDeathScreenScoreHeight);
+		drawScore(GameState.getGandhiScore(), kMaxGandhiScore, scoreBounds, &numbers);
+
+		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
+		drawScore(GameState.getWSCScore(), kMaxWSCScore, scoreBounds, &numbers);
+
+		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
+		drawScore(GameState.getNoradScore(), kMaxNoradScore, scoreBounds, &numbers);
+
+		scoreBounds.translate(0, kDeathScreenScoreSkipVert);
+		drawScore(GameState.getMarsScore(), kMaxMarsScore, scoreBounds, &numbers);
+		// fall through
+	case kDeathFallOffCliff:
+	case kDeathEatenByDinosaur:
+	case kDeathStranded:
+	case kDeathShotByTSARobots:
+		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert,
+				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert + kDeathScreenScoreHeight);
+		drawScore(GameState.getPrehistoricScore(), kMaxPrehistoricScore, scoreBounds, &numbers);
+		// fall through
+	case kDeathUncreatedInCaldoria:
+	case kDeathUncreatedInTSA:
+		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop, kDeathScreenScoreLeft + kDeathScreenScoreWidth,
+				kDeathScreenScoreTop + kDeathScreenScoreHeight);
+		caldoriaTotal += kMaxCaldoriaTSAScoreBefore;
+		drawScore(GameState.getCaldoriaTSAScore(), caldoriaTotal, scoreBounds, &numbers);
+
+		scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6,
+				kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6 + kDeathScreenScoreHeight);
+
+		drawScore(GameState.getTotalScore(), kMaxTotalScore, scoreBounds, &numbers);
+		break;
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
index 581fb5f..1724220 100755
--- a/engines/pegasus/menu.h
+++ b/engines/pegasus/menu.h
@@ -52,6 +52,11 @@ protected:
 
 	InputHandler *_previousHandler;
 	tGameMenuCommand _lastCommand;
+
+	void drawScore(tGameScoreType, tGameScoreType, const Common::Rect &, Surface *);
+
+private:
+	void drawNumber(tGameScoreType, tCoordType &, tCoordType, Surface *);
 };
 
 class Hotspot;
@@ -91,7 +96,7 @@ protected:
 
 class CreditsMenu : public GameMenu {
 public:
-	CreditsMenu(void);
+	CreditsMenu();
 	virtual ~CreditsMenu() {}
 	
 	virtual void handleInput(const Input &input, const Hotspot *);
@@ -108,6 +113,36 @@ protected:
 	Picture _smallSelect;
 };
 
+class DeathMenu : public GameMenu {
+public:
+	DeathMenu(const tDeathReason);
+	virtual ~DeathMenu() {}
+
+	virtual void handleInput(const Input &input, const Hotspot *);
+
+	bool playerWon() { return _playerWon; }
+
+protected:
+	void drawAllScores();
+
+	void updateDisplay();
+
+	bool _playerWon;
+	int _menuSelection;
+	tDeathReason _deathReason;
+
+	Picture _deathBackground;
+	Picture _continueButton;
+	Picture _restoreButton;
+	Picture _mainMenuButton;
+	Picture _quitButton;
+
+	Picture _largeSelect;
+	Picture _smallSelect;
+
+	Sound _triumphSound;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index be5a22e..468f3a4 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -259,47 +259,7 @@ void PegasusEngine::runIntro() {
 
 	video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
 
-	while (!shouldQuit() && !video->endOfVideo()) {
-		if (video->needsUpdate()) {
-			const Graphics::Surface *frame = video->decodeNextFrame();
-
-			// Scale up the frame doing some simple scaling
-			Graphics::Surface scaledFrame;
-			scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
-			const byte *src = (const byte *)frame->pixels;
-			byte *dst1 = (byte *)scaledFrame.pixels;
-			byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
-
-			for (int y = 0; y < frame->h; y++) {
-				for (int x = 0; x < frame->w; x++) {
-					memcpy(dst1, src, frame->format.bytesPerPixel);
-					dst1 += frame->format.bytesPerPixel;
-					memcpy(dst1, src, frame->format.bytesPerPixel);
-					dst1 += frame->format.bytesPerPixel;
-					memcpy(dst2, src, frame->format.bytesPerPixel);
-					dst2 += frame->format.bytesPerPixel;
-					memcpy(dst2, src, frame->format.bytesPerPixel);
-					dst2 += frame->format.bytesPerPixel;
-					src += frame->format.bytesPerPixel;
-				}
-
-				src += frame->pitch - frame->format.bytesPerPixel * frame->w;
-				dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-				dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-			}
-
-			_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, 0, 0, scaledFrame.w, scaledFrame.h);
-			_system->updateScreen();
-			scaledFrame.free();
-		}
-
-		Input input;
-		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
-		if (input.anyInput())
-			break;
-
-		_system->delayMillis(10);
-	}
+	playMovieScaled(video, 0, 0);
 
 	delete video;
 }
@@ -462,6 +422,8 @@ void PegasusEngine::loadFromContinuePoint() {
 
 	if (!loadFromStream(_continuePoint))
 		error("Failed loading continue point");
+
+	error("STUB: loadFromContinuePoint()");
 }
 
 Common::Error PegasusEngine::loadGameState(int slot) {
@@ -608,6 +570,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		}
 		break;
 	case kMenuCmdQuit:
+	case kMenuCmdDeathQuitDemo:
 		if (isDemo())
 			showTempScreen("Images/Demo/NGquitScrn.pict");
 		_system->quit();
@@ -622,6 +585,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		error("Start new game (walkthrough mode)");
 		break;
 	case kMenuCmdRestore:
+	case kMenuCmdDeathRestore:
 		error("Load game");
 		break;
 	case kMenuCmdCreditsMainMenu:
@@ -632,6 +596,53 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		// TODO: Fade in
 		resetIntroTimer();
 		break;
+	case kMenuCmdDeathContinue:
+		if (((DeathMenu *)_gameMenu)->playerWon()) {
+			if (isDemo()) {
+				showTempScreen("Images/Demo/DemoCredits.pict");
+				// TODO: Fade out
+				_gfx->updateDisplay();
+				// TODO: Fade in
+			} else {
+				// TODO: Fade out
+				useMenu(0);
+				_gfx->clearScreen();
+				_gfx->updateDisplay();
+
+				Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
+				if (!video->loadFile(_introDirectory + "/Closing.movie"))
+					error("Could not load closing movie");
+
+				uint16 x = (640 - video->getWidth() * 2) / 2;
+				uint16 y = (480 - video->getHeight() * 2) / 2;
+
+				playMovieScaled(video, x, y);
+
+				delete video;
+
+				if (shouldQuit())
+					return;
+
+				useMenu(new MainMenu());
+				_gfx->updateDisplay();
+				((MainMenu *)_gameMenu)->startMainMenuLoop();
+				// TODO: Fade in
+				resetIntroTimer();
+			}
+		} else {
+			loadFromContinuePoint();
+		}
+		break;
+	case kMenuCmdDeathMainMenuDemo:
+	case kMenuCmdDeathMainMenu:
+		// TODO: Fade out
+		useMenu(new MainMenu());
+		_gfx->updateDisplay();
+		((MainMenu *)_gameMenu)->startMainMenuLoop();
+		// TODO: Fade in
+		if (!isDemo())
+			resetIntroTimer();
+		break;
 	case kMenuCmdNoCommand:
 		break;
 	default:
@@ -961,4 +972,52 @@ void PegasusEngine::checkFlashlight() {
 		_neighborhood->checkFlashlight();
 }
 
+bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y) {
+	bool skipped = false;
+
+	while (!shouldQuit() && !video->endOfVideo() && !skipped) {
+		if (video->needsUpdate()) {
+			const Graphics::Surface *frame = video->decodeNextFrame();
+
+			// Scale up the frame doing some simple scaling
+			Graphics::Surface scaledFrame;
+			scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
+			const byte *src = (const byte *)frame->pixels;
+			byte *dst1 = (byte *)scaledFrame.pixels;
+			byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
+
+			for (int i = 0; i < frame->h; i++) {
+				for (int j = 0; j < frame->w; j++) {
+					memcpy(dst1, src, frame->format.bytesPerPixel);
+					dst1 += frame->format.bytesPerPixel;
+					memcpy(dst1, src, frame->format.bytesPerPixel);
+					dst1 += frame->format.bytesPerPixel;
+					memcpy(dst2, src, frame->format.bytesPerPixel);
+					dst2 += frame->format.bytesPerPixel;
+					memcpy(dst2, src, frame->format.bytesPerPixel);
+					dst2 += frame->format.bytesPerPixel;
+					src += frame->format.bytesPerPixel;
+				}
+
+				src += frame->pitch - frame->format.bytesPerPixel * frame->w;
+				dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+				dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+			}
+
+			_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+			_system->updateScreen();
+			scaledFrame.free();
+		}
+
+		Input input;
+		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+		if (input.anyInput())
+			skipped = true;
+
+		_system->delayMillis(10);
+	}
+
+	return skipped;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 6a5913d..f881aa6 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -40,7 +40,7 @@
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Video {
-	class QuickTimeDecoder;
+	class SeekableVideoDecoder;
 }
 
 namespace Pegasus {
@@ -187,6 +187,7 @@ private:
 	Hotspot _returnHotspot;
 	void showLoadDialog();
 	void showTempScreen(const Common::String &fileName);
+	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: e412b62ffce4297da7df8fc4b71a619fa3a89880
    https://github.com/scummvm/scummvm/commit/e412b62ffce4297da7df8fc4b71a619fa3a89880
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-26T06:29:17-07:00

Commit Message:
PEGASUS: Implement the death code

Changed paths:
    engines/pegasus/energymonitor.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index fc22a32..b1ea044 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -160,9 +160,9 @@ int32 EnergyMonitor::getCurrentEnergy() {
 
 void EnergyMonitor::timeChanged(const TimeValue currentTime) {
 	if (currentTime == getStop()) {
-		// TODO: Die :P
-		if (((PegasusEngine *)g_engine)->getEnergyDeathReason() != -1)
-			error("You're dead");
+		PegasusEngine *vm = (PegasusEngine *)g_engine;
+		if (vm->getEnergyDeathReason() != -1)
+			vm->die(vm->getEnergyDeathReason());
 	} else {
 		uint32 currentEnergy = kMaxJMPEnergy - currentTime;
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 468f3a4..3a8e868 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -495,6 +495,9 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 #endif
 			break;
 		}
+		case kPlayerDiedFlag:
+			doDeath();
+			break;
 		default:
 			break;
 		}
@@ -1020,4 +1023,23 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x
 	return skipped;
 }
 
+void PegasusEngine::die(const tDeathReason reason) {
+	// TODO: Stop dragging
+
+	_deathReason = reason;
+	_shellNotification.setNotificationFlags(kPlayerDiedFlag, kPlayerDiedFlag);
+}
+
+void PegasusEngine::doDeath() {
+	// TODO: Fade out
+	throwAwayEverything();
+	useMenu(new DeathMenu(_deathReason));
+	_gfx->updateDisplay();
+	// TODO: Fade in
+}
+
+void PegasusEngine::throwAwayEverything() {
+	// TODO
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index f881aa6..b01e192 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -111,6 +111,7 @@ public:
 	void setEnergyDeathReason(const tDeathReason reason) { _deathReason = reason; } 
 	tDeathReason getEnergyDeathReason() { return _deathReason; }
 	void resetEnergyDeathReason();
+	void die(const tDeathReason);
 
 	// Volume
 	uint16 getSoundFXLevel();
@@ -188,6 +189,7 @@ private:
 	void showLoadDialog();
 	void showTempScreen(const Common::String &fileName);
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
+	void throwAwayEverything();
 
 	// Menu
 	GameMenu *_gameMenu;
@@ -199,6 +201,7 @@ private:
 
 	// Death
 	tDeathReason _deathReason;
+	void doDeath();
 
 	// Neighborhood
 	Neighborhood *_neighborhood;


Commit: e343e4c5d816ffb5502f44dfa7f49fc8c2bcca24
    https://github.com/scummvm/scummvm/commit/e343e4c5d816ffb5502f44dfa7f49fc8c2bcca24
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-26T06:29:31-07:00

Commit Message:
PEGASUS: Add a debugger command to die

Changed paths:
    engines/pegasus/console.cpp
    engines/pegasus/console.h



diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
index d6a8c1e..2c1a761 100644
--- a/engines/pegasus/console.cpp
+++ b/engines/pegasus/console.cpp
@@ -29,10 +29,34 @@
 namespace Pegasus {
 
 PegasusConsole::PegasusConsole(PegasusEngine *vm) : GUI::Debugger(), _vm(vm) {
-	// TODO! :P
+	DCmd_Register("die", WRAP_METHOD(PegasusConsole, Cmd_Die));
 }
 
 PegasusConsole::~PegasusConsole() {
 }
 
+bool PegasusConsole::Cmd_Die(int argc, const char **argv) {
+	if (argc == 1) {
+		DebugPrintf("Usage: die <death reason>\n");
+		return true;
+	}
+
+	int reason = atoi(argv[1]);
+
+	bool invalidReason = (reason == 0 || reason > kPlayerWonGame);
+
+	if (!invalidReason && _vm->isDemo())
+		invalidReason = (reason != kDeathFallOffCliff) && (reason != kDeathEatenByDinosaur) &&
+				(reason != kDeathStranded) && (reason != kPlayerWonGame);
+
+
+	if (invalidReason) {
+		DebugPrintf("Invalid death reason %d\n", reason);
+		return true;
+	}
+
+	_vm->die(atoi(argv[1]));
+	return false;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/console.h b/engines/pegasus/console.h
index f544344..07adccd 100644
--- a/engines/pegasus/console.h
+++ b/engines/pegasus/console.h
@@ -38,6 +38,8 @@ public:
 	virtual ~PegasusConsole();
 
 private:
+	bool Cmd_Die(int argc, const char **argv);
+
 	PegasusEngine *_vm;
 };
 


Commit: 4f358e7615f7d68887eb3ab608a9d7ce1d9a4d93
    https://github.com/scummvm/scummvm/commit/4f358e7615f7d68887eb3ab608a9d7ce1d9a4d93
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-26T09:36:50-07:00

Commit Message:
PEGASUS: Begin populating the Neighborhood class with more useful functions

Changed paths:
    engines/pegasus/ai/ai_condition.cpp
    engines/pegasus/elements.h
    engines/pegasus/energymonitor.cpp
    engines/pegasus/fader.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/ai/ai_condition.cpp b/engines/pegasus/ai/ai_condition.cpp
index dbb66dd..f01d5f9 100755
--- a/engines/pegasus/ai/ai_condition.cpp
+++ b/engines/pegasus/ai/ai_condition.cpp
@@ -28,6 +28,7 @@
 #include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/ai/ai_condition.h"
+#include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/items/inventory/inventoryitem.h"
 
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 46b3bc5..f806f26 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -32,7 +32,6 @@
 #include "graphics/pict.h"
 #include "graphics/surface.h"
 
-#include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
 #include "pegasus/util.h"
 
diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index b1ea044..9a82e36 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/energymonitor.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/surface.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
index 3d8305b..8eb1c01 100755
--- a/engines/pegasus/fader.cpp
+++ b/engines/pegasus/fader.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/fader.h"
+#include "pegasus/sound.h"
 #include "pegasus/util.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 6f0bf79..cba6fd9 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -26,6 +26,7 @@
 #include "common/debug.h"
 #include "common/stream.h"
 
+#include "pegasus/compass.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/input.h"
 #include "pegasus/pegasus.h"
@@ -33,9 +34,21 @@
 
 namespace Pegasus {
 
+StriderCallBack::StriderCallBack(Neighborhood *neighborhood) {
+	_neighborhood = neighborhood;
+}
+
+void StriderCallBack::callBack() {
+	_neighborhood->checkStriding();
+}
+
+static const TimeValue kStridingSlop = 39;
+
 Neighborhood *g_neighborhood = 0;
 
-Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) : InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName) {
+Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id)
+		: InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName), _navMovie(kNavMovieID), _stridingCallBack(this),
+		_neighborhoodNotification(kNeighborhoodNotificationID, (NotificationManager *)vm) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 	_interruptionFilter = kFilterAllInput;
@@ -435,4 +448,86 @@ tAirQuality Neighborhood::getAirQuality(const tRoomID) {
 	return kAirQualityGood;
 }
 
+void Neighborhood::checkStriding() {
+	if (stillMoveForward()) {
+		ExitTable::Entry nextExit;
+		getExitEntry(GameState.getNextRoom(), GameState.getNextDirection(), nextExit);
+		keepStriding(nextExit);
+	} else {
+		stopStriding();
+	}
+}
+
+bool Neighborhood::stillMoveForward() {
+	Input input;
+
+	InputHandler::readInputDevice(input);
+	return input.upButtonAnyDown();
+}
+
+void Neighborhood::keepStriding(ExitTable::Entry &nextExitEntry) {
+	FaderMoveSpec compassMove;
+
+	// TODO: Map
+	if (g_compass)
+		getExitCompassMove(nextExitEntry, compassMove);
+
+	GameState.setCurrentRoom(GameState.getNextRoom());
+	GameState.setCurrentDirection(GameState.getNextDirection());
+	GameState.setNextRoom(nextExitEntry.exitRoom);
+	GameState.setNextDirection(nextExitEntry.exitDirection);
+
+	if (nextExitEntry.movieEnd == nextExitEntry.exitEnd)
+		scheduleNavCallBack(kNeighborhoodMovieCompletedFlag | kMoveForwardCompletedFlag);
+	else
+		scheduleStridingCallBack(nextExitEntry.movieEnd - kStridingSlop, kStrideCompletedFlag);
+
+	if (g_compass)
+		g_compass->startFader(compassMove);
+}
+
+void Neighborhood::stopStriding() {
+	_navMovie.stop();
+	_neighborhoodNotification.setNotificationFlags(kNeighborhoodMovieCompletedFlag |
+			kMoveForwardCompletedFlag, kNeighborhoodMovieCompletedFlag | kMoveForwardCompletedFlag);
+}
+
+//	Compass support
+uint16 Neighborhood::getStaticCompassAngle(const tRoomID, const tDirectionConstant dir) {
+	//	North, south, east, west
+	static const uint16 compassAngles[] = { 0, 180, 90, 270 };
+	return compassAngles[dir];
+}
+
+void Neighborhood::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {	
+	int32 startAngle = getStaticCompassAngle(exitEntry.room, exitEntry.direction);
+	int32 stopAngle = getStaticCompassAngle(exitEntry.exitRoom, exitEntry.exitDirection);
+
+	if (startAngle > stopAngle) {
+		if (stopAngle + 180 < startAngle)
+			stopAngle += 360;
+	} else {
+		if (startAngle + 180 < stopAngle)
+			startAngle += 360;
+	}
+
+	compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, startAngle, exitEntry.movieEnd, stopAngle);
+}
+
+void Neighborhood::scheduleNavCallBack(tNotificationFlags flags) {
+	_navMovieCallBack.cancelCallBack();
+
+	if (flags != 0) {
+		_navMovieCallBack.setCallBackFlag(flags);
+		_navMovieCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+}
+
+void Neighborhood::scheduleStridingCallBack(const TimeValue strideStop, tNotificationFlags flags) {	
+	_stridingCallBack.cancelCallBack();
+
+	if (flags != 0)
+		_stridingCallBack.scheduleCallBack(kTriggerTimeFwd, strideStop, _navMovie.getScale());
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index fcfc833..5d3e75b 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -29,10 +29,13 @@
 #include "common/queue.h"
 #include "common/str.h"
 
+#include "pegasus/fader.h"
 #include "pegasus/hotspot.h"
 #include "pegasus/input.h"
+#include "pegasus/movie.h"
 #include "pegasus/notification.h"
 #include "pegasus/sound.h"
+#include "pegasus/timers.h"
 #include "pegasus/util.h"
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
@@ -83,9 +86,24 @@ struct tQueueRequest {
 bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
 bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
+class Neighborhood;
+
+class StriderCallBack : public TimeBaseCallBack {
+public:
+	StriderCallBack(Neighborhood *);
+	virtual ~StriderCallBack() {}
+
+protected:
+	virtual void callBack();
+
+	Neighborhood *_neighborhood;
+};
+
 typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
 class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler {
+friend class StriderCallBack;
+
 public:
 	Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
 	virtual ~Neighborhood();
@@ -131,19 +149,30 @@ public:
 	virtual void shieldOn() {}
 	virtual void shieldOff() {}
 
+	virtual void scheduleNavCallBack(tNotificationFlags);
+
 protected:
+	PegasusEngine *_vm;
+	Common::String _resName;
+
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
 
 	virtual void createNeighborhoodSpots();
 	virtual void loadSoundSpots();
 
+	// Nav movie sequences.
+	virtual void checkStriding();
+	virtual void keepStriding(ExitTable::Entry &);
+	virtual void stopStriding();
+	virtual bool stillMoveForward();
+	virtual void scheduleStridingCallBack(const TimeValue, tNotificationFlags flags);
+
+	// Action queue stuff
 	void popActionQueue();
 	void serviceActionQueue();
 	void requestAction(const tQueueRequestType, const tExtraID, const TimeValue, const TimeValue, const tInputBits, const tNotificationFlags);
 
-	PegasusEngine *_vm;
-	Common::String _resName;
-
+	// Navigation Data
 	DoorTable _doorTable;
 	ExitTable _exitTable;
 	ExtraTable _extraTable;
@@ -152,6 +181,16 @@ protected:
 	TurnTable _turnTable;
 	ViewTable _viewTable;
 	ZoomTable _zoomTable;
+	virtual uint16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
+	virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+
+	// Graphics
+	Movie _navMovie;
+
+	// Callbacks
+	Notification _neighborhoodNotification;
+	NotificationCallBack _navMovieCallBack;
+	StriderCallBack _stridingCallBack;
 
 	tAlternateID _currentAlternate;
 


Commit: 122d484c4f0505e914a2c8c3fcaea6769f6d3296
    https://github.com/scummvm/scummvm/commit/122d484c4f0505e914a2c8c3fcaea6769f6d3296
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-26T19:09:56-07:00

Commit Message:
PEGASUS: Import a bunch more neighborhood code

Changed paths:
    engines/pegasus/neighborhood/exit.h
    engines/pegasus/neighborhood/hotspotinfo.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/types.h



diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index cd7bec4..671f307 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -68,6 +68,10 @@ public:
 
 	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
 
+	typedef Common::Array<Entry>::iterator iterator;
+	iterator begin() { return _entries.begin(); }
+	iterator end() { return _entries.end(); }
+
 private:
 	Common::Array<Entry> _entries;
 };
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
index a9acfe7..3c958c9 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.h
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -64,6 +64,10 @@ public:
 
 	Entry findEntry(tHotSpotID hotspot);
 
+	typedef Common::Array<Entry>::iterator iterator;
+	iterator begin() { return _entries.begin(); }
+	iterator end() { return _entries.end(); }
+
 private:
 	Common::Array<Entry> _entries;
 };
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index cba6fd9..f92c2b7 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -27,9 +27,13 @@
 #include "common/stream.h"
 
 #include "pegasus/compass.h"
+#include "pegasus/cursor.h"
+#include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/input.h"
+#include "pegasus/interface.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
@@ -48,7 +52,8 @@ Neighborhood *g_neighborhood = 0;
 
 Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id)
 		: InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName), _navMovie(kNavMovieID), _stridingCallBack(this),
-		_neighborhoodNotification(kNeighborhoodNotificationID, (NotificationManager *)vm) {
+		_neighborhoodNotification(kNeighborhoodNotificationID, (NotificationManager *)vm), _pushIn(kNoDisplayElement),
+		_turnPush(kTurnPushID), _croppedMovie(kCroppedMovieID) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
 	_interruptionFilter = kFilterAllInput;
@@ -115,9 +120,39 @@ void Neighborhood::init() {
 	delete stream;
 
 	createNeighborhoodSpots();
+
+	// TODO: Load _navMovie
+	_navMovie.setVolume(_vm->getSoundFXLevel());
+
 	loadSoundSpots();
+	_spotSounds.setVolume(_vm->getSoundFXLevel());
+
+	_navMovie.setDisplayOrder(kNavMovieOrder);
+	_navMovie.startDisplaying();
 
-	// TODO: AI, movies, notifications, buncha other stuff
+	Common::Rect bounds;
+	_navMovie.getBounds(bounds);
+	_pushIn.allocateSurface(bounds);
+
+	_turnPush.setInAndOutElements(&_pushIn, &_navMovie);
+	_turnPush.setDisplayOrder(kTurnPushOrder);
+	_turnPush.startDisplaying();
+	_navMovieCallBack.initCallBack(&_navMovie, kCallBackAtExtremes);
+	_stridingCallBack.initCallBack(&_navMovie, kCallBackAtTime);
+	_turnPushCallBack.initCallBack(&_turnPush, kCallBackAtExtremes);
+	_delayCallBack.initCallBack(&_delayTimer, kCallBackAtExtremes);
+
+	// TODO
+	//_spotSoundCallBack.initCallBack(&_spotSounds, kCallBackAtExtremes);
+
+	setUpAIRules();
+
+	if (g_compass)
+		g_compass->setFaderValue(getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+
+	_soundLoop1.attachFader(&_loop1Fader);
+	_soundLoop2.attachFader(&_loop2Fader);
+	startIdling();
 }
 
 void Neighborhood::start() {
@@ -127,14 +162,54 @@ void Neighborhood::start() {
 }
 
 void Neighborhood::receiveNotification(Notification *, const tNotificationFlags flags) {
+	if ((flags & (kNeighborhoodMovieCompletedFlag | kTurnCompletedFlag)) != 0 && g_AIArea)
+		g_AIArea->unlockAI();
 	if (flags & kMoveForwardCompletedFlag)
 		arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
-
-	// TODO: Other types
+	if (flags & kTurnCompletedFlag)
+		turnTo(GameState.getNextDirection());
+	if (flags & kSpotCompletedFlag)
+		spotCompleted();
+	if (flags & kDoorOpenCompletedFlag)
+		doorOpened();
+	if (flags & kActionRequestCompletedFlag)
+		popActionQueue();
+	if (flags & kDeathExtraCompletedFlag)
+		die(_extraDeathReason);
 }
 
 void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
-	// TODO
+	// TODO: Map
+
+	GameState.setCurrentNeighborhood(getObjectID());
+
+	_currentActivation = kActivateHotSpotAlways;
+	_interruptionFilter = kFilterAllInput;
+
+	if (room != GameState.getCurrentRoom() || direction != GameState.getCurrentDirection()) {
+		GameState.setCurrentRoom(room);
+		GameState.setCurrentDirection(direction);
+		loadAmbientLoops();
+		activateCurrentView(room, direction, kSpotOnArrivalMask);
+	} else {
+		loadAmbientLoops();
+		showViewFrame(getViewTime(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+	}
+
+	if (GameState.getOpenDoorRoom() != kNoRoomID) {
+		// Arriving always closes a door.
+		loadAmbientLoops();
+		closeDoorOffScreen(GameState.getOpenDoorRoom(), GameState.getOpenDoorDirection());
+		GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
+	}
+
+	if (g_compass)
+		g_compass->setFaderValue(getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+
+	if (g_AIArea)
+		g_AIArea->checkMiddleArea();
+
+	checkContinuePoint(room, direction);
 }
 
 //	These functions can be overridden to tweak the exact frames used.
@@ -172,11 +247,11 @@ void Neighborhood::getDoorEntry(const tRoomID room, const tDirectionConstant dir
 		doorEntry = _doorTable.findEntry(room, direction, kNoAlternateID);
 }
 
-tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn) {
-	TurnTable::Entry turnEntry = _turnTable.findEntry(room, direction, turn, _currentAlternate);
+tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turnDirection) {
+	TurnTable::Entry turnEntry = _turnTable.findEntry(room, direction, turnDirection, _currentAlternate);
 
 	if (turnEntry.isEmpty())
-		turnEntry = _turnTable.findEntry(room, direction, turn, kNoAlternateID);
+		turnEntry = _turnTable.findEntry(room, direction, turnDirection, kNoAlternateID);
 
 	return turnEntry.turnDirection;
 }
@@ -230,8 +305,8 @@ tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	return kCanMoveForward;
 }
 
-tCanTurnReason Neighborhood::canTurn(tTurnDirection turn, tDirectionConstant &nextDir) {
-	nextDir = getTurnEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), turn);
+tCanTurnReason Neighborhood::canTurn(tTurnDirection turnDirection, tDirectionConstant &nextDir) {
+	nextDir = getTurnEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), turnDirection);
 
 	if (nextDir == kNoDirection)
 		return kCantTurnNoTurn;
@@ -393,6 +468,23 @@ void Neighborhood::requestSpotSound(const TimeValue in, const TimeValue out, con
 	requestAction(kSpotSoundRequest, 0xFFFFFFFF, in, out, interruptionFilter, flags);
 }
 
+void Neighborhood::playSpotSoundSync(const TimeValue in, const TimeValue out) {
+	// Let the action queue play out first...
+	while (!actionQueueEmpty()) {
+		_vm->refreshDisplay();
+		_vm->checkNotifications();
+		_vm->_system->delayMillis(10);
+	}
+
+	_spotSounds.stopSound();
+	_spotSounds.playSoundSegment(in * 1000 / 600, out * 1000 / 600);
+
+	while (_spotSounds.isPlaying()) {
+		_vm->refreshDisplay();
+		_vm->_system->delayMillis(10);
+	}
+}
+
 void Neighborhood::requestDelay(const TimeValue delayDuration, const TimeScale delayScale, const tInputBits interruptionFilter, const tNotificationFlags flags) {
 	requestAction(kDelayRequest, 0xFFFFFFFF, delayDuration, delayScale, interruptionFilter, flags);
 }
@@ -530,4 +622,756 @@ void Neighborhood::scheduleStridingCallBack(const TimeValue strideStop, tNotific
 		_stridingCallBack.scheduleCallBack(kTriggerTimeFwd, strideStop, _navMovie.getScale());
 }
 
+void Neighborhood::moveNavTo(const tCoordType h, const tCoordType v) {
+	tCoordType oldH, oldV;
+	_navMovie.getLocation(oldH, oldV);
+
+	tCoordType offH = h - oldH;
+	tCoordType offV = v - oldV;
+
+	_navMovie.moveElementTo(h, v);
+	_turnPush.moveElementTo(h, v);
+
+	if (offH != 0 || offV != 0)
+		for (HotspotList::iterator it = _neighborhoodHotspots.begin(); it != _neighborhoodHotspots.end(); it++)
+			if ((*it)->getHotspotFlags() & kNeighborhoodSpotFlag)
+				(*it)->moveSpot(offH, offV);
+}
+
+void Neighborhood::activateHotspots() {	
+	InputHandler::activateHotspots();
+
+	for (HotspotInfoTable::iterator it = _hotspotInfoTable.begin(); it != _hotspotInfoTable.end(); it++) {
+		HotspotInfoTable::Entry entry = *it;
+
+		if (entry.hotspotRoom == GameState.getCurrentRoom() && entry.hotspotDirection == GameState.getCurrentDirection()
+				&& (entry.hotspotActivation == _currentActivation || entry.hotspotActivation == kActivateHotSpotAlways)) {
+			Hotspot *hotspot = g_allHotspots.findHotspotByID(entry.hotspot);
+			if (hotspot)
+				activateOneHotspot(entry, hotspot);
+		}
+	}
+}
+
+void Neighborhood::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {	
+	tHotSpotFlags flags = clickedSpot->getHotspotFlags();
+
+	if ((flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag)) != 0) {
+		tItemID itemID = kNoItemID;
+
+		for (HotspotInfoTable::iterator it = _hotspotInfoTable.begin(); it != _hotspotInfoTable.end(); it++) {
+			if (it->hotspot == clickedSpot->getObjectID()) {
+				itemID = it->hotspotItem;
+				break;
+			}
+		}
+
+		if (itemID != kNoItemID) {
+			Item *draggingItem = g_allItems.findItemByID(itemID);
+
+			if (draggingItem) {
+				takeItemFromRoom(draggingItem);
+
+				if ((flags & kPickUpItemSpotFlag) != 0)
+					_vm->dragItem(input, draggingItem, kDragInventoryPickup);
+				else
+					_vm->dragItem(input, draggingItem, kDragBiochipPickup);
+			}
+		}
+	} else {
+		// Check other flags here?
+		if ((flags & kZoomSpotFlags) != 0) {
+			zoomTo(clickedSpot);
+		} else if ((flags & kPlayExtraSpotFlag) != 0) {
+			HotspotInfoTable::Entry hotspotEntry;
+			getHotspotEntry(clickedSpot->getObjectID(), hotspotEntry);
+			startExtraSequence(hotspotEntry.hotspotExtra, kExtraCompletedFlag, kFilterNoInput);
+		} else if ((flags & kOpenDoorSpotFlag) != 0) {
+			openDoor();
+		} else {
+			InputHandler::clickInHotspot(input, clickedSpot);
+		}
+	}
+}
+
+void Neighborhood::cantMoveThatWay(tCanMoveForwardReason reason) {
+	switch (reason) {
+	case kCantMoveDoorClosed:
+	case kCantMoveDoorLocked:
+		openDoor();
+		break;
+	case kCantMoveBlocked:
+		zoomUpOrBump();
+		break;
+	default:
+		bumpIntoWall();
+		break;
+	}
+}
+
+void Neighborhood::cantOpenDoor(tCanOpenDoorReason) {
+	bumpIntoWall();
+}
+
+void Neighborhood::turnTo(const tDirectionConstant direction) {
+	// TODO: Map
+
+	_pushIn.copyToCurrentPort();
+	
+	// Added 2/10/97. Shouldn't this be here? Shouldn't we set the current activation to
+	// always when turning to a new view?
+	_currentActivation = kActivateHotSpotAlways;
+	
+	_interruptionFilter = kFilterAllInput;
+
+	if (direction != GameState.getCurrentDirection()) {
+		GameState.setCurrentDirection(direction);
+		activateCurrentView(GameState.getCurrentRoom(), direction, kSpotOnTurnMask);
+	} else {
+		showViewFrame(getViewTime(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+	}
+
+	if (GameState.getOpenDoorRoom() != kNoRoomID) {
+		// Turning always closes a door.
+		loadAmbientLoops();
+		closeDoorOffScreen(GameState.getOpenDoorRoom(), GameState.getOpenDoorDirection());
+		GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
+	}
+
+	if (g_AIArea)
+		g_AIArea->checkMiddleArea();
+
+	checkContinuePoint(GameState.getCurrentRoom(), direction);
+
+	_vm->_cursor->hideUntilMoved();
+}
+
+void Neighborhood::spotCompleted() {
+	_interruptionFilter = kFilterAllInput;
+	showViewFrame(getViewTime(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+}
+
+void Neighborhood::doorOpened() {	
+	_interruptionFilter = kFilterAllInput;
+
+	// 2/23/97
+	// Fixes funny bug with doors that are opened by dropping things on them...
+	setCurrentActivation(kActivateHotSpotAlways);
+
+	GameState.setOpenDoorLocation(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+
+	SpotTable::Entry entry;
+	findSpotEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), kSpotOnDoorOpenMask, entry);
+
+	if (entry.dstFlags & kSpotOnDoorOpenMask) {
+		startSpotOnceOnly(entry.movieStart, entry.movieEnd);
+	} else {
+		findSpotEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), kSpotOnDoorOpenMask | kSpotLoopsMask, entry);
+
+		if (entry.dstFlags & kSpotOnDoorOpenMask)
+			startSpotLoop(entry.movieStart, entry.movieEnd);
+	}
+
+	loadAmbientLoops();
+
+	// TODO: Map
+
+	if (g_AIArea)
+		g_AIArea->checkMiddleArea();
+}
+
+void Neighborhood::moveForward() {
+	ExitTable::Entry exitEntry;
+	tCanMoveForwardReason moveReason = canMoveForward(exitEntry);
+
+	if (moveReason == kCanMoveForward)
+		startExitMovie(exitEntry);
+	else
+		cantMoveThatWay(moveReason);
+}
+
+void Neighborhood::turn(const tTurnDirection turnDirection) {
+	tDirectionConstant nextDir;	
+	tCanTurnReason turnReason = canTurn(turnDirection, nextDir);
+
+	if (turnReason == kCanTurn)
+		startTurnPush(turnDirection, getViewTime(GameState.getCurrentRoom(), nextDir), nextDir);
+	else
+		cantTurnThatWay(turnReason);
+}
+
+void Neighborhood::turnLeft() {
+	turn(kTurnLeft);
+}
+
+void Neighborhood::turnRight() {
+	turn(kTurnRight);
+}
+
+void Neighborhood::turnUp() {
+	turn(kTurnUp);
+}
+
+void Neighborhood::turnDown() {
+	turn(kTurnDown);
+}
+
+void Neighborhood::openDoor() {
+	DoorTable::Entry door;	
+	tCanOpenDoorReason doorReason = canOpenDoor(door);
+
+	if (doorReason == kCanOpenDoor)
+		startDoorOpenMovie(door.movieStart, door.movieEnd);
+	else
+		cantOpenDoor(doorReason);
+}
+
+void Neighborhood::zoomTo(const Hotspot *hotspot) {
+	ZoomTable::Entry zoomEntry;
+	getZoomEntry(hotspot->getObjectID(), zoomEntry);
+	if (!zoomEntry.isEmpty())
+		startZoomMovie(zoomEntry);
+}
+
+void Neighborhood::updateViewFrame() {
+	showViewFrame(getViewTime(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
+}
+
+void Neighborhood::startSpotLoop(TimeValue startTime, TimeValue stopTime, tNotificationFlags flags) {
+	_turnPush.hide();
+	startMovieSequence(startTime, stopTime, flags, true, kFilterAllInput);
+}
+
+void Neighborhood::showViewFrame(TimeValue viewTime) {	
+	if ((int32)viewTime >= 0) {
+		_turnPush.hide();
+		_navMovie.stop();
+		_navMovie.setFlags(0);
+		_navMovie.setSegment(0, _navMovie.getDuration());
+		_navMovie.setTime(viewTime);
+
+		Common::Rect pushBounds;
+		_turnPush.getBounds(pushBounds);
+
+		_navMovie.moveElementTo(pushBounds.left, pushBounds.top);
+		_navMovie.show();
+		_navMovie.redrawMovieWorld();
+	}
+}
+
+void Neighborhood::startExtraSequence(const tExtraID extraID, const tNotificationFlags flags, const tInputBits interruptionFilter) {
+	ExtraTable::Entry entry;
+	getExtraEntry(extraID, entry);
+
+	if (entry.movieStart != 0xffffffff)
+		playExtraMovie(entry, flags, interruptionFilter);
+}
+
+bool Neighborhood::startExtraSequenceSync(const tExtraID extraID, const tInputBits interruptionFilter) {
+	InputHandler::getCurrentInputDevice()->waitInput(interruptionFilter);
+	return prepareExtraSync(extraID) && waitMovieFinish(&_navMovie, interruptionFilter);
+}
+
+void Neighborhood::loopExtraSequence(const uint32 extraID, tNotificationFlags flags) {
+	ExtraTable::Entry entry;
+	getExtraEntry(extraID, entry);
+	
+	if (entry.movieStart != 0xffffffff) {
+		_lastExtra = extraID;
+		startSpotLoop(entry.movieStart, entry.movieEnd, flags);
+	}
+}
+
+bool Neighborhood::navMoviePlaying() {
+	return _navMovie.isRunning();
+}
+
+void Neighborhood::playDeathExtra(tExtraID extra, tDeathReason deathReason) {
+	_extraDeathReason = deathReason;
+	startExtraSequence(extra, kDeathExtraCompletedFlag, kFilterNoInput);
+}
+
+void Neighborhood::die(const tDeathReason deathReason) {
+	loadLoopSound1("");
+	loadLoopSound2("");
+	_vm->die(deathReason);
+}
+
+void Neighborhood::setSoundFXLevel(const uint16 fxLevel) {
+	if (_navMovie.isSurfaceValid())
+		_navMovie.setVolume(fxLevel);
+	if (_spotSounds.isSoundLoaded())
+		_spotSounds.setVolume(fxLevel);
+	// TODO
+	//if (_currentInteraction)
+	//	_currentInteraction->setSoundFXLevel(fxLevel);
+}
+
+void Neighborhood::setAmbienceLevel(const uint16 ambientLevel) {
+	if (_soundLoop1.isSoundLoaded())
+		_loop1Fader.setMasterVolume(_vm->getAmbienceLevel());
+	if (_soundLoop2.isSoundLoaded())
+		_loop2Fader.setMasterVolume(_vm->getAmbienceLevel());
+	// TODO
+	//if (_currentInteraction)
+	//	_currentInteraction->setAmbienceLevel(ambientLevel);
+}
+
+// Force the exit taken from (room, direction, alternate) to come to a stop.
+void Neighborhood::forceStridingStop(const tRoomID room, const tDirectionConstant direction, const tAlternateID alternate) {
+	ExitTable::Entry entry = _exitTable.findEntry(room, direction, alternate);
+
+	if (entry.movieStart != 0xffffffff) {
+		TimeValue strideStop = entry.exitEnd;
+		TimeValue exitStop = entry.movieEnd;
+
+		if (strideStop != exitStop) {
+			for (ExitTable::iterator it = _exitTable.begin(); it != _exitTable.end(); it++) {
+				entry = *it;
+
+				if (entry.exitEnd == strideStop && entry.movieEnd <= exitStop) {
+					entry.exitEnd = exitStop;
+					*it = entry;
+				}
+			}
+		}
+	}
+}
+
+// Restore the exit taken from (room, direction, alternate) to stride.
+void Neighborhood::restoreStriding(const tRoomID room, const tDirectionConstant direction, const tAlternateID alternate) {
+	ExitTable::Entry entry = _exitTable.findEntry(room, direction, alternate);
+
+	if (entry.movieStart != 0xffffffff) {
+		TimeValue strideStop = entry.exitEnd;
+		TimeValue exitStop = entry.movieEnd;
+
+		if (strideStop != entry.originalEnd) {
+			for (ExitTable::iterator it = _exitTable.begin(); it != _exitTable.end(); it++) {
+				entry = *it;
+
+				if (entry.exitEnd == strideStop && entry.movieEnd <= exitStop) {
+					entry.exitEnd = entry.originalEnd;
+					*it = entry;
+				}
+			}
+		}
+	}
+}
+
+HotspotInfoTable::Entry *Neighborhood::findHotspotEntry(const tHotSpotID id) {
+	for (HotspotInfoTable::iterator it = _hotspotInfoTable.begin(); it != _hotspotInfoTable.end(); it++)
+		if (it->hotspot == id)
+			return &(*it);
+
+	return 0;
+}
+
+void Neighborhood::hideNav() {
+	_isRunning = _navMovie.isRunning();
+	_navMovie.stop();
+	_navMovie.hide();
+	_turnPush.stopFader();
+	_turnPush.hide();
+}
+
+void Neighborhood::showNav() {
+	_navMovie.show();
+	_turnPush.hide();
+	if (_isRunning)
+		_navMovie.start();
+}
+
+void Neighborhood::startExitMovie(const ExitTable::Entry &exitEntry) {
+	FaderMoveSpec compassMove;
+	
+	if (g_compass)
+		getExitCompassMove(exitEntry, compassMove);
+
+	GameState.setNextRoom(exitEntry.exitRoom);
+	GameState.setNextDirection(exitEntry.exitDirection);
+
+	if (exitEntry.movieEnd == exitEntry.exitEnd) // Just a walk.
+		startMovieSequence(exitEntry.movieStart, exitEntry.movieEnd, kMoveForwardCompletedFlag, kFilterNoInput, false);
+	else // We're stridin'!
+		startMovieSequence(exitEntry.movieStart, exitEntry.exitEnd, kStrideCompletedFlag, kFilterNoInput, false, exitEntry.movieEnd);
+
+	if (g_compass)
+		g_compass->startFader(compassMove);
+}
+
+void Neighborhood::startZoomMovie(const ZoomTable::Entry &zoomEntry) {
+	FaderMoveSpec compassMove;
+	
+	if (g_compass)
+		getZoomCompassMove(zoomEntry, compassMove);
+
+	GameState.setNextRoom(zoomEntry.room);
+	GameState.setNextDirection(zoomEntry.direction);
+
+	startMovieSequence(zoomEntry.movieStart, zoomEntry.movieEnd, kMoveForwardCompletedFlag, kFilterNoInput, false);
+
+	if (g_compass)
+		g_compass->startFader(compassMove);
+}
+
+void Neighborhood::startDoorOpenMovie(const TimeValue startTime, const TimeValue stopTime) {
+	startMovieSequence(startTime, stopTime, kDoorOpenCompletedFlag, kFilterNoInput, false);
+}
+
+void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeValue newView, const tDirectionConstant nextDir) {
+	if (g_AIArea)
+		g_AIArea->lockAIOut();
+
+	_vm->_cursor->hide();
+
+	GameState.setNextDirection(nextDir);
+
+	_interruptionFilter = kFilterNoInput;
+	_turnPush.stopFader();
+
+	// Set up callback.
+	_turnPushCallBack.setCallBackFlag(kTurnCompletedFlag);
+	_turnPushCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+	// Stop nav movie.
+	_navMovie.stop();
+	_navMovie.setFlags(0);
+
+	// Set segment of nav movie to whole movie, so that subsequent initFromMovieFrame
+	// will work.
+	_navMovie.setSegment(0, _navMovie.getDuration());
+
+	// TODO
+	//_pushIn.initFromMovieFrame(_navMovie.getMovie(), newView, kNoMask);
+
+	_navMovie.hide();
+
+	switch (turnDirection) {
+	case kTurnLeft:
+		_turnPush.setSlideDirection(kSlideRightMask);
+		break;
+	case kTurnRight:
+		_turnPush.setSlideDirection(kSlideLeftMask);
+		break;
+	case kTurnUp:
+		_turnPush.setSlideDirection(kSlideDownMask);
+		break;
+	case kTurnDown:
+		_turnPush.setSlideDirection(kSlideUpMask);
+		break;
+	}
+
+	_turnPush.show();
+
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(60, 0, 0, 15, 1000);
+	_turnPush.startFader(moveSpec);
+
+	if (g_compass) {
+		_turnPush.pauseFader();
+
+		int32 startAngle = getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+		int32 stopAngle = getStaticCompassAngle(GameState.getCurrentRoom(), nextDir);
+
+		if (turnDirection == kTurnLeft) {
+			if (startAngle < stopAngle)
+				startAngle += 360;
+		} else {
+			if (stopAngle < startAngle)
+				stopAngle += 360;
+		}
+
+		FaderMoveSpec turnSpec;
+		_turnPush.getCurrentFaderMove(turnSpec);
+
+		FaderMoveSpec compassMove;
+		compassMove.makeTwoKnotFaderSpec(turnSpec.getFaderScale(), turnSpec.getNthKnotTime(0), startAngle, turnSpec.getNthKnotTime(1), stopAngle);
+		g_compass->startFader(compassMove);
+	}
+
+	_turnPushCallBack.cancelCallBack();
+	_turnPush.continueFader();
+
+	do {
+		_vm->refreshDisplay();
+		_vm->_system->delayMillis(10);
+	} while (_turnPush.isFading());
+
+	_turnPush.stopFader();
+	_neighborhoodNotification.setNotificationFlags(kTurnCompletedFlag, kTurnCompletedFlag);
+}
+
+void Neighborhood::playExtraMovie(const ExtraTable::Entry &extraEntry, const tNotificationFlags flags, const tInputBits interruptionInput) {
+	FaderMoveSpec compassMove;
+
+	if (g_compass)
+		getExtraCompassMove(extraEntry, compassMove);
+
+	_lastExtra = extraEntry.extra;
+	_turnPush.hide();
+	startMovieSequence(extraEntry.movieStart, extraEntry.movieEnd, flags, false, interruptionInput);
+
+	if (g_compass)
+		g_compass->startFader(compassMove);
+}
+
+void Neighborhood::activateCurrentView(const tRoomID room, const tDirectionConstant direction, tSpotFlags flag) {
+	SpotTable::Entry entry;
+	findSpotEntry(room, direction, flag, entry);
+
+	if (entry.dstFlags & flag) {
+		startSpotOnceOnly(entry.movieStart, entry.movieEnd);
+	} else {
+		findSpotEntry(room, direction, flag | kSpotLoopsMask, entry);
+
+		if (entry.dstFlags & flag)
+			startSpotLoop(entry.movieStart, entry.movieEnd);
+		else
+			showViewFrame(getViewTime(room, direction));
+	}
+}
+
+void Neighborhood::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
+	switch (_vm->getDragType()) {
+	case kDragInventoryUse:
+		if ((hotspot->getHotspotFlags() & kDropItemSpotFlag) != 0 &&
+				_vm->getDraggingItem()->getObjectID() == entry.hotspotItem)
+			hotspot->setActive();
+		break;
+	case kDragInventoryPickup:
+	case kDragBiochipPickup:
+		// Do nothing -- neighborhoods activate no hot spots in this case...
+		break;
+	default:
+		if ((hotspot->getHotspotFlags() & kPickUpBiochipSpotFlag) != 0) {
+			Item *item = g_allItems.findItemByID(entry.hotspotItem);
+			if (item &&	item->getItemNeighborhood() == getObjectID())
+				hotspot->setActive();
+		} else {
+			tHotSpotFlags flags = hotspot->getHotspotFlags();
+
+			if ((flags & kNeighborhoodSpotFlag) != 0) {
+				if (flags & kOpenDoorSpotFlag) {
+					if (!GameState.isCurrentDoorOpen())
+						hotspot->setActive();
+				} else if ((flags & (kZoomSpotFlags | kClickSpotFlag | kPlayExtraSpotFlag)) != 0) {
+					hotspot->setActive();
+				} else if ((flags & kPickUpItemSpotFlag) != 0) {
+					// Changed this 2/19/96
+					// Should only light up this hot spot if the item's taken flag is not
+					// set. It's not based on neighborhood ID since that can be reset by the
+					// destroying process.
+
+					if (!GameState.isTakenItemID(entry.hotspotItem))
+						hotspot->setActive();
+				}
+			}
+		}
+		break;
+	}
+}
+
+void Neighborhood::startSpotOnceOnly(TimeValue startTime, TimeValue stopTime) {
+	_turnPush.hide();
+	startMovieSequence(startTime, stopTime, kSpotCompletedFlag, kFilterNoInput, false);
+}
+
+void Neighborhood::startMovieSequence(const TimeValue startTime, const TimeValue stopTime, tNotificationFlags flags, bool loopSequence,
+		const tInputBits interruptionInput, const TimeValue strideStop) {
+	if (!loopSequence && g_AIArea)
+		g_AIArea->lockAIOut();
+	
+	_interruptionFilter = interruptionInput;
+
+	// Stop the movie before doing anything else
+	_navMovie.stop();
+
+	Common::Rect pushBounds;
+	_turnPush.getBounds(pushBounds);
+
+	_navMovie.moveElementTo(pushBounds.left, pushBounds.top);
+	_navMovie.show();
+	_navMovie.setFlags(0);
+	_navMovie.setSegment(startTime, stopTime);
+	_navMovie.setTime(startTime);
+
+	if (loopSequence)
+		_navMovie.setFlags(kLoopTimeBase);
+	else
+		flags |= kNeighborhoodMovieCompletedFlag;
+
+	if (strideStop != 0xffffffff)
+		// Subtract a little slop from the striding stop time to keep from "pumping" at the
+		// end of a walk.
+		// 40 is one frame (scale == 600, 15 fps).
+		scheduleStridingCallBack(strideStop - kStridingSlop, flags);
+	else
+		scheduleNavCallBack(flags);
+
+	_navMovie.start();
+}
+
+void Neighborhood::throwAwayInterface() {
+	_doorTable.clear();
+	_exitTable.clear();
+	_extraTable.clear();
+	_hotspotInfoTable.clear();
+	_spotTable.clear();
+	_turnTable.clear();
+	_viewTable.clear();
+	_zoomTable.clear();
+
+	_navMovie.stopDisplaying();
+	_navMovie.releaseMovie();
+	_pushIn.deallocateSurface();
+	_turnPush.stopDisplaying();
+	_turnPush.setInAndOutElements(0, 0);
+	_turnPush.disposeAllCallBacks();
+
+	for (HotspotList::iterator it = _neighborhoodHotspots.begin(); it != _neighborhoodHotspots.end(); it++)
+		g_allHotspots.remove(*it);
+
+	_neighborhoodHotspots.deleteHotspots();
+	_spotSounds.disposeSound();
+	_delayTimer.disposeAllCallBacks();
+
+	if (g_AIArea) {
+		g_AIArea->saveAIState();
+		g_AIArea->removeAllRules();
+	}
+
+	// TODO: Interaction
+
+	_croppedMovie.releaseMovie();
+
+	loadLoopSound1("");
+	loadLoopSound2("");
+
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->saveCurrentEnergyValue();
+	}
+
+	delete g_interface;
+}
+
+bool Neighborhood::prepareExtraSync(const tExtraID extraID) {
+	ExtraTable::Entry extraEntry;
+	FaderMoveSpec compassMove;
+	
+	if (g_compass) {
+		getExtraEntry(extraID, extraEntry);
+		getExtraCompassMove(extraEntry, compassMove);
+	}
+
+	ExtraTable::Entry entry;
+	getExtraEntry(extraID, entry);
+	bool result;
+
+	if (entry.movieStart != 0xffffffff) {
+		_turnPush.hide();
+
+		// Stop the movie before doing anything else
+		_navMovie.stop();
+
+		Common::Rect pushBounds;
+		_turnPush.getBounds(pushBounds);
+		_navMovie.moveElementTo(pushBounds.left, pushBounds.top);
+
+		_navMovie.show();
+		_navMovie.setFlags(0);
+		_navMovie.setSegment(entry.movieStart, entry.movieEnd);
+		_navMovie.setTime(entry.movieStart);
+		_navMovie.start();
+		result = true;
+	} else {
+		result = false;
+	}
+
+	if (result && g_compass)
+		g_compass->startFader(compassMove);
+
+	return result;
+}
+
+bool Neighborhood::waitMovieFinish(Movie *movie, const tInputBits interruptionFilter) {
+	Input input;
+	bool result = true;
+	bool saveAllowed = _vm->swapSaveAllowed(false);
+	bool openAllowed = _vm->swapLoadAllowed(false);
+
+	while (movie->isRunning()) {
+		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter);
+
+		if (input.anyInput() || _vm->shouldQuit()) {
+			result = false;
+			break;
+		}
+
+		_vm->refreshDisplay();
+		_vm->_system->delayMillis(10);
+	}
+
+	movie->stop();
+	_vm->swapSaveAllowed(saveAllowed);
+	_vm->swapLoadAllowed(openAllowed);
+
+	return result;
+}
+
+tInputBits Neighborhood::getInputFilter() {
+	return _interruptionFilter & InputHandler::getInputFilter();
+}
+
+void Neighborhood::getZoomCompassMove(const ZoomTable::Entry &zoomEntry, FaderMoveSpec &compassMove) {	
+	int32 startAngle = getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+	int32 stopAngle = getStaticCompassAngle(zoomEntry.room, zoomEntry.direction);
+
+	if (startAngle > stopAngle) {
+		if (stopAngle + 180 < startAngle)
+			stopAngle += 360;
+	} else {
+		if (startAngle + 180 < stopAngle)
+			startAngle += 360;
+	}
+
+	compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), zoomEntry.movieStart, startAngle, zoomEntry.movieEnd, stopAngle);
+}
+
+void Neighborhood::getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &compassMove) {
+	compassMove.makeOneKnotFaderSpec(g_compass->getFaderValue());
+}
+
+void Neighborhood::setUpAIRules() {
+	// TODO
+}
+
+void Neighborhood::newInteraction(const tInteractionID interactionID) {
+	// TODO
+}
+
+void Neighborhood::bumpIntoWall() {
+	// TODO
+}
+
+void Neighborhood::zoomUpOrBump() {
+	// TODO
+}
+
+void Neighborhood::loadLoopSound1(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) {
+	// TODO
+}
+
+void Neighborhood::loadLoopSound2(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) {
+	// TODO
+}
+
+void Neighborhood::takeItemFromRoom(Item *item) {
+	item->setItemRoom(kNoNeighborhoodID, kNoRoomID, kNoDirection);
+	// Also set the taken item flag. Do this before updating the view frame.
+	GameState.setTakenItem(item, true);
+	updateViewFrame();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 5d3e75b..b06fb75 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -36,6 +36,7 @@
 #include "pegasus/notification.h"
 #include "pegasus/sound.h"
 #include "pegasus/timers.h"
+#include "pegasus/transition.h"
 #include "pegasus/util.h"
 #include "pegasus/neighborhood/door.h"
 #include "pegasus/neighborhood/exit.h"
@@ -64,6 +65,10 @@ const tNeighborhoodID kNoradDeltaID = 8;
 // to allow an easy transition out of Norad Alpha.
 const tNeighborhoodID kNoradSubChaseID = 1000;
 
+const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
+const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
+const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
+
 enum tQueueRequestType {
 	kNavExtraRequest,
 	kSpotSoundRequest,
@@ -101,7 +106,7 @@ protected:
 
 typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
-class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler {
+class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
 friend class StriderCallBack;
 
 public:
@@ -110,27 +115,83 @@ public:
 
 	virtual void init();
 	void start();
+	virtual void moveNavTo(const tCoordType, const tCoordType);
+	virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0;
 
-	void arriveAt(tRoomID room, tDirectionConstant direction);
-
-	virtual void getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry);
-	virtual TimeValue getViewTime(const tRoomID room, const tDirectionConstant direction);
-	virtual void getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry);
-	virtual tDirectionConstant getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn);
-	virtual void findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry);
-	virtual void getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry);
-	virtual void getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
-	virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
 
 	tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
 	tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
 	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
 
+	virtual void cantMoveThatWay(tCanMoveForwardReason);
+	virtual void cantTurnThatWay(tCanTurnReason) {}
+	virtual void cantOpenDoor(tCanOpenDoorReason);
+	virtual void arriveAt(tRoomID room, tDirectionConstant direction);
+	virtual void turnTo(const tDirectionConstant);
+	virtual void spotCompleted();
+	virtual void doorOpened();
+	virtual void closeDoorOffScreen(const tRoomID, const tDirectionConstant) {}
+
+	virtual void moveForward();
+	virtual void turn(const tTurnDirection);
+	virtual void turnLeft();
+	virtual void turnRight();
+	virtual void turnUp();
+	virtual void turnDown();
+	virtual void openDoor();
+	virtual void zoomTo(const Hotspot *);
+
+	virtual void updateViewFrame();
+	
 	void requestExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
 	void requestSpotSound(const TimeValue, const TimeValue, const tInputBits interruptionFilter, const tNotificationFlags);
+	void playSpotSoundSync(const TimeValue in, const TimeValue out);
 	void requestDelay(const TimeValue, const TimeScale, const tInputBits interruptionFilter, const tNotificationFlags);
 
+	Notification *getNeighborhoodNotification() { return &_neighborhoodNotification; }
+
+	virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
+	virtual void startSpotLoop(TimeValue, TimeValue, tNotificationFlags = 0);
 	virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
+	virtual void showViewFrame(TimeValue);
+	virtual void findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry);
+	virtual void startExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
+	bool startExtraSequenceSync(const tExtraID, const tInputBits);
+	virtual void loopExtraSequence(const uint32, tNotificationFlags = 0);
+	int32 getLastExtra() const { return _lastExtra; }
+	virtual void scheduleNavCallBack(tNotificationFlags);
+	
+	Movie *getNavMovie() { return &_navMovie; }
+	bool navMoviePlaying();
+	
+	void setCurrentAlternate(const tAlternateID alt) { _currentAlternate = alt; }
+	tAlternateID getCurrentAlternate() const { return _currentAlternate; }
+	
+	void setCurrentActivation(const tHotSpotActivationID a) { _currentActivation = a; }
+	tHotSpotActivationID getCurrentActivation() { return _currentActivation; }
+	
+	virtual void playDeathExtra(tExtraID, tDeathReason);
+	virtual void die(const tDeathReason);
+
+	virtual void setSoundFXLevel(const uint16);
+	virtual void setAmbienceLevel(const uint16);
+	
+	void forceStridingStop(const tRoomID, const tDirectionConstant, const tAlternateID);
+	void restoreStriding(const tRoomID, const tDirectionConstant, const tAlternateID);
+	
+	HotspotInfoTable::Entry *findHotspotEntry(const tHotSpotID);
+	
+	Push *getTurnPush() { return &_turnPush; }
+	Picture *getTurnPushPicture() { return &_pushIn; }
+	
+	void hideNav();
+	void showNav();
+	
+	virtual void loadAmbientLoops() {}
+	
+	virtual void flushGameState() {}
 
 	virtual Common::String getBriefingMovie();
 	virtual Common::String getEnvScanMovie();
@@ -149,29 +210,81 @@ public:
 	virtual void shieldOn() {}
 	virtual void shieldOff() {}
 
-	virtual void scheduleNavCallBack(tNotificationFlags);
+	virtual void loadLoopSound1(const Common::String &, const uint16 volume = 0x100,
+			const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn,
+			const TimeScale fadeScale = kDefaultLoopFadeScale);
+	virtual void loadLoopSound2(const Common::String &, const uint16 volume = 0x100,
+			const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn,
+			const TimeScale fadeScale = kDefaultLoopFadeScale);
+
+	virtual void takeItemFromRoom(Item *);
 
 protected:
 	PegasusEngine *_vm;
 	Common::String _resName;
+	
+	virtual void loadSoundSpots();
 
+	// Notification function.
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
 
-	virtual void createNeighborhoodSpots();
-	virtual void loadSoundSpots();
+	// Map info functions.
+	virtual void getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry);
+	virtual TimeValue getViewTime(const tRoomID room, const tDirectionConstant direction);
+	virtual void getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry);
+	virtual tDirectionConstant getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn);
+	virtual void getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry);
+	virtual void getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
 
 	// Nav movie sequences.
-	virtual void checkStriding();
+	virtual void startExitMovie(const ExitTable::Entry &);
 	virtual void keepStriding(ExitTable::Entry &);
 	virtual void stopStriding();
+	virtual void checkStriding();
 	virtual bool stillMoveForward();
 	virtual void scheduleStridingCallBack(const TimeValue, tNotificationFlags flags);
+	virtual void startZoomMovie(const ZoomTable::Entry &);
+	virtual void startDoorOpenMovie(const TimeValue, const TimeValue);
+	virtual void startTurnPush(const tTurnDirection, const TimeValue, const tDirectionConstant);
+	virtual void playExtraMovie(const ExtraTable::Entry &, const tNotificationFlags, const tInputBits interruptionFilter);
+	
+	virtual void activateCurrentView(const tRoomID, const tDirectionConstant, tSpotFlags);
+	
+	virtual void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
+	
+	virtual void startSpotOnceOnly(TimeValue, TimeValue);
+	
+	virtual void startMovieSequence(const TimeValue, const TimeValue, tNotificationFlags,
+  			bool loopSequence, const tInputBits interruptionFilter, const TimeValue strideStop = 0xffffffff);
+	
+	virtual void createNeighborhoodSpots();
+	
+	void resetLastExtra() { _lastExtra = -1; }
+	
+	virtual void throwAwayInterface();
 
 	// Action queue stuff
 	void popActionQueue();
 	void serviceActionQueue();
 	void requestAction(const tQueueRequestType, const tExtraID, const TimeValue, const TimeValue, const tInputBits, const tNotificationFlags);
 
+	virtual bool prepareExtraSync(const tExtraID);
+	virtual bool waitMovieFinish(Movie *, const tInputBits);
+	
+	virtual tInputBits getInputFilter();
+
+	// Misc.
+	virtual uint16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
+	virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	virtual void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec&);
+	virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&);
+
+	virtual void setUpAIRules();
+
+	virtual void newInteraction(const tInteractionID);
+	virtual void bumpIntoWall();
+	virtual void zoomUpOrBump();
+
 	// Navigation Data
 	DoorTable _doorTable;
 	ExitTable _exitTable;
@@ -181,26 +294,57 @@ protected:
 	TurnTable _turnTable;
 	ViewTable _viewTable;
 	ZoomTable _zoomTable;
-	virtual uint16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
-	virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	tAlternateID _currentAlternate;
+	tHotSpotActivationID _currentActivation;
+	
+	int32 _lastExtra;
+	tDeathReason _extraDeathReason;
 
 	// Graphics
 	Movie _navMovie;
+	Picture _pushIn;
+	Push _turnPush;
 
 	// Callbacks
 	Notification _neighborhoodNotification;
 	NotificationCallBack _navMovieCallBack;
 	StriderCallBack _stridingCallBack;
+	NotificationCallBack _turnPushCallBack;
+	NotificationCallBack _spotSoundCallBack;
+	NotificationCallBack _delayCallBack;
 
-	tAlternateID _currentAlternate;
-
+	// Hotspots
 	HotspotList _neighborhoodHotspots;
 
-	NeighborhoodActionQueue _actionQueue;
-
+	// Sounds
 	Sound _spotSounds;
 
+	// Action queue
+	NeighborhoodActionQueue _actionQueue;
+	TimeBase _delayTimer;
+
+	// Interruptibility...
 	tInputBits _interruptionFilter;
+
+	// Nav hiding (for info support...)
+	bool _isRunning;
+
+	// TODO
+	//GameInteraction *_currentInteraction;
+	bool _doneWithInteraction;
+	Movie _croppedMovie;
+	
+	Sound _soundLoop1;
+	Common::String _loop1SoundString;
+	SoundFader _loop1Fader;
+	
+	Sound _soundLoop2;
+	Common::String _loop2SoundString;
+	SoundFader _loop2Fader;
+
+	// The event timer...
+	FuseFunction _eventTimer;
+	uint32 _timerEvent;
 };
 
 extern Neighborhood *g_neighborhood;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 3a8e868..60d5b9a 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -63,6 +63,8 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_gameMenu = 0;
 	_deathReason = kDeathStranded;
 	_neighborhood = 0;
+	_FXLevel = 0x80;
+	_ambientLevel = 0x80;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -873,11 +875,6 @@ void PegasusEngine::resetEnergyDeathReason() {
 	_deathReason = kDeathStranded;
 }
 
-uint16 PegasusEngine::getSoundFXLevel() {
-	// TODO
-	return 0x100;
-}
-
 bool PegasusEngine::playerHasItem(const Item *item) {
 	return playerHasItemID(item->getObjectID());
 }
@@ -1042,4 +1039,10 @@ void PegasusEngine::throwAwayEverything() {
 	// TODO
 }
 
+void PegasusEngine::dragItem(const Input &, Item *, tDragType) {
+	// TODO
+}
+
+
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index b01e192..550761f 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -114,7 +114,8 @@ public:
 	void die(const tDeathReason);
 
 	// Volume
-	uint16 getSoundFXLevel();
+	uint16 getSoundFXLevel() { return _FXLevel; }
+	uint16 getAmbienceLevel() { return _ambientLevel; }
 
 	// Items
 	bool playerHasItem(const Item *);
@@ -145,6 +146,11 @@ public:
 	// Neighborhood
 	void jumpToNewEnvironment(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
 
+	// Dragging
+	void dragItem(const Input &, Item *, tDragType);
+	tDragType getDragType() const { return (tDragType)0; } // TODO
+	Item *getDraggingItem() const { return 0; } // TODO
+
 protected:
 	Common::Error run();
 
@@ -205,6 +211,10 @@ private:
 
 	// Neighborhood
 	Neighborhood *_neighborhood;
+
+	// Sound
+	uint16 _ambientLevel;
+	uint16 _FXLevel;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/types.h b/engines/pegasus/types.h
index 6c51c93..ed22784 100755
--- a/engines/pegasus/types.h
+++ b/engines/pegasus/types.h
@@ -180,6 +180,13 @@ enum tAirQuality {
 	kAirQualityVacuum
 };
 
+enum tDragType {
+	kDragNoDrag,
+	kDragInventoryPickup,
+	kDragBiochipPickup,
+	kDragInventoryUse
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: d205ac2e2737b97741f1cde09b320538dcbef98e
    https://github.com/scummvm/scummvm/commit/d205ac2e2737b97741f1cde09b320538dcbef98e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-26T20:04:20-07:00

Commit Message:
PEGASUS: Add the GameInteraction class

Changed paths:
  A engines/pegasus/interaction.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h
new file mode 100755
index 0000000..b54c59e
--- /dev/null
+++ b/engines/pegasus/interaction.h
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_INTERACTION_H
+#define PEGASUS_INTERACTION_H
+
+#include "pegasus/input.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+static const tInteractionID kNoInteractionID = -1;
+
+class Neighborhood;
+
+class GameInteraction : public IDObject, public InputHandler {
+public:
+	GameInteraction(const tInteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) {
+		_isInteracting = false;
+		_savedHandler = 0;
+		_owner = nextHandler;
+	}
+
+	// If the interaction is open (_isInteracting == true), it's too late to do anything
+	// about it here.
+	virtual ~GameInteraction() {}
+
+	// startInteraction and stopInteraction are called by the outside world to
+	// start and stop the interaction sequence.
+	// isInteracting returns a bool indicating whether or not the interaction
+	// is going.
+	void startInteraction() {
+		if (!isInteracting()) {
+			openInteraction();
+			initInteraction();
+			_isInteracting = true;
+			_savedHandler = InputHandler::setInputHandler(this);
+		}
+	}
+	void stopInteraction() {
+		if (isInteracting()) {
+			closeInteraction();
+			_isInteracting = false;
+			if (InputHandler::_inputHandler == this)
+				InputHandler::setInputHandler(_savedHandler);
+		}
+	}
+	void startOverInteraction() {
+		if (isInteracting())
+			resetInteraction();
+	}
+	bool isInteracting() const { return _isInteracting; }
+	Neighborhood *getOwner() const { return _owner; }
+
+	virtual Common::String getBriefingMovie() { return ""; }
+	virtual Common::String getEnvScanMovie() { return ""; }
+	virtual long getNumHints() { return 0; }
+	virtual Common::String getHintMovie(uint) { return ""; }
+	virtual bool canSolve() { return false; }
+	
+	virtual void setSoundFXLevel(const uint16) {}
+	virtual void setAmbienceLevel(const uint16) {}
+	
+	virtual void doSolve() {}
+
+protected:
+	// Subclasses override openInteraction and closeInteraction to perform
+	// specific initialization and cleanup. Override resetInteraction to
+	// "start the interaction over." resetInteraction is called only when
+	// the interaction is already open.
+	// These functions are only called in pairs, never two opens or closes
+	// in a row.
+	virtual void openInteraction() {}
+	virtual void initInteraction() {}
+	virtual void closeInteraction() {}
+	virtual void resetInteraction() {}
+	
+	InputHandler *_savedHandler;
+	Neighborhood *_owner;
+	
+private:
+	// Private so that only StartInteraction and StopInteraction can touch it.
+	bool _isInteracting;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index f92c2b7..936f4ff 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -31,6 +31,7 @@
 #include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/input.h"
+#include "pegasus/interaction.h"
 #include "pegasus/interface.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
@@ -499,37 +500,43 @@ bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2) {
 }
 
 Common::String Neighborhood::getBriefingMovie() {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		return _currentInteraction->getBriefingMovie();
 
 	return Common::String();
 }
 
 Common::String Neighborhood::getEnvScanMovie() {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		return _currentInteraction->getEnvScanMovie();
 
 	return Common::String();
 }
 
 uint Neighborhood::getNumHints() {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		return _currentInteraction->getNumHints();
 
 	return 0;
 }
 
 Common::String Neighborhood::getHintMovie(uint hintNum) {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		return _currentInteraction->getHintMovie(hintNum);
 
 	return Common::String();
 }
 
 bool Neighborhood::canSolve() {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		return _currentInteraction->canSolve();
 
 	return false;
 }
 
 void Neighborhood::doSolve() {
-	// TODO: Interaction check
+	if (_currentInteraction)
+		_currentInteraction->doSolve();
 }
 
 bool Neighborhood::okayToJump() {
@@ -902,9 +909,8 @@ void Neighborhood::setSoundFXLevel(const uint16 fxLevel) {
 		_navMovie.setVolume(fxLevel);
 	if (_spotSounds.isSoundLoaded())
 		_spotSounds.setVolume(fxLevel);
-	// TODO
-	//if (_currentInteraction)
-	//	_currentInteraction->setSoundFXLevel(fxLevel);
+	if (_currentInteraction)
+		_currentInteraction->setSoundFXLevel(fxLevel);
 }
 
 void Neighborhood::setAmbienceLevel(const uint16 ambientLevel) {
@@ -912,9 +918,8 @@ void Neighborhood::setAmbienceLevel(const uint16 ambientLevel) {
 		_loop1Fader.setMasterVolume(_vm->getAmbienceLevel());
 	if (_soundLoop2.isSoundLoaded())
 		_loop2Fader.setMasterVolume(_vm->getAmbienceLevel());
-	// TODO
-	//if (_currentInteraction)
-	//	_currentInteraction->setAmbienceLevel(ambientLevel);
+	if (_currentInteraction)
+		_currentInteraction->setAmbienceLevel(ambientLevel);
 }
 
 // Force the exit taken from (room, direction, alternate) to come to a stop.
@@ -1241,7 +1246,8 @@ void Neighborhood::throwAwayInterface() {
 		g_AIArea->removeAllRules();
 	}
 
-	// TODO: Interaction
+	if (_currentInteraction)
+		newInteraction(kNoInteractionID);
 
 	_croppedMovie.releaseMovie();
 
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index b06fb75..805d8a2 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -91,6 +91,7 @@ struct tQueueRequest {
 bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
 bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
+class GameInteraction;
 class Neighborhood;
 
 class StriderCallBack : public TimeBaseCallBack {
@@ -329,8 +330,7 @@ protected:
 	// Nav hiding (for info support...)
 	bool _isRunning;
 
-	// TODO
-	//GameInteraction *_currentInteraction;
+	GameInteraction *_currentInteraction;
 	bool _doneWithInteraction;
 	Movie _croppedMovie;
 	


Commit: 96198e7bdd01c4ef642c148db4bd567fb12b9519
    https://github.com/scummvm/scummvm/commit/96198e7bdd01c4ef642c148db4bd567fb12b9519
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T09:21:05-07:00

Commit Message:
PEGASUS: Import the remainder of the Neighborhood code

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 6678b70..4061225 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -728,6 +728,14 @@ static const tDirectionConstant kSouth = 1;
 static const tDirectionConstant kEast = 2;
 static const tDirectionConstant kWest = 3;
 
+/////////////////////////////////////////////
+//
+//	Mode constants.
+
+static const tGameMode kModeInventoryPick = kLastGameShellMode + 1;
+static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
+static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
+
 // TODO: Remove me
 const tRoomID kTSA37 = 42;
 const tRoomID kTinyTSA37 = 0;
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 936f4ff..60668a7 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -57,8 +57,14 @@ Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const C
 		_turnPush(kTurnPushID), _croppedMovie(kCroppedMovieID) {
 	GameState.setOpenDoorLocation(kNoRoomID, kNoDirection);
 	_currentAlternate = 0;
+	_currentActivation = kActivateHotSpotAlways;
 	_interruptionFilter = kFilterAllInput;
+	allowInput(true);
+	resetLastExtra();
 	g_neighborhood = this;
+	_currentInteraction = 0;
+	_doneWithInteraction = false;
+	_croppedMovie.setDisplayOrder(kCroppedMovieLayer);
 }
 
 Neighborhood::~Neighborhood() {
@@ -400,15 +406,15 @@ void Neighborhood::popActionQueue() {
 		tQueueRequest topRequest = _actionQueue.pop();
 
 		switch (topRequest.requestType) {
-			case kNavExtraRequest:
-				// TODO
-				break;
-			case kSpotSoundRequest:
-				_spotSounds.stopSound();
-				break;
-			case kDelayRequest:
-				// TODO
-				break;
+		case kNavExtraRequest:
+			_navMovie.stop();
+			break;
+		case kSpotSoundRequest:
+			_spotSounds.stopSound();
+			break;
+		case kDelayRequest:
+			_delayTimer.stop();
+			break;
 		}
 
 		serviceActionQueue();
@@ -423,7 +429,7 @@ void Neighborhood::serviceActionQueue() {
 			topRequest.playing = true;
 			switch (topRequest.requestType) {
 			case kNavExtraRequest:
-				// TODO
+				startExtraSequence(topRequest.extra, topRequest.flags, topRequest.interruptionFilter);
 				break;
 			case kSpotSoundRequest:
 				_spotSounds.stopSound();
@@ -432,7 +438,13 @@ void Neighborhood::serviceActionQueue() {
 				// TODO: stop trigger
 				break;
 			case kDelayRequest:
-				// TODO
+				_delayTimer.stop();
+				_delayCallBack.setCallBackFlag(topRequest.flags);
+				_delayTimer.setSegment(0, topRequest.start, topRequest.stop);
+				_delayTimer.setTime(0);
+				_delayCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+				_interruptionFilter = topRequest.interruptionFilter;
+				_delayTimer.start();
 				break;
 			}
 		}
@@ -453,9 +465,7 @@ void Neighborhood::requestAction(const tQueueRequestType requestType, const tExt
 	request.interruptionFilter = interruptionFilter;
 	request.playing = false;
 	request.flags = flags | kActionRequestCompletedFlag;
-
-	// TODO: notification
-
+	request.notification = &_neighborhoodNotification;
 	_actionQueue.push(request);
 	if (_actionQueue.size() == 1)
 		serviceActionQueue();
@@ -1350,27 +1360,152 @@ void Neighborhood::getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec
 }
 
 void Neighborhood::setUpAIRules() {
-	// TODO
+	//	Set up default rules here:
+	//	--  Energy warning rules.
+
+	if (g_AIArea) {
+		g_AIArea->forceAIUnlocked();
+
+		if (getObjectID() == kPrehistoricID || getObjectID() == kNoradAlphaID ||
+				getObjectID() == kNoradDeltaID || getObjectID() == kMarsID || getObjectID() == kWSCID) {
+
+			AIEnergyMonitorCondition *condition50 = new AIEnergyMonitorCondition(kWorriedEnergy);
+			AIPlayMessageAction *message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4A", false);
+			AIRule *rule50 = new AIRule(condition50, message);
+
+			AIEnergyMonitorCondition *condition25 = new AIEnergyMonitorCondition(kNervousEnergy);
+			AICompoundAction *compound = new AICompoundAction();
+			message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4B", false);
+			compound->addAction(message);
+			AIDeactivateRuleAction *deactivate = new AIDeactivateRuleAction(rule50);
+			compound->addAction(deactivate);
+			AIRule *rule25 = new AIRule(condition25, compound);
+
+			AIEnergyMonitorCondition *condition5 = new AIEnergyMonitorCondition(kPanicStrickenEnergy);
+			compound = new AICompoundAction();
+			message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4C", false);
+			compound->addAction(message);
+			deactivate = new AIDeactivateRuleAction(rule50);
+			compound->addAction(deactivate);
+			deactivate = new AIDeactivateRuleAction(rule25);
+			compound->addAction(deactivate);
+			AIRule *rule5 = new AIRule(condition5, compound);
+
+			g_AIArea->addAIRule(rule5);
+			g_AIArea->addAIRule(rule25);
+			g_AIArea->addAIRule(rule50);
+		}
+	}
+}
+
+GameInteraction *Neighborhood::makeInteraction(const tInteractionID interactionID) {
+	if (interactionID == kNoInteractionID)
+		return 0;
+
+	return new GameInteraction(interactionID, this);
 }
 
 void Neighborhood::newInteraction(const tInteractionID interactionID) {
-	// TODO
+	GameInteraction *interaction = makeInteraction(interactionID);
+	_doneWithInteraction = false;
+
+	if (_currentInteraction) {
+		_currentInteraction->stopInteraction();
+		delete _currentInteraction;
+	}
+
+	_currentInteraction = interaction;
+
+	if (_currentInteraction)
+		_currentInteraction->startInteraction();
+
+	if (g_AIArea)
+		g_AIArea->checkMiddleArea();
 }
 
 void Neighborhood::bumpIntoWall() {
 	// TODO
+	warning("bump");
 }
 
 void Neighborhood::zoomUpOrBump() {
-	// TODO
+	Hotspot *zoomSpot = 0;
+
+	for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) {
+		Hotspot *hotspot = *it;
+
+		if ((hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomInSpotFlag)) == (kNeighborhoodSpotFlag | kZoomInSpotFlag)) {
+			HotspotInfoTable::Entry *entry = findHotspotEntry(hotspot->getObjectID());
+
+			if (entry && entry->hotspotRoom == GameState.getCurrentRoom() && entry->hotspotDirection == GameState.getCurrentDirection()) {
+				if (zoomSpot) {
+					zoomSpot = 0;
+					break;
+				} else {
+					zoomSpot = hotspot;
+				}
+			}
+		}
+	}
+
+	if (zoomSpot)
+		zoomTo(zoomSpot);
+	else
+		bumpIntoWall();
 }
 
 void Neighborhood::loadLoopSound1(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) {
-	// TODO
+	FaderMoveSpec faderMove;
+	
+	if (!loop1Loaded(soundName)) {
+		_loop1SoundString = soundName;
+
+		if (_soundLoop1.isSoundLoaded()) {
+			faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop1Fader.getFaderValue(), fadeOut, 0);
+			_loop1Fader.startFaderSync(faderMove);
+		}
+
+		if (!_loop1SoundString.empty()) {
+			_soundLoop1.initFromAIFFFile(_loop1SoundString);
+			_soundLoop1.loopSound();
+			_loop1Fader.setMasterVolume(_vm->getAmbienceLevel());
+			_loop1Fader.setFaderValue(0);
+			faderMove.makeTwoKnotFaderSpec(fadeScale, 0, 0, fadeIn, volume);
+			_loop1Fader.startFaderSync(faderMove);
+		} else {
+			_soundLoop1.disposeSound();
+		}
+	} else if (_loop1Fader.getFaderValue() != volume) {
+		faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop1Fader.getFaderValue(), fadeIn, volume);
+		_loop1Fader.startFaderSync(faderMove);
+	}
 }
 
 void Neighborhood::loadLoopSound2(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) {
-	// TODO
+	FaderMoveSpec faderMove;
+	
+	if (!loop2Loaded(soundName)) {
+		_loop2SoundString = soundName;
+
+		if (_soundLoop2.isSoundLoaded()) {
+			faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop2Fader.getFaderValue(), fadeOut, 0);
+			_loop2Fader.startFaderSync(faderMove);
+		}
+
+		if (!_loop2SoundString.empty()) {
+			_soundLoop2.initFromAIFFFile(_loop2SoundString);
+			_soundLoop2.loopSound();
+			_loop2Fader.setMasterVolume(_vm->getAmbienceLevel());
+			_loop2Fader.setFaderValue(0);
+			faderMove.makeTwoKnotFaderSpec(fadeScale, 0, 0, fadeIn, volume);
+			_loop2Fader.startFaderSync(faderMove);
+		} else {
+			_soundLoop2.disposeSound();
+		}
+	} else if (_loop2Fader.getFaderValue() != volume) {
+		faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop2Fader.getFaderValue(), fadeIn, volume);
+		_loop2Fader.startFaderSync(faderMove);
+	}
 }
 
 void Neighborhood::takeItemFromRoom(Item *item) {
@@ -1380,4 +1515,263 @@ void Neighborhood::takeItemFromRoom(Item *item) {
 	updateViewFrame();
 }
 
+void Neighborhood::dropItemIntoRoom(Item *item, Hotspot *) {
+	item->setItemRoom(getObjectID(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
+	// Also set the taken item flag. Do this before updating the view frame.
+	GameState.setTakenItem(item, false);
+	updateViewFrame();
+}
+
+void Neighborhood::makeContinuePoint() {
+	_vm->makeContinuePoint();
+}
+
+void Neighborhood::startLoop1Fader(const FaderMoveSpec &faderMove) {
+	_loop1Fader.startFader(faderMove);
+}
+
+void Neighborhood::startLoop2Fader(const FaderMoveSpec &faderMove) {
+	_loop2Fader.startFader(faderMove);
+}
+
+// *** Revised 6/13/96 to use the last frame of the extra sequence.
+//     Necessary for Cinepak buildup.
+void Neighborhood::showExtraView(uint32 extraID) {
+	ExtraTable::Entry entry;
+	getExtraEntry(extraID, entry);
+
+	if (entry.movieEnd != 0xffffffff)
+		showViewFrame(entry.movieEnd - 1);
+}
+
+void Neighborhood::startExtraLongSequence(const uint32 firstExtra, const uint32 lastExtra, tNotificationFlags flags,
+		const tInputBits interruptionFilter) {
+	ExtraTable::Entry firstEntry, lastEntry;
+	getExtraEntry(firstExtra, firstEntry);
+
+	if (firstEntry.movieStart != 0xffffffff) {
+		getExtraEntry(lastExtra, lastEntry);
+		_lastExtra = firstExtra;
+		_turnPush.hide();
+		startMovieSequence(firstEntry.movieStart, lastEntry.movieEnd, flags, kFilterNoInput, interruptionFilter);
+	}
+}
+
+void Neighborhood::openCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) {
+	if (_croppedMovie.isMovieValid())
+		closeCroppedMovie();
+
+	_croppedMovie.initFromMovieFile(movieName);
+	_croppedMovie.moveElementTo(left, top);
+	_croppedMovie.startDisplaying();
+	_croppedMovie.show();
+}
+
+void Neighborhood::loopCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) {
+	openCroppedMovie(movieName, left, top);
+	_croppedMovie.redrawMovieWorld();
+	_croppedMovie.setFlags(kLoopTimeBase);
+	_croppedMovie.start();
+}
+
+void Neighborhood::closeCroppedMovie() {
+	_croppedMovie.releaseMovie();
+}
+
+void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, tCoordType left, tCoordType top, const tInputBits interruptionFilter) {	
+	openCroppedMovie(movieName, left, top);
+	_croppedMovie.redrawMovieWorld();
+	_croppedMovie.start();
+
+	tInputBits oldInterruptionFilter = _interruptionFilter;
+	if (oldInterruptionFilter != kFilterNoInput)
+		_interruptionFilter = kFilterNoInput;
+
+	bool saveAllowed = _vm->swapSaveAllowed(false);
+	bool openAllowed = _vm->swapLoadAllowed(false);
+
+	Input input;
+	while (_croppedMovie.isRunning() && !_vm->shouldQuit()) {
+		_vm->processShell();
+		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter);
+		if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request
+			break;
+		_vm->_system->delayMillis(10);
+	}
+
+	if (oldInterruptionFilter != kFilterNoInput)
+		_interruptionFilter = oldInterruptionFilter;
+
+	closeCroppedMovie();
+	_vm->swapSaveAllowed(saveAllowed);
+	_vm->swapLoadAllowed(openAllowed);
+}
+
+void Neighborhood::playMovieSegment(Movie *movie, TimeValue startTime, TimeValue stopTime) {
+	TimeValue oldStart, oldStop;
+	movie->getSegment(oldStart, oldStop);
+
+	if (stopTime == 0xffffffff)
+		stopTime = movie->getDuration();
+	
+	movie->setSegment(startTime, stopTime);
+	movie->setTime(startTime);
+	movie->start();
+
+	while (movie->isRunning()) {
+		_vm->checkCallBacks();
+		_vm->refreshDisplay();
+		_vm->_system->delayMillis(10);
+	}
+
+	movie->stop();
+	movie->setSegment(oldStart, oldStop);
+}
+
+void Neighborhood::recallToTSASuccess() {
+	if (GameState.allTimeZonesFinished())
+		_vm->jumpToNewEnvironment(kFullTSAID, kTSA37, kNorth);
+	else
+		_vm->jumpToNewEnvironment(kTinyTSAID, kTinyTSA37, kNorth);
+}
+
+void Neighborhood::recallToTSAFailure() {
+	_vm->jumpToNewEnvironment(kTinyTSAID, kTinyTSA37, kNorth);
+}
+
+void Neighborhood::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_vm->getGameMode() == kModeNavigation) {
+		if (input.upButtonAnyDown())
+			upButton(input);
+		else if (input.downButtonAnyDown())
+			downButton(input);
+		else if (input.leftButtonAnyDown())
+			leftButton(input);
+		else if (input.rightButtonAnyDown())
+			rightButton(input);
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void Neighborhood::setHotspotFlags(const tHotSpotID id, const tHotSpotFlags flags) {
+	Hotspot *hotspot = g_allHotspots.findHotspotByID(id);
+	hotspot->setMaskedHotspotFlags(flags, flags);
+}
+
+void Neighborhood::setIsItemTaken(const tItemID id) {
+	GameState.setTakenItemID(id, _vm->playerHasItemID(id));
+}
+
+void Neighborhood::upButton(const Input &) {
+	moveForward();
+}
+
+void Neighborhood::leftButton(const Input &) {
+	turnLeft();
+}
+
+void Neighborhood::rightButton(const Input &) {
+	turnRight();
+}
+
+void Neighborhood::downButton(const Input &) {
+	if (_inputHandler->wantsCursor()) {
+		g_allHotspots.deactivateAllHotspots();
+		_inputHandler->activateHotspots();
+
+		for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) {
+			Hotspot *hotspot = *it;
+
+			if (hotspot->isSpotActive() && (hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) == (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) {
+				HotspotInfoTable::Entry *entry = findHotspotEntry(hotspot->getObjectID());
+
+				if (entry && entry->hotspotRoom == GameState.getCurrentRoom() && entry->hotspotDirection == GameState.getCurrentDirection()) {
+					Input scratch;
+					_inputHandler->clickInHotspot(scratch, hotspot);
+					return;
+				}
+			}
+		}
+	}
+}
+
+void Neighborhood::initOnePicture(Picture *picture, const Common::String &pictureName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) {
+	picture->initFromPICTFile(pictureName);
+	picture->setDisplayOrder(order);
+	picture->moveElementTo(left, top);
+	picture->startDisplaying();
+	if (show)
+		picture->show();
+}
+
+void Neighborhood::initOneMovie(Movie *movie, const Common::String &movieName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) {
+	movie->initFromMovieFile(movieName);
+	movie->setDisplayOrder(order);
+	movie->moveElementTo(left, top);
+	movie->startDisplaying();
+
+	if (show)
+		movie->show();
+
+	movie->redrawMovieWorld();
+}
+
+void Neighborhood::reinstateMonocleInterface() {
+	// TODO: Disable erase?
+
+	_vm->createInterface();
+
+	if (g_AIArea)
+		setNextHandler(g_AIArea);
+
+	init();
+
+	moveNavTo(kNavAreaLeft, kNavAreaTop);
+
+	if (g_interface)
+		g_interface->setDate(getDateResID());
+
+	if (g_AIArea)
+		g_AIArea->restoreAIState();
+}
+
+void Neighborhood::useIdleTime() {
+	if (_doneWithInteraction) {
+		newInteraction(kNoInteractionID);
+		loadAmbientLoops();
+	}
+}
+
+void timerFunction(FunctionPtr *, void *neighborhood) {
+	((Neighborhood *)neighborhood)->timerExpired(((Neighborhood *)neighborhood)->getTimerEvent());
+}
+
+void Neighborhood::scheduleEvent(const TimeValue time, const TimeScale scale, const uint32 eventType) {
+	_eventTimer.stopFuse();
+	_eventTimer.primeFuse(time, scale);
+	_timerEvent = eventType;
+	_eventTimer.setFunctionPtr(&timerFunction, this);
+	_eventTimer.lightFuse();
+}
+
+void Neighborhood::cancelEvent() {
+	_eventTimer.stopFuse();
+}
+
+void Neighborhood::pauseTimer() {
+	_eventTimer.pauseFuse();
+}
+
+void Neighborhood::resumeTimer() {
+	// NOTE: Yes, this function calls pauseFuse!
+	// Looks like an original game bug, will need
+	// to investigate how this affects gameplay.
+	_eventTimer.pauseFuse();
+}
+
+bool Neighborhood::timerPaused() {
+	return _eventTimer.isFusePaused();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 805d8a2..46f0f66 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -109,6 +109,7 @@ typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
 
 class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
 friend class StriderCallBack;
+friend void timerFunction(FunctionPtr *, void *);
 
 public:
 	Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
@@ -118,6 +119,7 @@ public:
 	void start();
 	virtual void moveNavTo(const tCoordType, const tCoordType);
 	virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0;
+	void makeContinuePoint();
 
 	virtual void activateHotspots();
 	virtual void clickInHotspot(const Input &, const Hotspot *);
@@ -217,9 +219,36 @@ public:
 	virtual void loadLoopSound2(const Common::String &, const uint16 volume = 0x100,
 			const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn,
 			const TimeScale fadeScale = kDefaultLoopFadeScale);
+	bool loop1Loaded(const Common::String &soundName) { return _loop1SoundString == soundName; }
+	bool loop2Loaded(const Common::String &soundName) { return _loop2SoundString == soundName; }
+	void startLoop1Fader(const FaderMoveSpec &);
+	void startLoop2Fader(const FaderMoveSpec &);
 
 	virtual void takeItemFromRoom(Item *);
+	virtual void dropItemIntoRoom(Item *, Hotspot *);
+	virtual Hotspot *getItemScreenSpot(Item *, DisplayElement *) { return 0; }
 
+	virtual GameInteraction *makeInteraction(const tInteractionID);
+	virtual void requestDeleteCurrentInteraction() { _doneWithInteraction = true; }
+
+	virtual uint16 getDateResID() const = 0;
+
+	virtual void showExtraView(uint32);
+	virtual void startExtraLongSequence(const uint32, const uint32, tNotificationFlags, const tInputBits interruptionFilter);
+	
+	void openCroppedMovie(const Common::String &, tCoordType, tCoordType);
+	void loopCroppedMovie(const Common::String &, tCoordType, tCoordType);
+	void closeCroppedMovie();
+	void playCroppedMovieOnce(const Common::String &, tCoordType, tCoordType, const tInputBits interruptionFilter = kFilterNoInput);
+
+	void playMovieSegment(Movie *, TimeValue = 0, TimeValue = 0xffffffff);
+
+	virtual void recallToTSASuccess();
+	virtual void recallToTSAFailure();
+	
+	virtual void pickedUpItem(Item *) {}
+
+	virtual void handleInput(const Input &, const Hotspot *);
 protected:
 	PegasusEngine *_vm;
 	Common::String _resName;
@@ -281,11 +310,34 @@ protected:
 	virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&);
 
 	virtual void setUpAIRules();
+	virtual void setHotspotFlags(const tHotSpotID, const tHotSpotFlags);
+	virtual void setIsItemTaken(const tItemID);
+
+	virtual void upButton(const Input &);
+	virtual void leftButton(const Input &);
+	virtual void rightButton(const Input &);
+	virtual void downButton(const Input &);
+
+	void initOnePicture(Picture *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool);
+	void initOneMovie(Movie *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool);
+
+	void reinstateMonocleInterface();
 
 	virtual void newInteraction(const tInteractionID);
+	virtual void useIdleTime();
 	virtual void bumpIntoWall();
 	virtual void zoomUpOrBump();
 
+	void scheduleEvent(const TimeValue, const TimeScale, const uint32);
+	void cancelEvent();
+	virtual void timerExpired(const uint32) {}
+	bool isEventTimerRunning() { return _eventTimer.isFuseLit(); }
+	uint32 getTimerEvent() { return _timerEvent; }
+
+	void pauseTimer();
+	void resumeTimer();
+	bool timerPaused();
+
 	// Navigation Data
 	DoorTable _doorTable;
 	ExitTable _exitTable;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 60d5b9a..d6a4ce1 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -65,6 +65,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_neighborhood = 0;
 	_FXLevel = 0x80;
 	_ambientLevel = 0x80;
+	_gameMode = kNoMode;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -125,12 +126,8 @@ Common::Error PegasusEngine::run() {
 	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 	g_allHotspots.push_back(&_returnHotspot);
 
-	while (!shouldQuit()) {
-		checkCallBacks();
-		checkNotifications();
-		InputHandler::pollForInput();
-		refreshDisplay();
-	}
+	while (!shouldQuit())
+		processShell();
 
 	return Common::kNoError;
 }
@@ -1043,6 +1040,37 @@ void PegasusEngine::dragItem(const Input &, Item *, tDragType) {
 	// TODO
 }
 
+void PegasusEngine::processShell() {
+	checkCallBacks();
+	checkNotifications();
+	InputHandler::pollForInput();
+	refreshDisplay();
+}
+
+void PegasusEngine::createInterface() {
+	if (!g_interface)
+		new Interface();
 
+	g_interface->createInterface();
+}
+
+void PegasusEngine::setGameMode(const tGameMode newMode) {
+	if (newMode != _gameMode && canSwitchGameMode(newMode, _gameMode)) {
+		switchGameMode(newMode, _gameMode);
+		_gameMode = newMode;
+	}
+}
+
+void PegasusEngine::switchGameMode(const tGameMode newMode, const tGameMode oldMode) {
+	// TODO
+}
+
+bool PegasusEngine::canSwitchGameMode(const tGameMode newMode, const tGameMode oldMode) {
+	if (newMode == kModeInventoryPick && oldMode == kModeBiochipPick)
+		return false;
+	if (newMode == kModeBiochipPick && oldMode == kModeInventoryPick)
+		return false;
+	return true;
+}
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 550761f..988b6a5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -88,20 +88,15 @@ public:
 	void removeIdler(Idler *idler);
 	void addTimeBase(TimeBase *timeBase);
 	void removeTimeBase(TimeBase *timeBase);
-	bool swapSaveAllowed(bool allow) {
-		bool old = _saveAllowed;
-		_saveAllowed = allow;
-		return old;
-	}
-	bool swapLoadAllowed(bool allow) {
-		bool old = _loadAllowed;
-		_loadAllowed = allow;
-		return old;
-	}
 	void delayShell(TimeValue time, TimeScale scale);
 	void resetIntroTimer();
 	void refreshDisplay();
 	bool playerAlive();
+	void processShell();
+	void checkCallBacks();
+	void createInterface();
+	void setGameMode(const tGameMode);
+	tGameMode getGameMode() const { return _gameMode; }
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
@@ -151,6 +146,19 @@ public:
 	tDragType getDragType() const { return (tDragType)0; } // TODO
 	Item *getDraggingItem() const { return 0; } // TODO
 
+	// Save/Load
+	void makeContinuePoint();
+	bool swapSaveAllowed(bool allow) {
+		bool old = _saveAllowed;
+		_saveAllowed = allow;
+		return old;
+	}
+	bool swapLoadAllowed(bool allow) {
+		bool old = _loadAllowed;
+		_loadAllowed = allow;
+		return old;
+	}
+
 protected:
 	Common::Error run();
 
@@ -180,12 +188,10 @@ private:
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;
-	void checkCallBacks();
 
 	// Save/Load
 	bool loadFromStream(Common::ReadStream *stream);
 	bool writeToStream(Common::WriteStream *stream, int saveType);
-	void makeContinuePoint();
 	void loadFromContinuePoint();
 	Common::ReadStream *_continuePoint;
 	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
@@ -215,6 +221,11 @@ private:
 	// Sound
 	uint16 _ambientLevel;
 	uint16 _FXLevel;
+
+	// Game Mode
+	tGameMode _gameMode;
+	void switchGameMode(const tGameMode, const tGameMode);
+	bool canSwitchGameMode(const tGameMode, const tGameMode);
 };
 
 } // End of namespace Pegasus


Commit: fe03cd1bfabeab154573b55216c581bb0af41e9a
    https://github.com/scummvm/scummvm/commit/fe03cd1bfabeab154573b55216c581bb0af41e9a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T09:24:45-07:00

Commit Message:
PEGASUS: Partially revert 4aed723368b9a4e82205bc3ed950a4e04ba3d8dc

startFaderSync does indeed to hold the main thread.

Changed paths:
    engines/pegasus/fader.cpp
    engines/pegasus/fader.h



diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
index 8eb1c01..fe292d9 100755
--- a/engines/pegasus/fader.cpp
+++ b/engines/pegasus/fader.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/fader.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/sound.h"
 #include "pegasus/util.h"
 
@@ -32,7 +33,6 @@ namespace Pegasus {
 Fader::Fader() {
 	_currentValue = 0;
 	_currentFaderMove._numKnots = 0;
-	_syncMode = false;
 }
 
 void Fader::setFaderValue(const uint32 newValue) {
@@ -86,14 +86,22 @@ void Fader::startFader(const FaderMoveSpec &spec) {
 }
 
 void Fader::startFaderSync(const FaderMoveSpec &spec) {
-	if (initFaderMove(spec)) {
-		_syncMode = true;
-	
+	if (initFaderMove(spec)) {	
 		setFlags(0);
 		setScale(spec._faderScale);
 		setSegment(spec._knots[0].knotTime, spec._knots[spec._numKnots - 1].knotTime);
 		setTime(spec._knots[0].knotTime);
-		start();		
+		start();
+
+		while (isFading()) {
+			((PegasusEngine *)g_engine)->checkCallBacks();
+			useIdleTime();
+		}
+
+		// Once more, for good measure, to make sure that there are no boundary
+		// condition problems.
+		useIdleTime();
+		stopFader();
 	}
 }
 
@@ -140,18 +148,6 @@ void Fader::timeChanged(const TimeValue newTime) {
 	}
 }
 
-void Fader::checkCallBacks() {
-	IdlerTimeBase::checkCallBacks();
-
-	if (_syncMode && !isRunning()) {
-		// Once more, for good measure, to make sure that there are no boundary
-		// condition problems.
-		useIdleTime();
-		stopFader();
-		_syncMode = false;
-	}
-}
-
 void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
 	_numKnots = 1;
 	_knots[0].knotTime = 0;
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
index 83f5a81..fe5b1ae 100755
--- a/engines/pegasus/fader.h
+++ b/engines/pegasus/fader.h
@@ -89,15 +89,12 @@ public:
 
 	void getCurrentFaderMove(FaderMoveSpec &spec) { spec = _currentFaderMove; }
 
-	virtual void checkCallBacks();
-
 protected:
 	bool initFaderMove(const FaderMoveSpec &);
 	virtual void timeChanged(const TimeValue);
 	
 	uint32 _currentValue;
 	FaderMoveSpec _currentFaderMove;
-	bool _syncMode;
 };
 
 class FaderAnimation : public DisplayElement, public Fader {


Commit: 02781cf2cee4f4ea1724628863bcdb1ad4019df1
    https://github.com/scummvm/scummvm/commit/02781cf2cee4f4ea1724628863bcdb1ad4019df1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T09:27:20-07:00

Commit Message:
PEGASUS: Make the menu music fade in but not block for now

Changed paths:
    engines/pegasus/menu.cpp



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index fb6af17..2aba4f0 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -237,7 +237,10 @@ void MainMenu::startMainMenuLoop() {
 
 	_menuLoop.loopSound();
 	spec.makeTwoKnotFaderSpec(30, 0, 0, 30, 255);
-	_menuFader.startFaderSync(spec);
+
+	// FIXME: Should be sync, but it's a pain to use the main menu right now
+	// with this one.
+	_menuFader.startFader(spec);
 }
 
 void MainMenu::stopMainMenuLoop() {


Commit: 59d6b036dc66b6988ee189ba8e55a0b858a81449
    https://github.com/scummvm/scummvm/commit/59d6b036dc66b6988ee189ba8e55a0b858a81449
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T16:42:42-07:00

Commit Message:
PEGASUS: Fader values should be signed

Changed paths:
    engines/pegasus/compass.cpp
    engines/pegasus/compass.h
    engines/pegasus/fader.cpp
    engines/pegasus/fader.h
    engines/pegasus/transition.cpp
    engines/pegasus/transition.h



diff --git a/engines/pegasus/compass.cpp b/engines/pegasus/compass.cpp
index 3772827..2c80c5c 100755
--- a/engines/pegasus/compass.cpp
+++ b/engines/pegasus/compass.cpp
@@ -53,8 +53,8 @@ void Compass::deallocateCompass() {
 	_compassImage.deallocateSurface();
 }
 
-void Compass::setFaderValue(const uint32 angle) {
-	int16 a = (int32)angle % 360;
+void Compass::setFaderValue(const int32 angle) {
+	int16 a = angle % 360;
 
 	if (a < 0)
 		a += 360;
diff --git a/engines/pegasus/compass.h b/engines/pegasus/compass.h
index f669dd3..d66b432 100755
--- a/engines/pegasus/compass.h
+++ b/engines/pegasus/compass.h
@@ -43,7 +43,7 @@ public:
 	void deallocateCompass();
 	bool isCompassValid() const { return _compassImage.isSurfaceValid(); }
 	
-	void setFaderValue(const uint32);
+	void setFaderValue(const int32);
 
 protected:
 	void draw(const Common::Rect &);
diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
index fe292d9..77ad2cb 100755
--- a/engines/pegasus/fader.cpp
+++ b/engines/pegasus/fader.cpp
@@ -35,13 +35,13 @@ Fader::Fader() {
 	_currentFaderMove._numKnots = 0;
 }
 
-void Fader::setFaderValue(const uint32 newValue) {
+void Fader::setFaderValue(const int32 newValue) {
 	_currentValue = newValue;
 }
 
 bool Fader::initFaderMove(const FaderMoveSpec &spec) {	
 	bool faderMoves = false;
-	uint32 value = 0;
+	int32 value = 0;
 
 	if (spec._numKnots > 0) {
 		stopFader();
@@ -135,7 +135,7 @@ void Fader::timeChanged(const TimeValue newTime) {
 			if (_currentFaderMove._knots[i].knotTime > newTime)
 				break;
 
-		uint32 newValue;
+		int32 newValue;
 		if (i == 0)
 			newValue = _currentFaderMove._knots[0].knotValue;
 		else if (i == _currentFaderMove._numKnots)
@@ -148,13 +148,13 @@ void Fader::timeChanged(const TimeValue newTime) {
 	}
 }
 
-void FaderMoveSpec::makeOneKnotFaderSpec(const uint32 knotValue) {
+void FaderMoveSpec::makeOneKnotFaderSpec(const int32 knotValue) {
 	_numKnots = 1;
 	_knots[0].knotTime = 0;
 	_knots[0].knotValue = knotValue;
 }
 
-void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeValue time1, const uint32 value1, const TimeValue time2, const uint32 value2) {
+void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeValue time1, const int32 value1, const TimeValue time2, const int32 value2) {
 	_numKnots = 2;
 	_faderScale = faderScale;
 	_knots[0].knotTime = time1;
@@ -163,7 +163,7 @@ void FaderMoveSpec::makeTwoKnotFaderSpec(const TimeScale faderScale, const TimeV
 	_knots[1].knotValue = value2;
 }
 
-void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const uint32 knotValue) {	
+void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const int32 knotValue) {	
 	if (_numKnots != kMaxFaderKnots) {
 		uint32 index;
 		for (index = 0; index < _numKnots; index++) {
@@ -184,7 +184,7 @@ void FaderMoveSpec::insertFaderKnot(const TimeValue knotTime, const uint32 knotV
 	}
 }
 
-void FaderAnimation::setFaderValue(const uint32 newValue) {
+void FaderAnimation::setFaderValue(const int32 newValue) {
 	if (getFaderValue() != newValue) {
 		Fader::setFaderValue(newValue);
 		triggerRedraw();
@@ -203,7 +203,7 @@ void SoundFader::attachSound(Sound *sound) {
 	_sound = sound;
 }
 
-void SoundFader::setFaderValue(const uint32 newVolume) {	
+void SoundFader::setFaderValue(const int32 newVolume) {	
 	if (_sound)
 		_sound->setVolume((newVolume * _masterVolume) >> 8);
 
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
index fe5b1ae..8c4fb0b 100755
--- a/engines/pegasus/fader.h
+++ b/engines/pegasus/fader.h
@@ -49,19 +49,19 @@ public:
 	void setFaderScale(const TimeScale scale) { _faderScale = scale; }
 	TimeScale getFaderScale() const { return _faderScale; }
 
-	void makeOneKnotFaderSpec(const uint32);
-	void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const uint32, const TimeValue, const uint32);
+	void makeOneKnotFaderSpec(const int32);
+	void makeTwoKnotFaderSpec(const TimeScale, const TimeValue, const int32, const TimeValue, const int32);
 
-	void insertFaderKnot(const TimeValue, const uint32);
+	void insertFaderKnot(const TimeValue, const int32);
 
 	uint32 getNumKnots() const { return _numKnots; }
-	uint32 getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
-	uint32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }
+	TimeValue getNthKnotTime(const uint32 index) const { return _knots[index].knotTime; }
+	int32 getNthKnotValue(const uint32 index) const { return _knots[index].knotValue; }
 
 protected:
 	struct FaderKnot {
 		TimeValue knotTime;
-		uint32 knotValue;
+		int32 knotValue;
 	};
 	
 	TimeScale _faderScale;
@@ -76,8 +76,8 @@ public:
 	Fader();
 	virtual ~Fader() {}
 
-	virtual void setFaderValue(const uint32);
-	uint32 getFaderValue() const { return _currentValue; }
+	virtual void setFaderValue(const int32);
+	int32 getFaderValue() const { return _currentValue; }
 	virtual void startFader(const FaderMoveSpec &);
 	virtual void startFaderSync(const FaderMoveSpec &);
 	virtual void loopFader(const FaderMoveSpec &);
@@ -93,7 +93,7 @@ protected:
 	bool initFaderMove(const FaderMoveSpec &);
 	virtual void timeChanged(const TimeValue);
 	
-	uint32 _currentValue;
+	int32 _currentValue;
 	FaderMoveSpec _currentFaderMove;
 };
 
@@ -102,7 +102,7 @@ public:
 	FaderAnimation(const tDisplayElementID id) : DisplayElement(id) {}
 	virtual ~FaderAnimation() {}
 
-	void setFaderValue(const uint32);
+	void setFaderValue(const int32);
 };
 
 class Sound;
@@ -113,7 +113,7 @@ public:
 	SoundFader();
 	virtual ~SoundFader() {}
 
-	void setFaderValue(const uint32);
+	void setFaderValue(const int32);
 
 	void setMasterVolume(const uint16);
 	uint16 getMasterVolume() const { return _masterVolume; }
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
index 20b9959..73bd277 100755
--- a/engines/pegasus/transition.cpp
+++ b/engines/pegasus/transition.cpp
@@ -51,7 +51,7 @@ void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale,
 	startFaderSync(spec);
 }
 
-void ScreenFader::setFaderValue(const uint32 value) {
+void ScreenFader::setFaderValue(const int32 value) {
 	if (value != getFaderValue()) {
 		Fader::setFaderValue(value);
 
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index d34f318..718808c 100755
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -38,7 +38,7 @@ public:
 	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
 	void doFadeInSync(const TimeValue = kHalfSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
 
-	void setFaderValue(const uint32);	
+	void setFaderValue(const int32);	
 
 protected:
 	uint32 _fadeTarget;


Commit: c581cb189a23e889ab82156d22c4a46175c2e923
    https://github.com/scummvm/scummvm/commit/c581cb189a23e889ab82156d22c4a46175c2e923
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T16:49:30-07:00

Commit Message:
PEGASUS: Add the Prehistoric neighborhood

Yes, the first neighborhood is here! And all the world rejoiced, yet it was still not used in the code so the rejoicing was kept to a low murmur.

It's the smallest neighborhood and will be used as a testbed for the code while the other neighborhoods are coded.

Changed paths:
  A engines/pegasus/neighborhood/prehistoric.cpp
  A engines/pegasus/neighborhood/prehistoric.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index d0b661a..667ba4e 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -45,6 +45,7 @@ MODULE_OBJS = \
 	neighborhood/extra.o \
 	neighborhood/hotspotinfo.o \
 	neighborhood/neighborhood.o \
+	neighborhood/prehistoric.o \
 	neighborhood/spot.o \
 	neighborhood/turn.o \
 	neighborhood/view.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 60668a7..7b7f229 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -128,7 +128,7 @@ void Neighborhood::init() {
 
 	createNeighborhoodSpots();
 
-	// TODO: Load _navMovie
+	_navMovie.initFromMovieFile(getNavMovieName());
 	_navMovie.setVolume(_vm->getSoundFXLevel());
 
 	loadSoundSpots();
@@ -602,9 +602,9 @@ void Neighborhood::stopStriding() {
 }
 
 //	Compass support
-uint16 Neighborhood::getStaticCompassAngle(const tRoomID, const tDirectionConstant dir) {
+int16 Neighborhood::getStaticCompassAngle(const tRoomID, const tDirectionConstant dir) {
 	//	North, south, east, west
-	static const uint16 compassAngles[] = { 0, 180, 90, 270 };
+	static const int16 compassAngles[] = { 0, 180, 90, 270 };
 	return compassAngles[dir];
 }
 
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 46f0f66..1896e0f 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -254,6 +254,7 @@ protected:
 	Common::String _resName;
 	
 	virtual void loadSoundSpots();
+	virtual Common::String getNavMovieName() = 0;
 
 	// Notification function.
 	virtual void receiveNotification(Notification *, const tNotificationFlags);
@@ -304,7 +305,7 @@ protected:
 	virtual tInputBits getInputFilter();
 
 	// Misc.
-	virtual uint16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
+	virtual int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
 	virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
 	virtual void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec&);
 	virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&);
diff --git a/engines/pegasus/neighborhood/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric.cpp
new file mode 100755
index 0000000..b290c81
--- /dev/null
+++ b/engines/pegasus/neighborhood/prehistoric.cpp
@@ -0,0 +1,685 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/compass.h"
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_action.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/ai/ai_condition.h"
+#include "pegasus/ai/ai_rule.h"
+#include "pegasus/neighborhood/prehistoric.h"
+
+namespace Pegasus {
+
+static const int16 s_prehistoricCompass[kPrehistoric25 + 1][4] = {
+	{ 0, 170, 90, 270 },   // kPrehistoric01
+	{ 0, 180, 90, 270 },   // kPrehistoric02
+	{ 10, 180, 90, 270 },  // kPrehistoric03
+	{ 10, 190, 90, 270 },  // kPrehistoric04
+	{ 10, 195, 90, 270 },  // kPrehistoric05
+	{ 20, 210, 90, 270 },  // kPrehistoric06
+	{ 20, 200, 130, 276 }, // kPrehistoric07
+	{ 20, 176, 110, 260 }, // kPrehistoric08
+	{ 20, 200, 100, 270 }, // kPrehistoric09
+	{ 14, 186, 100, 280 }, // kPrehistoric10
+	{ 26, 206, 116, 296 }, // kPrehistoric11
+	{ 60, 226, 140, 320 }, // kPrehistoric12
+	{ 0, 180, 80, 270 },   // kPrehistoric13
+	{ 14, 200, 106, 286 }, // kPrehistoric14
+	{ -10, 174, 80, 260 }, // kPrehistoric15
+	{ 54, 236, 140, 210 }, // kPrehistoric16
+	{ -24, 160, 70, 250 }, // kPrehistoric17
+	{ 26, 206, 140, 296 }, // kPrehistoric18
+	{ -16, 160, 70, 250 }, // kPrehistoric19
+	{ -16, 160, 70, 250 }, // kPrehistoric20
+	{ -10, 160, 90, 250 }, // kPrehistoric21
+	{ -20, 160, 70, 244 }, // kPrehistoric22
+	{ -20, 160, 70, 244 }, // kPrehistoric22North
+	{ 60, 234, 150, 330 }, // kPrehistoric23
+	{ 50, 230, 140, 320 }, // kPrehistoric24
+	{ 60, 240, 140, 330 }  // kPrehistoric25
+};
+
+static const TimeValue kPrehistoricFlashlightClickIn = 0;
+static const TimeValue kPrehistoricFlashlightClickOut = 138;
+
+static const TimeValue kPrehistoricBumpIntoWallIn = 138;
+static const TimeValue kPrehistoricBumpIntoWallOut = 291;
+
+static const TimeValue kBridgeRetractIn = 291;
+static const TimeValue kBridgeRetractOut = 1499;
+
+static const TimeValue kPrehistoricWarningTimeLimit = kTenMinutes;
+
+Prehistoric::Prehistoric(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Prehistoric", kPrehistoricID) {
+	setIsItemTaken(kHistoricalLog);
+}
+
+uint16 Prehistoric::getDateResID() const {
+	return kDatePrehistoricID;
+}
+
+void Prehistoric::init() {
+	Neighborhood::init();
+	
+	// Forces a stop so the flashlight can turn off...
+	forceStridingStop(kPrehistoric12, kSouth, kNoAlternateID);
+}
+
+void Prehistoric::start() {
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->restoreLastEnergyValue();
+		_vm->resetEnergyDeathReason();
+		g_energyMonitor->startEnergyDraining();
+	}
+
+	Neighborhood::start();
+}
+
+class FinishPrehistoricAction : public AIPlayMessageAction {
+public:
+	FinishPrehistoricAction() : AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false) {}
+	~FinishPrehistoricAction() {}
+	
+	void performAIAction(AIRule *);
+
+};
+
+void FinishPrehistoricAction::performAIAction(AIRule *rule) {
+	AIPlayMessageAction::performAIAction(rule);
+	((PegasusEngine *)g_engine)->die(kPlayerWonGame);
+}
+
+void Prehistoric::setUpAIRules() {
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		if (_vm->isDemo()) {
+			FinishPrehistoricAction *doneAction = new FinishPrehistoricAction();
+			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
+			AIRule *rule = new AIRule(hasLogCondition, doneAction);
+			g_AIArea->addAIRule(rule);
+		} else {
+			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP1NB", false);
+			AILocationCondition *locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric16, kNorth));
+			AIRule *rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric01, kSouth));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new  AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric08, kEast));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric25, kWest));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP16NB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric23, kNorth));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP18NB", false);
+			AITimerCondition *timerCondition = new AITimerCondition(kPrehistoricWarningTimeLimit, 1, true);
+			rule = new AIRule(timerCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false);
+			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
+			rule = new AIRule(hasLogCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		}
+	}
+}
+
+TimeValue Prehistoric::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry extra;
+	uint32 extraID = 0xffffffff;
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric02, kSouth):
+		if (!GameState.getPrehistoricSeenTimeStream()) {
+			getExtraEntry(kPreArrivalFromTSA, extra);
+			return extra.movieStart;
+		}
+		break;
+	case MakeRoomView(kPrehistoric25, kEast):
+		if (_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag)) {
+			if (_vm->itemInLocation(kHistoricalLog, kPrehistoricID, kPrehistoric25, kEast))
+				extraID = kPre25EastViewWithLog;
+			else
+				extraID = kPre25EastViewNoLog;
+		}
+		break;
+	}
+
+	if (extraID == 0xffffffff)
+		return Neighborhood::getViewTime(room, direction);
+	
+	getExtraEntry(extraID, extra);
+	return extra.movieEnd - 1;
+}
+
+
+void Prehistoric::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
+	Neighborhood::findSpotEntry(room, direction, flags, entry);
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric01, kSouth):
+	case MakeRoomView(kPrehistoric25, kSouth):
+		entry.clear();
+		break;
+	case MakeRoomView(kPrehistoric01, kEast):
+		if (GameState.getPrehistoricSeenFlyer1())
+			entry.clear();
+		else
+			GameState.setPrehistoricSeenFlyer1(true);
+		break;
+	case MakeRoomView(kPrehistoric08, kEast):
+		if (GameState.getPrehistoricSeenFlyer2())
+			entry.clear();
+		else
+			GameState.setPrehistoricSeenFlyer2(true);
+		break;
+	}
+}
+
+int16 Prehistoric::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	if (room == kPrehistoricDeath)
+		return g_compass->getFaderValue();
+
+	return s_prehistoricCompass[room][dir];
+}
+
+void Prehistoric::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	uint32 angle;
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
+	case MakeRoomView(kPrehistoric01, kNorth):
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 2, -10);
+		break;
+	case MakeRoomView(kPrehistoric06, kEast):
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4, 95);
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4 * 1, 100);
+		break;
+	case MakeRoomView(kPrehistoric18, kEast):
+		if (getCurrentAlternate() == kAltPrehistoricBridgeSet) {
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 11, 145);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 26, 145);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 39, 148);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 114, 140);
+		} else {
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 10, 140);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 16, 145);
+			compassMove.insertFaderKnot(exitEntry.movieEnd, 145);
+		}
+		break;
+	case MakeRoomView(kPrehistoric23, kWest):
+		angle = compassMove.getNthKnotValue(0);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 17, angle);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 32, angle - 90);
+		compassMove.insertFaderKnot(exitEntry.movieEnd, angle - 90);
+		break;
+	}
+}
+
+void Prehistoric::turnTo(const tDirectionConstant newDirection) {
+	setCurrentAlternate(kAltPrehistoricNormal);
+	_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, false);
+	Neighborhood::turnTo(newDirection);
+
+	Item *keyCard;
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kPrehistoric18, kEast):
+		zoomToVault();
+		break;
+	case MakeRoomView(kPrehistoric18, kNorth):
+	case MakeRoomView(kPrehistoric18, kSouth):
+		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
+			playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
+			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
+			loadAmbientLoops();
+		}
+		// fall through
+	case MakeRoomView(kPrehistoric25, kEast):
+		setCurrentActivation(kActivationVaultClosed);
+		break;
+	case MakeRoomView(kPrehistoric16, kNorth):
+	case MakeRoomView(kPrehistoric21, kWest):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+		if (keyCard->getItemState() == kFlashlightOff) {
+			keyCard->setItemState(kFlashlightOn);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	case MakeRoomView(kPrehistoric16, kEast):
+	case MakeRoomView(kPrehistoric16, kWest):
+	case MakeRoomView(kPrehistoric21, kNorth):
+	case MakeRoomView(kPrehistoric21, kSouth):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+		if (keyCard->getItemState() == kFlashlightOn) {
+			keyCard->setItemState(kFlashlightOff);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	}
+}
+
+void Prehistoric::zoomToVault() {
+	if (!GameState.getPrehistoricSeenBridgeZoom())
+		startExtraSequence(kPre18EastZoom, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void Prehistoric::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric08, kEast):
+	case MakeRoomView(kPrehistoric18, kSouth):
+	case MakeRoomView(kPrehistoric16, kNorth):
+	case MakeRoomView(kPrehistoric21, kNorth):
+	case MakeRoomView(kPrehistoric25, kNorth):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void Prehistoric::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	Item *keyCard;
+	
+	if (MakeRoomView(room, direction) == MakeRoomView(kPrehistoric25, kEast) &&
+			_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
+		_navMovie.stop();
+		playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
+		_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
+	}
+
+	Neighborhood::arriveAt(room, direction);
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoricDeath, kNorth):
+	case MakeRoomView(kPrehistoricDeath, kSouth):
+	case MakeRoomView(kPrehistoricDeath, kEast):
+	case MakeRoomView(kPrehistoricDeath, kWest):
+		if (GameState.getLastRoom() == kPrehistoric23)
+			die(kDeathEatenByDinosaur);
+		else
+			die(kDeathFallOffCliff);
+		break;
+	case MakeRoomView(kPrehistoric02, kSouth):
+		if (!GameState.getPrehistoricSeenTimeStream()) {
+			GameState.setPrehistoricTriedToExtendBridge(false);
+			GameState.setPrehistoricSeenFlyer1(false);
+			GameState.setPrehistoricSeenFlyer2(false);
+			GameState.setPrehistoricSeenBridgeZoom(false);
+			GameState.setPrehistoricBreakerThrown(false);
+			startExtraSequence(kPreArrivalFromTSA, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case MakeRoomView(kPrehistoric18, kEast):
+		zoomToVault();
+		break;
+	case MakeRoomView(kPrehistoric16, kNorth):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+
+		if (keyCard->getItemState() == kFlashlightOff) {
+			keyCard->setItemState(kFlashlightOn);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+
+		if (g_AIArea)
+			g_AIArea->checkRules();
+		break;
+	case MakeRoomView(kPrehistoric01, kSouth):
+	case MakeRoomView(kPrehistoric23, kNorth):
+		if (g_AIArea)
+			g_AIArea->checkRules();
+		break;
+	case MakeRoomView(kPrehistoric08, kSouth):
+	case MakeRoomView(kPrehistoric10, kSouth):
+	case MakeRoomView(kPrehistoric12, kSouth):
+	case MakeRoomView(kPrehistoric13, kNorth):
+	case MakeRoomView(kPrehistoric14, kSouth):
+	case MakeRoomView(kPrehistoric15, kNorth):
+	case MakeRoomView(kPrehistoric16, kSouth):
+	case MakeRoomView(kPrehistoric17, kNorth):
+	case MakeRoomView(kPrehistoric18, kSouth):
+	case MakeRoomView(kPrehistoric19, kNorth):
+	case MakeRoomView(kPrehistoric20, kNorth):
+	case MakeRoomView(kPrehistoric21, kEast):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+
+		if (keyCard->getItemState() == kFlashlightOn) {
+			keyCard->setItemState(kFlashlightOff);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	case MakeRoomView(kPrehistoric25, kEast):
+		setCurrentActivation(kActivationVaultClosed);
+		break;
+	}
+}
+
+void Prehistoric::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+	
+	switch (room) {
+	case kPrehistoric02:
+		// 1/4 volume.
+		if (GameState.getPrehistoricSeenTimeStream())
+			loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
+		break;
+	case kPrehistoric01:
+	case kPrehistoric03:
+	case kPrehistoric04:
+	case kPrehistoric05:
+	case kPrehistoric06:
+	case kPrehistoric07:
+	case kPrehistoric09:
+	case kPrehistoric11:
+	case kPrehistoric13:
+	case kPrehistoric15:
+	case kPrehistoric17:
+	case kPrehistoric19:
+	case kPrehistoric20:
+		// 1/4 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
+		break;
+	case kPrehistoric08:
+	case kPrehistoric10:
+	case kPrehistoric12:
+	case kPrehistoric14:
+	case kPrehistoric16:
+	case kPrehistoric18:
+	case kPrehistoric21:
+		// 3/16 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 48);
+		break;
+	case kPrehistoric25:
+		// 1/8 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 32);
+		break;
+	case kPrehistoric22:
+	case kPrehistoric22North:
+	case kPrehistoric23:
+	case kPrehistoric24:
+	case kPrehistoricDeath:
+		// 0 volume.
+		loadLoopSound1("");
+		break;
+	}
+
+	switch (room) {
+	case kPrehistoric02:
+	case kPrehistoric03:
+	case kPrehistoric04:
+	case kPrehistoric05:
+	case kPrehistoric06:
+	case kPrehistoric07:
+	case kPrehistoric08:
+	case kPrehistoric09:
+	case kPrehistoric10:
+	case kPrehistoric11:
+	case kPrehistoric12:
+	case kPrehistoric13:
+	case kPrehistoric14:
+	case kPrehistoric15:
+	case kPrehistoric16:
+	case kPrehistoric17:
+	case kPrehistoric19:
+	case kPrehistoric20:
+	case kPrehistoric21:
+	case kPrehistoricDeath:
+		loadLoopSound2("");
+		break;
+	case kPrehistoric01:
+	case kPrehistoric25:
+		loadLoopSound2("Sounds/Prehistoric/VolcLoop.22K.AIFF", 64);
+		break;
+	case kPrehistoric18:
+		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+			loadLoopSound2("Sounds/Prehistoric/P18EAL00.22k.AIFF", 0x100, 0, 0);
+		else
+			loadLoopSound2("");
+		break;
+	case kPrehistoric23:
+	case kPrehistoric24:
+	case kPrehistoric22:
+	case kPrehistoric22North:
+		loadLoopSound2("Sounds/Prehistoric/P24NAL00.22k.AIFF", 64);
+		break;
+	}
+}
+
+void Prehistoric::activateHotspots() {
+	Neighborhood::activateHotspots();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kPrehistoric18, kEast):
+		if (!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+			g_allHotspots.activateOneHotspot(kPre18EastSpotID);
+		break;
+	case MakeRoomView(kPrehistoric22North, kNorth):
+		g_allHotspots.activateOneHotspot(kPre22NorthBreakerSpotID);
+		break;
+	}
+}
+
+void Prehistoric::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kPre18EastSpotID:
+		if (GameState.getPrehistoricBreakerThrown())
+			startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kPre18EastBridgeOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kPre22NorthBreakerSpotID:
+		startExtraSequence(kPre22ThrowBreaker, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Neighborhood::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void Prehistoric::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	Neighborhood::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		_interruptionFilter = kFilterAllInput;
+
+		switch (_lastExtra) {
+		case kPreArrivalFromTSA:
+			GameState.setPrehistoricSeenTimeStream(true);
+			loadAmbientLoops();
+			makeContinuePoint();
+			break;
+		case kPre18EastZoom:
+			startExtraSequence(kPre18EastZoomOut, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kPre18EastZoomOut:
+			GameState.setPrehistoricSeenBridgeZoom(true);
+			break;
+		case kPre18EastBridgeOn:
+			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, true);
+			setCurrentAlternate(kAltPrehistoricBridgeSet);
+			GameState.setPrehistoricTriedToExtendBridge(false);
+			loadAmbientLoops();
+			GameState.setScoringExtendedBridge(true);
+			break;
+		case kPre18EastBridgeOut:
+			GameState.setPrehistoricTriedToExtendBridge(true);
+			if (g_AIArea)
+				g_AIArea->checkMiddleArea();
+			break;
+		case kPre22ThrowBreaker:
+			GameState.setPrehistoricBreakerThrown(true);
+			GameState.setScoringThrewBreaker(true);
+			break;
+		case kPre25EastUnlockingVaultNoLog:
+		case kPre25EastUnlockingVaultWithLog:
+			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kJourneymanKey));
+			break;
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+Common::String Prehistoric::getBriefingMovie() {
+	Common::String movieName = Neighborhood::getBriefingMovie();
+
+	if (movieName.empty())
+		movieName = "Images/AI/Prehistoric/XPE";
+
+	return movieName;
+}
+
+Common::String Prehistoric::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		if (!_vm->isDemo()) {
+			switch (GameState.getCurrentRoom()) {
+			case kPrehistoric16:
+			case kPrehistoric23:
+			case kPrehistoric24:
+				return "Images/AI/Prehistoric/XP7WB";
+			}
+		}
+
+		return "Images/AI/Prehistoric/XP17NB";
+	}
+
+	return movieName;
+}
+
+uint Prehistoric::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+	
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kPrehistoric18, kEast):
+			if (!GameState.getPrehistoricBreakerThrown() && GameState.getPrehistoricTriedToExtendBridge() &&
+					!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+				numHints = 1;
+			break;
+		case MakeRoomView(kPrehistoric25, kEast):
+			if (!_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag))
+				numHints = 1;
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String Prehistoric::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kPrehistoric18, kEast):
+			return "Images/AI/Prehistoric/XP18WD";
+		case MakeRoomView(kPrehistoric25, kEast):
+			return "Images/AI/Globals/XGLOB1A";
+		}
+	}
+
+	return movieName;
+}
+
+bool Prehistoric::canSolve() {
+	return	GameState.getCurrentRoomAndView() == MakeRoomView(kPrehistoric18, kEast) &&
+			!GameState.getPrehistoricBreakerThrown() &&
+			GameState.getPrehistoricTriedToExtendBridge() &&
+			!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag);
+}
+
+void Prehistoric::doSolve() {
+	GameState.setPrehistoricBreakerThrown(true);
+	startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
+}
+
+Hotspot *Prehistoric::getItemScreenSpot(Item *item, DisplayElement *element) {
+	if (item->getObjectID() == kHistoricalLog)
+		return g_allHotspots.findHotspotByID(kPrehistoricHistoricalLogSpotID);
+
+	return Neighborhood::getItemScreenSpot(item, element);
+}
+
+void Prehistoric::pickedUpItem(Item *item) {
+	switch (item->getObjectID()) {
+	case kHistoricalLog:
+		GameState.setScoringGotHistoricalLog(true);
+		break;
+	}
+
+	Neighborhood::pickedUpItem(item);
+}
+
+void Prehistoric::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
+	switch (item->getObjectID()) {
+	case kJourneymanKey:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+
+		if (GameState.isTakenItemID(kHistoricalLog))
+			startExtraLongSequence(kPre25EastUnlockingVaultNoLog, kPre25EastVaultOpenNoLog, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraLongSequence(kPre25EastUnlockingVaultWithLog, kPre25EastVaultOpenWithLog, kExtraCompletedFlag, kFilterNoInput);
+
+		_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, true);
+		setCurrentActivation(kActivationVaultOpen);
+		break;
+	default:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	}
+}
+
+void Prehistoric::bumpIntoWall() {
+	requestSpotSound(kPrehistoricBumpIntoWallIn, kPrehistoricBumpIntoWallOut, kFilterAllInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+Common::String Prehistoric::getNavMovieName() {
+	return "Images/Prehistoric/Prehistoric.movie";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/prehistoric.h b/engines/pegasus/neighborhood/prehistoric.h
new file mode 100755
index 0000000..ecc62da
--- /dev/null
+++ b/engines/pegasus/neighborhood/prehistoric.h
@@ -0,0 +1,157 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
+#define PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+const TimeScale kPrehistoricMovieScale = 600;
+const TimeScale kPrehistoricFramesPerSecond = 15;
+const TimeScale kPrehistoricFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltPrehistoricNormal = 0;
+const tAlternateID kAltPrehistoricBridgeSet = 1;
+
+//	Room IDs.
+
+const tRoomID kPrehistoric01 = 0;
+const tRoomID kPrehistoric02 = 1;
+const tRoomID kPrehistoric03 = 2;
+const tRoomID kPrehistoric04 = 3;
+const tRoomID kPrehistoric05 = 4;
+const tRoomID kPrehistoric06 = 5;
+const tRoomID kPrehistoric07 = 6;
+const tRoomID kPrehistoric08 = 7;
+const tRoomID kPrehistoric09 = 8;
+const tRoomID kPrehistoric10 = 9;
+const tRoomID kPrehistoric11 = 10;
+const tRoomID kPrehistoric12 = 11;
+const tRoomID kPrehistoric13 = 12;
+const tRoomID kPrehistoric14 = 13;
+const tRoomID kPrehistoric15 = 14;
+const tRoomID kPrehistoric16 = 15;
+const tRoomID kPrehistoric17 = 16;
+const tRoomID kPrehistoric18 = 17;
+const tRoomID kPrehistoric19 = 18;
+const tRoomID kPrehistoric20 = 19;
+const tRoomID kPrehistoric21 = 20;
+const tRoomID kPrehistoric22 = 21;
+const tRoomID kPrehistoric22North = 22;
+const tRoomID kPrehistoric23 = 23;
+const tRoomID kPrehistoric24 = 24;
+const tRoomID kPrehistoric25 = 25;
+const tRoomID kPrehistoricDeath = 26;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationVaultClosed = 1;
+const tHotSpotActivationID kActivationVaultOpen = 2;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kPre18EastSpotID = 5000;
+const tHotSpotID kPre22NorthSpotID = 5001;
+const tHotSpotID kPre22NorthOutSpotID = 5002;
+const tHotSpotID kPre22NorthBreakerSpotID = 5003;
+const tHotSpotID kPrehistoricKeyDropSpotID = 5004;
+const tHotSpotID kPrehistoricHistoricalLogSpotID = 5005;
+
+//	Extra sequence IDs.
+
+const tExtraID kPreArrivalFromTSA = 0;
+const tExtraID kPre18EastBridgeOut = 1;
+const tExtraID kPre18EastBridgeOn = 2;
+const tExtraID kPre18EastZoom = 3;
+const tExtraID kPre18EastZoomOut = 4;
+const tExtraID kPre22ThrowBreaker = 5;
+const tExtraID kPre25EastUnlockingVaultWithLog = 6;
+const tExtraID kPre25EastVaultOpenWithLog = 7;
+const tExtraID kPre25EastViewWithLog = 8;
+const tExtraID kPre25EastUnlockingVaultNoLog = 9;
+const tExtraID kPre25EastVaultOpenNoLog = 10;
+const tExtraID kPre25EastViewNoLog = 11;
+
+class PegasusEngine;
+
+class Prehistoric : public Neighborhood {
+public:
+	Prehistoric(InputHandler *, PegasusEngine *);
+	virtual ~Prehistoric() {}
+	
+	virtual uint16 getDateResID() const;
+	virtual void init();
+	
+	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void pickedUpItem(Item *);
+
+	void start();
+
+	void bumpIntoWall();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+protected:
+	enum {
+		kPrehistoricPrivateVaultOpenFlag,
+		kPrehistoricPrivateExtendedBridgeFlag,
+		kNumPrehistoricPrivateFlags
+	};
+
+	void setUpAIRules();
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	void turnTo(const tDirectionConstant);
+	void zoomToVault();
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+
+	void loadAmbientLoops();
+	
+	FlagsArray<byte, kNumPrehistoricPrivateFlags> _privateFlags;
+
+	Common::String getNavMovieName();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index f4fdf81..5d8f150 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -65,8 +65,9 @@ public:
 	void clear();
 
 	struct Entry {
-		Entry() { movieStart = 0xffffffff; }
+		Entry() { clear(); }
 		bool isEmpty() { return movieStart == 0xffffffff; }
+		void clear() { movieStart = 0xffffffff; }
 
 		tRoomID room;
 		tDirectionConstant direction;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d6a4ce1..d9f296d 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -41,6 +41,7 @@
 #include "pegasus/movie.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/timers.h"
+#include "pegasus/ai/ai_area.h"
 #include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/biochipitem.h"
@@ -1073,4 +1074,38 @@ bool PegasusEngine::canSwitchGameMode(const tGameMode newMode, const tGameMode o
 	return true;
 }
 
+bool PegasusEngine::itemInLocation(const tItemID itemID, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+	tNeighborhoodID itemNeighborhood;
+	tRoomID itemRoom;
+	tDirectionConstant itemDirection;
+	
+	Item *item = g_allItems.findItemByID(itemID);
+	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
+
+	return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
+}
+
+tInventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
+	tInventoryResult result;
+	
+	do {
+		if (g_interface)
+			result = g_interface->addInventoryItem(item);
+		else
+			result = _items.addItem(item);
+
+		// TODO
+		if (result == kTooMuchWeight)
+			error("Out of inventory space");
+	} while (result != kInventoryOK);
+
+	GameState.setTakenItem(item, true);
+	if (g_neighborhood)
+			g_neighborhood->pickedUpItem(item);
+
+	g_AIArea->checkMiddleArea();
+
+	return result;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 988b6a5..4856da6 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -116,12 +116,14 @@ public:
 	bool playerHasItem(const Item *);
 	bool playerHasItemID(const tItemID);
 	void checkFlashlight();
+	bool itemInLocation(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
 
 	// Inventory Items
 	InventoryItem *getCurrentInventoryItem();
 	bool itemInInventory(InventoryItem *);
 	bool itemInInventory(tItemID);
 	Inventory *getItemsInventory() { return &_items; }
+	tInventoryResult addItemToInventory(InventoryItem *);
 
 	// Biochips
 	BiochipItem *getCurrentBiochip();


Commit: d0914e6dc35d4b1c3b2c2eb486a3289785762eb9
    https://github.com/scummvm/scummvm/commit/d0914e6dc35d4b1c3b2c2eb486a3289785762eb9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T17:09:26-07:00

Commit Message:
PEGASUS: Push the sound spots file name to subclasses

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/neighborhood/prehistoric.cpp
    engines/pegasus/neighborhood/prehistoric.h



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 7b7f229..d87a536 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -131,7 +131,7 @@ void Neighborhood::init() {
 	_navMovie.initFromMovieFile(getNavMovieName());
 	_navMovie.setVolume(_vm->getSoundFXLevel());
 
-	loadSoundSpots();
+	_spotSounds.initFromQuickTime(getSoundSpotsName());
 	_spotSounds.setVolume(_vm->getSoundFXLevel());
 
 	_navMovie.setDisplayOrder(kNavMovieOrder);
@@ -367,40 +367,6 @@ void Neighborhood::createNeighborhoodSpots() {
 	delete hotspotList;
 }
 
-void Neighborhood::loadSoundSpots() {
-	// TODO: Eventually push to the subclasses
-
-	Common::String fileName = "Sounds/";
-
-	switch (getObjectID()) {
-	case kCaldoriaID:
-		fileName += "Caldoria/Caldoria Spots";
-		break;
-	case kFullTSAID:
-	case kFinalTSAID:
-	case kTinyTSAID:
-		fileName += "TSA/TSA Spots";
-		break;
-	case kPrehistoricID:
-		fileName += "Prehistoric/Prehistoric Spots";
-		break;
-	case kMarsID:
-		fileName += "Mars/Mars Spots";
-		break;
-	case kWSCID:
-		fileName += "World Science Center/WSC Spots";
-		break;
-	case kNoradAlphaID:
-		fileName += "Norad/Norad Alpha Spots";
-		break;
-	case kNoradDeltaID:
-		fileName += "Norad/Norad Delta Spots";
-		break;
-	}
-
-	_spotSounds.initFromQuickTime(fileName);
-}
-
 void Neighborhood::popActionQueue() {	
 	if (!_actionQueue.empty()) {
 		tQueueRequest topRequest = _actionQueue.pop();
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 1896e0f..1ceb3a2 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -253,7 +253,7 @@ protected:
 	PegasusEngine *_vm;
 	Common::String _resName;
 	
-	virtual void loadSoundSpots();
+	virtual Common::String getSoundSpotsName() = 0;
 	virtual Common::String getNavMovieName() = 0;
 
 	// Notification function.
diff --git a/engines/pegasus/neighborhood/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric.cpp
index b290c81..26c9e54 100755
--- a/engines/pegasus/neighborhood/prehistoric.cpp
+++ b/engines/pegasus/neighborhood/prehistoric.cpp
@@ -682,4 +682,8 @@ Common::String Prehistoric::getNavMovieName() {
 	return "Images/Prehistoric/Prehistoric.movie";
 }
 
+Common::String Prehistoric::getSoundSpotsName() {
+	return "Sounds/Prehistoric/Prehistoric Spots";
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/prehistoric.h b/engines/pegasus/neighborhood/prehistoric.h
index ecc62da..44084f5 100755
--- a/engines/pegasus/neighborhood/prehistoric.h
+++ b/engines/pegasus/neighborhood/prehistoric.h
@@ -150,6 +150,7 @@ protected:
 	FlagsArray<byte, kNumPrehistoricPrivateFlags> _privateFlags;
 
 	Common::String getNavMovieName();
+	Common::String getSoundSpotsName();
 };
 
 } // End of namespace Pegasus


Commit: 20f18e447faba964178d7a8dc48f8ed4bd434506
    https://github.com/scummvm/scummvm/commit/20f18e447faba964178d7a8dc48f8ed4bd434506
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T17:41:45-07:00

Commit Message:
PEGASUS: Add the remaining gameshell remnants

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d9f296d..fe140cd 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -75,6 +75,9 @@ PegasusEngine::~PegasusEngine() {
 	delete _cursor;
 	delete _continuePoint;
 	delete _gameMenu;
+	delete _neighborhood;
+
+	// NOTE: This must be deleted last!
 	delete _gfx;
 }
 
@@ -1108,4 +1111,18 @@ tInventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
 	return result;
 }
 
+void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
+	delete _neighborhood;
+	_neighborhood = neighborhood;
+
+	if (_neighborhood) {
+		InputHandler::setInputHandler(_neighborhood);
+		_neighborhood->init();
+		_neighborhood->moveNavTo(kNavAreaLeft, kNavAreaTop);
+		g_interface->setDate(_neighborhood->getDateResID());
+	} else {
+		InputHandler::setInputHandler(this);
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 4856da6..d72b9d1 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -219,6 +219,7 @@ private:
 
 	// Neighborhood
 	Neighborhood *_neighborhood;
+	void useNeighborhood(Neighborhood *neighborhood);
 
 	// Sound
 	uint16 _ambientLevel;


Commit: 817f775da957318e12d1eb14c11b77e384018d66
    https://github.com/scummvm/scummvm/commit/817f775da957318e12d1eb14c11b77e384018d66
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T17:45:51-07:00

Commit Message:
PEGASUS: Update copyright notice on pegasus.cpp/h

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index fe140cd..5eb3340 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -4,6 +4,9 @@
  * are too numerous to list here. Please refer to the COPYRIGHT
  * file distributed with this source distribution.
  *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index d72b9d1..8fa50e9 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -4,6 +4,9 @@
  * are too numerous to list here. Please refer to the COPYRIGHT
  * file distributed with this source distribution.
  *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2


Commit: af78726e4f3bc13910a615fad13477de6ce4a9f7
    https://github.com/scummvm/scummvm/commit/af78726e4f3bc13910a615fad13477de6ce4a9f7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T18:24:12-07:00

Commit Message:
PEGASUS: Add the ItemDragger classes

Changed paths:
  A engines/pegasus/items/itemdragger.cpp
  A engines/pegasus/items/itemdragger.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/itemdragger.cpp b/engines/pegasus/items/itemdragger.cpp
new file mode 100755
index 0000000..79cd101
--- /dev/null
+++ b/engines/pegasus/items/itemdragger.cpp
@@ -0,0 +1,188 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/elements.h"
+#include "pegasus/hotspot.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/items/itemdragger.h"
+
+namespace Pegasus {
+
+SpriteDragger::SpriteDragger() {
+	_draggingSprite = 0;
+	_limitRect = Common::Rect(-30000, -30000, 30000, 30000);
+	_slopRect = Common::Rect(-30000, -30000, 30000, 30000);
+	_dragOffset.x = 0;
+	_dragOffset.y = 0;
+	_lastHotspot = 0;
+}
+
+void SpriteDragger::setDragSprite(Sprite *newSprite) {
+	if (!isTracking())
+		_draggingSprite = newSprite;
+}
+
+void SpriteDragger::setDragConstraints(const Common::Rect &limitRect, const Common::Rect &slopRect) {
+	if (!isTracking()) {
+		_rawLimitRect = limitRect;
+		_slopRect = slopRect;
+	}
+}
+
+void SpriteDragger::getDragConstraints(Common::Rect &limitRect, Common::Rect &slopRect) const {
+	limitRect = _rawLimitRect;
+	slopRect = _slopRect;
+}
+
+void SpriteDragger::startTracking(const Input &input) {
+	if (_draggingSprite) {
+		Tracker::startTracking(input);
+
+		if (isTracking()) {
+			input.getInputLocation(_startPoint);
+			_lastRawPoint = _startRawPoint = _startPoint;
+
+			Common::Rect r;
+			_draggingSprite->getBounds(r);
+			_dragOffset.x = _startPoint.x - r.left;
+			_dragOffset.y = _startPoint.y - r.top;
+
+			_limitRect = _rawLimitRect;
+			_limitRect.left += _dragOffset.x;
+			_limitRect.top += _dragOffset.y;
+			_limitRect.right -= r.width() - _dragOffset.x;
+			_limitRect.bottom -= r.height() - _dragOffset.y;
+			pinPointInRect(_limitRect, _startPoint);
+
+			_lastPoint = _startPoint;
+			if (_startPoint != _startRawPoint) {
+				Common::Point pt = _startPoint - _dragOffset;
+				_draggingSprite->moveElementTo(pt.x, pt.y);
+			}
+
+			_lastHotspot = g_allHotspots.findHotspot(_lastRawPoint);
+			if (_lastHotspot)
+				enterHotspot(_lastHotspot);
+		}
+	}
+}
+
+void SpriteDragger::continueTracking(const Input &input) {	
+	if (_draggingSprite) {
+		Common::Point rawPoint;
+		input.getInputLocation(rawPoint);
+
+		if (!_slopRect.contains(rawPoint))
+			rawPoint = _startRawPoint;
+	
+		if (rawPoint != _lastRawPoint) {
+			Common::Point newPoint = rawPoint;
+			pinPointInRect(_limitRect, newPoint);
+			newPoint -= _dragOffset;
+
+			if (newPoint != _lastPoint) {
+				_draggingSprite->moveElementTo(newPoint.x, newPoint.y);
+				_lastPoint = newPoint;
+			}
+
+			Hotspot *newHotspot = g_allHotspots.findHotspot(rawPoint);
+			if (newHotspot != _lastHotspot) {
+				if (_lastHotspot)
+					exitHotspot(_lastHotspot);
+				if (newHotspot)
+					enterHotspot(newHotspot);
+				_lastHotspot = newHotspot;
+			}
+
+			_lastRawPoint = rawPoint;
+		}
+	}
+}
+
+void SpriteDragger::pinPointInRect(const Common::Rect &r, Common::Point &pt) {
+	pt.x = CLIP<int>(pt.x, r.left, r.right - 1);
+	pt.y = CLIP<int>(pt.y, r.top, r.bottom - 1);
+}
+
+ItemDragger::ItemDragger(PegasusEngine *owner) : _inventoryDropSpot(kInventoryDropSpotID), _biochipDropSpot(kBiochipDropSpotID),
+		_inventoryHighlight(kInventoryDropHighlightID), _biochipHighlight(kBiochipDropHighlightID) {	
+	_owner = owner;
+	
+	_inventoryHighlight.setBounds(Common::Rect(76, 334, 172, 430));
+	_biochipHighlight.setBounds(Common::Rect(364, 334, 460, 430));
+
+	Common::Rect r(kInventoryDropLeft, kInventoryDropTop, kInventoryDropRight, kInventoryDropBottom);
+	_inventoryDropSpot.setArea(r);
+	_inventoryDropSpot.setHotspotFlags(kDropItemSpotFlag);
+	g_allHotspots.push_back(&_inventoryDropSpot);
+	
+	r = Common::Rect(kBiochipDropLeft, kBiochipDropTop, kBiochipDropRight, kBiochipDropBottom);
+	_biochipDropSpot.setArea(r);
+	_biochipDropSpot.setHotspotFlags(kDropBiochipSpotFlag);
+	g_allHotspots.push_back(&_biochipDropSpot);
+}
+
+void ItemDragger::startTracking(const Input &input) {
+	_inventoryHighlight.setDisplayOrder(kInventoryHiliteOrder);
+	_inventoryHighlight.startDisplaying();
+	
+	_biochipHighlight.setDisplayOrder(kBiochipHiliteOrder);
+	_biochipHighlight.startDisplaying();
+	
+	SpriteDragger::startTracking(input);
+}
+
+void ItemDragger::stopTracking(const Input &input) {
+	SpriteDragger::stopTracking(input);
+	_inventoryHighlight.hide();
+	_biochipHighlight.hide();
+	_inventoryHighlight.stopDisplaying();
+	_biochipHighlight.stopDisplaying();
+	_owner->dragTerminated(input);
+}
+
+bool ItemDragger::stopTrackingInput(const Input &input) {
+	return !JMPPPInput::isDraggingInput(input);
+}
+
+void ItemDragger::enterHotspot(Hotspot *spot) {
+	if (spot->getObjectID() == kInventoryDropSpotID)
+		_inventoryHighlight.show();
+	else if (spot->getObjectID() == kBiochipDropSpotID)
+		_biochipHighlight.show();
+	else if ((spot->getHotspotFlags() & kDropItemSpotFlag) != 0)
+		_draggingSprite->setCurrentFrameIndex(1);
+}
+
+void ItemDragger::exitHotspot(Hotspot *spot) {
+	if (spot->getObjectID() == kInventoryDropSpotID)
+		_inventoryHighlight.hide();
+	else if (spot->getObjectID() == kBiochipDropSpotID)
+		_biochipHighlight.hide();
+	else if ((spot->getHotspotFlags() & kDropItemSpotFlag) != 0)
+		_draggingSprite->setCurrentFrameIndex(0);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/itemdragger.h b/engines/pegasus/items/itemdragger.h
new file mode 100755
index 0000000..3775fb2
--- /dev/null
+++ b/engines/pegasus/items/itemdragger.h
@@ -0,0 +1,94 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_ITEMDRAGGER_H
+#define PEGASUS_ITEMS_ITEMDRAGGER_H
+
+#include "pegasus/input.h"
+
+namespace Pegasus {
+
+// TODO: Merge SpriteDragger and ItemDragger
+
+class Hotspot;
+class Sprite;
+
+class SpriteDragger : public Tracker {
+public:
+	SpriteDragger();
+	virtual ~SpriteDragger() {}
+
+	void setDragSprite(Sprite *);
+	Sprite *getDragSprite() { return _draggingSprite; }
+
+	void setDragConstraints(const Common::Rect &, const Common::Rect &);
+	void getDragConstraints(Common::Rect &, Common::Rect &) const;
+	
+	void startTracking(const Input &);
+	void continueTracking(const Input&);
+	
+	Hotspot *getLastHotspot() const { return _lastHotspot; }
+
+protected:
+	virtual void enterHotspot(Hotspot *) {}
+	virtual void exitHotspot(Hotspot *) {}
+	
+	Sprite *_draggingSprite;
+	Common::Point _startPoint, _lastPoint, _dragOffset;
+	Common::Point _startRawPoint, _lastRawPoint;
+	Common::Rect _rawLimitRect;
+	Common::Rect _limitRect;
+	Common::Rect _slopRect;
+	Hotspot *_lastHotspot;
+
+	// This is a replica of QuickDraw's PinPointInRect function
+	void pinPointInRect(const Common::Rect &, Common::Point &);
+};
+
+class PegasusEngine;
+
+class ItemDragger : public SpriteDragger {
+public:
+	ItemDragger(PegasusEngine *);
+	virtual ~ItemDragger() {}
+	
+	void startTracking(const Input &);
+	void stopTracking(const Input &);
+	bool stopTrackingInput(const Input &);
+
+protected:
+	virtual void enterHotspot(Hotspot *);
+	virtual void exitHotspot(Hotspot *);
+	
+	PegasusEngine *_owner;
+	DropHighlight _inventoryHighlight;
+	Hotspot _inventoryDropSpot;
+	DropHighlight _biochipHighlight;
+	Hotspot _biochipDropSpot;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 667ba4e..281188f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -29,6 +29,7 @@ MODULE_OBJS = \
 	items/inventory.o \
 	items/inventorypicture.o \
 	items/item.o \
+	items/itemdragger.o \
 	items/itemlist.o \
 	items/biochips/aichip.o \
 	items/biochips/biochipitem.o \
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 8fa50e9..5edc595 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -150,6 +150,7 @@ public:
 	void dragItem(const Input &, Item *, tDragType);
 	tDragType getDragType() const { return (tDragType)0; } // TODO
 	Item *getDraggingItem() const { return 0; } // TODO
+	void dragTerminated(const Input &) {} // TODO
 
 	// Save/Load
 	void makeContinuePoint();


Commit: a0a3cbd602940dcf87775363e7a60c5900c97bba
    https://github.com/scummvm/scummvm/commit/a0a3cbd602940dcf87775363e7a60c5900c97bba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-27T18:26:51-07:00

Commit Message:
PEGASUS: Keep specific neighborhood code in subfolders

Changed paths:
  A engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
  A engines/pegasus/neighborhood/prehistoric/prehistoric.h
  R engines/pegasus/neighborhood/prehistoric.cpp
  R engines/pegasus/neighborhood/prehistoric.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 281188f..c3c0bd8 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -46,11 +46,11 @@ MODULE_OBJS = \
 	neighborhood/extra.o \
 	neighborhood/hotspotinfo.o \
 	neighborhood/neighborhood.o \
-	neighborhood/prehistoric.o \
 	neighborhood/spot.o \
 	neighborhood/turn.o \
 	neighborhood/view.o \
-	neighborhood/zoom.o
+	neighborhood/zoom.o \
+	neighborhood/prehistoric/prehistoric.o
 
 
 # This module can be built as a plugin
diff --git a/engines/pegasus/neighborhood/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric.cpp
deleted file mode 100755
index 26c9e54..0000000
--- a/engines/pegasus/neighborhood/prehistoric.cpp
+++ /dev/null
@@ -1,689 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "pegasus/compass.h"
-#include "pegasus/energymonitor.h"
-#include "pegasus/gamestate.h"
-#include "pegasus/pegasus.h"
-#include "pegasus/ai/ai_action.h"
-#include "pegasus/ai/ai_area.h"
-#include "pegasus/ai/ai_condition.h"
-#include "pegasus/ai/ai_rule.h"
-#include "pegasus/neighborhood/prehistoric.h"
-
-namespace Pegasus {
-
-static const int16 s_prehistoricCompass[kPrehistoric25 + 1][4] = {
-	{ 0, 170, 90, 270 },   // kPrehistoric01
-	{ 0, 180, 90, 270 },   // kPrehistoric02
-	{ 10, 180, 90, 270 },  // kPrehistoric03
-	{ 10, 190, 90, 270 },  // kPrehistoric04
-	{ 10, 195, 90, 270 },  // kPrehistoric05
-	{ 20, 210, 90, 270 },  // kPrehistoric06
-	{ 20, 200, 130, 276 }, // kPrehistoric07
-	{ 20, 176, 110, 260 }, // kPrehistoric08
-	{ 20, 200, 100, 270 }, // kPrehistoric09
-	{ 14, 186, 100, 280 }, // kPrehistoric10
-	{ 26, 206, 116, 296 }, // kPrehistoric11
-	{ 60, 226, 140, 320 }, // kPrehistoric12
-	{ 0, 180, 80, 270 },   // kPrehistoric13
-	{ 14, 200, 106, 286 }, // kPrehistoric14
-	{ -10, 174, 80, 260 }, // kPrehistoric15
-	{ 54, 236, 140, 210 }, // kPrehistoric16
-	{ -24, 160, 70, 250 }, // kPrehistoric17
-	{ 26, 206, 140, 296 }, // kPrehistoric18
-	{ -16, 160, 70, 250 }, // kPrehistoric19
-	{ -16, 160, 70, 250 }, // kPrehistoric20
-	{ -10, 160, 90, 250 }, // kPrehistoric21
-	{ -20, 160, 70, 244 }, // kPrehistoric22
-	{ -20, 160, 70, 244 }, // kPrehistoric22North
-	{ 60, 234, 150, 330 }, // kPrehistoric23
-	{ 50, 230, 140, 320 }, // kPrehistoric24
-	{ 60, 240, 140, 330 }  // kPrehistoric25
-};
-
-static const TimeValue kPrehistoricFlashlightClickIn = 0;
-static const TimeValue kPrehistoricFlashlightClickOut = 138;
-
-static const TimeValue kPrehistoricBumpIntoWallIn = 138;
-static const TimeValue kPrehistoricBumpIntoWallOut = 291;
-
-static const TimeValue kBridgeRetractIn = 291;
-static const TimeValue kBridgeRetractOut = 1499;
-
-static const TimeValue kPrehistoricWarningTimeLimit = kTenMinutes;
-
-Prehistoric::Prehistoric(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Prehistoric", kPrehistoricID) {
-	setIsItemTaken(kHistoricalLog);
-}
-
-uint16 Prehistoric::getDateResID() const {
-	return kDatePrehistoricID;
-}
-
-void Prehistoric::init() {
-	Neighborhood::init();
-	
-	// Forces a stop so the flashlight can turn off...
-	forceStridingStop(kPrehistoric12, kSouth, kNoAlternateID);
-}
-
-void Prehistoric::start() {
-	if (g_energyMonitor) {
-		g_energyMonitor->stopEnergyDraining();
-		g_energyMonitor->restoreLastEnergyValue();
-		_vm->resetEnergyDeathReason();
-		g_energyMonitor->startEnergyDraining();
-	}
-
-	Neighborhood::start();
-}
-
-class FinishPrehistoricAction : public AIPlayMessageAction {
-public:
-	FinishPrehistoricAction() : AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false) {}
-	~FinishPrehistoricAction() {}
-	
-	void performAIAction(AIRule *);
-
-};
-
-void FinishPrehistoricAction::performAIAction(AIRule *rule) {
-	AIPlayMessageAction::performAIAction(rule);
-	((PegasusEngine *)g_engine)->die(kPlayerWonGame);
-}
-
-void Prehistoric::setUpAIRules() {
-	Neighborhood::setUpAIRules();
-
-	if (g_AIArea) {
-		if (_vm->isDemo()) {
-			FinishPrehistoricAction *doneAction = new FinishPrehistoricAction();
-			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
-			AIRule *rule = new AIRule(hasLogCondition, doneAction);
-			g_AIArea->addAIRule(rule);
-		} else {
-			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP1NB", false);
-			AILocationCondition *locCondition = new AILocationCondition(1);
-			locCondition->addLocation(MakeRoomView(kPrehistoric16, kNorth));
-			AIRule *rule = new AIRule(locCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
-			locCondition = new AILocationCondition(1);
-			locCondition->addLocation(MakeRoomView(kPrehistoric01, kSouth));
-			rule = new AIRule(locCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new  AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
-			locCondition = new AILocationCondition(1);
-			locCondition->addLocation(MakeRoomView(kPrehistoric08, kEast));
-			rule = new AIRule(locCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
-			locCondition = new AILocationCondition(1);
-			locCondition->addLocation(MakeRoomView(kPrehistoric25, kWest));
-			rule = new AIRule(locCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP16NB", false);
-			locCondition = new AILocationCondition(1);
-			locCondition->addLocation(MakeRoomView(kPrehistoric23, kNorth));
-			rule = new AIRule(locCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP18NB", false);
-			AITimerCondition *timerCondition = new AITimerCondition(kPrehistoricWarningTimeLimit, 1, true);
-			rule = new AIRule(timerCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		
-			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false);
-			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
-			rule = new AIRule(hasLogCondition, messageAction);
-			g_AIArea->addAIRule(rule);
-		}
-	}
-}
-
-TimeValue Prehistoric::getViewTime(const tRoomID room, const tDirectionConstant direction) {
-	ExtraTable::Entry extra;
-	uint32 extraID = 0xffffffff;
-
-	switch (MakeRoomView(room, direction)) {
-	case MakeRoomView(kPrehistoric02, kSouth):
-		if (!GameState.getPrehistoricSeenTimeStream()) {
-			getExtraEntry(kPreArrivalFromTSA, extra);
-			return extra.movieStart;
-		}
-		break;
-	case MakeRoomView(kPrehistoric25, kEast):
-		if (_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag)) {
-			if (_vm->itemInLocation(kHistoricalLog, kPrehistoricID, kPrehistoric25, kEast))
-				extraID = kPre25EastViewWithLog;
-			else
-				extraID = kPre25EastViewNoLog;
-		}
-		break;
-	}
-
-	if (extraID == 0xffffffff)
-		return Neighborhood::getViewTime(room, direction);
-	
-	getExtraEntry(extraID, extra);
-	return extra.movieEnd - 1;
-}
-
-
-void Prehistoric::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
-	Neighborhood::findSpotEntry(room, direction, flags, entry);
-
-	switch (MakeRoomView(room, direction)) {
-	case MakeRoomView(kPrehistoric01, kSouth):
-	case MakeRoomView(kPrehistoric25, kSouth):
-		entry.clear();
-		break;
-	case MakeRoomView(kPrehistoric01, kEast):
-		if (GameState.getPrehistoricSeenFlyer1())
-			entry.clear();
-		else
-			GameState.setPrehistoricSeenFlyer1(true);
-		break;
-	case MakeRoomView(kPrehistoric08, kEast):
-		if (GameState.getPrehistoricSeenFlyer2())
-			entry.clear();
-		else
-			GameState.setPrehistoricSeenFlyer2(true);
-		break;
-	}
-}
-
-int16 Prehistoric::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
-	if (room == kPrehistoricDeath)
-		return g_compass->getFaderValue();
-
-	return s_prehistoricCompass[room][dir];
-}
-
-void Prehistoric::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
-	uint32 angle;
-	Neighborhood::getExitCompassMove(exitEntry, compassMove);
-
-	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
-	case MakeRoomView(kPrehistoric01, kNorth):
-		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 2, -10);
-		break;
-	case MakeRoomView(kPrehistoric06, kEast):
-		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4, 95);
-		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4 * 1, 100);
-		break;
-	case MakeRoomView(kPrehistoric18, kEast):
-		if (getCurrentAlternate() == kAltPrehistoricBridgeSet) {
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 11, 145);
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 26, 145);
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 39, 148);
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 114, 140);
-		} else {
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 10, 140);
-			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 16, 145);
-			compassMove.insertFaderKnot(exitEntry.movieEnd, 145);
-		}
-		break;
-	case MakeRoomView(kPrehistoric23, kWest):
-		angle = compassMove.getNthKnotValue(0);
-		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 17, angle);
-		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 32, angle - 90);
-		compassMove.insertFaderKnot(exitEntry.movieEnd, angle - 90);
-		break;
-	}
-}
-
-void Prehistoric::turnTo(const tDirectionConstant newDirection) {
-	setCurrentAlternate(kAltPrehistoricNormal);
-	_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, false);
-	Neighborhood::turnTo(newDirection);
-
-	Item *keyCard;
-
-	switch (GameState.getCurrentRoomAndView()) {
-	case MakeRoomView(kPrehistoric18, kEast):
-		zoomToVault();
-		break;
-	case MakeRoomView(kPrehistoric18, kNorth):
-	case MakeRoomView(kPrehistoric18, kSouth):
-		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
-			playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
-			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
-			loadAmbientLoops();
-		}
-		// fall through
-	case MakeRoomView(kPrehistoric25, kEast):
-		setCurrentActivation(kActivationVaultClosed);
-		break;
-	case MakeRoomView(kPrehistoric16, kNorth):
-	case MakeRoomView(kPrehistoric21, kWest):
-		keyCard = g_allItems.findItemByID(kKeyCard);
-		if (keyCard->getItemState() == kFlashlightOff) {
-			keyCard->setItemState(kFlashlightOn);
-			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
-		}
-		break;
-	case MakeRoomView(kPrehistoric16, kEast):
-	case MakeRoomView(kPrehistoric16, kWest):
-	case MakeRoomView(kPrehistoric21, kNorth):
-	case MakeRoomView(kPrehistoric21, kSouth):
-		keyCard = g_allItems.findItemByID(kKeyCard);
-		if (keyCard->getItemState() == kFlashlightOn) {
-			keyCard->setItemState(kFlashlightOff);
-			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
-		}
-		break;
-	}
-}
-
-void Prehistoric::zoomToVault() {
-	if (!GameState.getPrehistoricSeenBridgeZoom())
-		startExtraSequence(kPre18EastZoom, kExtraCompletedFlag, kFilterNoInput);
-}
-
-void Prehistoric::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
-	switch (MakeRoomView(room, direction)) {
-	case MakeRoomView(kPrehistoric08, kEast):
-	case MakeRoomView(kPrehistoric18, kSouth):
-	case MakeRoomView(kPrehistoric16, kNorth):
-	case MakeRoomView(kPrehistoric21, kNorth):
-	case MakeRoomView(kPrehistoric25, kNorth):
-		makeContinuePoint();
-		break;
-	}
-}
-
-void Prehistoric::arriveAt(const tRoomID room, const tDirectionConstant direction) {
-	Item *keyCard;
-	
-	if (MakeRoomView(room, direction) == MakeRoomView(kPrehistoric25, kEast) &&
-			_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
-		_navMovie.stop();
-		playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
-		_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
-	}
-
-	Neighborhood::arriveAt(room, direction);
-
-	switch (MakeRoomView(room, direction)) {
-	case MakeRoomView(kPrehistoricDeath, kNorth):
-	case MakeRoomView(kPrehistoricDeath, kSouth):
-	case MakeRoomView(kPrehistoricDeath, kEast):
-	case MakeRoomView(kPrehistoricDeath, kWest):
-		if (GameState.getLastRoom() == kPrehistoric23)
-			die(kDeathEatenByDinosaur);
-		else
-			die(kDeathFallOffCliff);
-		break;
-	case MakeRoomView(kPrehistoric02, kSouth):
-		if (!GameState.getPrehistoricSeenTimeStream()) {
-			GameState.setPrehistoricTriedToExtendBridge(false);
-			GameState.setPrehistoricSeenFlyer1(false);
-			GameState.setPrehistoricSeenFlyer2(false);
-			GameState.setPrehistoricSeenBridgeZoom(false);
-			GameState.setPrehistoricBreakerThrown(false);
-			startExtraSequence(kPreArrivalFromTSA, kExtraCompletedFlag, kFilterNoInput);
-		}
-		break;
-	case MakeRoomView(kPrehistoric18, kEast):
-		zoomToVault();
-		break;
-	case MakeRoomView(kPrehistoric16, kNorth):
-		keyCard = g_allItems.findItemByID(kKeyCard);
-
-		if (keyCard->getItemState() == kFlashlightOff) {
-			keyCard->setItemState(kFlashlightOn);
-			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
-		}
-
-		if (g_AIArea)
-			g_AIArea->checkRules();
-		break;
-	case MakeRoomView(kPrehistoric01, kSouth):
-	case MakeRoomView(kPrehistoric23, kNorth):
-		if (g_AIArea)
-			g_AIArea->checkRules();
-		break;
-	case MakeRoomView(kPrehistoric08, kSouth):
-	case MakeRoomView(kPrehistoric10, kSouth):
-	case MakeRoomView(kPrehistoric12, kSouth):
-	case MakeRoomView(kPrehistoric13, kNorth):
-	case MakeRoomView(kPrehistoric14, kSouth):
-	case MakeRoomView(kPrehistoric15, kNorth):
-	case MakeRoomView(kPrehistoric16, kSouth):
-	case MakeRoomView(kPrehistoric17, kNorth):
-	case MakeRoomView(kPrehistoric18, kSouth):
-	case MakeRoomView(kPrehistoric19, kNorth):
-	case MakeRoomView(kPrehistoric20, kNorth):
-	case MakeRoomView(kPrehistoric21, kEast):
-		keyCard = g_allItems.findItemByID(kKeyCard);
-
-		if (keyCard->getItemState() == kFlashlightOn) {
-			keyCard->setItemState(kFlashlightOff);
-			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
-		}
-		break;
-	case MakeRoomView(kPrehistoric25, kEast):
-		setCurrentActivation(kActivationVaultClosed);
-		break;
-	}
-}
-
-void Prehistoric::loadAmbientLoops() {
-	tRoomID room = GameState.getCurrentRoom();
-	
-	switch (room) {
-	case kPrehistoric02:
-		// 1/4 volume.
-		if (GameState.getPrehistoricSeenTimeStream())
-			loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
-		break;
-	case kPrehistoric01:
-	case kPrehistoric03:
-	case kPrehistoric04:
-	case kPrehistoric05:
-	case kPrehistoric06:
-	case kPrehistoric07:
-	case kPrehistoric09:
-	case kPrehistoric11:
-	case kPrehistoric13:
-	case kPrehistoric15:
-	case kPrehistoric17:
-	case kPrehistoric19:
-	case kPrehistoric20:
-		// 1/4 volume.
-		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
-		break;
-	case kPrehistoric08:
-	case kPrehistoric10:
-	case kPrehistoric12:
-	case kPrehistoric14:
-	case kPrehistoric16:
-	case kPrehistoric18:
-	case kPrehistoric21:
-		// 3/16 volume.
-		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 48);
-		break;
-	case kPrehistoric25:
-		// 1/8 volume.
-		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 32);
-		break;
-	case kPrehistoric22:
-	case kPrehistoric22North:
-	case kPrehistoric23:
-	case kPrehistoric24:
-	case kPrehistoricDeath:
-		// 0 volume.
-		loadLoopSound1("");
-		break;
-	}
-
-	switch (room) {
-	case kPrehistoric02:
-	case kPrehistoric03:
-	case kPrehistoric04:
-	case kPrehistoric05:
-	case kPrehistoric06:
-	case kPrehistoric07:
-	case kPrehistoric08:
-	case kPrehistoric09:
-	case kPrehistoric10:
-	case kPrehistoric11:
-	case kPrehistoric12:
-	case kPrehistoric13:
-	case kPrehistoric14:
-	case kPrehistoric15:
-	case kPrehistoric16:
-	case kPrehistoric17:
-	case kPrehistoric19:
-	case kPrehistoric20:
-	case kPrehistoric21:
-	case kPrehistoricDeath:
-		loadLoopSound2("");
-		break;
-	case kPrehistoric01:
-	case kPrehistoric25:
-		loadLoopSound2("Sounds/Prehistoric/VolcLoop.22K.AIFF", 64);
-		break;
-	case kPrehistoric18:
-		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
-			loadLoopSound2("Sounds/Prehistoric/P18EAL00.22k.AIFF", 0x100, 0, 0);
-		else
-			loadLoopSound2("");
-		break;
-	case kPrehistoric23:
-	case kPrehistoric24:
-	case kPrehistoric22:
-	case kPrehistoric22North:
-		loadLoopSound2("Sounds/Prehistoric/P24NAL00.22k.AIFF", 64);
-		break;
-	}
-}
-
-void Prehistoric::activateHotspots() {
-	Neighborhood::activateHotspots();
-
-	switch (GameState.getCurrentRoomAndView()) {
-	case MakeRoomView(kPrehistoric18, kEast):
-		if (!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
-			g_allHotspots.activateOneHotspot(kPre18EastSpotID);
-		break;
-	case MakeRoomView(kPrehistoric22North, kNorth):
-		g_allHotspots.activateOneHotspot(kPre22NorthBreakerSpotID);
-		break;
-	}
-}
-
-void Prehistoric::clickInHotspot(const Input &input, const Hotspot *spot) {
-	switch (spot->getObjectID()) {
-	case kPre18EastSpotID:
-		if (GameState.getPrehistoricBreakerThrown())
-			startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
-		else
-			startExtraSequence(kPre18EastBridgeOut, kExtraCompletedFlag, kFilterNoInput);
-		break;
-	case kPre22NorthBreakerSpotID:
-		startExtraSequence(kPre22ThrowBreaker, kExtraCompletedFlag, kFilterNoInput);
-		break;
-	default:
-		Neighborhood::clickInHotspot(input, spot);
-		break;
-	}
-}
-
-void Prehistoric::receiveNotification(Notification *notification, const tNotificationFlags flags) {
-	Neighborhood::receiveNotification(notification, flags);
-
-	if ((flags & kExtraCompletedFlag) != 0) {
-		_interruptionFilter = kFilterAllInput;
-
-		switch (_lastExtra) {
-		case kPreArrivalFromTSA:
-			GameState.setPrehistoricSeenTimeStream(true);
-			loadAmbientLoops();
-			makeContinuePoint();
-			break;
-		case kPre18EastZoom:
-			startExtraSequence(kPre18EastZoomOut, kExtraCompletedFlag, kFilterNoInput);
-			break;
-		case kPre18EastZoomOut:
-			GameState.setPrehistoricSeenBridgeZoom(true);
-			break;
-		case kPre18EastBridgeOn:
-			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, true);
-			setCurrentAlternate(kAltPrehistoricBridgeSet);
-			GameState.setPrehistoricTriedToExtendBridge(false);
-			loadAmbientLoops();
-			GameState.setScoringExtendedBridge(true);
-			break;
-		case kPre18EastBridgeOut:
-			GameState.setPrehistoricTriedToExtendBridge(true);
-			if (g_AIArea)
-				g_AIArea->checkMiddleArea();
-			break;
-		case kPre22ThrowBreaker:
-			GameState.setPrehistoricBreakerThrown(true);
-			GameState.setScoringThrewBreaker(true);
-			break;
-		case kPre25EastUnlockingVaultNoLog:
-		case kPre25EastUnlockingVaultWithLog:
-			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kJourneymanKey));
-			break;
-		}
-	}
-
-	g_AIArea->checkMiddleArea();
-}
-
-Common::String Prehistoric::getBriefingMovie() {
-	Common::String movieName = Neighborhood::getBriefingMovie();
-
-	if (movieName.empty())
-		movieName = "Images/AI/Prehistoric/XPE";
-
-	return movieName;
-}
-
-Common::String Prehistoric::getEnvScanMovie() {
-	Common::String movieName = Neighborhood::getEnvScanMovie();
-
-	if (movieName.empty()) {
-		if (!_vm->isDemo()) {
-			switch (GameState.getCurrentRoom()) {
-			case kPrehistoric16:
-			case kPrehistoric23:
-			case kPrehistoric24:
-				return "Images/AI/Prehistoric/XP7WB";
-			}
-		}
-
-		return "Images/AI/Prehistoric/XP17NB";
-	}
-
-	return movieName;
-}
-
-uint Prehistoric::getNumHints() {
-	uint numHints = Neighborhood::getNumHints();
-	
-	if (numHints == 0) {
-		switch (GameState.getCurrentRoomAndView()) {
-		case MakeRoomView(kPrehistoric18, kEast):
-			if (!GameState.getPrehistoricBreakerThrown() && GameState.getPrehistoricTriedToExtendBridge() &&
-					!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
-				numHints = 1;
-			break;
-		case MakeRoomView(kPrehistoric25, kEast):
-			if (!_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag))
-				numHints = 1;
-			break;
-		}
-	}
-
-	return numHints;
-}
-
-Common::String Prehistoric::getHintMovie(uint hintNum) {
-	Common::String movieName = Neighborhood::getHintMovie(hintNum);
-
-	if (movieName.empty()) {
-		switch (GameState.getCurrentRoomAndView()) {
-		case MakeRoomView(kPrehistoric18, kEast):
-			return "Images/AI/Prehistoric/XP18WD";
-		case MakeRoomView(kPrehistoric25, kEast):
-			return "Images/AI/Globals/XGLOB1A";
-		}
-	}
-
-	return movieName;
-}
-
-bool Prehistoric::canSolve() {
-	return	GameState.getCurrentRoomAndView() == MakeRoomView(kPrehistoric18, kEast) &&
-			!GameState.getPrehistoricBreakerThrown() &&
-			GameState.getPrehistoricTriedToExtendBridge() &&
-			!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag);
-}
-
-void Prehistoric::doSolve() {
-	GameState.setPrehistoricBreakerThrown(true);
-	startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
-}
-
-Hotspot *Prehistoric::getItemScreenSpot(Item *item, DisplayElement *element) {
-	if (item->getObjectID() == kHistoricalLog)
-		return g_allHotspots.findHotspotByID(kPrehistoricHistoricalLogSpotID);
-
-	return Neighborhood::getItemScreenSpot(item, element);
-}
-
-void Prehistoric::pickedUpItem(Item *item) {
-	switch (item->getObjectID()) {
-	case kHistoricalLog:
-		GameState.setScoringGotHistoricalLog(true);
-		break;
-	}
-
-	Neighborhood::pickedUpItem(item);
-}
-
-void Prehistoric::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
-	switch (item->getObjectID()) {
-	case kJourneymanKey:
-		Neighborhood::dropItemIntoRoom(item, dropSpot);
-
-		if (GameState.isTakenItemID(kHistoricalLog))
-			startExtraLongSequence(kPre25EastUnlockingVaultNoLog, kPre25EastVaultOpenNoLog, kExtraCompletedFlag, kFilterNoInput);
-		else
-			startExtraLongSequence(kPre25EastUnlockingVaultWithLog, kPre25EastVaultOpenWithLog, kExtraCompletedFlag, kFilterNoInput);
-
-		_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, true);
-		setCurrentActivation(kActivationVaultOpen);
-		break;
-	default:
-		Neighborhood::dropItemIntoRoom(item, dropSpot);
-		break;
-	}
-}
-
-void Prehistoric::bumpIntoWall() {
-	requestSpotSound(kPrehistoricBumpIntoWallIn, kPrehistoricBumpIntoWallOut, kFilterAllInput, 0);
-	Neighborhood::bumpIntoWall();
-}
-
-Common::String Prehistoric::getNavMovieName() {
-	return "Images/Prehistoric/Prehistoric.movie";
-}
-
-Common::String Prehistoric::getSoundSpotsName() {
-	return "Sounds/Prehistoric/Prehistoric Spots";
-}
-
-} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/prehistoric.h b/engines/pegasus/neighborhood/prehistoric.h
deleted file mode 100755
index 44084f5..0000000
--- a/engines/pegasus/neighborhood/prehistoric.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * Additional copyright for this file:
- * Copyright (C) 1995-1997 Presto Studios, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
-#define PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
-
-#include "pegasus/neighborhood/neighborhood.h"
-
-namespace Pegasus {
-
-const TimeScale kPrehistoricMovieScale = 600;
-const TimeScale kPrehistoricFramesPerSecond = 15;
-const TimeScale kPrehistoricFrameDuration = 40;
-
-//	Alternate IDs.
-
-const tAlternateID kAltPrehistoricNormal = 0;
-const tAlternateID kAltPrehistoricBridgeSet = 1;
-
-//	Room IDs.
-
-const tRoomID kPrehistoric01 = 0;
-const tRoomID kPrehistoric02 = 1;
-const tRoomID kPrehistoric03 = 2;
-const tRoomID kPrehistoric04 = 3;
-const tRoomID kPrehistoric05 = 4;
-const tRoomID kPrehistoric06 = 5;
-const tRoomID kPrehistoric07 = 6;
-const tRoomID kPrehistoric08 = 7;
-const tRoomID kPrehistoric09 = 8;
-const tRoomID kPrehistoric10 = 9;
-const tRoomID kPrehistoric11 = 10;
-const tRoomID kPrehistoric12 = 11;
-const tRoomID kPrehistoric13 = 12;
-const tRoomID kPrehistoric14 = 13;
-const tRoomID kPrehistoric15 = 14;
-const tRoomID kPrehistoric16 = 15;
-const tRoomID kPrehistoric17 = 16;
-const tRoomID kPrehistoric18 = 17;
-const tRoomID kPrehistoric19 = 18;
-const tRoomID kPrehistoric20 = 19;
-const tRoomID kPrehistoric21 = 20;
-const tRoomID kPrehistoric22 = 21;
-const tRoomID kPrehistoric22North = 22;
-const tRoomID kPrehistoric23 = 23;
-const tRoomID kPrehistoric24 = 24;
-const tRoomID kPrehistoric25 = 25;
-const tRoomID kPrehistoricDeath = 26;
-
-//	Hot Spot Activation IDs.
-
-const tHotSpotActivationID kActivationVaultClosed = 1;
-const tHotSpotActivationID kActivationVaultOpen = 2;
-
-//	Hot Spot IDs.
-
-const tHotSpotID kPre18EastSpotID = 5000;
-const tHotSpotID kPre22NorthSpotID = 5001;
-const tHotSpotID kPre22NorthOutSpotID = 5002;
-const tHotSpotID kPre22NorthBreakerSpotID = 5003;
-const tHotSpotID kPrehistoricKeyDropSpotID = 5004;
-const tHotSpotID kPrehistoricHistoricalLogSpotID = 5005;
-
-//	Extra sequence IDs.
-
-const tExtraID kPreArrivalFromTSA = 0;
-const tExtraID kPre18EastBridgeOut = 1;
-const tExtraID kPre18EastBridgeOn = 2;
-const tExtraID kPre18EastZoom = 3;
-const tExtraID kPre18EastZoomOut = 4;
-const tExtraID kPre22ThrowBreaker = 5;
-const tExtraID kPre25EastUnlockingVaultWithLog = 6;
-const tExtraID kPre25EastVaultOpenWithLog = 7;
-const tExtraID kPre25EastViewWithLog = 8;
-const tExtraID kPre25EastUnlockingVaultNoLog = 9;
-const tExtraID kPre25EastVaultOpenNoLog = 10;
-const tExtraID kPre25EastViewNoLog = 11;
-
-class PegasusEngine;
-
-class Prehistoric : public Neighborhood {
-public:
-	Prehistoric(InputHandler *, PegasusEngine *);
-	virtual ~Prehistoric() {}
-	
-	virtual uint16 getDateResID() const;
-	virtual void init();
-	
-	virtual void arriveAt(const tRoomID, const tDirectionConstant);
-	virtual void activateHotspots();
-	virtual void clickInHotspot(const Input &, const Hotspot *);
-	Common::String getBriefingMovie();
-	Common::String getEnvScanMovie();
-	uint getNumHints();
-	Common::String getHintMovie(uint);
-
-	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
-	void dropItemIntoRoom(Item *, Hotspot *);
-	void pickedUpItem(Item *);
-
-	void start();
-
-	void bumpIntoWall();
-
-	void checkContinuePoint(const tRoomID, const tDirectionConstant);
-
-	bool canSolve();
-	void doSolve();
-
-protected:
-	enum {
-		kPrehistoricPrivateVaultOpenFlag,
-		kPrehistoricPrivateExtendedBridgeFlag,
-		kNumPrehistoricPrivateFlags
-	};
-
-	void setUpAIRules();
-	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
-	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
-	virtual void receiveNotification(Notification *, const tNotificationFlags);
-	void turnTo(const tDirectionConstant);
-	void zoomToVault();
-	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
-	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
-
-	void loadAmbientLoops();
-	
-	FlagsArray<byte, kNumPrehistoricPrivateFlags> _privateFlags;
-
-	Common::String getNavMovieName();
-	Common::String getSoundSpotsName();
-};
-
-} // End of namespace Pegasus
-
-#endif
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
new file mode 100755
index 0000000..50b6d87
--- /dev/null
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
@@ -0,0 +1,689 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/compass.h"
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_action.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/ai/ai_condition.h"
+#include "pegasus/ai/ai_rule.h"
+#include "pegasus/neighborhood/prehistoric/prehistoric.h"
+
+namespace Pegasus {
+
+static const int16 s_prehistoricCompass[kPrehistoric25 + 1][4] = {
+	{ 0, 170, 90, 270 },   // kPrehistoric01
+	{ 0, 180, 90, 270 },   // kPrehistoric02
+	{ 10, 180, 90, 270 },  // kPrehistoric03
+	{ 10, 190, 90, 270 },  // kPrehistoric04
+	{ 10, 195, 90, 270 },  // kPrehistoric05
+	{ 20, 210, 90, 270 },  // kPrehistoric06
+	{ 20, 200, 130, 276 }, // kPrehistoric07
+	{ 20, 176, 110, 260 }, // kPrehistoric08
+	{ 20, 200, 100, 270 }, // kPrehistoric09
+	{ 14, 186, 100, 280 }, // kPrehistoric10
+	{ 26, 206, 116, 296 }, // kPrehistoric11
+	{ 60, 226, 140, 320 }, // kPrehistoric12
+	{ 0, 180, 80, 270 },   // kPrehistoric13
+	{ 14, 200, 106, 286 }, // kPrehistoric14
+	{ -10, 174, 80, 260 }, // kPrehistoric15
+	{ 54, 236, 140, 210 }, // kPrehistoric16
+	{ -24, 160, 70, 250 }, // kPrehistoric17
+	{ 26, 206, 140, 296 }, // kPrehistoric18
+	{ -16, 160, 70, 250 }, // kPrehistoric19
+	{ -16, 160, 70, 250 }, // kPrehistoric20
+	{ -10, 160, 90, 250 }, // kPrehistoric21
+	{ -20, 160, 70, 244 }, // kPrehistoric22
+	{ -20, 160, 70, 244 }, // kPrehistoric22North
+	{ 60, 234, 150, 330 }, // kPrehistoric23
+	{ 50, 230, 140, 320 }, // kPrehistoric24
+	{ 60, 240, 140, 330 }  // kPrehistoric25
+};
+
+static const TimeValue kPrehistoricFlashlightClickIn = 0;
+static const TimeValue kPrehistoricFlashlightClickOut = 138;
+
+static const TimeValue kPrehistoricBumpIntoWallIn = 138;
+static const TimeValue kPrehistoricBumpIntoWallOut = 291;
+
+static const TimeValue kBridgeRetractIn = 291;
+static const TimeValue kBridgeRetractOut = 1499;
+
+static const TimeValue kPrehistoricWarningTimeLimit = kTenMinutes;
+
+Prehistoric::Prehistoric(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Prehistoric", kPrehistoricID) {
+	setIsItemTaken(kHistoricalLog);
+}
+
+uint16 Prehistoric::getDateResID() const {
+	return kDatePrehistoricID;
+}
+
+void Prehistoric::init() {
+	Neighborhood::init();
+	
+	// Forces a stop so the flashlight can turn off...
+	forceStridingStop(kPrehistoric12, kSouth, kNoAlternateID);
+}
+
+void Prehistoric::start() {
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->restoreLastEnergyValue();
+		_vm->resetEnergyDeathReason();
+		g_energyMonitor->startEnergyDraining();
+	}
+
+	Neighborhood::start();
+}
+
+class FinishPrehistoricAction : public AIPlayMessageAction {
+public:
+	FinishPrehistoricAction() : AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false) {}
+	~FinishPrehistoricAction() {}
+	
+	void performAIAction(AIRule *);
+
+};
+
+void FinishPrehistoricAction::performAIAction(AIRule *rule) {
+	AIPlayMessageAction::performAIAction(rule);
+	((PegasusEngine *)g_engine)->die(kPlayerWonGame);
+}
+
+void Prehistoric::setUpAIRules() {
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		if (_vm->isDemo()) {
+			FinishPrehistoricAction *doneAction = new FinishPrehistoricAction();
+			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
+			AIRule *rule = new AIRule(hasLogCondition, doneAction);
+			g_AIArea->addAIRule(rule);
+		} else {
+			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP1NB", false);
+			AILocationCondition *locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric16, kNorth));
+			AIRule *rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric01, kSouth));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new  AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric08, kEast));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP2SB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric25, kWest));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP16NB", false);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kPrehistoric23, kNorth));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP18NB", false);
+			AITimerCondition *timerCondition = new AITimerCondition(kPrehistoricWarningTimeLimit, 1, true);
+			rule = new AIRule(timerCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		
+			messageAction = new AIPlayMessageAction("Images/AI/Prehistoric/XP25W", false);
+			AIHasItemCondition *hasLogCondition = new AIHasItemCondition(kHistoricalLog);
+			rule = new AIRule(hasLogCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+		}
+	}
+}
+
+TimeValue Prehistoric::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry extra;
+	uint32 extraID = 0xffffffff;
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric02, kSouth):
+		if (!GameState.getPrehistoricSeenTimeStream()) {
+			getExtraEntry(kPreArrivalFromTSA, extra);
+			return extra.movieStart;
+		}
+		break;
+	case MakeRoomView(kPrehistoric25, kEast):
+		if (_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag)) {
+			if (_vm->itemInLocation(kHistoricalLog, kPrehistoricID, kPrehistoric25, kEast))
+				extraID = kPre25EastViewWithLog;
+			else
+				extraID = kPre25EastViewNoLog;
+		}
+		break;
+	}
+
+	if (extraID == 0xffffffff)
+		return Neighborhood::getViewTime(room, direction);
+	
+	getExtraEntry(extraID, extra);
+	return extra.movieEnd - 1;
+}
+
+
+void Prehistoric::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
+	Neighborhood::findSpotEntry(room, direction, flags, entry);
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric01, kSouth):
+	case MakeRoomView(kPrehistoric25, kSouth):
+		entry.clear();
+		break;
+	case MakeRoomView(kPrehistoric01, kEast):
+		if (GameState.getPrehistoricSeenFlyer1())
+			entry.clear();
+		else
+			GameState.setPrehistoricSeenFlyer1(true);
+		break;
+	case MakeRoomView(kPrehistoric08, kEast):
+		if (GameState.getPrehistoricSeenFlyer2())
+			entry.clear();
+		else
+			GameState.setPrehistoricSeenFlyer2(true);
+		break;
+	}
+}
+
+int16 Prehistoric::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	if (room == kPrehistoricDeath)
+		return g_compass->getFaderValue();
+
+	return s_prehistoricCompass[room][dir];
+}
+
+void Prehistoric::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	uint32 angle;
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
+	case MakeRoomView(kPrehistoric01, kNorth):
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 2, -10);
+		break;
+	case MakeRoomView(kPrehistoric06, kEast):
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4, 95);
+		compassMove.insertFaderKnot(exitEntry.movieStart + (exitEntry.movieEnd - exitEntry.movieStart) / 4 * 1, 100);
+		break;
+	case MakeRoomView(kPrehistoric18, kEast):
+		if (getCurrentAlternate() == kAltPrehistoricBridgeSet) {
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 11, 145);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 26, 145);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 39, 148);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 114, 140);
+		} else {
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 10, 140);
+			compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 16, 145);
+			compassMove.insertFaderKnot(exitEntry.movieEnd, 145);
+		}
+		break;
+	case MakeRoomView(kPrehistoric23, kWest):
+		angle = compassMove.getNthKnotValue(0);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 17, angle);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kPrehistoricFrameDuration * 32, angle - 90);
+		compassMove.insertFaderKnot(exitEntry.movieEnd, angle - 90);
+		break;
+	}
+}
+
+void Prehistoric::turnTo(const tDirectionConstant newDirection) {
+	setCurrentAlternate(kAltPrehistoricNormal);
+	_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, false);
+	Neighborhood::turnTo(newDirection);
+
+	Item *keyCard;
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kPrehistoric18, kEast):
+		zoomToVault();
+		break;
+	case MakeRoomView(kPrehistoric18, kNorth):
+	case MakeRoomView(kPrehistoric18, kSouth):
+		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
+			playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
+			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
+			loadAmbientLoops();
+		}
+		// fall through
+	case MakeRoomView(kPrehistoric25, kEast):
+		setCurrentActivation(kActivationVaultClosed);
+		break;
+	case MakeRoomView(kPrehistoric16, kNorth):
+	case MakeRoomView(kPrehistoric21, kWest):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+		if (keyCard->getItemState() == kFlashlightOff) {
+			keyCard->setItemState(kFlashlightOn);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	case MakeRoomView(kPrehistoric16, kEast):
+	case MakeRoomView(kPrehistoric16, kWest):
+	case MakeRoomView(kPrehistoric21, kNorth):
+	case MakeRoomView(kPrehistoric21, kSouth):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+		if (keyCard->getItemState() == kFlashlightOn) {
+			keyCard->setItemState(kFlashlightOff);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	}
+}
+
+void Prehistoric::zoomToVault() {
+	if (!GameState.getPrehistoricSeenBridgeZoom())
+		startExtraSequence(kPre18EastZoom, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void Prehistoric::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoric08, kEast):
+	case MakeRoomView(kPrehistoric18, kSouth):
+	case MakeRoomView(kPrehistoric16, kNorth):
+	case MakeRoomView(kPrehistoric21, kNorth):
+	case MakeRoomView(kPrehistoric25, kNorth):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void Prehistoric::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	Item *keyCard;
+	
+	if (MakeRoomView(room, direction) == MakeRoomView(kPrehistoric25, kEast) &&
+			_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag)) {
+		_navMovie.stop();
+		playSpotSoundSync(kBridgeRetractIn, kBridgeRetractOut);
+		_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, false);
+	}
+
+	Neighborhood::arriveAt(room, direction);
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kPrehistoricDeath, kNorth):
+	case MakeRoomView(kPrehistoricDeath, kSouth):
+	case MakeRoomView(kPrehistoricDeath, kEast):
+	case MakeRoomView(kPrehistoricDeath, kWest):
+		if (GameState.getLastRoom() == kPrehistoric23)
+			die(kDeathEatenByDinosaur);
+		else
+			die(kDeathFallOffCliff);
+		break;
+	case MakeRoomView(kPrehistoric02, kSouth):
+		if (!GameState.getPrehistoricSeenTimeStream()) {
+			GameState.setPrehistoricTriedToExtendBridge(false);
+			GameState.setPrehistoricSeenFlyer1(false);
+			GameState.setPrehistoricSeenFlyer2(false);
+			GameState.setPrehistoricSeenBridgeZoom(false);
+			GameState.setPrehistoricBreakerThrown(false);
+			startExtraSequence(kPreArrivalFromTSA, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case MakeRoomView(kPrehistoric18, kEast):
+		zoomToVault();
+		break;
+	case MakeRoomView(kPrehistoric16, kNorth):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+
+		if (keyCard->getItemState() == kFlashlightOff) {
+			keyCard->setItemState(kFlashlightOn);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+
+		if (g_AIArea)
+			g_AIArea->checkRules();
+		break;
+	case MakeRoomView(kPrehistoric01, kSouth):
+	case MakeRoomView(kPrehistoric23, kNorth):
+		if (g_AIArea)
+			g_AIArea->checkRules();
+		break;
+	case MakeRoomView(kPrehistoric08, kSouth):
+	case MakeRoomView(kPrehistoric10, kSouth):
+	case MakeRoomView(kPrehistoric12, kSouth):
+	case MakeRoomView(kPrehistoric13, kNorth):
+	case MakeRoomView(kPrehistoric14, kSouth):
+	case MakeRoomView(kPrehistoric15, kNorth):
+	case MakeRoomView(kPrehistoric16, kSouth):
+	case MakeRoomView(kPrehistoric17, kNorth):
+	case MakeRoomView(kPrehistoric18, kSouth):
+	case MakeRoomView(kPrehistoric19, kNorth):
+	case MakeRoomView(kPrehistoric20, kNorth):
+	case MakeRoomView(kPrehistoric21, kEast):
+		keyCard = g_allItems.findItemByID(kKeyCard);
+
+		if (keyCard->getItemState() == kFlashlightOn) {
+			keyCard->setItemState(kFlashlightOff);
+			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
+		}
+		break;
+	case MakeRoomView(kPrehistoric25, kEast):
+		setCurrentActivation(kActivationVaultClosed);
+		break;
+	}
+}
+
+void Prehistoric::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+	
+	switch (room) {
+	case kPrehistoric02:
+		// 1/4 volume.
+		if (GameState.getPrehistoricSeenTimeStream())
+			loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
+		break;
+	case kPrehistoric01:
+	case kPrehistoric03:
+	case kPrehistoric04:
+	case kPrehistoric05:
+	case kPrehistoric06:
+	case kPrehistoric07:
+	case kPrehistoric09:
+	case kPrehistoric11:
+	case kPrehistoric13:
+	case kPrehistoric15:
+	case kPrehistoric17:
+	case kPrehistoric19:
+	case kPrehistoric20:
+		// 1/4 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 64);
+		break;
+	case kPrehistoric08:
+	case kPrehistoric10:
+	case kPrehistoric12:
+	case kPrehistoric14:
+	case kPrehistoric16:
+	case kPrehistoric18:
+	case kPrehistoric21:
+		// 3/16 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 48);
+		break;
+	case kPrehistoric25:
+		// 1/8 volume.
+		loadLoopSound1("Sounds/Prehistoric/P02SAL00.22k.AIFF", 32);
+		break;
+	case kPrehistoric22:
+	case kPrehistoric22North:
+	case kPrehistoric23:
+	case kPrehistoric24:
+	case kPrehistoricDeath:
+		// 0 volume.
+		loadLoopSound1("");
+		break;
+	}
+
+	switch (room) {
+	case kPrehistoric02:
+	case kPrehistoric03:
+	case kPrehistoric04:
+	case kPrehistoric05:
+	case kPrehistoric06:
+	case kPrehistoric07:
+	case kPrehistoric08:
+	case kPrehistoric09:
+	case kPrehistoric10:
+	case kPrehistoric11:
+	case kPrehistoric12:
+	case kPrehistoric13:
+	case kPrehistoric14:
+	case kPrehistoric15:
+	case kPrehistoric16:
+	case kPrehistoric17:
+	case kPrehistoric19:
+	case kPrehistoric20:
+	case kPrehistoric21:
+	case kPrehistoricDeath:
+		loadLoopSound2("");
+		break;
+	case kPrehistoric01:
+	case kPrehistoric25:
+		loadLoopSound2("Sounds/Prehistoric/VolcLoop.22K.AIFF", 64);
+		break;
+	case kPrehistoric18:
+		if (_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+			loadLoopSound2("Sounds/Prehistoric/P18EAL00.22k.AIFF", 0x100, 0, 0);
+		else
+			loadLoopSound2("");
+		break;
+	case kPrehistoric23:
+	case kPrehistoric24:
+	case kPrehistoric22:
+	case kPrehistoric22North:
+		loadLoopSound2("Sounds/Prehistoric/P24NAL00.22k.AIFF", 64);
+		break;
+	}
+}
+
+void Prehistoric::activateHotspots() {
+	Neighborhood::activateHotspots();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kPrehistoric18, kEast):
+		if (!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+			g_allHotspots.activateOneHotspot(kPre18EastSpotID);
+		break;
+	case MakeRoomView(kPrehistoric22North, kNorth):
+		g_allHotspots.activateOneHotspot(kPre22NorthBreakerSpotID);
+		break;
+	}
+}
+
+void Prehistoric::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kPre18EastSpotID:
+		if (GameState.getPrehistoricBreakerThrown())
+			startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kPre18EastBridgeOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kPre22NorthBreakerSpotID:
+		startExtraSequence(kPre22ThrowBreaker, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Neighborhood::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void Prehistoric::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	Neighborhood::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		_interruptionFilter = kFilterAllInput;
+
+		switch (_lastExtra) {
+		case kPreArrivalFromTSA:
+			GameState.setPrehistoricSeenTimeStream(true);
+			loadAmbientLoops();
+			makeContinuePoint();
+			break;
+		case kPre18EastZoom:
+			startExtraSequence(kPre18EastZoomOut, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kPre18EastZoomOut:
+			GameState.setPrehistoricSeenBridgeZoom(true);
+			break;
+		case kPre18EastBridgeOn:
+			_privateFlags.setFlag(kPrehistoricPrivateExtendedBridgeFlag, true);
+			setCurrentAlternate(kAltPrehistoricBridgeSet);
+			GameState.setPrehistoricTriedToExtendBridge(false);
+			loadAmbientLoops();
+			GameState.setScoringExtendedBridge(true);
+			break;
+		case kPre18EastBridgeOut:
+			GameState.setPrehistoricTriedToExtendBridge(true);
+			if (g_AIArea)
+				g_AIArea->checkMiddleArea();
+			break;
+		case kPre22ThrowBreaker:
+			GameState.setPrehistoricBreakerThrown(true);
+			GameState.setScoringThrewBreaker(true);
+			break;
+		case kPre25EastUnlockingVaultNoLog:
+		case kPre25EastUnlockingVaultWithLog:
+			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kJourneymanKey));
+			break;
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+Common::String Prehistoric::getBriefingMovie() {
+	Common::String movieName = Neighborhood::getBriefingMovie();
+
+	if (movieName.empty())
+		movieName = "Images/AI/Prehistoric/XPE";
+
+	return movieName;
+}
+
+Common::String Prehistoric::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		if (!_vm->isDemo()) {
+			switch (GameState.getCurrentRoom()) {
+			case kPrehistoric16:
+			case kPrehistoric23:
+			case kPrehistoric24:
+				return "Images/AI/Prehistoric/XP7WB";
+			}
+		}
+
+		return "Images/AI/Prehistoric/XP17NB";
+	}
+
+	return movieName;
+}
+
+uint Prehistoric::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+	
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kPrehistoric18, kEast):
+			if (!GameState.getPrehistoricBreakerThrown() && GameState.getPrehistoricTriedToExtendBridge() &&
+					!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
+				numHints = 1;
+			break;
+		case MakeRoomView(kPrehistoric25, kEast):
+			if (!_privateFlags.getFlag(kPrehistoricPrivateVaultOpenFlag))
+				numHints = 1;
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String Prehistoric::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kPrehistoric18, kEast):
+			return "Images/AI/Prehistoric/XP18WD";
+		case MakeRoomView(kPrehistoric25, kEast):
+			return "Images/AI/Globals/XGLOB1A";
+		}
+	}
+
+	return movieName;
+}
+
+bool Prehistoric::canSolve() {
+	return	GameState.getCurrentRoomAndView() == MakeRoomView(kPrehistoric18, kEast) &&
+			!GameState.getPrehistoricBreakerThrown() &&
+			GameState.getPrehistoricTriedToExtendBridge() &&
+			!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag);
+}
+
+void Prehistoric::doSolve() {
+	GameState.setPrehistoricBreakerThrown(true);
+	startExtraSequence(kPre18EastBridgeOn, kExtraCompletedFlag, kFilterNoInput);
+}
+
+Hotspot *Prehistoric::getItemScreenSpot(Item *item, DisplayElement *element) {
+	if (item->getObjectID() == kHistoricalLog)
+		return g_allHotspots.findHotspotByID(kPrehistoricHistoricalLogSpotID);
+
+	return Neighborhood::getItemScreenSpot(item, element);
+}
+
+void Prehistoric::pickedUpItem(Item *item) {
+	switch (item->getObjectID()) {
+	case kHistoricalLog:
+		GameState.setScoringGotHistoricalLog(true);
+		break;
+	}
+
+	Neighborhood::pickedUpItem(item);
+}
+
+void Prehistoric::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
+	switch (item->getObjectID()) {
+	case kJourneymanKey:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+
+		if (GameState.isTakenItemID(kHistoricalLog))
+			startExtraLongSequence(kPre25EastUnlockingVaultNoLog, kPre25EastVaultOpenNoLog, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraLongSequence(kPre25EastUnlockingVaultWithLog, kPre25EastVaultOpenWithLog, kExtraCompletedFlag, kFilterNoInput);
+
+		_privateFlags.setFlag(kPrehistoricPrivateVaultOpenFlag, true);
+		setCurrentActivation(kActivationVaultOpen);
+		break;
+	default:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	}
+}
+
+void Prehistoric::bumpIntoWall() {
+	requestSpotSound(kPrehistoricBumpIntoWallIn, kPrehistoricBumpIntoWallOut, kFilterAllInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+Common::String Prehistoric::getNavMovieName() {
+	return "Images/Prehistoric/Prehistoric.movie";
+}
+
+Common::String Prehistoric::getSoundSpotsName() {
+	return "Sounds/Prehistoric/Prehistoric Spots";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.h b/engines/pegasus/neighborhood/prehistoric/prehistoric.h
new file mode 100755
index 0000000..44084f5
--- /dev/null
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.h
@@ -0,0 +1,158 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
+#define PEGASUS_NEIGHBORHOOD_PREHISTORIC_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+const TimeScale kPrehistoricMovieScale = 600;
+const TimeScale kPrehistoricFramesPerSecond = 15;
+const TimeScale kPrehistoricFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltPrehistoricNormal = 0;
+const tAlternateID kAltPrehistoricBridgeSet = 1;
+
+//	Room IDs.
+
+const tRoomID kPrehistoric01 = 0;
+const tRoomID kPrehistoric02 = 1;
+const tRoomID kPrehistoric03 = 2;
+const tRoomID kPrehistoric04 = 3;
+const tRoomID kPrehistoric05 = 4;
+const tRoomID kPrehistoric06 = 5;
+const tRoomID kPrehistoric07 = 6;
+const tRoomID kPrehistoric08 = 7;
+const tRoomID kPrehistoric09 = 8;
+const tRoomID kPrehistoric10 = 9;
+const tRoomID kPrehistoric11 = 10;
+const tRoomID kPrehistoric12 = 11;
+const tRoomID kPrehistoric13 = 12;
+const tRoomID kPrehistoric14 = 13;
+const tRoomID kPrehistoric15 = 14;
+const tRoomID kPrehistoric16 = 15;
+const tRoomID kPrehistoric17 = 16;
+const tRoomID kPrehistoric18 = 17;
+const tRoomID kPrehistoric19 = 18;
+const tRoomID kPrehistoric20 = 19;
+const tRoomID kPrehistoric21 = 20;
+const tRoomID kPrehistoric22 = 21;
+const tRoomID kPrehistoric22North = 22;
+const tRoomID kPrehistoric23 = 23;
+const tRoomID kPrehistoric24 = 24;
+const tRoomID kPrehistoric25 = 25;
+const tRoomID kPrehistoricDeath = 26;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationVaultClosed = 1;
+const tHotSpotActivationID kActivationVaultOpen = 2;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kPre18EastSpotID = 5000;
+const tHotSpotID kPre22NorthSpotID = 5001;
+const tHotSpotID kPre22NorthOutSpotID = 5002;
+const tHotSpotID kPre22NorthBreakerSpotID = 5003;
+const tHotSpotID kPrehistoricKeyDropSpotID = 5004;
+const tHotSpotID kPrehistoricHistoricalLogSpotID = 5005;
+
+//	Extra sequence IDs.
+
+const tExtraID kPreArrivalFromTSA = 0;
+const tExtraID kPre18EastBridgeOut = 1;
+const tExtraID kPre18EastBridgeOn = 2;
+const tExtraID kPre18EastZoom = 3;
+const tExtraID kPre18EastZoomOut = 4;
+const tExtraID kPre22ThrowBreaker = 5;
+const tExtraID kPre25EastUnlockingVaultWithLog = 6;
+const tExtraID kPre25EastVaultOpenWithLog = 7;
+const tExtraID kPre25EastViewWithLog = 8;
+const tExtraID kPre25EastUnlockingVaultNoLog = 9;
+const tExtraID kPre25EastVaultOpenNoLog = 10;
+const tExtraID kPre25EastViewNoLog = 11;
+
+class PegasusEngine;
+
+class Prehistoric : public Neighborhood {
+public:
+	Prehistoric(InputHandler *, PegasusEngine *);
+	virtual ~Prehistoric() {}
+	
+	virtual uint16 getDateResID() const;
+	virtual void init();
+	
+	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void pickedUpItem(Item *);
+
+	void start();
+
+	void bumpIntoWall();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+protected:
+	enum {
+		kPrehistoricPrivateVaultOpenFlag,
+		kPrehistoricPrivateExtendedBridgeFlag,
+		kNumPrehistoricPrivateFlags
+	};
+
+	void setUpAIRules();
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	void turnTo(const tDirectionConstant);
+	void zoomToVault();
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+
+	void loadAmbientLoops();
+	
+	FlagsArray<byte, kNumPrehistoricPrivateFlags> _privateFlags;
+
+	Common::String getNavMovieName();
+	Common::String getSoundSpotsName();
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 54dd0c266eb8f5fe0d067f2298e6964e1ab9032f
    https://github.com/scummvm/scummvm/commit/54dd0c266eb8f5fe0d067f2298e6964e1ab9032f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T11:32:03-07:00

Commit Message:
PEGASUS: Import a bunch more code in preparation for actual gameplay

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/input.h
    engines/pegasus/items/itemdragger.cpp
    engines/pegasus/items/itemdragger.h
    engines/pegasus/movie.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 4061225..4c31b45 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -737,8 +737,9 @@ static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
 static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 // TODO: Remove me
-const tRoomID kTSA37 = 42;
-const tRoomID kTinyTSA37 = 0;
+static const tRoomID kTSA37 = 42;
+static const tRoomID kTinyTSA37 = 0;
+static const tRoomID kCaldoria00 = 1;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 05217fa..6cce9dd 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -189,5 +189,17 @@ void GraphicsManager::clearScreen() {
 	g_system->unlockScreen();
 	_modifiedScreen = true;
 }
+
+DisplayElement *GraphicsManager::findDisplayElement(const tDisplayElementID id) {
+	DisplayElement *runner = _firstDisplayElement;
+
+	while (runner) {
+		if (runner->getObjectID() == id)
+			return runner;
+		runner = runner->_nextElement;
+	}
+
+	return 0;
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 90d0f33..fffa3a6 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -53,6 +53,7 @@ public:
 	void updateDisplay();
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
+	DisplayElement *findDisplayElement(const tDisplayElementID id);
 
 private:		
 	PegasusEngine *_vm;
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 298a78f..96df249 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -438,7 +438,7 @@ protected:
 class Tracker : public InputHandler {
 public:
 	Tracker() : InputHandler(0) {}
-	virtual ~Tracker();
+	virtual ~Tracker() {}
 
 	virtual void handleInput(const Input &, const Hotspot *);
 	virtual bool stopTrackingInput(const Input &) { return false; }
diff --git a/engines/pegasus/items/itemdragger.cpp b/engines/pegasus/items/itemdragger.cpp
index 79cd101..4e3a9f1 100755
--- a/engines/pegasus/items/itemdragger.cpp
+++ b/engines/pegasus/items/itemdragger.cpp
@@ -129,9 +129,6 @@ void SpriteDragger::pinPointInRect(const Common::Rect &r, Common::Point &pt) {
 ItemDragger::ItemDragger(PegasusEngine *owner) : _inventoryDropSpot(kInventoryDropSpotID), _biochipDropSpot(kBiochipDropSpotID),
 		_inventoryHighlight(kInventoryDropHighlightID), _biochipHighlight(kBiochipDropHighlightID) {	
 	_owner = owner;
-	
-	_inventoryHighlight.setBounds(Common::Rect(76, 334, 172, 430));
-	_biochipHighlight.setBounds(Common::Rect(364, 334, 460, 430));
 
 	Common::Rect r(kInventoryDropLeft, kInventoryDropTop, kInventoryDropRight, kInventoryDropBottom);
 	_inventoryDropSpot.setArea(r);
@@ -185,4 +182,9 @@ void ItemDragger::exitHotspot(Hotspot *spot) {
 		_draggingSprite->setCurrentFrameIndex(0);
 }
 
+void ItemDragger::setHighlightBounds() {
+	_inventoryHighlight.setBounds(Common::Rect(76, 334, 172, 430));
+	_biochipHighlight.setBounds(Common::Rect(364, 334, 460, 430));
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/itemdragger.h b/engines/pegasus/items/itemdragger.h
index 3775fb2..6961231 100755
--- a/engines/pegasus/items/itemdragger.h
+++ b/engines/pegasus/items/itemdragger.h
@@ -26,6 +26,7 @@
 #ifndef PEGASUS_ITEMS_ITEMDRAGGER_H
 #define PEGASUS_ITEMS_ITEMDRAGGER_H
 
+#include "pegasus/elements.h"
 #include "pegasus/input.h"
 
 namespace Pegasus {
@@ -73,7 +74,8 @@ class ItemDragger : public SpriteDragger {
 public:
 	ItemDragger(PegasusEngine *);
 	virtual ~ItemDragger() {}
-	
+
+	void setHighlightBounds();
 	void startTracking(const Input &);
 	void stopTracking(const Input &);
 	bool stopTrackingInput(const Input &);
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index e102c70..bbe63a0 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -175,7 +175,7 @@ void Movie::checkCallBacks() {
 
 	// The reason why we overrode TimeBase's checkCallBacks():
 	// Again, avoiding timers and handling it here
-	if (!_video->isPaused()) {
+	if (_video && !_video->isPaused()) {
 		if (_video->needsUpdate())
 			redrawMovieWorld();
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5eb3340..c63a01f 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -38,6 +38,7 @@
 
 #include "pegasus/console.h"
 #include "pegasus/cursor.h"
+#include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/interface.h"
 #include "pegasus/menu.h"
@@ -57,11 +58,13 @@
 #include "pegasus/items/inventory/inventoryitem.h"
 #include "pegasus/items/inventory/keycard.h"
 #include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/prehistoric/prehistoric.h"
 
 namespace Pegasus {
 
 PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
-		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID) {
+		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID), _itemDragger(this), _bigInfoMovie(kNoDisplayElement),
+		_smallInfoMovie(kNoDisplayElement) {
 	_continuePoint = 0;
 	_saveAllowed = _loadAllowed = true;
 	_gameMenu = 0;
@@ -70,6 +73,9 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_FXLevel = 0x80;
 	_ambientLevel = 0x80;
 	_gameMode = kNoMode;
+	_switchModesSync = false;
+	_draggingItem = 0;
+	_dragType = kDragNoDrag;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -100,6 +106,9 @@ Common::Error PegasusEngine::run() {
 	_cursor->addCursorFrames(0x80); // Main
 	_cursor->addCursorFrames(900);  // Mars Shuttle
 
+	// Initialize the item dragger bounds
+	_itemDragger.setHighlightBounds();
+
 	if (!isDemo() && !detectOpeningClosingDirectory()) {
 		Common::String message = "Missing intro directory. ";
 
@@ -504,6 +513,10 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 		case kPlayerDiedFlag:
 			doDeath();
 			break;
+		case kNeedNewJumpFlag:
+			performJump(GameState.getNextNeighborhood());
+			startNeighborhood();
+			break;
 		default:
 			break;
 		}
@@ -661,7 +674,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 
 void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	if (!checkGameMenu())
-		; // TODO: Other input
+		shellGameInput(input, cursorSpot);
 
 	// Handle the console here
 	if (input.isConsoleRequested()) {
@@ -1043,10 +1056,6 @@ void PegasusEngine::throwAwayEverything() {
 	// TODO
 }
 
-void PegasusEngine::dragItem(const Input &, Item *, tDragType) {
-	// TODO
-}
-
 void PegasusEngine::processShell() {
 	checkCallBacks();
 	checkNotifications();
@@ -1069,7 +1078,38 @@ void PegasusEngine::setGameMode(const tGameMode newMode) {
 }
 
 void PegasusEngine::switchGameMode(const tGameMode newMode, const tGameMode oldMode) {
-	// TODO
+	// Start raising panels before lowering panels, to give the activating panel time
+	// to set itself up without cutting into the lowering panel's animation time.
+	
+	if (_switchModesSync) {
+		if (newMode == kModeInventoryPick)
+			raiseInventoryDrawerSync();
+		else if (newMode == kModeBiochipPick)
+			raiseBiochipDrawerSync();
+		else if (newMode == kModeInfoScreen)
+			showInfoScreen();
+		
+		if (oldMode == kModeInventoryPick)
+			lowerInventoryDrawerSync();
+		else if (oldMode == kModeBiochipPick)
+			lowerBiochipDrawerSync();
+		else if (oldMode == kModeInfoScreen)
+			hideInfoScreen();
+	} else {
+		if (newMode == kModeInventoryPick)
+			raiseInventoryDrawer();
+		else if (newMode == kModeBiochipPick)
+			raiseBiochipDrawer();
+		else if (newMode == kModeInfoScreen)
+			showInfoScreen();
+		
+		if (oldMode == kModeInventoryPick)
+			lowerInventoryDrawer();
+		else if (oldMode == kModeBiochipPick)
+			lowerBiochipDrawer();
+		else if (oldMode == kModeInfoScreen)
+			hideInfoScreen();
+	}
 }
 
 bool PegasusEngine::canSwitchGameMode(const tGameMode newMode, const tGameMode oldMode) {
@@ -1128,4 +1168,465 @@ void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 	}
 }
 
+void PegasusEngine::performJump(const tNeighborhoodID neighborhoodID) {
+	if (neighborhoodID == kNoradSubChaseID)
+		error("TODO: Sub chase");
+
+	if (_neighborhood)
+		useNeighborhood(0);
+
+	Neighborhood *neighborhood;
+	makeNeighborhood(neighborhoodID, neighborhood);
+	useNeighborhood(neighborhood);
+}
+
+void PegasusEngine::startNeighborhood() {
+	if (_currentItemID != kNoItemID)
+		g_interface->setCurrentInventoryItemID(_currentItemID);
+	
+	if (_currentBiochipID != kNoItemID)
+		g_interface->setCurrentBiochipID(_currentBiochipID);
+	
+	setGameMode(kModeNavigation);
+	
+	if (_neighborhood)
+		_neighborhood->start();
+}
+
+void PegasusEngine::startNewGame() {
+	// WORKAROUND: The original game ignored the menu difficulty
+	// setting. We're going to pass it through here so that
+	// the menu actually makes sense now.
+	bool isWalkthrough = GameState.getWalkthroughMode();
+	GameState.resetGameState();
+	GameState.setWalkthroughMode(isWalkthrough);
+
+	// TODO: Enable erase
+	// TODO: Fade out
+	useMenu(0);
+	_gfx->updateDisplay();
+
+	createInterface();
+
+	if (isDemo()) {
+		setLastEnergyValue(kFullEnergy);
+		jumpToNewEnvironment(kPrehistoricID, kPrehistoric02, kSouth);
+		GameState.setPrehistoricSeenTimeStream(false);
+		GameState.setPrehistoricSeenFlyer1(false);
+		GameState.setPrehistoricSeenFlyer2(false);
+		GameState.setPrehistoricSeenBridgeZoom(false);
+		GameState.setPrehistoricBreakerThrown(false);
+	} else {
+		jumpToNewEnvironment(kCaldoriaID, kCaldoria00, kEast);
+	}
+
+	removeAllItemsFromInventory();
+	removeAllItemsFromBiochips();
+
+	BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
+	addItemToBiochips(biochip);
+
+	if (isDemo()) {
+		biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
+		addItemToBiochips(biochip);
+		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
+		addItemToBiochips(biochip);
+		InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+		addItemToInventory(item);
+		item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
+		addItemToInventory(item);
+		_currentItemID = kJourneymanKey;
+	} else {
+		_currentItemID = kNoItemID;
+	}
+
+	_currentBiochipID = kAIBiochip;
+
+	// Clear jump notification flags and just perform the jump...
+	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
+	
+	performJump(GameState.getNextNeighborhood());
+	
+	startNeighborhood();
+}
+
+void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhood *&neighborhood) {
+	// TODO: CD check
+	
+	switch (neighborhoodID) {
+	case kPrehistoricID:
+		neighborhood = new Prehistoric(g_AIArea, this);
+		break;
+	}
+}
+
+bool PegasusEngine::wantsCursor() {
+	return _gameMenu == 0;
+}
+
+void PegasusEngine::updateCursor(const Common::Point, const Hotspot *cursorSpot) {	
+	if (_itemDragger.isTracking()) {
+		_cursor->setCurrentFrameIndex(5);
+	} else {
+		if (!cursorSpot) {
+			_cursor->setCurrentFrameIndex(0);
+		} else {
+			uint32 id = cursorSpot->getObjectID();
+
+			switch (id) {
+			case kCurrentItemSpotID:
+				if (countInventoryItems() != 0)
+					_cursor->setCurrentFrameIndex(4);
+				else
+					_cursor->setCurrentFrameIndex(0);
+				break;
+			default:
+				tHotSpotFlags flags = cursorSpot->getHotspotFlags();
+
+				if (flags & kZoomInSpotFlag)
+					_cursor->setCurrentFrameIndex(1);
+				else if (flags & kZoomOutSpotFlag)
+					_cursor->setCurrentFrameIndex(2);
+				else if (flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag))
+					_cursor->setCurrentFrameIndex(4);
+				else if (flags & kJMPClickingSpotFlags)
+					_cursor->setCurrentFrameIndex(3);
+				else
+					_cursor->setCurrentFrameIndex(0);
+			}
+		}
+	}
+}
+
+void PegasusEngine::toggleInventoryDisplay() {
+	if (_gameMode == kModeInventoryPick)
+		setGameMode(kModeNavigation);
+	else
+		setGameMode(kModeInventoryPick);
+}
+
+void PegasusEngine::toggleBiochipDisplay() {
+	if (_gameMode == kModeBiochipPick)
+		setGameMode(kModeNavigation);
+	else
+		setGameMode(kModeBiochipPick);
+}
+
+void PegasusEngine::showInfoScreen() {	
+	if (g_neighborhood) {
+		// Break the input handler chain...
+		_savedHandler = InputHandler::getCurrentHandler();
+		InputHandler::setInputHandler(this);
+		
+		Picture *pushPicture = ((Neighborhood *)g_neighborhood)->getTurnPushPicture();
+		
+		_bigInfoMovie.shareSurface(pushPicture);
+		_smallInfoMovie.shareSurface(pushPicture);
+
+		g_neighborhood->hideNav();
+
+		_smallInfoMovie.initFromMovieFile("Images/Items/Info Right Movie");
+		_smallInfoMovie.setDisplayOrder(kInfoSpinOrder);
+		_smallInfoMovie.moveElementTo(kNavAreaLeft + 304, kNavAreaTop + 8);
+		_smallInfoMovie.moveMovieBoxTo(304, 8);
+		_smallInfoMovie.startDisplaying();
+		_smallInfoMovie.show();
+
+		TimeValue startTime, stopTime;
+		g_AIArea->getSmallInfoSegment(startTime, stopTime);
+		_smallInfoMovie.setSegment(startTime, stopTime);
+		_smallInfoMovie.setFlags(kLoopTimeBase);
+
+		_bigInfoMovie.initFromMovieFile("Images/Items/Info Left Movie");
+		_bigInfoMovie.setDisplayOrder(kInfoBackgroundOrder);
+		_bigInfoMovie.moveElementTo(kNavAreaLeft, kNavAreaTop);
+		_bigInfoMovie.startDisplaying();
+		_bigInfoMovie.show();
+		_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
+
+		_bigInfoMovie.redrawMovieWorld();
+		_smallInfoMovie.redrawMovieWorld();
+		_smallInfoMovie.start();
+	}
+}
+
+void PegasusEngine::hideInfoScreen() {
+	if (g_neighborhood) {
+		InputHandler::setInputHandler(_savedHandler);
+
+		_bigInfoMovie.hide();
+		_bigInfoMovie.stopDisplaying();
+		_bigInfoMovie.releaseMovie();
+
+		_smallInfoMovie.hide();
+		_smallInfoMovie.stopDisplaying();
+		_smallInfoMovie.stop();
+		_smallInfoMovie.releaseMovie();
+
+		g_neighborhood->showNav();
+	}
+}
+
+void PegasusEngine::raiseInventoryDrawer() {
+	if (g_interface)
+		g_interface->raiseInventoryDrawer();
+}
+
+void PegasusEngine::raiseBiochipDrawer() {
+	if (g_interface)
+		g_interface->raiseBiochipDrawer();
+}
+
+void PegasusEngine::lowerInventoryDrawer() {
+	if (g_interface)
+		g_interface->lowerInventoryDrawer();
+}
+
+void PegasusEngine::lowerBiochipDrawer() {
+	if (g_interface)
+		g_interface->lowerBiochipDrawer();
+}
+
+void PegasusEngine::raiseInventoryDrawerSync() {
+	if (g_interface)
+		g_interface->raiseInventoryDrawerSync();
+}
+
+void PegasusEngine::raiseBiochipDrawerSync() {
+	if (g_interface)
+		g_interface->raiseBiochipDrawerSync();
+}
+
+void PegasusEngine::lowerInventoryDrawerSync() {
+	if (g_interface)
+		g_interface->lowerInventoryDrawerSync();
+}
+
+void PegasusEngine::lowerBiochipDrawerSync() {
+	if (g_interface)
+		g_interface->lowerBiochipDrawerSync();
+}
+
+void PegasusEngine::toggleInfo() {
+	if (_gameMode == kModeInfoScreen)
+		setGameMode(kModeNavigation);
+	else if (_gameMode == kModeNavigation)
+		setGameMode(kModeInfoScreen);
+}
+
+void PegasusEngine::dragTerminated(const Input &) {
+	Hotspot *finalSpot = _itemDragger.getLastHotspot();
+	tInventoryResult result;
+
+	if (_dragType == kDragInventoryPickup) {
+		if (finalSpot && finalSpot->getObjectID() == kInventoryDropSpotID)
+			result = addItemToInventory((InventoryItem *)_draggingItem);
+		else
+			result = kTooMuchWeight;
+
+		if (result != kInventoryOK)
+			warning("Auto drag item into the room");
+		else
+			delete _draggingSprite;
+	} else if (_dragType == kDragBiochipPickup) {
+		if (finalSpot && finalSpot->getObjectID() == kBiochipDropSpotID)
+			result = addItemToBiochips((BiochipItem *)_draggingItem);
+		else
+			result = kTooMuchWeight;
+
+		if (result != kInventoryOK)
+			warning("Auto drag item into the room");
+		else
+			delete _draggingSprite;
+	} else if (_dragType == kDragInventoryUse) {
+		if (finalSpot && (finalSpot->getHotspotFlags() & kDropItemSpotFlag) != 0) {
+			//	*** Need to decide on a case by case basis what to do here.
+			//	the crowbar should break the cover off the Mars reactor if its frozen, the
+			//	global transport card should slide through the slot, the oxygen mask should
+			//	attach to the filling station, and so on...
+			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
+			delete _draggingSprite;
+		} else {
+			warning("Auto drag item into inventory");
+		}
+	}
+
+	_dragType = kDragNoDrag;
+
+	if (g_AIArea)
+		g_AIArea->unlockAI();
+}
+
+
+void PegasusEngine::dragItem(const Input &input, Item *item, tDragType type) {	
+	_draggingItem = item;
+	_dragType = type;
+
+	//	Create the sprite.
+	_draggingSprite = _draggingItem->getDragSprite(kDraggingSpriteID);
+	Common::Point where;
+	input.getInputLocation(where);
+	Common::Rect r1;
+	_draggingSprite->getBounds(r1);
+	r1 = Common::Rect::center(where.x, where.y, r1.width(), r1.height());
+	_draggingSprite->setBounds(r1);
+
+	//	Set up drag constraints.
+	DisplayElement *navMovie = _gfx->findDisplayElement(kNavMovieID);
+	Common::Rect r2;
+	navMovie->getBounds(r2);
+	r2.left -= r1.width() / 3;
+	r2.right += r1.width() / 3;
+	r2.top -= r1.height() / 3;
+	r2.bottom += r2.height() / 3;
+
+	r1 = Common::Rect(-30000, -30000, 30000, 30000);
+	_itemDragger.setDragConstraints(r2, r1);
+
+	// Start dragging.
+	_draggingSprite->setDisplayOrder(kDragSpriteOrder);
+	_draggingSprite->startDisplaying();
+	_draggingSprite->show();
+	_itemDragger.setDragSprite(_draggingSprite);
+	_itemDragger.setNextHandler(_neighborhood);
+	_itemDragger.startTracking(input);
+
+	if (g_AIArea)
+		g_AIArea->lockAIOut();
+}
+
+void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_gameMode == kModeInfoScreen) {
+		if (JMPPPInput::isToggleAIMiddleInput(input)) {
+			tLowerClientSignature middleOwner = g_AIArea->getMiddleAreaOwner();
+			g_AIArea->toggleMiddleAreaOwner();
+
+			if (middleOwner != g_AIArea->getMiddleAreaOwner()) {
+				_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
+				_smallInfoMovie.stop();
+				_smallInfoMovie.setFlags(0);
+
+				TimeValue startTime, stopTime;
+				g_AIArea->getSmallInfoSegment(startTime, stopTime);
+				_smallInfoMovie.setSegment(startTime, stopTime);
+				_smallInfoMovie.setFlags(kLoopTimeBase);
+
+				_bigInfoMovie.redrawMovieWorld();
+				_smallInfoMovie.redrawMovieWorld();
+				_smallInfoMovie.start();
+			}
+		}
+	} else {
+		if (JMPPPInput::isRaiseInventoryInput(input))
+			toggleInventoryDisplay();
+
+		if (JMPPPInput::isRaiseBiochipsInput(input))
+			toggleBiochipDisplay();
+
+		// TODO
+		if (JMPPPInput::isTogglePauseInput(input) && _neighborhood)
+			warning("Pause");
+	}
+
+	if (JMPPPInput::isToggleInfoInput(input))
+		toggleInfo();
+}
+
+void PegasusEngine::activateHotspots() {
+	if (_gameMode == kModeInfoScreen) {
+		g_allHotspots.activateOneHotspot(kInfoReturnSpotID);
+	} else {
+		// Set up hot spots.
+		if (_dragType == kDragInventoryPickup)
+			g_allHotspots.activateOneHotspot(kInventoryDropSpotID);
+		else if (_dragType == kDragBiochipPickup)
+			g_allHotspots.activateOneHotspot(kBiochipDropSpotID);
+		else if (_dragType == kDragNoDrag)
+			g_allHotspots.activateMaskedHotspots(kShellSpotFlag);
+	}
+}
+
+bool PegasusEngine::isClickInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_cursor->isVisible() && cursorSpot)
+		return JMPPPInput::isClickInput(input);
+	else
+		return false;
+}
+
+tInputBits PegasusEngine::getClickFilter() {
+	return JMPPPInput::getClickInputFilter();
+}
+
+void PegasusEngine::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
+	if (clickedSpot->getObjectID() == kCurrentItemSpotID) {
+		InventoryItem *currentItem = getCurrentInventoryItem();
+		if (currentItem) {
+			removeItemFromInventory(currentItem);
+			dragItem(input, currentItem, kDragInventoryUse);
+		}
+	} else if (clickedSpot->getObjectID() == kInfoReturnSpotID) {
+		toggleInfo();
+	}
+}
+
+tInventoryResult PegasusEngine::removeItemFromInventory(InventoryItem *item) {
+	tInventoryResult result;
+	
+	if (g_interface)
+		result = g_interface->removeInventoryItem(item);
+	else
+		result = _items.removeItem(item);
+
+	// This should never happen
+	assert(result == kInventoryOK);
+
+	return result;
+}
+
+void PegasusEngine::removeAllItemsFromInventory() {
+	if (g_interface)
+		g_interface->removeAllItemsFromInventory();
+	else
+		_items.removeAllItems();
+}
+
+/////////////////////////////////////////////
+//
+// Biochip handling.
+
+// Adding biochips to the biochip drawer is a little funny, because of two things:
+//      --  We get the map biochip and pegasus biochip at the same time by dragging
+//          one sprite in TSA
+//      --  We can drag in more than one copy of the various biochips.
+// Because of this we need to make sure that no more than one copy of each biochip
+// is ever added.
+
+tInventoryResult PegasusEngine::addItemToBiochips(BiochipItem *biochip) {
+	tInventoryResult result;
+
+	if (g_interface)
+		result = g_interface->addBiochip(biochip);
+	else
+		result = _biochips.addItem(biochip);
+
+	// This can never happen
+	assert(result == kInventoryOK);
+
+	GameState.setTakenItem(biochip, true);
+
+	if (g_neighborhood)
+		g_neighborhood->pickedUpItem(biochip);
+
+	g_AIArea->checkMiddleArea();
+
+	return result;
+}
+
+void PegasusEngine::removeAllItemsFromBiochips() {
+	if (g_interface)
+		g_interface->removeAllItemsFromBiochips();
+	else
+		_biochips.removeAllItems();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 5edc595..8405a51 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -40,6 +40,7 @@
 #include "pegasus/input.h"
 #include "pegasus/notification.h"
 #include "pegasus/items/inventory.h"
+#include "pegasus/items/itemdragger.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
 namespace Video {
@@ -127,12 +128,17 @@ public:
 	bool itemInInventory(tItemID);
 	Inventory *getItemsInventory() { return &_items; }
 	tInventoryResult addItemToInventory(InventoryItem *);
+	void removeAllItemsFromInventory();
+	tInventoryResult removeItemFromInventory(InventoryItem *);
+	uint32 countInventoryItems() { return _items.getNumItems(); }
 
 	// Biochips
 	BiochipItem *getCurrentBiochip();
 	bool itemInBiochips(BiochipItem *);
 	bool itemInBiochips(tItemID);
 	Inventory *getBiochipsInventory() { return &_biochips; }
+	void removeAllItemsFromBiochips();
+	tInventoryResult addItemToBiochips(BiochipItem *);
 
 	// AI
 	Common::String getBriefingMovie();
@@ -148,9 +154,10 @@ public:
 
 	// Dragging
 	void dragItem(const Input &, Item *, tDragType);
-	tDragType getDragType() const { return (tDragType)0; } // TODO
-	Item *getDraggingItem() const { return 0; } // TODO
-	void dragTerminated(const Input &) {} // TODO
+	bool isDragging() const { return _dragType != kDragNoDrag; }
+	tDragType getDragType() const { return _dragType; } // TODO
+	Item *getDraggingItem() const { return _draggingItem; } // TODO
+	void dragTerminated(const Input &);
 
 	// Save/Load
 	void makeContinuePoint();
@@ -172,6 +179,14 @@ protected:
 	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
 
 	void handleInput(const Input &input, const Hotspot *cursorSpot);
+	virtual bool isClickInput(const Input &, const Hotspot *);
+	virtual tInputBits getClickFilter();
+
+	void clickInHotspot(const Input &, const Hotspot *);
+	void activateHotspots(void);
+
+	void updateCursor(const Common::Point, const Hotspot *);
+	bool wantsCursor();
 
 private:
 	// Console
@@ -191,6 +206,8 @@ private:
 	void createItem(tItemID itemID, tNeighborhoodID neighborhoodID, tRoomID roomID, tDirectionConstant direction);
 	Inventory _items;
 	Inventory _biochips;
+	tItemID _currentItemID;
+	tItemID _currentBiochipID;
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;
@@ -204,10 +221,12 @@ private:
 
 	// Misc.
 	Hotspot _returnHotspot;
+	InputHandler *_savedHandler;
 	void showLoadDialog();
 	void showTempScreen(const Common::String &fileName);
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 	void throwAwayEverything();
+	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
 
 	// Menu
 	GameMenu *_gameMenu;
@@ -224,6 +243,10 @@ private:
 	// Neighborhood
 	Neighborhood *_neighborhood;
 	void useNeighborhood(Neighborhood *neighborhood);
+	void performJump(const tNeighborhoodID start);
+	void startNewGame();
+	void startNeighborhood();
+	void makeNeighborhood(tNeighborhoodID, Neighborhood *&);
 
 	// Sound
 	uint16 _ambientLevel;
@@ -231,8 +254,31 @@ private:
 
 	// Game Mode
 	tGameMode _gameMode;
+	bool _switchModesSync;
 	void switchGameMode(const tGameMode, const tGameMode);
 	bool canSwitchGameMode(const tGameMode, const tGameMode);
+
+	// Dragging
+	ItemDragger _itemDragger;
+	Item *_draggingItem;
+	Sprite *_draggingSprite;
+	tDragType _dragType;
+
+	// Interface
+	void toggleInventoryDisplay();
+	void toggleBiochipDisplay();
+	void raiseInventoryDrawer();
+	void raiseBiochipDrawer();
+	void lowerInventoryDrawer();
+	void lowerBiochipDrawer();
+	void raiseInventoryDrawerSync();
+	void raiseBiochipDrawerSync();
+	void lowerInventoryDrawerSync();
+	void lowerBiochipDrawerSync();
+	void showInfoScreen();
+	void hideInfoScreen();
+	void toggleInfo();
+	Movie _bigInfoMovie, _smallInfoMovie;
 };
 
 } // End of namespace Pegasus


Commit: 1659c82c370983bcf477f086f6e788ce64c3c6ee
    https://github.com/scummvm/scummvm/commit/1659c82c370983bcf477f086f6e788ce64c3c6ee
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T15:24:15-07:00

Commit Message:
PEGASUS: Fix frame sequences

Changed paths:
    engines/pegasus/elements.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 99f3fbd..4fe449d 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -228,6 +228,7 @@ FrameSequence::FrameSequence(const tDisplayElementID id) : IdlerAnimation(id) {
 	_duration = 0;
 	_currentFrameNum = 0;
 	_resFork = new Common::MacResManager();
+	_numFrames = 0;
 }
 
 FrameSequence::~FrameSequence() {


Commit: 426ab47067a68dc1704f476c94de633492944af2
    https://github.com/scummvm/scummvm/commit/426ab47067a68dc1704f476c94de633492944af2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T15:50:10-07:00

Commit Message:
PEGASUS: Fix bug in redrawMovieWorld

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index bbe63a0..586c2f5 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -92,8 +92,8 @@ void Movie::redrawMovieWorld() {
 			g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, bounds.left, bounds.top, frame->w, frame->h);
 		} else {
 			// Copy to the surface using _movieBox
-			uint16 width = MIN<int>(MIN<int>(frame->w, _movieBox.width()), _surface->w - _movieBox.left);
-			uint16 height = MIN<int>(MIN<int>(frame->h, _movieBox.height()), _surface->h - _movieBox.top);
+			uint16 width = MIN<int>(frame->w, _movieBox.width());
+			uint16 height = MIN<int>(frame->h, _movieBox.height());
 
 			for (uint16 y = 0; y < height; y++)
 				memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);


Commit: ffff1beb1b8108dff51fa261f298cee67d43f37c
    https://github.com/scummvm/scummvm/commit/ffff1beb1b8108dff51fa261f298cee67d43f37c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T15:50:21-07:00

Commit Message:
PEGASUS: Fix stupid inventory weight typo

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index c63a01f..a608eae 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -129,7 +129,7 @@ Common::Error PegasusEngine::run() {
 	allowInput(true);
 
 	// Set up inventories
-	_items.setWeightLimit(0);
+	_items.setWeightLimit(9);
 	_items.setOwnerID(kPlayerID);
 	_biochips.setWeightLimit(8);
 	_biochips.setOwnerID(kPlayerID);


Commit: 81eff30b8e5309a2dde8f6709f55a098acf27e48
    https://github.com/scummvm/scummvm/commit/81eff30b8e5309a2dde8f6709f55a098acf27e48
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T16:00:57-07:00

Commit Message:
PEGASUS: Fix date positioning

Changed paths:
    engines/pegasus/surface.cpp



diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index fb64c92..ebef03e 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -239,7 +239,7 @@ void Picture::initFromPICTFile(const Common::String &fileName, bool transparent)
 
 	Common::Rect surfaceBounds;
 	getSurfaceBounds(surfaceBounds);
-	setBounds(surfaceBounds);
+	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 }
 
 void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
@@ -247,7 +247,7 @@ void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bo
 
 	Common::Rect surfaceBounds;
 	getSurfaceBounds(surfaceBounds);
-	setBounds(surfaceBounds);
+	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 }
 
 } // End of namespace Pegasus


Commit: cd744aa60e21611c3d4135b9e5864bcba10dbe3a
    https://github.com/scummvm/scummvm/commit/cd744aa60e21611c3d4135b9e5864bcba10dbe3a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T17:16:50-07:00

Commit Message:
PEGASUS: Fix the movie box code

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 586c2f5..6dd44fc 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -65,10 +65,12 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 	_video->pauseVideo(true);
 
 	Common::Rect bounds(0, 0, _video->getWidth(), _video->getHeight());
-	allocateSurface(bounds);
-	setBounds(bounds);
+	sizeElement(_video->getWidth(), _video->getHeight());
 	_movieBox = bounds;
 
+	if (!isSurfaceValid())
+		allocateSurface(bounds);
+
 	setStart(0, getScale());
 	setStop(_video->getDuration() * getScale() / 1000, getScale());
 }
@@ -103,19 +105,16 @@ void Movie::redrawMovieWorld() {
 	}
 }
 
-void Movie::draw(const Common::Rect &r) {
-	Common::Rect surfaceBounds;
-	getSurfaceBounds(surfaceBounds);
-	Common::Rect r1 = r;
+void Movie::draw(const Common::Rect &r) {	
+	Common::Rect worldBounds = _movieBox;
+	Common::Rect elementBounds;
+	getBounds(elementBounds);
 
-	Common::Rect bounds;
-	getBounds(bounds);
-	surfaceBounds.moveTo(bounds.left, bounds.top);
-	r1 = r1.findIntersectingRect(surfaceBounds);
-	getSurfaceBounds(surfaceBounds);
+	worldBounds.moveTo(elementBounds.left, elementBounds.top);
+	Common::Rect r1 = r.findIntersectingRect(worldBounds);
 
 	Common::Rect r2 = r1;
-	r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
+	r2.translate(_movieBox.left - elementBounds.left, _movieBox.top - elementBounds.top);
 	drawImage(r2, r1);
 }
 


Commit: 2e2f8d9168c5b945402559995c8fffed47ef5aae
    https://github.com/scummvm/scummvm/commit/2e2f8d9168c5b945402559995c8fffed47ef5aae
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T17:30:07-07:00

Commit Message:
PEGASUS: Fix stop time of movies

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 6dd44fc..380834f 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -182,6 +182,11 @@ void Movie::checkCallBacks() {
 		uint32 stopTime = _stopTime * getScale() / _stopScale;
 		uint32 actualTime = CLIP<int>(_video->getElapsedTime() * getScale() / 1000, startTime, stopTime);
 		_time = Common::Rational(actualTime, getScale());
+
+		// Stop the video when we go past our end
+		// TODO: Check if this should really be -1
+		if (actualTime >= stopTime - 1)
+			stop();
 	}
 }
 


Commit: 1112b11df93805f763c0a44b392301bb7ea51ca1
    https://github.com/scummvm/scummvm/commit/1112b11df93805f763c0a44b392301bb7ea51ca1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T17:45:37-07:00

Commit Message:
PEGASUS: Fix valgrind warnings with the spots

Changed paths:
    engines/pegasus/neighborhood/spot.h



diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index 5d8f150..38cc81d 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -67,7 +67,15 @@ public:
 	struct Entry {
 		Entry() { clear(); }
 		bool isEmpty() { return movieStart == 0xffffffff; }
-		void clear() { movieStart = 0xffffffff; }
+		void clear() {
+			room = kNoRoomID;
+			direction = kNoDirection;
+			srcFlags = kNoSpotFlags;
+			altCode = kNoAlternateID;
+			movieStart = 0xffffffff;
+			movieEnd = 0xffffffff;
+			dstFlags = kNoSpotFlags;
+		}
 
 		tRoomID room;
 		tDirectionConstant direction;


Commit: 03739c66aa6c9d3e683b046b23cbd90adea457fa
    https://github.com/scummvm/scummvm/commit/03739c66aa6c9d3e683b046b23cbd90adea457fa
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T18:05:04-07:00

Commit Message:
PEGASUS: Fix exit table loading

Changed paths:
    engines/pegasus/neighborhood/exit.cpp
    engines/pegasus/neighborhood/exit.h



diff --git a/engines/pegasus/neighborhood/exit.cpp b/engines/pegasus/neighborhood/exit.cpp
index ce3fe9d..0ef12cc 100755
--- a/engines/pegasus/neighborhood/exit.cpp
+++ b/engines/pegasus/neighborhood/exit.cpp
@@ -43,7 +43,7 @@ void ExitTable::loadFromStream(Common::SeekableReadStream *stream) {
 		_entries[i].movieEnd = stream->readUint32BE();
 		_entries[i].exitEnd = stream->readUint32BE();
 		_entries[i].exitLoop = stream->readUint32BE();
-		_entries[i].exitRoom = stream->readUint32BE();
+		_entries[i].exitRoom = stream->readUint16BE();
 		_entries[i].exitDirection = stream->readByte();
 		stream->readByte(); // alignment
 
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index 671f307..d3e8d50 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -48,8 +48,20 @@ public:
 	void clear();
 
 	struct Entry {
-		Entry() { movieStart = 0xffffffff; }
+		Entry() { clear(); }
 		bool isEmpty() { return movieStart == 0xffffffff; }
+		void clear() {
+			room = kNoRoomID;
+			direction = kNoDirection;
+			altCode = kNoAlternateID;
+			movieStart = 0xffffffff;
+			movieEnd = 0xffffffff;
+			exitEnd = 0xffffffff;
+			originalEnd = 0xffffffff;
+			exitLoop = 0xffffffff;
+			exitRoom = kNoRoomID;
+			exitDirection = kNoDirection;
+		}
 
 		tRoomID room;
 		tDirectionConstant direction;


Commit: 16a25cd7fdc48e192b2a97de8a23dd0e83bc09bc
    https://github.com/scummvm/scummvm/commit/16a25cd7fdc48e192b2a97de8a23dd0e83bc09bc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T18:07:51-07:00

Commit Message:
PEGASUS: Start the demo off!

Only the jump-in video is currently shown though. For some reason, the input is disabled...

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a608eae..ddc13d7 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -575,7 +575,13 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 	switch (command) {
 	case kMenuCmdStartAdventure:
 		GameState.setWalkthroughMode(false);
-		error("Start new game (adventure mode)");
+
+		// Only start the game in the demo for now
+		// (until it works and I implement Caldoria)
+		if (isDemo())
+			startNewGame();
+		else
+			error("Start new game (adventure mode)");
 		break;
 	case kMenuCmdCredits:
 		if (isDemo()) {


Commit: 091df1815e5fc4d5054f9005e6a80bd305588118
    https://github.com/scummvm/scummvm/commit/091df1815e5fc4d5054f9005e6a80bd305588118
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T18:38:49-07:00

Commit Message:
PEGASUS: Use proper key for the right fire button

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 993af63..6906dd9 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -92,7 +92,8 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 			case Common::KEYCODE_NUMLOCK: // Yes, the original uses Num Lock/Clear on the Mac...
 				currentBits |= (kRawButtonDown << kLeftFireButtonShift);
 				break;
-			case Common::KEYCODE_DELETE:
+			case Common::KEYCODE_BACKSPACE:
+			case Common::KEYCODE_KP_MULTIPLY:
 				currentBits |= (kRawButtonDown << kRightFireButtonShift);
 				break;
 			case Common::KEYCODE_d:


Commit: 6440d4d5f6b4183cd857ee685cebd08937137cf8
    https://github.com/scummvm/scummvm/commit/6440d4d5f6b4183cd857ee685cebd08937137cf8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T22:15:54-07:00

Commit Message:
PEGASUS: Implement the ScreenDimmer class

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 4fe449d..bd3b4db 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -478,4 +478,50 @@ void SpriteSequence::newFrame(const uint16 frame) {
 	_sprite.setCurrentFrameIndex(frame);
 }
 
+#define DRAW_PIXEL() \
+	if (bytesPerPixel == 2) \
+		*((uint16 *)dst) = black; \
+	else \
+		*((uint32 *)dst) = black; \
+	dst += bytesPerPixel
+
+#define SKIP_PIXEL() \
+	dst += bytesPerPixel
+
+void ScreenDimmer::draw(const Common::Rect &r) {
+	// We're going to emulate QuickDraw's srcOr+gray mode here
+	// In this mode, every other y column is all black (odd-columns).
+	// Basically, every row does three black and then one transparent
+	// repeatedly.
+
+	// The output is identical to the original
+
+	uint32 black = g_system->getScreenFormat().RGBToColor(0, 0, 0);
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+	byte bytesPerPixel = g_system->getScreenFormat().bytesPerPixel;
+
+	// We're currently doing it to the whole screen to simplify the code
+
+	for (int y = 0; y < 480; y++) {
+		byte *dst = (byte *)screen->getBasePtr(0, y);
+
+		for (int x = 0; x < 640; x += 4) {
+			if (y & 1) {
+				DRAW_PIXEL();
+				DRAW_PIXEL();
+				SKIP_PIXEL();
+				DRAW_PIXEL();
+			} else {
+				SKIP_PIXEL();
+				DRAW_PIXEL();
+				DRAW_PIXEL();
+				DRAW_PIXEL();
+			}
+		}
+	}
+}
+
+#undef DRAW_PIXEL
+#undef SKIP_PIXEL
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index f806f26..84c390a 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -224,6 +224,14 @@ protected:
 	Sprite _sprite;
 };
 
+class ScreenDimmer : public DisplayElement {
+public:
+	ScreenDimmer() : DisplayElement(kScreenDimmerID) {}
+	virtual ~ScreenDimmer() {}
+
+	virtual void draw(const Common::Rect &);
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ddc13d7..6af7f08 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -142,6 +142,9 @@ Common::Error PegasusEngine::run() {
 	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 	g_allHotspots.push_back(&_returnHotspot);
 
+	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
+	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
+
 	while (!shouldQuit())
 		processShell();
 
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 8405a51..c0a7d02 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -232,6 +232,7 @@ private:
 	GameMenu *_gameMenu;
 	void doGameMenuCommand(const tGameMenuCommand);
 	void doInterfaceOverview();
+	ScreenDimmer _screenDimmer;
 
 	// Energy
 	int32 _savedEnergyValue;


Commit: 34fd248f8a0fcc95ab08743106daed6715274c2d
    https://github.com/scummvm/scummvm/commit/34fd248f8a0fcc95ab08743106daed6715274c2d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-28T22:29:42-07:00

Commit Message:
PEGASUS: Add the SoundLevel class

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index bd3b4db..905be50 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -524,4 +524,45 @@ void ScreenDimmer::draw(const Common::Rect &r) {
 #undef DRAW_PIXEL
 #undef SKIP_PIXEL
 
+SoundLevel::SoundLevel(const tDisplayElementID id) : DisplayElement(id) {
+	_soundLevel = 0;
+}
+
+void SoundLevel::incrementLevel() {
+	if (_soundLevel < 12) {
+		_soundLevel++;
+		triggerRedraw();
+	}
+}
+
+void SoundLevel::decrementLevel() {
+	if (_soundLevel > 0) {
+		_soundLevel--;
+		triggerRedraw();
+	}
+}
+
+uint16 SoundLevel::getSoundLevel() {
+	return CLIP<int>(_soundLevel * 22, 0, 256);
+}
+
+void SoundLevel::setSoundLevel(uint16 level) {
+	uint16 newLevel = (level + 21) / 22;
+
+	if (newLevel != _soundLevel) {
+		_soundLevel = newLevel;
+		triggerRedraw();
+	}
+}
+
+void SoundLevel::draw(const Common::Rect &r) {
+	Common::Rect levelRect(_bounds.right - (8 * (_soundLevel - 12)), _bounds.top, _bounds.right, _bounds.bottom);
+	levelRect = r.findIntersectingRect(levelRect);
+
+	if (!levelRect.isEmpty()) {
+		Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+		screen->fillRect(levelRect, g_system->getScreenFormat().RGBToColor(0, 0, 0));
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 84c390a..6e20e72 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -232,6 +232,23 @@ public:
 	virtual void draw(const Common::Rect &);
 };
 
+class SoundLevel : public DisplayElement {
+public:
+	SoundLevel(const tDisplayElementID);
+	virtual ~SoundLevel() {}
+	
+	void incrementLevel();
+	void decrementLevel();
+	
+	uint16 getSoundLevel();
+	void setSoundLevel(uint16);
+	
+	void draw(const Common::Rect &);
+
+protected:
+	uint16 _soundLevel;
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: 878601b2a3b1e60c4ec96ec1ca99d2e5eb5359be
    https://github.com/scummvm/scummvm/commit/878601b2a3b1e60c4ec96ec1ca99d2e5eb5359be
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T08:37:02-07:00

Commit Message:
PEGASUS: Fix a typo in the SoundLevel code

Changed paths:
    engines/pegasus/elements.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 905be50..103dfcf 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -556,7 +556,7 @@ void SoundLevel::setSoundLevel(uint16 level) {
 }
 
 void SoundLevel::draw(const Common::Rect &r) {
-	Common::Rect levelRect(_bounds.right - (8 * (_soundLevel - 12)), _bounds.top, _bounds.right, _bounds.bottom);
+	Common::Rect levelRect(_bounds.right + (8 * (_soundLevel - 12)), _bounds.top, _bounds.right, _bounds.bottom);
 	levelRect = r.findIntersectingRect(levelRect);
 
 	if (!levelRect.isEmpty()) {


Commit: 69badbebc43488caa66bd5ac25d942fb36592259
    https://github.com/scummvm/scummvm/commit/69badbebc43488caa66bd5ac25d942fb36592259
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T08:52:35-07:00

Commit Message:
PEGASUS: Add the PauseMenu code

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/menu.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 2aba4f0..dfef67c 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -914,4 +914,302 @@ void DeathMenu::drawAllScores() {
 	}
 }
 
+enum {
+	kPauseMenuSave,
+	kPauseMenuContinue,
+	kPauseMenuRestore,
+	kPauseMenuSoundFX,
+	kPauseMenuAmbience,
+	kPauseMenuWalkthru,
+	kPauseMenuQuitToMainMenu,
+	
+	kFirstPauseSelection = kPauseMenuSave,
+	kLastPauseSelection = kPauseMenuQuitToMainMenu
+};
+
+const tCoordType kPauseLeft = 194;
+const tCoordType kPauseTop = 68;
+
+const tCoordType kSaveGameLeft = kPauseLeft + 6;
+const tCoordType kSaveGameTop = kPauseTop + 56;
+
+const tCoordType kSaveGameSelectLeft = kPauseLeft - 44;
+const tCoordType kSaveGameSelectTop = kPauseTop + 52;
+
+const tCoordType kPauseContinueLeft = kPauseLeft + 18;
+const tCoordType kPauseContinueTop = kPauseTop + 100;
+
+const tCoordType kPauseContinueSelectLeft = kPauseLeft - 44;
+const tCoordType kPauseContinueSelectTop = kPauseTop + 95;
+
+const tCoordType kPauseRestoreLeft = kPauseLeft + 18;
+const tCoordType kPauseRestoreTop = kPauseTop + 136;
+
+const tCoordType kPauseRestoreSelectLeft = kPauseLeft - 44;
+const tCoordType kPauseRestoreSelectTop = kPauseTop + 131;
+
+const tCoordType kSoundFXLeft = kPauseLeft + 128;
+const tCoordType kSoundFXTop = kPauseTop + 187;
+const tCoordType kSoundFXRight = kSoundFXLeft + 96;
+const tCoordType kSoundFXBottom = kSoundFXTop + 14;
+
+const tCoordType kSoundFXSelectLeft = kPauseLeft - 44;
+const tCoordType kSoundFXSelectTop = kPauseTop + 172;
+
+const tCoordType kAmbienceLeft = kPauseLeft + 128;
+const tCoordType kAmbienceTop = kPauseTop + 227;
+const tCoordType kAmbienceRight = kAmbienceLeft + 96;
+const tCoordType kAmbienceBottom = kAmbienceTop + 14;
+
+const tCoordType kAmbienceSelectLeft = kPauseLeft - 44;
+const tCoordType kAmbienceSelectTop = kPauseTop + 212;
+
+const tCoordType kWalkthruLeft = kPauseLeft + 128;
+const tCoordType kWalkthruTop = kPauseTop + 264;
+
+const tCoordType kWalkthruSelectLeft = kPauseLeft - 44;
+const tCoordType kWalkthruSelectTop = kPauseTop + 255;
+
+const tCoordType kQuitLeft = kPauseLeft + 18;
+const tCoordType kQuitTop = kPauseTop + 302;
+
+const tCoordType kQuitSelectLeft = kPauseLeft - 44;
+const tCoordType kQuitSelectTop = kPauseTop + 297;
+
+//	These are relative to the pause background.
+const tCoordType kPauseScoreLeft = 130;
+const tCoordType kPauseScoreTop = 34;
+const tCoordType kPauseScoreRight = kPauseScoreLeft + 108;
+const tCoordType kPauseScoreBottom = kPauseScoreTop + 12;
+
+// Never set the current input handler to the CPauseMenu.
+PauseMenu::PauseMenu() : GameMenu(kPauseMenuID), _pauseBackground(0), _saveButton(0), _restoreButton(0),
+		_walkthroughButton(0), _continueButton(0), _soundFXLevel(0), _ambienceLevel(0), _quitButton(0),
+		_largeSelect(0), _smallSelect(0) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	_pauseBackground.initFromPICTFile("Images/Pause Screen/PausScrn.pict", true);
+
+	if (!vm->isDemo()) {
+		Surface numbers;
+		numbers.getImageFromPICTFile("Images/Pause Screen/Numbers.pict");
+		drawScore(GameState.getTotalScore(), kMaxTotalScore,
+				Common::Rect(kPauseScoreLeft, kPauseScoreTop, kPauseScoreRight, kPauseScoreBottom), &numbers);
+	}
+
+	_pauseBackground.setDisplayOrder(kPauseMenuOrder);
+	_pauseBackground.moveElementTo(kPauseLeft, kPauseTop);
+	_pauseBackground.startDisplaying();
+	_pauseBackground.show();
+
+	if (!vm->isDemo()) {
+		_saveButton.initFromPICTFile("Images/Pause Screen/SaveGame.pict");
+		_saveButton.setDisplayOrder(kSaveGameOrder);
+		_saveButton.moveElementTo(kSaveGameLeft, kSaveGameTop);
+		_saveButton.startDisplaying();
+
+		_restoreButton.initFromPICTFile("Images/Pause Screen/Restore.pict");
+		_restoreButton.setDisplayOrder(kRestoreOrder);
+		_restoreButton.moveElementTo(kPauseRestoreLeft, kPauseRestoreTop);
+		_restoreButton.startDisplaying();
+
+		_walkthroughButton.initFromPICTFile("Images/Pause Screen/Walkthru.pict");
+		_walkthroughButton.setDisplayOrder(kWalkthruOrder);
+		_walkthroughButton.moveElementTo(kWalkthruLeft, kWalkthruTop);
+		_walkthroughButton.startDisplaying();
+
+		if (GameState.getWalkthroughMode())
+			_walkthroughButton.show();
+	}
+
+	_continueButton.initFromPICTFile("Images/Pause Screen/Continue.pict");
+	_continueButton.setDisplayOrder(kContinueOrder);
+	_continueButton.moveElementTo(kPauseContinueLeft, kPauseContinueTop);
+	_continueButton.startDisplaying();
+
+	_soundFXLevel.setDisplayOrder(kSoundFXOrder);
+	_soundFXLevel.setBounds(Common::Rect(kSoundFXLeft, kSoundFXTop, kSoundFXRight, kSoundFXBottom));
+	_soundFXLevel.startDisplaying();
+	_soundFXLevel.show();
+	_soundFXLevel.setSoundLevel(vm->getSoundFXLevel());
+
+	_ambienceLevel.setDisplayOrder(kAmbienceOrder);
+	_ambienceLevel.setBounds(Common::Rect(kAmbienceLeft, kAmbienceTop, kAmbienceRight, kAmbienceBottom));
+	_ambienceLevel.startDisplaying();
+	_ambienceLevel.show();
+	_ambienceLevel.setSoundLevel(vm->getAmbienceLevel());
+
+	_quitButton.initFromPICTFile("Images/Pause Screen/Quit2MM.pict");
+	_quitButton.setDisplayOrder(kQuitToMainMenuOrder);
+	_quitButton.moveElementTo(kQuitLeft, kQuitTop);
+	_quitButton.startDisplaying();
+
+	_largeSelect.initFromPICTFile("Images/Pause Screen/SelectL.pict", true);
+	_largeSelect.setDisplayOrder(kPauseLargeHiliteOrder);
+	_largeSelect.startDisplaying();
+
+	_smallSelect.initFromPICTFile("Images/Pause Screen/SelectS.pict", true);
+	_smallSelect.setDisplayOrder(kPauseSmallHiliteOrder);
+	_smallSelect.startDisplaying();
+
+	_menuSelection = (vm->isDemo()) ? kPauseMenuContinue : kPauseMenuSave;
+
+	updateDisplay();
+}
+
+void PauseMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	if (input.upButtonDown()) {
+		if (vm->isDemo()) {
+			if (_menuSelection > kPauseMenuContinue) {
+				switch (_menuSelection) {
+				case kPauseMenuSoundFX:
+					_menuSelection = kPauseMenuContinue;
+					break;
+				case kPauseMenuAmbience:
+					_menuSelection = kPauseMenuSoundFX;
+					break;
+				case kPauseMenuQuitToMainMenu:
+					_menuSelection = kPauseMenuAmbience;
+					break;
+				}
+				updateDisplay();
+			}
+		} else {
+			if (_menuSelection > kFirstPauseSelection) {
+				_menuSelection--;
+				updateDisplay();
+			}
+		}
+	} else if (input.downButtonDown()) {
+		if (vm->isDemo()) {
+			if (_menuSelection < kPauseMenuQuitToMainMenu) {
+				switch (_menuSelection) {
+				case kPauseMenuContinue:
+					_menuSelection = kPauseMenuSoundFX;
+					break;
+				case kPauseMenuSoundFX:
+					_menuSelection = kPauseMenuAmbience;
+					break;
+				case kPauseMenuAmbience:
+					_menuSelection = kPauseMenuQuitToMainMenu;
+					break;
+				}
+				updateDisplay();
+			}
+		} else {
+			if (_menuSelection < kLastPauseSelection) {
+				_menuSelection++;
+				updateDisplay();
+			}
+		}
+	} else if (input.leftButtonDown()) {
+		if (_menuSelection == kPauseMenuSoundFX) {
+			_soundFXLevel.decrementLevel();
+			vm->setSoundFXLevel(_soundFXLevel.getSoundLevel());
+		} else if (_menuSelection == kPauseMenuAmbience) {
+			_ambienceLevel.decrementLevel();
+			vm->setAmbienceLevel(_ambienceLevel.getSoundLevel());
+		} else if (!vm->isDemo() && _menuSelection == kPauseMenuWalkthru) {
+			GameState.setWalkthroughMode(!GameState.getWalkthroughMode());
+			if (GameState.getWalkthroughMode())
+				_walkthroughButton.show();
+			else
+				_walkthroughButton.hide();
+		}
+	} else if (input.rightButtonDown()) {
+		if (_menuSelection == kPauseMenuSoundFX) {
+			_soundFXLevel.incrementLevel();
+			vm->setSoundFXLevel(_soundFXLevel.getSoundLevel());
+		} else if (_menuSelection == kPauseMenuAmbience) {
+			_ambienceLevel.incrementLevel();
+			vm->setAmbienceLevel(_ambienceLevel.getSoundLevel());
+		} else if (!vm->isDemo() && _menuSelection == kPauseMenuWalkthru) {
+			GameState.setWalkthroughMode(!GameState.getWalkthroughMode());
+			if (GameState.getWalkthroughMode())
+				_walkthroughButton.show();
+			else
+				_walkthroughButton.hide();
+		}
+	} else if (JMPPPInput::isMenuButtonPressInput(input)) {
+		switch (_menuSelection) {
+		case kPauseMenuSave:
+			_saveButton.show();
+			vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+			_saveButton.hide();
+			setLastCommand(kMenuCmdPauseSave);
+			break;
+		case kPauseMenuRestore:
+			_restoreButton.show();
+			vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+			_restoreButton.hide();
+			setLastCommand(kMenuCmdPauseRestore);
+			break;
+		case kPauseMenuContinue:
+			_continueButton.show();
+			vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+			_continueButton.hide();
+			setLastCommand(kMenuCmdPauseContinue);
+			break;
+		case kPauseMenuWalkthru:
+			GameState.setWalkthroughMode(!GameState.getWalkthroughMode());
+			if (GameState.getWalkthroughMode())
+				_walkthroughButton.show();
+			else
+				_walkthroughButton.hide();
+			break;
+		case kPauseMenuQuitToMainMenu:
+			_quitButton.show();
+			vm->delayShell(kMenuButtonHiliteTime, kMenuButtonHiliteScale);
+			_quitButton.hide();
+			setLastCommand(kMenuCmdPauseQuit);
+			break;
+		}
+	}
+
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void PauseMenu::updateDisplay() {
+	switch (_menuSelection) {
+	case kPauseMenuSave:
+		_largeSelect.moveElementTo(kSaveGameSelectLeft, kSaveGameSelectTop);
+		_largeSelect.show();
+		_smallSelect.hide();
+		break;
+	case kPauseMenuContinue:
+		_smallSelect.moveElementTo(kPauseContinueSelectLeft, kPauseContinueSelectTop);
+		_smallSelect.show();
+		_largeSelect.hide();
+		break;
+	case kPauseMenuRestore:
+		_smallSelect.moveElementTo(kPauseRestoreSelectLeft, kPauseRestoreSelectTop);
+		_smallSelect.show();
+		_largeSelect.hide();
+		break;
+	case kPauseMenuSoundFX:
+		_largeSelect.moveElementTo(kSoundFXSelectLeft, kSoundFXSelectTop);
+		_largeSelect.show();
+		_smallSelect.hide();
+		break;
+	case kPauseMenuAmbience:
+		_largeSelect.moveElementTo(kAmbienceSelectLeft, kAmbienceSelectTop);
+		_largeSelect.show();
+		_smallSelect.hide();
+		break;
+	case kPauseMenuWalkthru:
+		_largeSelect.moveElementTo(kWalkthruSelectLeft, kWalkthruSelectTop);
+		_largeSelect.show();
+		_smallSelect.hide();
+		break;
+	case kPauseMenuQuitToMainMenu:
+		_smallSelect.moveElementTo(kQuitSelectLeft, kQuitSelectTop);
+		_smallSelect.show();
+		_largeSelect.hide();
+		break;
+	}
+}
+
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
index 1724220..7416623 100755
--- a/engines/pegasus/menu.h
+++ b/engines/pegasus/menu.h
@@ -143,6 +143,29 @@ protected:
 	Sound _triumphSound;
 };
 
+class PauseMenu : public GameMenu {
+public:
+	PauseMenu();
+	virtual ~PauseMenu() {}
+
+	virtual void handleInput(const Input &input, const Hotspot *);
+
+protected:
+	void updateDisplay();
+
+	uint32 _menuSelection;
+	Picture _pauseBackground;
+	Picture _saveButton;
+	Picture _restoreButton;
+	Picture _walkthroughButton;
+	Picture _continueButton;
+	SoundLevel _soundFXLevel;
+	SoundLevel _ambienceLevel;
+	Picture _quitButton;
+	Picture _largeSelect;
+	Picture _smallSelect;
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 6af7f08..037688b 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -674,6 +674,31 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		if (!isDemo())
 			resetIntroTimer();
 		break;
+	case kMenuCmdPauseSave:
+		error("Save game");
+		break;
+	case kMenuCmdPauseContinue:
+		pauseMenu(false);
+		break;
+	case kMenuCmdPauseRestore:
+		error("Load game");
+		break;
+	case kMenuCmdPauseQuit:
+#if 1
+		// TODO: This doesn't work yet
+		error("Return to main menu");
+#else
+		// TODO: Fade out
+		throwAwayEverything();
+		pauseMenu(false);
+		useMenu(new MainMenu());
+		_gfx->updateDisplay();
+		((MainMenu *)_gameMenu)->startMainMenuLoop();
+		// TODO: Fade in
+		if (!isDemo())
+			resetIntroTimer();
+#endif
+		break;
 	case kMenuCmdNoCommand:
 		break;
 	default:
@@ -1532,9 +1557,8 @@ void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot
 		if (JMPPPInput::isRaiseBiochipsInput(input))
 			toggleBiochipDisplay();
 
-		// TODO
 		if (JMPPPInput::isTogglePauseInput(input) && _neighborhood)
-			warning("Pause");
+			pauseMenu(!isPaused());
 	}
 
 	if (JMPPPInput::isToggleInfoInput(input))
@@ -1638,4 +1662,34 @@ void PegasusEngine::removeAllItemsFromBiochips() {
 		_biochips.removeAllItems();
 }
 
+void PegasusEngine::setSoundFXLevel(uint16 fxLevel) {
+	_FXLevel = fxLevel;
+	if (_neighborhood)
+		_neighborhood->setSoundFXLevel(fxLevel);
+	if (g_AIArea)
+		g_AIArea->setAIVolume(fxLevel);
+}
+
+void PegasusEngine::setAmbienceLevel(uint16 ambientLevel) {
+	_ambientLevel = ambientLevel;
+	if (_neighborhood)
+		_neighborhood->setAmbienceLevel(ambientLevel);
+}
+
+void PegasusEngine::pauseMenu(bool menuUp) {
+	if (menuUp) {
+		// TODO: Pause engine
+		_screenDimmer.startDisplaying();
+		_screenDimmer.show();
+		_gfx->updateDisplay();
+		useMenu(new PauseMenu());
+	} else {
+		// TODO: Resume engine
+		_screenDimmer.hide();
+		_screenDimmer.stopDisplaying();
+		useMenu(0);
+		g_AIArea->checkMiddleArea();
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index c0a7d02..a79d2a7 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -114,7 +114,9 @@ public:
 
 	// Volume
 	uint16 getSoundFXLevel() { return _FXLevel; }
+	void setSoundFXLevel(uint16);
 	uint16 getAmbienceLevel() { return _ambientLevel; }
+	void setAmbienceLevel(uint16);
 
 	// Items
 	bool playerHasItem(const Item *);
@@ -227,12 +229,14 @@ private:
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 	void throwAwayEverything();
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
+	bool isPaused() { return false; } // TODO
 
 	// Menu
 	GameMenu *_gameMenu;
 	void doGameMenuCommand(const tGameMenuCommand);
 	void doInterfaceOverview();
 	ScreenDimmer _screenDimmer;
+	void pauseMenu(bool menuUp);
 
 	// Energy
 	int32 _savedEnergyValue;


Commit: de5849b102d4fbb1eb9c25f0b9456101de6836bf
    https://github.com/scummvm/scummvm/commit/de5849b102d4fbb1eb9c25f0b9456101de6836bf
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T09:08:42-07:00

Commit Message:
PEGASUS: Fix TimeBase::setTime

Need to reset _lastMillis or checkCallBacks won't work properly

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index b3dd3cf..d09d029 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -81,6 +81,7 @@ TimeBase::~TimeBase() {
 
 void TimeBase::setTime(const TimeValue time, const TimeScale scale) {
 	_time = Common::Rational(time, (scale == 0) ? _preferredScale : scale);
+	_lastMillis = 0;
 }
 
 TimeValue TimeBase::getTime(const TimeScale scale) {


Commit: 8bc240124ad8ea7ffd36f11d697a460e746956a8
    https://github.com/scummvm/scummvm/commit/8bc240124ad8ea7ffd36f11d697a460e746956a8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T09:27:38-07:00

Commit Message:
PEGASUS: Allow getting frames from videos

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index d87a536..7c77381 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1023,8 +1023,7 @@ void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeV
 	// will work.
 	_navMovie.setSegment(0, _navMovie.getDuration());
 
-	// TODO
-	//_pushIn.initFromMovieFrame(_navMovie.getMovie(), newView, kNoMask);
+	_pushIn.initFromMovieFrame(_navMovie.getMovie(), newView);
 
 	_navMovie.hide();
 
@@ -1075,6 +1074,7 @@ void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeV
 	_turnPush.continueFader();
 
 	do {
+		_vm->checkCallBacks();
 		_vm->refreshDisplay();
 		_vm->_system->delayMillis(10);
 	} while (_turnPush.isFading());
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index ebef03e..43cf90a 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -131,6 +131,22 @@ void Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
 	_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
 }
 
+void Surface::getImageFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time) {
+	video->seekToTime(Audio::Timestamp(0, time, 600));
+	const Graphics::Surface *frame = video->decodeNextFrame();
+
+	if (frame) {
+		if (!_surface)
+			_surface = new Graphics::Surface();
+
+		_surface->copyFrom(*frame);
+		_ownsSurface = true;
+		_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
+	} else {
+		deallocateSurface();
+	}
+}
+
 void Surface::copyToCurrentPort() const {
 	copyToCurrentPort(_bounds);
 }
@@ -218,6 +234,11 @@ void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool
 	_transparent = transparent;
 }
 
+void Frame::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
+	getImageFromMovieFrame(video, time);
+	_transparent = transparent;
+}
+
 void Picture::draw(const Common::Rect &r) {
 	Common::Rect surfaceBounds;
 	getSurfaceBounds(surfaceBounds);
@@ -250,4 +271,12 @@ void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bo
 	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 }
 
+void Picture::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
+	Frame::initFromMovieFrame(video, time, transparent);
+
+	Common::Rect surfaceBounds;
+	getSurfaceBounds(surfaceBounds);
+	sizeElement(surfaceBounds.width(), surfaceBounds.height());
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index 72d614f..c94ccdf 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -73,6 +73,7 @@ public:
 
 	virtual void getImageFromPICTFile(const Common::String &fileName);
 	virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
+	virtual void getImageFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue);
 
 protected:
 	bool _ownsSurface;
@@ -103,6 +104,7 @@ public:
 
 	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
 	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
+	virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);
 };
 
 class SpriteFrame : public Frame {
@@ -122,6 +124,7 @@ public:
 
 	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
 	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
+	virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);
 
 	virtual void draw(const Common::Rect &);
 };


Commit: bbacb4e5c76561e4c5fcf79e0aa41aa3a9cc0efd
    https://github.com/scummvm/scummvm/commit/bbacb4e5c76561e4c5fcf79e0aa41aa3a9cc0efd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T09:31:41-07:00

Commit Message:
PEGASUS: Fix energy monitor not showing up

Changed paths:
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 1ceb3a2..f0e9f49 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -116,7 +116,7 @@ public:
 	virtual ~Neighborhood();
 
 	virtual void init();
-	void start();
+	virtual void start();
 	virtual void moveNavTo(const tCoordType, const tCoordType);
 	virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0;
 	void makeContinuePoint();


Commit: b54a6275cf3661e8babce18eb8c699cf8d01310a
    https://github.com/scummvm/scummvm/commit/b54a6275cf3661e8babce18eb8c699cf8d01310a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T13:40:11-07:00

Commit Message:
PEGASUS: Fix sprites being drawn incorrectly

Changed paths:
    engines/pegasus/elements.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 103dfcf..79faa1a 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -430,7 +430,7 @@ void Sprite::draw(const Common::Rect &r) {
 		Common::Rect r1 = frameBounds.findIntersectingRect(r);
 
 		Common::Rect r2 = frameBounds;
-		r2.translate(frameBounds.left - _bounds.left - _currentFrame->frameLeft, frameBounds.top - _bounds.top - _currentFrame->frameTop);
+		r2.translate(-_bounds.left - _currentFrame->frameLeft, -_bounds.top - _currentFrame->frameTop);
 
 		_currentFrame->frame->drawImage(r2, r1);
 	}


Commit: 9ab6246123ef92ff655e90ea086c25cffc02ae43
    https://github.com/scummvm/scummvm/commit/9ab6246123ef92ff655e90ea086c25cffc02ae43
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T13:42:37-07:00

Commit Message:
PEGASUS: Fix compass not showing

Changed paths:
    engines/pegasus/interface.cpp



diff --git a/engines/pegasus/interface.cpp b/engines/pegasus/interface.cpp
index 10a1042..4f9183b 100755
--- a/engines/pegasus/interface.cpp
+++ b/engines/pegasus/interface.cpp
@@ -132,7 +132,7 @@ void Interface::setDate(const uint16 dateResID) {
 }
 
 void Interface::validateCompass() {
-	if (g_compass) {
+	if (!g_compass) {
 		new Compass();
 		g_compass->initCompass();
 		g_compass->setDisplayOrder(kCompassOrder);


Commit: 7390d327f19df4d0da38ef6d989aa99bfd08b684
    https://github.com/scummvm/scummvm/commit/7390d327f19df4d0da38ef6d989aa99bfd08b684
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T13:58:22-07:00

Commit Message:
COMMON: Ensure numTypes is set to 0 on close

Changed paths:
    common/macresman.cpp



diff --git a/common/macresman.cpp b/common/macresman.cpp
index c1cab8b..2b9c68a 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -69,6 +69,7 @@ void MacResManager::close() {
 	delete[] _resLists; _resLists = 0;
 	delete[] _resTypes; _resTypes = 0;
 	delete _stream; _stream = 0;
+	_resMap.numTypes = 0;
 }
 
 bool MacResManager::hasDataFork() const {


Commit: 447b7204f34230044c379022f9a89d14129acbb7
    https://github.com/scummvm/scummvm/commit/447b7204f34230044c379022f9a89d14129acbb7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T13:59:02-07:00

Commit Message:
PEGASUS: Returning from the pause menu works now

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 037688b..690af4b 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -684,10 +684,6 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		error("Load game");
 		break;
 	case kMenuCmdPauseQuit:
-#if 1
-		// TODO: This doesn't work yet
-		error("Return to main menu");
-#else
 		// TODO: Fade out
 		throwAwayEverything();
 		pauseMenu(false);
@@ -697,7 +693,6 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		// TODO: Fade in
 		if (!isDemo())
 			resetIntroTimer();
-#endif
 		break;
 	case kMenuCmdNoCommand:
 		break;
@@ -1087,7 +1082,21 @@ void PegasusEngine::doDeath() {
 }
 
 void PegasusEngine::throwAwayEverything() {
-	// TODO
+	if (_items.getNumItems() != 0)
+		_currentItemID = g_interface->getCurrentInventoryItem()->getObjectID();
+	else
+		_currentItemID = kNoItemID;
+
+	if (_biochips.getNumItems() != 0)
+		_currentItemID = g_interface->getCurrentBiochip()->getObjectID();
+	else
+		_currentItemID = kNoItemID;
+
+	useMenu(0);
+	useNeighborhood(0);
+
+	delete g_interface;
+	g_interface = 0;
 }
 
 void PegasusEngine::processShell() {


Commit: 5be808fe201f9204fb256112dcf7f89a12e61b6b
    https://github.com/scummvm/scummvm/commit/5be808fe201f9204fb256112dcf7f89a12e61b6b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T14:10:13-07:00

Commit Message:
PEGASUS: Fix use of Common::List::erase

Changed paths:
    engines/pegasus/notification.cpp



diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
index 9725cfb..5ded610 100755
--- a/engines/pegasus/notification.cpp
+++ b/engines/pegasus/notification.cpp
@@ -66,9 +66,12 @@ void Notification::notifyMe(NotificationReceiver *receiver, tNotificationFlags f
 }
 
 void Notification::cancelNotification(NotificationReceiver *receiver) {
-	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
+	for (tReceiverIterator it = _receivers.begin(); it != _receivers.end();) {
 		if (it->receiver == receiver)
-			_receivers.erase(it);
+			it = _receivers.erase(it);
+		else
+			it++;
+	}
 }
 
 void Notification::setNotificationFlags(tNotificationFlags flags, tNotificationFlags mask) {
@@ -124,9 +127,12 @@ void NotificationManager::addNotification(Notification *notification) {
 }
 
 void NotificationManager::removeNotification(Notification *notification) {
-	for (tNotificationIterator it = _notifications.begin(); it != _notifications.end(); it++)
+	for (tNotificationIterator it = _notifications.begin(); it != _notifications.end();) {
 		if ((*it) == notification)
-			_notifications.erase(it);
+			it = _notifications.erase(it);
+		else
+			it++;
+	}
 }
 
 void NotificationManager::detachNotifications() {


Commit: 956f3d46444bc043f9e3153c3dc76d76f6dee7ac
    https://github.com/scummvm/scummvm/commit/956f3d46444bc043f9e3153c3dc76d76f6dee7ac
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T16:26:17-07:00

Commit Message:
PEGASUS: Add the auto dragger code

Changed paths:
  A engines/pegasus/items/autodragger.cpp
  A engines/pegasus/items/autodragger.h
    engines/pegasus/module.mk
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp
new file mode 100755
index 0000000..baad699
--- /dev/null
+++ b/engines/pegasus/items/autodragger.cpp
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/elements.h"
+#include "pegasus/items/autodragger.h"
+
+namespace Pegasus {
+
+AutoDragger::AutoDragger() {
+	_draggingElement = NULL;
+	_lastTime = 0;
+	initCallBack(this, kCallBackAtExtremes);
+}
+
+void AutoDragger::autoDrag(DisplayElement *dragElement, const Common::Point &startPoint, const Common::Point &stopPoint,
+		TimeValue dragTime, TimeScale dragScale) {
+	_draggingElement = dragElement;
+
+	if (_draggingElement) {
+		_startLocation = startPoint;
+		_stopLocation = stopPoint;
+		_lastTime = 0;
+		_done = false;
+		_draggingElement->moveElementTo(_startLocation.x, _startLocation.y);
+		setScale(dragScale);
+		setSegment(0, dragTime);
+		setTime(0);
+		scheduleCallBack(kTriggerAtStop, 0, 0);
+		startIdling();
+		start();
+	} else {
+		stopDragging();
+	}
+}
+
+void AutoDragger::stopDragging() {
+	cancelCallBack();
+	stopIdling();
+	_draggingElement = 0;
+	_startLocation = Common::Point();
+	_stopLocation = Common::Point();
+	_lastTime = 0;
+	_done = true;
+}
+
+bool AutoDragger::isDragging() {
+	return isIdling();
+}
+
+void AutoDragger::useIdleTime() {	
+	TimeValue thisTime = getTime();
+
+	if (thisTime != _lastTime) {
+		uint32 offsetX = (_stopLocation.x - _startLocation.x) * thisTime / getDuration();
+		uint32 offsetY = (_stopLocation.y - _startLocation.y) * thisTime / getDuration();
+		_draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.x + offsetY);
+		_lastTime = thisTime;
+	}
+
+	if (_done)
+		stopDragging();
+}
+
+void AutoDragger::callBack() {
+	if (isIdling())
+		_done = true;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/autodragger.h b/engines/pegasus/items/autodragger.h
new file mode 100755
index 0000000..6783fdf
--- /dev/null
+++ b/engines/pegasus/items/autodragger.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_AUTODRAGGER_H
+#define PEGASUS_ITEMS_AUTODRAGGER_H
+
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class DisplayElement;
+
+class AutoDragger : private Idler, private TimeBase, private TimeBaseCallBack {
+public:
+	AutoDragger();
+	virtual ~AutoDragger() {}
+
+	void autoDrag(DisplayElement *, const Common::Point &, const Common::Point &, TimeValue, TimeScale);
+	bool isDragging();
+	void stopDragging();
+
+protected:
+	void useIdleTime();
+	void callBack();
+
+	DisplayElement *_draggingElement;
+	Common::Point _startLocation, _stopLocation;
+	TimeValue _lastTime;
+	bool _done;
+};
+
+} // End of namespace Pegasus
+
+#endif
+
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index c3c0bd8..3759780 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS = \
 	ai/ai_area.o \
 	ai/ai_condition.o \
 	ai/ai_rule.o \
+	items/autodragger.o \
 	items/inventory.o \
 	items/inventorypicture.o \
 	items/item.o \
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 690af4b..9cb1bd2 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1468,7 +1468,7 @@ void PegasusEngine::dragTerminated(const Input &) {
 			result = kTooMuchWeight;
 
 		if (result != kInventoryOK)
-			warning("Auto drag item into the room");
+			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 		else
 			delete _draggingSprite;
 	} else if (_dragType == kDragBiochipPickup) {
@@ -1478,7 +1478,7 @@ void PegasusEngine::dragTerminated(const Input &) {
 			result = kTooMuchWeight;
 
 		if (result != kInventoryOK)
-			warning("Auto drag item into the room");
+			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 		else
 			delete _draggingSprite;
 	} else if (_dragType == kDragInventoryUse) {
@@ -1490,7 +1490,7 @@ void PegasusEngine::dragTerminated(const Input &) {
 			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
 			delete _draggingSprite;
 		} else {
-			warning("Auto drag item into inventory");
+			autoDragItemIntoInventory(_draggingItem, _draggingSprite);
 		}
 	}
 
@@ -1701,4 +1701,79 @@ void PegasusEngine::pauseMenu(bool menuUp) {
 	}
 }
 
+void PegasusEngine::autoDragItemIntoRoom(Item *item, Sprite *draggingSprite) {	
+	if (g_AIArea)
+		g_AIArea->lockAIOut();
+
+	Common::Point start, stop;
+	draggingSprite->getLocation(start.x, start.y);
+
+	Hotspot *dropSpot = _neighborhood->getItemScreenSpot(item, draggingSprite);
+
+	if (dropSpot) {
+		dropSpot->getCenter(stop.x, stop.y);
+	} else {
+		stop.x = kNavAreaLeft + 256;
+		stop.y = kNavAreaTop + 128;
+	}
+
+	Common::Rect bounds;
+	draggingSprite->getBounds(bounds);
+	stop.x -= bounds.width() >> 1;
+	stop.y -= bounds.height() >> 1;
+
+	int dx = ABS(stop.x - start.x);
+	int dy = ABS(stop.y = start.y);
+	TimeValue time = MAX(dx, dy);
+
+	allowInput(false);
+	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
+
+	while (_autoDragger.isDragging()) {
+		checkCallBacks();
+		refreshDisplay();
+		_system->delayMillis(10);
+	}
+
+	_neighborhood->dropItemIntoRoom(_draggingItem, dropSpot);
+	allowInput(true);
+	delete _draggingSprite;
+
+	if (g_AIArea)
+		g_AIArea->unlockAI();
+}
+
+void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {	
+	if (g_AIArea)
+		g_AIArea->lockAIOut();
+
+	Common::Point start;
+	draggingSprite->getLocation(start.x, start.y);
+
+	Common::Rect r;
+	draggingSprite->getBounds(r);
+
+	Common::Point stop((76 + 172 - r.width()) / 2, 334 - (2 * r.height() / 3));
+
+	int dx = ABS(stop.x - start.x);
+	int dy = ABS(stop.y = start.y);
+	TimeValue time = MAX(dx, dy);
+
+	allowInput(false);
+	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
+
+	while (_autoDragger.isDragging()) {
+		checkCallBacks();
+		refreshDisplay();
+		_system->delayMillis(10);
+	}
+
+	addItemToInventory((InventoryItem *)_draggingItem);
+	allowInput(true);
+	delete _draggingSprite;
+
+	if (g_AIArea)
+		g_AIArea->unlockAI();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index a79d2a7..277f3bd 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -39,6 +39,7 @@
 #include "pegasus/hotspot.h"
 #include "pegasus/input.h"
 #include "pegasus/notification.h"
+#include "pegasus/items/autodragger.h"
 #include "pegasus/items/inventory.h"
 #include "pegasus/items/itemdragger.h"
 #include "pegasus/neighborhood/neighborhood.h"
@@ -157,9 +158,11 @@ public:
 	// Dragging
 	void dragItem(const Input &, Item *, tDragType);
 	bool isDragging() const { return _dragType != kDragNoDrag; }
-	tDragType getDragType() const { return _dragType; } // TODO
-	Item *getDraggingItem() const { return _draggingItem; } // TODO
+	tDragType getDragType() const { return _dragType; }
+	Item *getDraggingItem() const { return _draggingItem; }
 	void dragTerminated(const Input &);
+	void autoDragItemIntoRoom(Item *, Sprite *);
+	void autoDragItemIntoInventory(Item *, Sprite*);
 
 	// Save/Load
 	void makeContinuePoint();
@@ -268,6 +271,7 @@ private:
 	Item *_draggingItem;
 	Sprite *_draggingSprite;
 	tDragType _dragType;
+	AutoDragger _autoDragger;
 
 	// Interface
 	void toggleInventoryDisplay();


Commit: 1fe7ca1d3868a701a2e53c08fbbeaac69df74dd0
    https://github.com/scummvm/scummvm/commit/1fe7ca1d3868a701a2e53c08fbbeaac69df74dd0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T16:45:17-07:00

Commit Message:
PEGASUS: Update save/load code a bit

Changed paths:
    engines/pegasus/detection.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index af651c8..fe797b4 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -77,7 +77,7 @@ static const PegasusGameDescription gameDescriptions[] = {
 			Common::EN_ANY,
 			Common::kPlatformMacintosh,
 			ADGF_MACRESFORK|ADGF_DEMO,
-			Common::GUIO_NONE
+			Common::GUIO_NOLAUNCHLOAD
 		},
 	},
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 9cb1bd2..ac6946d 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -326,7 +326,13 @@ void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
 }
 
 bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
-	// TODO: Dispose currently running stuff (neighborhood, etc.)
+	// Dispose currently running stuff
+	useMenu(0);
+	useNeighborhood(0);
+	removeAllItemsFromInventory();
+	removeAllItemsFromBiochips();
+	_currentItemID = kNoItemID;
+	_currentBiochipID = kNoItemID;
 
 	// Signature
 	uint32 creator = stream->readUint32BE();
@@ -370,18 +376,48 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	// Death reason
 	setEnergyDeathReason(stream->readByte());
 
-	// TODO: This is as far as we can go right now
+	// TODO: This is as far as we can go right now (until I implement the mapping biochip and AI rules loading)
 	return true;
 
 	// Items
 	g_allItems.readFromStream(stream);
 
-	// TODO: Player Inventory
-	// TODO: Player BioChips
+	// Inventory
+	uint32 itemCount = stream->readUint32BE();
+
+	if (itemCount > 0) {
+		for (uint32 i = 0; i < itemCount; i++) {
+			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((tItemID)stream->readUint16BE());
+			addItemToInventory(inv);
+		}
+
+		g_interface->setCurrentInventoryItemID((tItemID)stream->readUint16BE());
+	}
+
+	// Biochips
+	uint32 biochipCount = stream->readUint32BE();
+
+	if (biochipCount > 0) {
+		for (uint32 i = 0; i < biochipCount; i++) {
+			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((tItemID)stream->readUint16BE());
+			addItemToBiochips(biochip);
+		}
+
+		g_interface->setCurrentBiochipID((tItemID)stream->readUint16BE());
+	}
+
+
 	// TODO: Disc check
-	// TODO: Jump to environment
+
+	// Jump to environment
+	jumpToNewEnvironment(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
+	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
+	performJump(GameState.getCurrentNeighborhood());
+
 	// TODO: AI rules
 
+	startNeighborhood();
+
 	// Make a new continue point if this isn't already one
 	if (saveType == kNormalSave)
 		makeContinuePoint();
@@ -417,10 +453,30 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	// Items
 	g_allItems.writeToStream(stream);
 
-	// TODO: Player Inventory
-	// TODO: Player BioChips
-	// TODO: Jump to environment
+	// Inventory
+	uint32 itemCount = _items.getNumItems();
+	stream->writeUint32BE(itemCount);
+
+	if (itemCount > 0) {
+		for (uint32 i = 0; i < itemCount; i++)
+			stream->writeUint16BE(_items.getItemIDAt(i));
+
+		stream->writeUint16BE(g_interface->getCurrentInventoryItem()->getObjectID());
+	}
+
+	// Biochips
+	uint32 biochipCount = _biochips.getNumItems();
+	stream->writeUint32BE(biochipCount);
+
+	if (itemCount > 0) {
+		for (uint32 i = 0; i < biochipCount; i++)
+			stream->writeUint16BE(_biochips.getItemIDAt(i));
+
+		stream->writeUint16BE(g_interface->getCurrentBiochip()->getObjectID());
+	}
+
 	// TODO: AI rules
+
 	return true;
 }
 
@@ -440,8 +496,6 @@ void PegasusEngine::loadFromContinuePoint() {
 
 	if (!loadFromStream(_continuePoint))
 		error("Failed loading continue point");
-
-	error("STUB: loadFromContinuePoint()");
 }
 
 Common::Error PegasusEngine::loadGameState(int slot) {
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 277f3bd..6f2309a 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -73,8 +73,8 @@ public:
 	const PegasusGameDescription *_gameDescription;
 	bool hasFeature(EngineFeature f) const;
 	GUI::Debugger *getDebugger();
-	bool canLoadGameStateCurrently() { return _loadAllowed; }
-	bool canSaveGameStateCurrently() { return _saveAllowed; }
+	bool canLoadGameStateCurrently() { return _loadAllowed && !isDemo(); }
+	bool canSaveGameStateCurrently() { return _saveAllowed && !isDemo(); }
 	Common::Error loadGameState(int slot);
 	Common::Error saveGameState(int slot, const Common::String &desc);
 


Commit: c4c83e2346e9a281e84c423717c0fc23d402d698
    https://github.com/scummvm/scummvm/commit/c4c83e2346e9a281e84c423717c0fc23d402d698
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T17:12:51-07:00

Commit Message:
PEGASUS: Resolve some TODO's and cleanup

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 6cce9dd..e0bf6fd 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -201,5 +201,13 @@ DisplayElement *GraphicsManager::findDisplayElement(const tDisplayElementID id)
 
 	return 0;
 }
+
+void GraphicsManager::doFadeOutSync() {
+	// TODO
+}
+
+void GraphicsManager::doFadeInSync() {
+	// TODO
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index fffa3a6..8745243 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -54,6 +54,8 @@ public:
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
 	DisplayElement *findDisplayElement(const tDisplayElementID id);
+	void doFadeOutSync();
+	void doFadeInSync();
 
 private:		
 	PegasusEngine *_vm;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ac6946d..5996d97 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -643,15 +643,15 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 	case kMenuCmdCredits:
 		if (isDemo()) {
 			showTempScreen("Images/Demo/DemoCredits.pict");
-			// TODO: Fade out
+			_gfx->doFadeOutSync();
 			_gfx->updateDisplay();
-			// TODO: Fade in
+			_gfx->doFadeInSync();
 		} else {
 			// TODO: Stop intro timer
-			// TODO: Fade out
+			_gfx->doFadeOutSync();
 			useMenu(new CreditsMenu());
 			_gfx->updateDisplay();
-			// TODO: Fade in
+			_gfx->doFadeInSync();
 		}
 		break;
 	case kMenuCmdQuit:
@@ -674,22 +674,22 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		error("Load game");
 		break;
 	case kMenuCmdCreditsMainMenu:
-		// TODO: Fade out
+		_gfx->doFadeOutSync();
 		useMenu(new MainMenu());
 		_gfx->updateDisplay();
 		((MainMenu *)_gameMenu)->startMainMenuLoop();
-		// TODO: Fade in
+		_gfx->doFadeInSync();
 		resetIntroTimer();
 		break;
 	case kMenuCmdDeathContinue:
 		if (((DeathMenu *)_gameMenu)->playerWon()) {
 			if (isDemo()) {
 				showTempScreen("Images/Demo/DemoCredits.pict");
-				// TODO: Fade out
+				_gfx->doFadeOutSync();
 				_gfx->updateDisplay();
-				// TODO: Fade in
+				_gfx->doFadeInSync();
 			} else {
-				// TODO: Fade out
+				_gfx->doFadeOutSync();
 				useMenu(0);
 				_gfx->clearScreen();
 				_gfx->updateDisplay();
@@ -711,7 +711,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 				useMenu(new MainMenu());
 				_gfx->updateDisplay();
 				((MainMenu *)_gameMenu)->startMainMenuLoop();
-				// TODO: Fade in
+				_gfx->doFadeInSync();
 				resetIntroTimer();
 			}
 		} else {
@@ -720,11 +720,11 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		break;
 	case kMenuCmdDeathMainMenuDemo:
 	case kMenuCmdDeathMainMenu:
-		// TODO: Fade out
+		_gfx->doFadeOutSync();
 		useMenu(new MainMenu());
 		_gfx->updateDisplay();
 		((MainMenu *)_gameMenu)->startMainMenuLoop();
-		// TODO: Fade in
+		_gfx->doFadeInSync();
 		if (!isDemo())
 			resetIntroTimer();
 		break;
@@ -738,13 +738,13 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		error("Load game");
 		break;
 	case kMenuCmdPauseQuit:
-		// TODO: Fade out
+		_gfx->doFadeOutSync();
 		throwAwayEverything();
 		pauseMenu(false);
 		useMenu(new MainMenu());
 		_gfx->updateDisplay();
 		((MainMenu *)_gameMenu)->startMainMenuLoop();
-		// TODO: Fade in
+		_gfx->doFadeInSync();
 		if (!isDemo())
 			resetIntroTimer();
 		break;
@@ -765,7 +765,6 @@ void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 		_console->onFrame();
 	}
 
-	// TODO: Quit request
 	// TODO: Save request
 	// TODO: Load request
 }
@@ -786,7 +785,7 @@ void PegasusEngine::doInterfaceOverview() {
 		Common::Rect(542, 36, 542 + 58, 36 + 20)
 	};
 
-	// TODO: fade out
+	_gfx->doFadeOutSync();
 	useMenu(0);
 
 	Picture leftBackground(kNoDisplayElement);
@@ -878,7 +877,7 @@ void PegasusEngine::doInterfaceOverview() {
 	_cursor->show();
 
 	_gfx->updateDisplay();
-	// TODO: Fade in
+	_gfx->doFadeInSync();
 
 	for (;;) {
 		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
@@ -924,17 +923,17 @@ void PegasusEngine::doInterfaceOverview() {
 	highlight.hide();
 	_cursor->hide();
 
-	// TODO: Fade out
+	_gfx->doFadeOutSync();
 	useMenu(new MainMenu());
 	_gfx->updateDisplay();
 	((MainMenu *)_gameMenu)->startMainMenuLoop();
-	// TODO: Fade in
+	_gfx->doFadeInSync();
 
 	// TODO: Cancel save/load requests?
 }
 
 void PegasusEngine::showTempScreen(const Common::String &fileName) {
-	// TODO: Fade out
+	_gfx->doFadeOutSync();
 
 	Picture picture(0);
 	picture.initFromPICTFile(fileName);
@@ -943,7 +942,7 @@ void PegasusEngine::showTempScreen(const Common::String &fileName) {
 	picture.show();
 	_gfx->updateDisplay();
 
-	// TODO: Fade in
+	_gfx->doFadeInSync();
 
 	// Wait for the next event
 	bool done = false;
@@ -971,8 +970,21 @@ void PegasusEngine::refreshDisplay() {
 }
 
 void PegasusEngine::resetEnergyDeathReason() {
-	// TODO!
-	_deathReason = kDeathStranded;
+	switch (getCurrentNeighborhoodID()) {
+	case kMarsID:
+		_deathReason = kDeathArrestedInMars;
+		break;
+	case kNoradAlphaID:
+	case kNoradDeltaID:
+		_deathReason = kDeathArrestedInNorad;
+		break;
+	case kWSCID:
+		_deathReason = kDeathArrestedInWSC;
+		break;
+	default:
+		_deathReason = kDeathStranded;
+		break;
+	}
 }
 
 bool PegasusEngine::playerHasItem(const Item *item) {
@@ -1121,18 +1133,20 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x
 }
 
 void PegasusEngine::die(const tDeathReason reason) {
-	// TODO: Stop dragging
+	Input dummy;
+	if (isDragging())
+		_itemDragger.stopTracking(dummy);
 
 	_deathReason = reason;
 	_shellNotification.setNotificationFlags(kPlayerDiedFlag, kPlayerDiedFlag);
 }
 
 void PegasusEngine::doDeath() {
-	// TODO: Fade out
+	_gfx->doFadeOutSync();
 	throwAwayEverything();
 	useMenu(new DeathMenu(_deathReason));
 	_gfx->updateDisplay();
-	// TODO: Fade in
+	_gfx->doFadeInSync();
 }
 
 void PegasusEngine::throwAwayEverything() {
@@ -1299,7 +1313,7 @@ void PegasusEngine::startNewGame() {
 	GameState.setWalkthroughMode(isWalkthrough);
 
 	// TODO: Enable erase
-	// TODO: Fade out
+	_gfx->doFadeOutSync();
 	useMenu(0);
 	_gfx->updateDisplay();
 
@@ -1830,4 +1844,11 @@ void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {
 		g_AIArea->unlockAI();
 }
 
+tNeighborhoodID PegasusEngine::getCurrentNeighborhoodID() const {
+	if (_neighborhood)
+		return _neighborhood->getObjectID();
+
+	return kNoNeighborhoodID;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 6f2309a..e8e67b5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -154,6 +154,7 @@ public:
 
 	// Neighborhood
 	void jumpToNewEnvironment(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	tNeighborhoodID getCurrentNeighborhoodID() const;
 
 	// Dragging
 	void dragItem(const Input &, Item *, tDragType);


Commit: 821813e808453ba965872e36676daa5222c480a6
    https://github.com/scummvm/scummvm/commit/821813e808453ba965872e36676daa5222c480a6
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T17:28:12-07:00

Commit Message:
PEGASUS: Allow saving/loading of AI rules

Changed paths:
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/ai/ai_area.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 0b7e435..8a135ed 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -79,6 +79,14 @@ void AIArea::restoreAIState() {
 	// TODO
 }
 
+void AIArea::writeAIRules(Common::WriteStream *stream) {
+	_AIRules.writeAIRules(stream);
+}
+
+void AIArea::readAIRules(Common::ReadStream *stream) {
+	_AIRules.readAIRules(stream);
+}
+
 void AIArea::initAIArea() {
 	allocateSurface(Common::Rect(0, 0, 384, 96));
 	
diff --git a/engines/pegasus/ai/ai_area.h b/engines/pegasus/ai/ai_area.h
index 0338f2b..7387b40 100755
--- a/engines/pegasus/ai/ai_area.h
+++ b/engines/pegasus/ai/ai_area.h
@@ -31,6 +31,11 @@
 #include "pegasus/timers.h"
 #include "pegasus/ai/ai_rule.h"
 
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
 /*
 
 	The AI area is the area at the bottom of the screen. There are three areas within
@@ -80,6 +85,9 @@ public:
 	AIArea(InputHandler *);
 	virtual ~AIArea();
 
+	void writeAIRules(Common::WriteStream *stream);
+	void readAIRules(Common::ReadStream *stream);
+
 	void initAIArea();
 
 	void saveAIState();
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5996d97..887a7cc 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -414,7 +414,9 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 	performJump(GameState.getCurrentNeighborhood());
 
-	// TODO: AI rules
+	// AI rules
+	if (g_AIArea)
+		g_AIArea->readAIRules(stream);
 
 	startNeighborhood();
 
@@ -475,7 +477,9 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 		stream->writeUint16BE(g_interface->getCurrentBiochip()->getObjectID());
 	}
 
-	// TODO: AI rules
+	// AI rules
+	if (g_AIArea)
+		g_AIArea->writeAIRules(stream);
 
 	return true;
 }


Commit: 06e2dbaa43c4d2aacf4e21dda79ef6fbfa4d82fb
    https://github.com/scummvm/scummvm/commit/06e2dbaa43c4d2aacf4e21dda79ef6fbfa4d82fb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T19:30:35-07:00

Commit Message:
PEGASUS: Fix stupid typo stopping the current biochip from being found

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 887a7cc..5fda8cc 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1016,7 +1016,7 @@ bool PegasusEngine::itemInInventory(tItemID id) {
 
 BiochipItem *PegasusEngine::getCurrentBiochip() {
 	if (g_interface)
-		g_interface->getCurrentBiochip();
+		return g_interface->getCurrentBiochip();
 
 	return 0;
 }


Commit: fdd50e8414070055e77bf61fcc5837841af2b014
    https://github.com/scummvm/scummvm/commit/fdd50e8414070055e77bf61fcc5837841af2b014
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T20:29:53-07:00

Commit Message:
PEGASUS: Fix cursor not showing up

Changed paths:
    engines/pegasus/cursor.cpp



diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
index c0af27b..9fa921a 100755
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@ -38,6 +38,7 @@ namespace Pegasus {
 Cursor::Cursor() {
 	_cursorObscured = false;
 	_index = -1;
+	startIdling();
 }
 
 Cursor::~Cursor() {
@@ -48,6 +49,8 @@ Cursor::~Cursor() {
 		}
 		delete[] _info[i].palette;
 	}
+
+	stopIdling();
 }
 
 void Cursor::addCursorFrames(uint16 id) {


Commit: e299f0ac7282313de737715ff427db76f6045cf1
    https://github.com/scummvm/scummvm/commit/e299f0ac7282313de737715ff427db76f6045cf1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T20:33:12-07:00

Commit Message:
PEGASUS: Fix drag sprite transparency

Changed paths:
    engines/pegasus/items/item.cpp



diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index e20549e..bcb85de 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -280,12 +280,12 @@ Sprite *Item::getDragSprite(const tDisplayElementID id) const {
 	Sprite *result = new Sprite(id);
 	SpriteFrame *frame = new SpriteFrame();
 
-	frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteNormalID);
+	frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteNormalID, true);
 	result->addFrame(frame, 0, 0);
 
 	if (_itemInfo.dragSpriteNormalID != _itemInfo.dragSpriteUsedID) {
 		frame = new SpriteFrame();
-		frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteUsedID);
+		frame->initFromPICTResource(vm->_resFork, _itemInfo.dragSpriteUsedID, true);
 	}
 
 	result->addFrame(frame, 0, 0);


Commit: 035cf8a7b34762a7dc59fb7763e600c2718fee00
    https://github.com/scummvm/scummvm/commit/035cf8a7b34762a7dc59fb7763e600c2718fee00
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T22:04:43-07:00

Commit Message:
PEGASUS: Fix AI videos not updating

Changed paths:
    engines/pegasus/ai/ai_area.cpp



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 8a135ed..0ccb935 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -299,6 +299,7 @@ bool AIArea::playAIMovie(const tLowerAreaSignature area, const Common::String &m
 			break;
 		}
 
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}


Commit: 23c7b9f0dc93181a388fb577e26fb9505c8f852f
    https://github.com/scummvm/scummvm/commit/23c7b9f0dc93181a388fb577e26fb9505c8f852f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-29T22:14:11-07:00

Commit Message:
PEGASUS: Introduce better cursor update code

Changed paths:
    engines/pegasus/cursor.cpp
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h



diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
index 9fa921a..ee3ab87 100755
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@ -31,6 +31,7 @@
 #include "graphics/surface.h"
 
 #include "pegasus/cursor.h"
+#include "pegasus/graphics.h"
 #include "pegasus/pegasus.h"
 
 namespace Pegasus {
@@ -83,6 +84,7 @@ void Cursor::setCurrentFrameIndex(int32 index) {
 			loadCursorImage(_info[index]);
 			CursorMan.replaceCursorPalette(_info[index].palette, 0, _info[index].colorCount);
 			CursorMan.replaceCursor((byte *)_info[index].surface->pixels, _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, 0);
+			((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 		}
 	}
 }
@@ -96,6 +98,7 @@ void Cursor::show() {
 		CursorMan.showMouse(true);
 
 	_cursorObscured = false;
+	((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 }
 
 void Cursor::hide() {
@@ -115,6 +118,7 @@ void Cursor::useIdleTime() {
 		_cursorLocation = g_system->getEventManager()->getMousePos();
 		if (_index != -1 && _cursorObscured)
 			show();
+		((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 	}
 }
 
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index e0bf6fd..8e5c86d 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -43,7 +43,6 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_frontLayer = kMaxAvailableOrder;
 	_firstDisplayElement = _lastDisplayElement = 0;
 	_workArea.create(640, 480, _vm->_system->getScreenFormat());
-	_lastMousePosition = Common::Point(-1, -1);
 	_modifiedScreen = false;
 }
 	
@@ -149,13 +148,6 @@ void GraphicsManager::removeDisplayElement(DisplayElement *oldElement) {
 void GraphicsManager::updateDisplay() {
 	bool screenDirty = false;
 
-	// TODO: Check for cursor change
-	Common::Point mousePos = g_system->getEventManager()->getMousePos();
-	if (_lastMousePosition != mousePos) {
-		screenDirty = true;
-		_lastMousePosition = mousePos;
-	}
-
 	if (!_dirtyRect.isEmpty()) {
 		for (DisplayElement *runner = _firstDisplayElement; runner != 0; runner = runner->_nextElement) {
 			Common::Rect bounds;
@@ -209,5 +201,9 @@ void GraphicsManager::doFadeOutSync() {
 void GraphicsManager::doFadeInSync() {
 	// TODO
 }
+
+void GraphicsManager::markCursorAsDirty() {
+	_modifiedScreen = true;
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 8745243..7aeb3c9 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -37,10 +37,12 @@
 
 namespace Pegasus {
 
+class Cursor;
 class DisplayElement;
 class PegasusEngine;
 
 class GraphicsManager {
+friend class Cursor;
 public:
 	GraphicsManager(PegasusEngine *vm);
 	~GraphicsManager();
@@ -57,6 +59,9 @@ public:
 	void doFadeOutSync();
 	void doFadeInSync();
 
+protected:
+	void markCursorAsDirty();
+
 private:		
 	PegasusEngine *_vm;
 
@@ -65,7 +70,6 @@ private:
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 	Graphics::Surface _workArea;
-	Common::Point _lastMousePosition;
 };
 
 } // End of namespace Pegasus


Commit: ec67dfae307736a4001bc76a64db47cc7e34f68f
    https://github.com/scummvm/scummvm/commit/ec67dfae307736a4001bc76a64db47cc7e34f68f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T09:26:49-07:00

Commit Message:
GRAPHICS: Add support for true 32bpp DirectBits images

Changed paths:
    graphics/pict.cpp



diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index a4cc67f..b2d8140 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -331,7 +331,7 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
 	if (packBitsData.pixMap.pixelSize <= 8)
 		bytesPerPixel = 1;
 	else if (packBitsData.pixMap.pixelSize == 32)
-		bytesPerPixel = 3;
+		bytesPerPixel = packBitsData.pixMap.cmpCount;
 	else
 		bytesPerPixel = packBitsData.pixMap.pixelSize / 8;
 
@@ -357,10 +357,12 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
 		}
 	}
 
-	if (bytesPerPixel == 1) {
+	switch (bytesPerPixel) {
+	case 1:
 		// Just copy to the image
 		memcpy(_outputSurface->pixels, buffer, _outputSurface->w * _outputSurface->h);
-	} else if (bytesPerPixel == 2) {
+		break;
+	case 2:
 		// Convert from 16-bit to whatever surface we need
 		for (uint16 y = 0; y < _outputSurface->h; y++) {
 			for (uint16 x = 0; x < _outputSurface->w; x++) {
@@ -373,7 +375,8 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
 					*((uint32 *)_outputSurface->getBasePtr(x, y)) = _pixelFormat.RGBToColor(r, g, b);
 			}
 		}
-	} else {
+		break;
+	case 3:
 		// Convert from 24-bit (planar!) to whatever surface we need
 		for (uint16 y = 0; y < _outputSurface->h; y++) {
 			for (uint16 x = 0; x < _outputSurface->w; x++) {
@@ -386,6 +389,22 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
 					*((uint32 *)_outputSurface->getBasePtr(x, y)) = _pixelFormat.RGBToColor(r, g, b);
 			}
 		}
+		break;
+	case 4:
+		// Convert from 32-bit (planar!) to whatever surface we need
+		for (uint16 y = 0; y < _outputSurface->h; y++) {
+			for (uint16 x = 0; x < _outputSurface->w; x++) {
+				byte r = *(buffer + y * _outputSurface->w * 4 + x);
+				byte g = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w + x);
+				byte b = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 2 + x);
+				byte a = *(buffer + y * _outputSurface->w * 4 + _outputSurface->w * 3 + x);
+				if (_pixelFormat.bytesPerPixel == 2)
+					*((uint16 *)_outputSurface->getBasePtr(x, y)) = _pixelFormat.ARGBToColor(r, g, b, a);
+				else
+					*((uint32 *)_outputSurface->getBasePtr(x, y)) = _pixelFormat.ARGBToColor(r, g, b, a);
+			}
+		}
+		break;
 	}
 
 	delete[] buffer;
@@ -421,7 +440,7 @@ void PictDecoder::unpackBitsLine(byte *out, uint32 length, Common::SeekableReadS
 		}
 	}
 
-	// HACK: rowBytes is in 32-bit, but the data is 24-bit...
+	// HACK: Even if the data is 24-bit, rowBytes is still 32-bit
 	if (bytesPerPixel == 3)
 		dataDecoded += length / 4;
 


Commit: b5af4bfc76eca31c1c784e944471dbdb2e4b0d1a
    https://github.com/scummvm/scummvm/commit/b5af4bfc76eca31c1c784e944471dbdb2e4b0d1a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T09:35:06-07:00

Commit Message:
PEGASUS: Fix typos in autoDragItemIntoInventory/Room

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5fda8cc..5c25be2 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1795,7 +1795,7 @@ void PegasusEngine::autoDragItemIntoRoom(Item *item, Sprite *draggingSprite) {
 	stop.y -= bounds.height() >> 1;
 
 	int dx = ABS(stop.x - start.x);
-	int dy = ABS(stop.y = start.y);
+	int dy = ABS(stop.y - start.y);
 	TimeValue time = MAX(dx, dy);
 
 	allowInput(false);
@@ -1828,7 +1828,7 @@ void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {
 	Common::Point stop((76 + 172 - r.width()) / 2, 334 - (2 * r.height() / 3));
 
 	int dx = ABS(stop.x - start.x);
-	int dy = ABS(stop.y = start.y);
+	int dy = ABS(stop.y - start.y);
 	TimeValue time = MAX(dx, dy);
 
 	allowInput(false);


Commit: 9be43b24ce9d7b4016139ce00b29c891717a12d3
    https://github.com/scummvm/scummvm/commit/9be43b24ce9d7b4016139ce00b29c891717a12d3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T09:52:04-07:00

Commit Message:
PEGASUS: Fix auto dragging

Changed paths:
    engines/pegasus/items/autodragger.cpp



diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp
index baad699..de03f81 100755
--- a/engines/pegasus/items/autodragger.cpp
+++ b/engines/pegasus/items/autodragger.cpp
@@ -73,9 +73,9 @@ void AutoDragger::useIdleTime() {
 	TimeValue thisTime = getTime();
 
 	if (thisTime != _lastTime) {
-		uint32 offsetX = (_stopLocation.x - _startLocation.x) * thisTime / getDuration();
-		uint32 offsetY = (_stopLocation.y - _startLocation.y) * thisTime / getDuration();
-		_draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.x + offsetY);
+		int32 offsetX = (_stopLocation.x - _startLocation.x) * (int32)thisTime / (int32)getDuration();
+		int32 offsetY = (_stopLocation.y - _startLocation.y) * (int32)thisTime / (int32)getDuration();
+		_draggingElement->moveElementTo(_startLocation.x + offsetX, _startLocation.y + offsetY);
 		_lastTime = thisTime;
 	}
 


Commit: 485b427ed8e1b547057dd84683009f43b131333c
    https://github.com/scummvm/scummvm/commit/485b427ed8e1b547057dd84683009f43b131333c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T13:26:31-07:00

Commit Message:
PEGASUS: Actually pause the game now

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 380834f..fa0cb95 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -163,12 +163,19 @@ void Movie::stop() {
 }
 
 void Movie::resume() {
-	if (_video && _video->isPaused())
+	if (_video)
 		_video->pauseVideo(false);
 
 	TimeBase::resume();
 }
 
+void Movie::pause() {
+	if (_video)
+		_video->pauseVideo(true);
+
+	TimeBase::pause();
+}
+
 void Movie::checkCallBacks() {
 	TimeBase::checkCallBacks();
 
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index a724914..3983a6f 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -60,6 +60,7 @@ public:
 	virtual void start();
 	virtual void stop();
 	virtual void resume();
+	virtual void pause();
 
 	virtual void moveMovieBoxTo(const tCoordType, const tCoordType);
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5c25be2..8ecab93 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1759,13 +1759,13 @@ void PegasusEngine::setAmbienceLevel(uint16 ambientLevel) {
 
 void PegasusEngine::pauseMenu(bool menuUp) {
 	if (menuUp) {
-		// TODO: Pause engine
+		pauseEngine(true);
 		_screenDimmer.startDisplaying();
 		_screenDimmer.show();
 		_gfx->updateDisplay();
 		useMenu(new PauseMenu());
 	} else {
-		// TODO: Resume engine
+		pauseEngine(false);
 		_screenDimmer.hide();
 		_screenDimmer.stopDisplaying();
 		useMenu(0);
@@ -1855,4 +1855,16 @@ tNeighborhoodID PegasusEngine::getCurrentNeighborhoodID() const {
 	return kNoNeighborhoodID;
 }
 
+void PegasusEngine::pauseEngineIntern(bool pause) {
+	Engine::pauseEngineIntern(pause);
+
+	if (pause) {
+		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
+			(*it)->pause();
+	} else {
+		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
+			(*it)->resume();
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index e8e67b5..13e975e 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -180,6 +180,7 @@ public:
 
 protected:
 	Common::Error run();
+	void pauseEngineIntern(bool pause);
 
 	Notification _shellNotification;
 	virtual void receiveNotification(Notification *notification, const tNotificationFlags flags);
@@ -233,7 +234,6 @@ private:
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 	void throwAwayEverything();
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
-	bool isPaused() { return false; } // TODO
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: 7227af4676aa465982d94e0e04c52b6e09361b29
    https://github.com/scummvm/scummvm/commit/7227af4676aa465982d94e0e04c52b6e09361b29
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T17:11:58-07:00

Commit Message:
VIDEO: Ensure audio paused status remains after a QuickTime seek

Changed paths:
    video/qt_decoder.cpp



diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index f93f0d6..2dfb56d 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -176,6 +176,10 @@ void QuickTimeDecoder::seekToFrame(uint32 frame) {
 
 		// Restart the audio
 		startAudio();
+
+		// Pause the audio again if we're still paused
+		if (isPaused() && _audStream)
+			g_system->getMixer()->pauseHandle(_audHandle, true);
 	}
 }
 


Commit: ad784cd5e8f2a4a40a6ebc146dc80dcba477b28e
    https://github.com/scummvm/scummvm/commit/ad784cd5e8f2a4a40a6ebc146dc80dcba477b28e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T17:24:28-07:00

Commit Message:
PEGASUS: Fix movie segment looping

Not the best way to handle it, but it works for now

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index fa0cb95..bd81f37 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -192,8 +192,14 @@ void Movie::checkCallBacks() {
 
 		// Stop the video when we go past our end
 		// TODO: Check if this should really be -1
-		if (actualTime >= stopTime - 1)
-			stop();
+		if (actualTime >= stopTime - 1) {
+			// HACK: Handle looping here as well
+			// Should be handled like the rest of TimeBases
+			if (getFlags() & kLoopTimeBase)
+				setTime(_startTime, _startScale);
+			else
+				stop();
+		}
 	}
 }
 


Commit: bfb2ad4778cc4a2c1df72d59dbd999f51881a297
    https://github.com/scummvm/scummvm/commit/bfb2ad4778cc4a2c1df72d59dbd999f51881a297
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T17:32:06-07:00

Commit Message:
PEGASUS: Fix inventory looping positions

Changed paths:
    engines/pegasus/items/inventorypicture.cpp



diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 33f497e..5eef7ef 100755
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -275,7 +275,7 @@ void InventoryItemsPicture::loopCurrentItem() {
 	if (_isLooping) {
 		tCoordType x, y;
 		getItemXY(_currentItemIndex, x, y);
-		_panelMovie.moveElementTo(x, y);
+		_panelMovie.moveMovieBoxTo(x, y);
 		_highlightBounds.moveTo(x, y);
 
 		TimeValue start, stop;


Commit: 9718b8e8036dbdb211e72c6a3d19781d69152230
    https://github.com/scummvm/scummvm/commit/9718b8e8036dbdb211e72c6a3d19781d69152230
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T18:24:01-07:00

Commit Message:
PEGASUS: Ease off the CPU

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 8ecab93..71e4ca0 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -145,8 +145,10 @@ Common::Error PegasusEngine::run() {
 	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
 
-	while (!shouldQuit())
+	while (!shouldQuit()) {
 		processShell();
+		_system->delayMillis(10); // Ease off the CPU
+	}
 
 	return Common::kNoError;
 }


Commit: 05c774bb8bca0a166c0656e73802dfc40667e052
    https://github.com/scummvm/scummvm/commit/05c774bb8bca0a166c0656e73802dfc40667e052
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T19:44:21-07:00

Commit Message:
PEGASUS: Resolve a couple AI TODO's

Changed paths:
    engines/pegasus/ai/ai_condition.cpp



diff --git a/engines/pegasus/ai/ai_condition.cpp b/engines/pegasus/ai/ai_condition.cpp
index f01d5f9..8b77d72 100755
--- a/engines/pegasus/ai/ai_condition.cpp
+++ b/engines/pegasus/ai/ai_condition.cpp
@@ -27,6 +27,7 @@
 
 #include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_condition.h"
 #include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/biochipitem.h"
@@ -230,9 +231,7 @@ AICurrentItemCondition::AICurrentItemCondition(const tItemID item) {
 }
 	
 bool AICurrentItemCondition::fireCondition() {
-	// TODO
-	//InventoryItem *item = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
-	InventoryItem *item = 0;
+	InventoryItem *item = ((PegasusEngine *)g_engine)->getCurrentInventoryItem();
 
 	if (_item == kNoItemID)
 		return item == 0;
@@ -245,9 +244,7 @@ AICurrentBiochipCondition::AICurrentBiochipCondition(const tItemID biochip)  {
 }
 
 bool AICurrentBiochipCondition::fireCondition() {
-	// TODO
-	///BiochipItem *biochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
-	BiochipItem *biochip = 0;
+	BiochipItem *biochip = ((PegasusEngine *)g_engine)->getCurrentBiochip();
 	
 	if (_biochip == kNoItemID)
 		return biochip == 0;
@@ -278,8 +275,7 @@ AILastExtraCondition::AILastExtraCondition(const tExtraID lastExtra) {
 }
 
 bool AILastExtraCondition::fireCondition() {
-	// TODO
-	return false;
+	return g_neighborhood && (tExtraID)g_neighborhood->getLastExtra() == _lastExtra;
 }
 
 AICondition *makeLocationAndDoesntHaveItemCondition(const tRoomID room, const tDirectionConstant direction, const tItemID item) {


Commit: a85165035c34143b2d56a632a718b8a8e553f6db
    https://github.com/scummvm/scummvm/commit/a85165035c34143b2d56a632a718b8a8e553f6db
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-09-30T19:51:09-07:00

Commit Message:
PEGASUS: Fix pausing normal TimeBases

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index d09d029..d610b2f 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -206,9 +206,9 @@ void TimeBase::checkCallBacks() {
 
 	// First step: update the times
 	if (_lastMillis == 0) {
-		_lastMillis = g_system->getMillis();
+		_lastMillis = g_engine->getTotalPlayTime();
 	} else {
-		uint32 curTime = g_system->getMillis();
+		uint32 curTime = g_engine->getTotalPlayTime();
 		if (_lastMillis == curTime) // No change
 			return;
 


Commit: ebb40e26cb3c26a49afb4b8603b5eaf38928dbee
    https://github.com/scummvm/scummvm/commit/ebb40e26cb3c26a49afb4b8603b5eaf38928dbee
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-01T09:11:02-07:00

Commit Message:
PEGASUS: Fix AI movies playing in the wrong box

Changed paths:
    engines/pegasus/ai/ai_area.cpp



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 0ccb935..9f297e3 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -275,6 +275,7 @@ bool AIArea::playAIMovie(const tLowerAreaSignature area, const Common::String &m
 		_leftAreaMovie.hide();
 	} else {
 		_AIMovie.moveElementTo(kAIRightAreaLeft, kAIRightAreaTop);
+		_AIMovie.moveMovieBoxTo(kAIRightAreaLeft - kAILeftAreaLeft, 0);
 		_rightAreaMovie.hide();
 	}
 


Commit: f3e34cde02072adcdf0cde66871d23e88897a61d
    https://github.com/scummvm/scummvm/commit/f3e34cde02072adcdf0cde66871d23e88897a61d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-01T10:09:14-07:00

Commit Message:
PEGASUS: Fix neighborhood callbacks

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 7c77381..4ff762f 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -76,6 +76,14 @@ Neighborhood::~Neighborhood() {
 }
 
 void Neighborhood::init() {
+	_neighborhoodNotification.notifyMe(this, kNeighborhoodFlags, kNeighborhoodFlags);
+	_navMovieCallBack.setNotification(&_neighborhoodNotification);
+	_turnPushCallBack.setNotification(&_neighborhoodNotification);
+	_delayCallBack.setNotification(&_neighborhoodNotification);
+
+	// TODO
+	//_spotSoundCallBack.setNotification(&_neighborhoodNotification);
+
 	debug(0, "Loading '%s' neighborhood resources", _resName.c_str());
 
 	Common::SeekableReadStream *stream = _vm->_resFork->getResource(_doorTable.getResTag(), _resName);


Commit: b24081c781d66cdc496a14b6326574f75b083dc6
    https://github.com/scummvm/scummvm/commit/b24081c781d66cdc496a14b6326574f75b083dc6
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-01T10:21:46-07:00

Commit Message:
PEGASUS: Fix time forward callbacks

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index d610b2f..0b052b5 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -229,7 +229,7 @@ void TimeBase::checkCallBacks() {
 	// Check if we've triggered any callbacks
 	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
 		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
-			if (time >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
+			if (getTime() >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
 				runner->callBack();
 		} else if (runner->_type == kCallBackAtExtremes) {
 			if (runner->_trigger == kTriggerAtStop) {


Commit: 8c7ebc803383a87cf3199b12d5b3485b2685a873
    https://github.com/scummvm/scummvm/commit/8c7ebc803383a87cf3199b12d5b3485b2685a873
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T17:52:09-07:00

Commit Message:
PEGASUS: Add the basic Caldoria neighborhood

Does not include the end-of-game timers and sequence yet. It's currently hooked up to the full game, but does not go beyond the first frame of the wake-up sequence right now.

Changed paths:
  A engines/pegasus/neighborhood/caldoria/caldoria.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria.h
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.h
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.h
    engines/pegasus/constants.h
    engines/pegasus/energymonitor.h
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 4c31b45..5ab2baa 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -739,7 +739,7 @@ static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 // TODO: Remove me
 static const tRoomID kTSA37 = 42;
 static const tRoomID kTinyTSA37 = 0;
-static const tRoomID kCaldoria00 = 1;
+static const tRoomID kTSA00 = 0;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
index cb5d449..cb1170c 100755
--- a/engines/pegasus/energymonitor.h
+++ b/engines/pegasus/energymonitor.h
@@ -53,7 +53,7 @@ protected:
 
 //	These are in seconds.
 //	Max is two hours
-static const uint32 kMaxJMPEnergy = 7200;
+static const uint32 kMaxJMPEnergy = 60 * 1;
 
 static const uint32 kCasualEnergy = kMaxJMPEnergy * 100 / 100;      // 100%
 static const uint32 kWorriedEnergy = kMaxJMPEnergy * 50 / 100;      // 50%
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 8e5c86d..1e529d0 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -194,11 +194,18 @@ DisplayElement *GraphicsManager::findDisplayElement(const tDisplayElementID id)
 	return 0;
 }
 
-void GraphicsManager::doFadeOutSync() {
-	// TODO
+void GraphicsManager::doFadeOutSync(const TimeValue, const TimeValue, uint32 color) {
+	if (color == 0)
+		color = g_system->getScreenFormat().RGBToColor(0, 0, 0);
+
+	// HACK: Until fading out is done, white-out the screen here
+	Graphics::Surface *screen = g_system->lockScreen();
+	screen->fillRect(Common::Rect(0, 0, 640, 480), color);
+	g_system->unlockScreen();
+	g_system->updateScreen();
 }
 
-void GraphicsManager::doFadeInSync() {
+void GraphicsManager::doFadeInSync(const TimeValue, const TimeValue, uint32) {
 	// TODO
 }
 
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 7aeb3c9..e1b3398 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -32,6 +32,7 @@
 #include "graphics/pict.h"
 #include "graphics/surface.h"
 
+#include "pegasus/constants.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/util.h"
 
@@ -56,8 +57,10 @@ public:
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
 	DisplayElement *findDisplayElement(const tDisplayElementID id);
-	void doFadeOutSync();
-	void doFadeInSync();
+
+	// These default to black
+	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
+	void doFadeInSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
 
 protected:
 	void markCursorAsDirty();
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 3759780..66cf70b 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -51,6 +51,10 @@ MODULE_OBJS = \
 	neighborhood/turn.o \
 	neighborhood/view.o \
 	neighborhood/zoom.o \
+	neighborhood/caldoria/caldoria.o \
+	neighborhood/caldoria/caldoria4dsystem.o \
+	neighborhood/caldoria/caldoriamessages.o \
+	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/prehistoric/prehistoric.o
 
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
new file mode 100755
index 0000000..7a5ec1b
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -0,0 +1,1920 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/system.h"
+#include "video/qt_decoder.h"
+
+#include "pegasus/cursor.h"
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/interface.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
+#include "pegasus/neighborhood/caldoria/caldoriamessages.h"
+#include "pegasus/neighborhood/caldoria/caldoriamirror.h"
+
+namespace Pegasus {
+
+const short kVidPhoneAngle = 30;
+const short kReplicatorAngle = 50;
+const short kDrawersAngle = -30;
+const short kCaldoria53Angle = 45;
+const short kCaldoria55Angle = -45;
+
+const TimeValue kSinclairInterruptionTime1 = 2955;
+const TimeValue kSinclairInterruptionTime2 = 6835;
+const TimeValue kSinclairInterruptionTime3 = 9835;
+const TimeValue kSinclairInterruptionTime4 = 12555;
+
+const tInputBits kPullbackInterruptFilter = kFilterAllInput;
+const tInputBits kRecalibrationInterruptFilter = kFilterAllInput;
+
+const TimeValue kCaldoriaReplicatorIntroIn = 4933;
+const TimeValue kCaldoriaReplicatorIntroOut = 6557;
+
+const TimeValue kCaldoriaReplicatorWrongChoiceIn = 6557;
+const TimeValue kCaldoriaReplicatorWrongChoiceOut = 8586;
+
+const TimeValue kCaldoriaReplicatorOJChoiceIn = 8586;
+const TimeValue kCaldoriaReplicatorOJChoiceOut = 11687;
+
+const TimeValue kCaldoriaMessagesIntroIn = 11687;
+const TimeValue kCaldoriaMessagesIntroOut = 13641;
+
+const TimeValue kCaldoriaFirstMessageIn = 13641;
+const TimeValue kCaldoriaFirstMessageOut = 14203;
+
+const TimeValue kCaldoriaSecondMessageIn = 14203;
+const TimeValue kCaldoriaSecondMessageOut = 14750;
+
+const TimeValue kCaldoriaDoorCloseIn = 14750;
+const TimeValue kCaldoriaDoorCloseOut = 15472;
+
+const TimeValue kCaldoriaElevatorCloseIn = 15472;
+const TimeValue kCaldoriaElevatorCloseOut = 16336;
+
+const TimeValue kCaldoriaShowerCloseIn = 16336;
+const TimeValue kCaldoriaShowerCloseOut = 17101;
+
+const TimeValue kCaldoriaGTDoorCloseIn = 17101;
+const TimeValue kCaldoriaGTDoorCloseOut = 18523;
+
+const TimeValue kCaldoriaNobodyHomeIn = 18523;
+const TimeValue kCaldoriaNobodyHomeOut = 21469;
+
+const TimeValue kCaldoriaNoOtherFloorIn = 21469;
+const TimeValue kCaldoriaNoOtherFloorOut = 28013;
+
+const TimeValue kCaldoria4DInstructionsIn = 28013;
+const TimeValue kCaldoria4DInstructionsOut = 29730;
+
+const TimeValue kCaldoriaDrinkOJIn = 33910;
+const TimeValue kCaldoriaDrinkOJOut = 35846;
+
+const TimeValue kCaldoriaNoOtherDestinationIn = 35846;
+const TimeValue kCaldoriaNoOtherDestinationOut = 37877;
+
+const TimeValue kCaldoriaUhghIn = 37877;
+const TimeValue kCaldoriaUhghOut = 38025;
+
+const TimeValue kCaldoriaSinclairShootsOSIn = 38025;
+const TimeValue kCaldoriaSinclairShootsOSOut = 40649;
+
+const TimeValue kCaldoriaScreamingAfterIn = 40649;
+const TimeValue kCaldoriaScreamingAfterOut = 47661;
+
+const TimeValue k4FloorTime = 0;
+
+const TimeValue k4To1Start = 40;
+const TimeValue k4To1Stop = 7720;
+
+const TimeValue k4To5Start = 7720;
+const TimeValue k4To5Stop = 10280;
+
+const TimeValue k4To2Time = 10280;
+
+const TimeValue k4To3Time = 10320;
+
+const TimeValue k1FloorTime = 10360;
+
+const TimeValue k1To4Start = 10400;
+const TimeValue k1To4Stop = 18080;
+
+const TimeValue k1To5Start = 18080;
+const TimeValue k1To5Stop = 28320;
+
+const TimeValue k1To2Time = 28320;
+
+const TimeValue k1To3Time = 28360;
+
+const TimeValue k5FloorTime = 28400;
+
+const TimeValue k5To1Start = 28440;
+const TimeValue k5To1Stop = 38680;
+
+const TimeValue k5To4Start = 38680;
+const TimeValue k5To4Stop = 41240;
+
+const TimeValue k5To2Time = 41240;
+
+const TimeValue k5To3Time = 41280;
+
+//	MMFuseFunction functions...
+
+const tNotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
+
+void doorBombTimerExpiredFunction(FunctionPtr *, void *caldoria) {
+	((Caldoria *)caldoria)->doorBombTimerExpired();
+}
+
+void sinclairTimerExpiredFunction(FunctionPtr *, void *caldoria) {
+	((Caldoria *)caldoria)->sinclairTimerExpired();
+}
+
+Caldoria::Caldoria(InputHandler* nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Caldoria", kCaldoriaID) {
+	setIsItemTaken(kKeyCard);
+	setIsItemTaken(kOrangeJuiceGlassEmpty);
+	GameState.setTakenItemID(kOrangeJuiceGlassFull, GameState.isTakenItemID(kOrangeJuiceGlassEmpty));
+	_zoomOutSpot = 0;
+	_gunSprite = 0;
+}
+
+Caldoria::~Caldoria() {
+}
+
+void Caldoria::init() {
+	Neighborhood::init();
+
+	//	We need this notification flag as well.
+	_neighborhoodNotification.notifyMe(this, kSinclairLoopDoneFlag, kSinclairLoopDoneFlag);
+
+	forceStridingStop(kCaldoria55, kSouth, kAltCaldoriaSinclairDown);
+	forceStridingStop(kCaldoria50, kNorth, kAltCaldoriaSinclairDown);
+}
+
+void Caldoria::start() {	
+	g_energyMonitor->stopEnergyDraining();
+
+	if (!GameState.getCaldoriaSeenPullback()) {
+		_vm->_gfx->doFadeOutSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
+
+		g_system->delayMillis(2 * 1000);
+
+		Video::VideoDecoder *pullbackMovie = new Video::QuickTimeDecoder();
+
+		if (!pullbackMovie->loadFile("Images/Caldoria/Pullback.movie"))
+			error("Could not load pullback movie");
+
+		bool skipped = false;
+		Input input;
+
+		_vm->_gfx->doFadeInSync(kTwoSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
+
+		bool saveAllowed = _vm->swapSaveAllowed(false);
+		bool openAllowed = _vm->swapLoadAllowed(false);
+
+		while (!_vm->shouldQuit() && !pullbackMovie->endOfVideo()) {
+			if (pullbackMovie->needsUpdate()) {
+				const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
+
+				if (frame) {
+					g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
+					g_system->updateScreen();
+				}
+			}
+
+			InputHandler::getCurrentInputDevice()->getInput(input, kPullbackInterruptFilter);
+			if (input.anyInput()) { // TODO: Save/Quit requests
+				skipped = true;
+				break;
+			}
+
+			g_system->delayMillis(10);
+		}
+
+		delete pullbackMovie;
+
+		_vm->swapSaveAllowed(saveAllowed);
+		_vm->swapLoadAllowed(openAllowed);
+
+		ExtraTable::Entry entry;
+
+		if (!skipped) {
+			uint32 white = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
+
+			_vm->_gfx->doFadeOutSync(kThreeSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond, white);
+
+			g_system->delayMillis(3 * 1000 / 2);
+
+			getExtraEntry(kCaldoria00WakeUp1, entry);
+			_navMovie.setTime(entry.movieStart);
+			_navMovie.redrawMovieWorld();
+			_navMovie.show();
+			_vm->refreshDisplay();
+			_vm->_gfx->doFadeInSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond, white);
+		} else {
+			getExtraEntry(kCaldoria00WakeUp1, entry);
+			_navMovie.setTime(entry.movieStart);
+			_navMovie.redrawMovieWorld();
+			_navMovie.show();
+		}
+
+		GameState.setCaldoriaSeenPullback(true);
+	}
+
+	Neighborhood::start();
+}
+
+void Caldoria::flushGameState() {
+	GameState.setCaldoriaFuseTimeLimit(_utilityFuse.getTimeRemaining());
+}
+
+void Caldoria::setUpAIRules() {
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		if (GameState.allTimeZonesFinished()) {
+			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X49NB1", false);
+			AILocationCondition *locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kCaldoria49, kNorth));
+			AIRule *rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+
+#if 0
+			// TODO
+			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X56EH1", false);
+			AIBombActiveCondition *activeCondition = new AIBombActiveCondition;
+			rule = new AIRule(activeCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+#endif
+		} else {
+			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XAB2", false);
+			AITimerCondition *timerCondition = new AITimerCondition(kLateWarning3TimeLimit, 1, true);
+			AILocationCondition *locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kCaldoria44, kEast));
+			AINotCondition *notCondition = new AINotCondition(locCondition);
+			AIAndCondition *andCondition = new AIAndCondition(timerCondition, notCondition);
+			AIRule *rule = new AIRule(andCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+
+			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XAB1", false);
+			timerCondition = new AITimerCondition(kLateWarning2TimeLimit, 1, true);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kCaldoria44, kEast));
+			notCondition = new AINotCondition(locCondition);
+			andCondition = new AIAndCondition(timerCondition, notCondition);
+			rule = new AIRule(andCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+
+			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XA44EB", false);
+			locCondition = new AILocationCondition(3);
+			locCondition->addLocation(MakeRoomView(kCaldoria01, kNorth));
+			locCondition->addLocation(MakeRoomView(kCaldoria01, kEast));
+			locCondition->addLocation(MakeRoomView(kCaldoria01, kSouth));
+			rule = new AIRule(locCondition, messageAction);
+			g_AIArea->addAIRule(rule);
+			
+			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X42WH1", false);
+			AICondition *condition = makeLocationAndDoesntHaveItemCondition(kCaldoria44, kEast, kKeyCard);
+			rule = new AIRule(condition, messageAction);
+			g_AIArea->addAIRule(rule);
+			
+			AIActivateRuleAction *ruleAction = new AIActivateRuleAction(rule);
+			locCondition = new AILocationCondition(1);
+			locCondition->addLocation(MakeRoomView(kCaldoria42, kEast));
+			rule = new AIRule(locCondition, ruleAction);
+			g_AIArea->addAIRule(rule);
+		}
+ 	}
+}
+
+uint16 Caldoria::getDateResID() const {
+	return kDate2318ID;
+}
+
+TimeValue Caldoria::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry extra;	
+	uint32 extraID = 0xffffffff;
+
+	switch (room) {
+	case kCaldoria00:
+		if (direction == kEast && _privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag))
+			extraID = k4DEnvironOpenView;
+		break;
+	case kCaldoriaDrawers:
+		if (direction == kNorth && _privateFlags.getFlag(kCaldoriaPrivateRightDrawerOpenFlag)) {
+			if (GameState.isTakenItemID(kKeyCard))
+				extraID = kRightDrawerOpenViewNoKeys;
+			else
+				extraID = kRightDrawerOpenViewWithKeys;
+		}
+		break;
+	case kCaldoria16:
+		if (direction == kSouth && GameState.getCaldoriaSeenSinclairInElevator())
+			extraID = kCaldoria16SouthViewWithElevator;
+		break;
+	case kCaldoriaReplicator:
+		if (GameState.getCaldoriaMadeOJ() && !(GameState.isTakenItemID(kOrangeJuiceGlassEmpty) || GameState.isTakenItemID(kOrangeJuiceGlassFull)))
+			extraID = kReplicatorNorthViewWithOJ;
+		break;
+	case kCaldoriaKiosk:
+	case kCaldoriaBinoculars:
+		return 0xffffffff;
+	case kCaldoria48:
+		if (direction == kNorth && GameState.getCaldoriaRoofDoorOpen())
+			extraID = kCa48NorthExplosion;
+		break;
+	}
+
+	if (extraID == 0xffffffff)
+		return Neighborhood::getViewTime(room, direction);
+
+	getExtraEntry(extraID, extra);
+	return extra.movieEnd - 1;
+}
+
+void Caldoria::startSpotOnceOnly(TimeValue startTime, TimeValue stopTime) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kCaldoria13, kEast):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen13CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen13CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria14, kEast):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen14CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen14CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria18, kWest):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen18CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen18CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria23, kSouth):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen23CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen23CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria33, kSouth):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen33CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen33CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria36, kNorth):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen36CarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen36CarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria41, kNorth):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41NorthCarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen41NorthCarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria41, kEast):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41EastCarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen41EastCarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	case MakeRoomView(kCaldoria41, kWest):
+		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41WestCarFlag) && _vm->getRandomBit() == 0) {
+			_privateFlags.setFlag(kCaldoriaPrivateSeen41WestCarFlag, true);
+			Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		}
+		break;
+	default:
+		Neighborhood::startSpotOnceOnly(startTime, stopTime);
+		break;
+	}
+}
+
+void Caldoria::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {	
+	Neighborhood::findSpotEntry(room, direction, flags, entry);
+
+	switch (room) {
+	case kCaldoria00:
+		if (direction == kEast && (!GameState.getCaldoriaINNAnnouncing() || GameState.getCaldoriaSeenINN()))
+			entry.clear();
+		break;
+	case kCaldoriaVidPhone:
+		if (direction == kNorth && GameState.getCaldoriaSeenMessages())
+			entry.clear();
+		break;
+	case kCaldoria44:
+		if (direction == kEast && GameState.getLastRoom() != kCaldoria42)
+			entry.clear();
+		break;
+	}
+}
+
+void Caldoria::startExitMovie(const ExitTable::Entry &exitEntry) {
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria05:
+	case kCaldoria07:
+		if (GameState.getCurrentDirection() == kWest)
+			closeCroppedMovie();
+		// fall through
+	case kCaldoria11:
+		if (GameState.getCurrentDirection() == kEast)
+			closeCroppedMovie();
+		break;
+	case kCaldoria13:
+	case kCaldoria14:
+		if (GameState.getCurrentDirection() == kNorth)
+			closeCroppedMovie();
+		break;
+	}
+
+	Neighborhood::startExitMovie(exitEntry);
+}
+
+void Caldoria::startZoomMovie(const ZoomTable::Entry &zoomEntry) {
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria12:
+		if (GameState.getCurrentDirection() == kNorth)
+			closeCroppedMovie();
+		break;
+	}
+
+	Neighborhood::startZoomMovie(zoomEntry);
+}
+
+void Caldoria::startDoorOpenMovie(const TimeValue startTime, const TimeValue stopTime) {
+	if (GameState.getCurrentRoom() == kCaldoria27 || GameState.getCurrentRoom() == kCaldoria28 || GameState.getCurrentRoom() == kCaldoria45)
+		// Must be opening elevator door.
+		closeCroppedMovie();
+
+	if (GameState.getCurrentRoom() == kCaldoria44 && GameState.getLastRoom() != kCaldoria42)
+		startExtraSequence(kArriveAtCaldoriaFromTSA, kDoorOpenCompletedFlag, false);
+	else
+		Neighborhood::startDoorOpenMovie(startTime, stopTime);
+}
+
+void Caldoria::startTurnPush(const tTurnDirection turnDirection, const TimeValue newViewTime, const tDirectionConstant destDirection) {
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria05:
+	case kCaldoria07:
+		if (GameState.getCurrentDirection() == kWest)
+			closeCroppedMovie();
+		break;
+	case kCaldoria11:
+		if (GameState.getCurrentDirection() == kEast)
+			closeCroppedMovie();
+		break;
+	case kCaldoria12:
+	case kCaldoria13:
+	case kCaldoria14:
+	case kCaldoria27:
+	case kCaldoria28:
+	case kCaldoria45:
+		if (GameState.getCurrentDirection() == kNorth)
+			closeCroppedMovie();
+		break;
+	case kCaldoria48:
+		if (_croppedMovie.isSurfaceValid())
+			closeCroppedMovie();
+		break;
+	}
+
+	Neighborhood::startTurnPush(turnDirection, newViewTime, destDirection);
+}
+
+void Caldoria::bumpIntoWall() {
+	requestSpotSound(kCaldoriaUhghIn, kCaldoriaUhghOut, kFilterNoInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+void Caldoria::closeDoorOffScreen(const tRoomID room, const tDirectionConstant direction) {
+	switch (room) {
+	case kCaldoria08:
+		if (direction == kNorth)
+			playSpotSoundSync(kCaldoriaShowerCloseIn, kCaldoriaShowerCloseOut);
+		else
+			playSpotSoundSync(kCaldoriaDoorCloseIn, kCaldoriaDoorCloseOut);
+		break;
+	case kCaldoria09:
+		playSpotSoundSync(kCaldoriaShowerCloseIn, kCaldoriaShowerCloseOut);
+		break;
+	case kCaldoria16:
+	case kCaldoria38:
+	case kCaldoria46:
+	case kCaldoria27:
+	case kCaldoria28:
+	case kCaldoria45:
+		playSpotSoundSync(kCaldoriaElevatorCloseIn, kCaldoriaElevatorCloseOut);
+		break;
+	case kCaldoria44:
+	case kCaldoria42:
+		if (GameState.getCurrentRoom() == kCaldoria42)
+			playSpotSoundSync(kCaldoriaGTDoorCloseIn, kCaldoriaGTDoorCloseOut);
+		break;
+	default:
+		playSpotSoundSync(kCaldoriaDoorCloseIn, kCaldoriaDoorCloseOut);
+		break;
+	}
+}
+
+int16 Caldoria::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	int16 result = Neighborhood::getStaticCompassAngle(room, dir);
+
+	switch (room) {
+	case kCaldoriaVidPhone:
+		result += kVidPhoneAngle;
+		break;
+	case kCaldoriaReplicator:
+		result += kReplicatorAngle;
+		break;
+	case kCaldoriaDrawers:
+		result += kDrawersAngle;
+		break;
+	case kCaldoria53:
+		result += kCaldoria53Angle;
+		break;
+	case kCaldoria55:
+		result += kCaldoria55Angle;
+		break;
+	}
+
+	return result;
+}
+
+void Caldoria::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
+	case MakeRoomView(kCaldoria08, kNorth):
+	case MakeRoomView(kCaldoria09, kSouth):
+		compassMove.insertFaderKnot((exitEntry.movieStart + exitEntry.movieEnd) >> 1, compassMove.getNthKnotValue(0) + 30);
+		break;
+	case MakeRoomView(kCaldoria10, kEast):
+		compassMove.insertFaderKnot(exitEntry.movieStart + 4 * kCaldoriaFrameDuration, 90);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 19 * kCaldoriaFrameDuration, -90);
+		break;
+	case MakeRoomView(kCaldoria42, kWest):
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, -90, exitEntry.movieEnd, 90);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 3 * kCaldoriaFrameDuration, -90);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 33 * kCaldoriaFrameDuration, 90);
+		break;
+	case MakeRoomView(kCaldoria54, kEast):
+		if (getCurrentAlternate() != kAltCaldoriaSinclairDown) {
+			compassMove.insertFaderKnot(exitEntry.movieStart + 16 * kCaldoriaFrameDuration, 135);
+			compassMove.insertFaderKnot(exitEntry.movieEnd, 135);
+		}
+		break;
+	case MakeRoomView(kCaldoria55, kNorth):
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, 315, exitEntry.movieEnd, 270);
+		break;
+	}
+}
+
+void Caldoria::getZoomCompassMove(const ZoomTable::Entry &zoomEntry, FaderMoveSpec &compassMove) {
+	Neighborhood::getZoomCompassMove(zoomEntry, compassMove);
+
+	switch (zoomEntry.hotspot) {
+	case kCaBathroomToiletSpotID:
+		compassMove.insertFaderKnot(zoomEntry.movieStart + 4 * kCaldoriaFrameDuration, 90);
+		compassMove.insertFaderKnot(zoomEntry.movieStart + 19 * kCaldoriaFrameDuration, -90);
+		compassMove.insertFaderKnot(zoomEntry.movieEnd, -90);
+		break;
+	}
+}
+
+void Caldoria::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
+	switch (entry.extra) {
+	case kCaldoria00WakeUp1:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 180);
+		compassMove.insertFaderKnot(entry.movieStart + 1000, 90);
+		compassMove.insertFaderKnot(entry.movieStart + 1640, 120);
+		compassMove.insertFaderKnot(entry.movieStart + 2240, 135);
+		compassMove.insertFaderKnot(entry.movieStart + 2640, 180);
+		break;
+	case kCaldoria00WakeUp2:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 180, entry.movieEnd, 90);
+		compassMove.insertFaderKnot(entry.movieStart + 560, 90);
+		break;
+	case kCaldoria56BombStage1:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 10);
+		compassMove.insertFaderKnot(entry.movieStart + 31 * kCaldoriaFrameDuration, 60);
+		compassMove.insertFaderKnot(entry.movieStart + 49 * kCaldoriaFrameDuration, 60);
+		compassMove.insertFaderKnot(entry.movieStart + 66 * kCaldoriaFrameDuration, 10);
+		break;
+	case kCaldoria56BombStage7:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 10, entry.movieEnd, 90);
+		compassMove.insertFaderKnot(entry.movieStart + 131 * kCaldoriaFrameDuration, 10);
+		compassMove.insertFaderKnot(entry.movieStart + 148 * kCaldoriaFrameDuration, 60);
+		compassMove.insertFaderKnot(entry.movieStart + 165 * kCaldoriaFrameDuration, 60);
+		compassMove.insertFaderKnot(entry.movieEnd - 5 * kCaldoriaFrameDuration, 90);
+		break;
+	default:
+		Neighborhood::getExtraCompassMove(entry, compassMove);
+		break;
+	}
+}
+
+void Caldoria::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+
+	if (room == kCaldoria00 && GameState.getCaldoriaWokenUp())
+		loadLoopSound1("Sounds/Caldoria/Apartment Music.AIFF", 0x100 / 4);
+	else if (room >= kCaldoria01 && room <= kCaldoria14)
+		loadLoopSound1("Sounds/Caldoria/Apartment Music.AIFF", 0x100 / 4);
+	else if (room == kCaldoria27 || room == kCaldoria28 || room == kCaldoria45)
+		loadLoopSound1("Sounds/Caldoria/Elevator Loop.AIFF", 0x100 / 5);
+	else if (room == kCaldoria44)
+		loadLoopSound1("Sounds/Caldoria/TSA Hum Loop.AIFF");
+	else if (room >= kCaldoria15 && room <= kCaldoria48)
+		loadLoopSound1("Sounds/Caldoria/Industrial Nuage.aiff", 2 * 0x100 / 3);
+	else if (room >= kCaldoria49 && room <= kCaldoria56)
+		loadLoopSound1("Sounds/Caldoria/A50NLB00.22K.AIFF", 0x100 / 4);
+}
+
+void Caldoria::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kCaldoria06, kSouth):
+	case MakeRoomView(kCaldoria13, kNorth):
+	case MakeRoomView(kCaldoria16, kSouth):
+	case MakeRoomView(kCaldoria38, kEast):
+	case MakeRoomView(kCaldoria38, kWest):
+	case MakeRoomView(kCaldoria40, kNorth):
+	case MakeRoomView(kCaldoria44, kEast):
+	case MakeRoomView(kCaldoria48, kNorth):
+	case MakeRoomView(kCaldoria49, kNorth):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void Caldoria::spotCompleted() {
+	Neighborhood::spotCompleted();
+	if (GameState.getCurrentRoom() == kCaldoriaBinoculars)
+		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void Caldoria::arriveAt(const tRoomID room, const tDirectionConstant direction) {	
+	switch (room) {
+	case kCaldoria56:
+		if (!GameState.getCaldoriaGunAimed())
+			// Fall through...
+	case kCaldoria49:
+	case kCaldoria50:
+	case kCaldoria51:
+	case kCaldoria52:
+	case kCaldoria53:
+	case kCaldoria54:
+	case kCaldoria55:
+		if (GameState.getCaldoriaSinclairShot())
+			setCurrentAlternate(kAltCaldoriaSinclairDown);
+		break;
+	}
+
+	Neighborhood::arriveAt(room, direction);
+	Input dummy;
+
+	switch (room) {
+	case kCaldoria00:
+		arriveAtCaldoria00();
+		break;
+	case kCaldoria05:
+		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
+			loopCroppedMovie("Images/Caldoria/A05 Light Loop", kCaldoriaA05LightLoopLeft, kCaldoriaA05LightLoopTop);
+		break;
+	case kCaldoria07:
+		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
+			loopCroppedMovie("Images/Caldoria/A07 Light Loop", kCaldoriaA07LightLoopLeft, kCaldoriaA07LightLoopTop);
+		break;
+	case kCaldoria09:
+		_lastExtra = 0xffffffff;
+		break;
+	case kCaldoriaToilet:
+		GameState.setScoringReadPaper(true);
+		break;
+	case kCaldoriaReplicator:
+		setCurrentActivation(kActivateReplicatorReady);
+		requestSpotSound(kCaldoriaReplicatorIntroIn, kCaldoriaReplicatorIntroOut, kFilterNoInput, 0);
+		break;
+	case kCaldoria11:
+		setCurrentAlternate(kAltCaldoriaNormal);
+		if (direction == kEast && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A11 Message Machine Loop", kCaldoria11MessageLoopLeft, kCaldoria11MessageLoopTop);
+		break;
+	case kCaldoria12:
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A12 Message Machine Loop", kCaldoria12MessageLoopLeft, kCaldoria12MessageLoopTop);
+		break;
+	case kCaldoriaDrawers:
+		setCurrentActivation(kActivateDrawersClosed);
+		break;
+	case kCaldoria13:
+		GameState.setCaldoriaINNAnnouncing(true);
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A13 Message Machine Loop", kCaldoria13MessageLoopLeft, kCaldoria13MessageLoopTop);
+		break;
+	case kCaldoria14:
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A14 Message Machine Loop", kCaldoria14MessageLoopLeft, kCaldoria14MessageLoopTop);
+		break;
+	case kCaldoria08:
+		if (direction == kWest)
+			setCurrentActivation(kActivateMirrorReady);
+		// Fall through...
+	case kCaldoria15:
+		GameState.setCaldoriaINNAnnouncing(true);
+		break;
+	case kCaldoria27:
+	case kCaldoria28:
+	case kCaldoria45:
+		if (GameState.getCurrentDirection() == kNorth)
+			openDoor();
+		break;
+	case kCaldoriaBinoculars:
+		GameState.setScoringLookThroughTelescope(true);
+		break;
+	case kCaldoriaKiosk:
+		GameState.setScoringSawCaldoriaKiosk(true);
+		startExtraSequenceSync(kCaldoriaKioskVideo, kFilterAllInput);
+		downButton(dummy);
+		break;
+	case kCaldoria44:
+		arriveAtCaldoria44();
+		break;
+	case kCaldoria49:
+		arriveAtCaldoria49();
+		break;
+	case kCaldoria53:
+		if (direction == kEast && !GameState.getCaldoriaSinclairShot())
+			zoomToSinclair();
+		break;
+	case kCaldoria50:
+		if (direction == kNorth && !GameState.getCaldoriaSinclairShot())
+			setUpSinclairLoops();
+		break;
+	case kCaldoria54:
+		if (direction == kSouth && !GameState.getCaldoriaSinclairShot())
+			setUpSinclairLoops();
+		break;
+	case kCaldoria56:
+		arriveAtCaldoria56();
+		break;
+	case kCaldoriaDeathRoom:
+		arriveAtCaldoriaDeath();
+		break;
+	}
+
+	checkSinclairShootsOS();
+	setUpRoofTop();
+}
+
+void Caldoria::doAIRecalibration() {
+	GameState.setCaldoriaDidRecalibration(true);
+	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB1", true, kRecalibrationInterruptFilter))
+		return;
+
+	g_interface->calibrateEnergyBar();
+	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB4", true, kRecalibrationInterruptFilter))
+		return;
+
+	g_interface->raiseInventoryDrawerSync();
+	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB6", true, kRecalibrationInterruptFilter)) {
+		g_interface->lowerInventoryDrawerSync();
+		return;
+	}
+
+	g_interface->lowerInventoryDrawerSync();
+	g_interface->raiseBiochipDrawerSync();
+
+	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB5", true, kRecalibrationInterruptFilter)) {
+		g_interface->lowerBiochipDrawerSync();
+		return;
+	}
+
+	g_interface->lowerBiochipDrawerSync();
+
+	g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB8", false, kRecalibrationInterruptFilter);
+}
+
+void Caldoria::arriveAtCaldoria00() {
+	if (GameState.getCurrentDirection() == kEast) {
+		if (GameState.getCaldoriaWokenUp()) {
+			if (!GameState.getCaldoriaDidRecalibration())
+				doAIRecalibration();
+			setCurrentActivation(kActivate4DClosed);
+		} else {
+			// Good morning, sleeping beauty
+			ExtraTable::Entry extra;
+			getExtraEntry(kCaldoria00WakeUp1, extra);
+
+			if (_navMovie.getTime() != extra.movieStart) {
+				_navMovie.setTime(extra.movieStart);
+				_navMovie.redrawMovieWorld();
+			}
+
+			startExtraSequenceSync(kCaldoria00WakeUp1, kFilterNoInput);
+			GameState.setCaldoriaWokenUp(true);
+			playCroppedMovieOnce("Images/Caldoria/VidPhone.movie", kCaldoriaVidPhoneLeft, kCaldoriaVidPhoneTop, kFilterAllInput);
+			startExtraSequence(kCaldoria00WakeUp2, kExtraCompletedFlag, kFilterNoInput);
+		}
+	}
+}
+
+bool Caldoria::wantsCursor() {
+	return GameState.getCaldoriaDidRecalibration();
+}
+
+void Caldoria::arriveAtCaldoria44() {
+	if (GameState.getLastNeighborhood() != kCaldoriaID) {
+		openDoor();
+	} else {
+		setCurrentActivation(kActivateReadyForCard);
+		loopExtraSequence(kCaldoriaTransporterArrowLoop, 0);
+	}
+}
+
+void Caldoria::arriveAtCaldoria49() {
+	if (GameState.getLastRoom() == kCaldoria48)
+		setCurrentAlternate(kAltCaldoriaNormal);
+
+	// Need to force the loop to play.
+	if (GameState.getCurrentDirection() == kNorth) {
+		GameState.setCaldoriaFuseTimeLimit(kSinclairShootsTimeLimit);
+		startExtraSequence(kCa49NorthVoiceAnalysis, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void Caldoria::arriveAtCaldoria56() {
+	if (!GameState.getCaldoriaBombDisarmed()) {
+		_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, true);
+
+		if (GameState.getCurrentDirection() == kNorth) {
+			turnRight();
+		} else if (GameState.getCurrentDirection() == kSouth) {
+			turnLeft();
+		} else if (GameState.getCurrentDirection() == kEast) {
+			_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, false);
+			newInteraction(kCaldoriaBombInteractionID);
+		}
+	}
+}
+
+void Caldoria::arriveAtCaldoriaDeath() {
+	if (GameState.getLastRoom() == kCaldoria49) {
+		if (GameState.getCaldoriaSinclairShot()) {
+			die(kDeathNuclearExplosion);
+		} else {
+			playSpotSoundSync(kCaldoriaSinclairShootsOSIn, kCaldoriaSinclairShootsOSOut);
+			playSpotSoundSync(kCaldoriaScreamingAfterIn, kCaldoriaScreamingAfterOut);
+			die(kDeathSinclairShotDelegate);
+		}
+	} else {
+		die(kDeathShotBySinclair);
+	}
+}
+
+void Caldoria::setUpRoofTop() {
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria48:
+		if (GameState.getCurrentDirection() == kNorth) {
+			if (GameState.getCaldoriaRoofDoorOpen()) {
+				setCurrentAlternate(kAltCaldoriaRoofDoorBlown);
+			} else if (GameState.getCaldoriaDoorBombed()) {
+				// Long enough for AI hints...?
+				_utilityFuse.primeFuse(kCardBombCountDownTime);
+				_utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
+				_utilityFuse.lightFuse();
+
+				loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
+			} else {
+				setCurrentActivation(kActivateRoofSlotEmpty);
+			}
+		}
+		break;
+	case kCaldoria56:
+		if (GameState.getCurrentDirection() == kEast && GameState.getCaldoriaGunAimed())
+			startExtraSequence(kCa53EastShootSinclair, kExtraCompletedFlag, false);
+		else
+			//	Fall through...
+	case kCaldoria49:
+	case kCaldoria50:
+	case kCaldoria51:
+	case kCaldoria52:
+	case kCaldoria53:
+	case kCaldoria54:
+	case kCaldoria55:
+		if (!GameState.getCaldoriaSinclairShot()) {
+			if (GameState.getCaldoriaSawVoiceAnalysis() && !_utilityFuse.isFuseLit()) {
+				_utilityFuse.primeFuse(GameState.getCaldoriaFuseTimeLimit());
+				_utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void *)this);
+				_utilityFuse.lightFuse();
+			}
+		} else {
+			setCurrentAlternate(kAltCaldoriaSinclairDown);
+		}
+		break;
+	}
+}
+
+void Caldoria::downButton(const Input &input) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kCaldoria01, kEast):
+		GameState.setCaldoriaWokenUp(true);
+		startExtraSequence(kCaldoria00SitDown, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Neighborhood::downButton(input);
+		break;
+	}
+}
+
+void Caldoria::turnTo(const tDirectionConstant direction) {
+	Neighborhood::turnTo(direction);
+
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria00:
+		if (direction == kEast)
+			setCurrentActivation(kActivate4DClosed);
+		break;
+	case kCaldoria01:
+		if (direction == kEast) {
+			GameState.setCaldoriaWokenUp(true);
+			startExtraSequence(kCaldoria00SitDown, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kCaldoria05:
+		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
+			loopCroppedMovie("Images/Caldoria/A05 Light Loop", kCaldoriaA05LightLoopLeft, kCaldoriaA05LightLoopTop);
+		break;
+	case kCaldoria07:
+		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
+			loopCroppedMovie("Images/Caldoria/A07 Light Loop", kCaldoriaA07LightLoopLeft, kCaldoriaA07LightLoopTop);
+		break;
+	case kCaldoria08:
+		if (direction == kWest)
+			setCurrentActivation(kActivateMirrorReady);
+		break;
+	case kCaldoria09:
+		_lastExtra = 0xffffffff;
+		break;
+	case kCaldoria11:
+		if (direction == kEast && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A11 Message Machine Loop", kCaldoria11MessageLoopLeft, kCaldoria11MessageLoopTop);
+		break;
+	case kCaldoria12:
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A12 Message Machine Loop", kCaldoria12MessageLoopLeft, kCaldoria12MessageLoopTop);
+		break;
+	case kCaldoria13:
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A13 Message Machine Loop", kCaldoria13MessageLoopLeft, kCaldoria13MessageLoopTop);
+		break;
+	case kCaldoria14:
+		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
+			loopCroppedMovie("Images/Caldoria/A14 Message Machine Loop", kCaldoria14MessageLoopLeft, kCaldoria14MessageLoopTop);
+		break;
+	case kCaldoria27:
+	case kCaldoria28:
+	case kCaldoria45:
+		if (direction == kNorth)
+			openElevatorMovie();
+		else
+			closeCroppedMovie();
+		break;
+	case kCaldoria48:
+		if (direction == kNorth && !GameState.getCaldoriaDoorBombed())
+			setCurrentActivation(kActivateRoofSlotEmpty);
+		break;
+	case kCaldoria53:
+		if (GameState.getCurrentDirection() == kEast && !GameState.getCaldoriaSinclairShot())
+			zoomToSinclair();
+		break;
+	case kCaldoria50:
+		if (direction == kNorth && !GameState.getCaldoriaSinclairShot())
+			setUpSinclairLoops();
+		break;
+	case kCaldoria54:
+		if (direction == kSouth && !GameState.getCaldoriaSinclairShot())
+			setUpSinclairLoops();
+		break;
+	case kCaldoria56:
+		if (_privateFlags.getFlag(kCaldoriaPrivateZoomingToBombFlag)) {
+			_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, false);
+			newInteraction(kCaldoriaBombInteractionID);
+		} else if (GameState.getCaldoriaBombDisarmed()) {
+			_vm->playEndMessage();
+		}
+		break;
+	}
+
+	checkSinclairShootsOS();
+}
+
+void Caldoria::zoomTo(const Hotspot *zoomOutSpot) {
+	// Need to set _zoomOutSpot here because we may come through
+	// this function another way, say by pressing the down arrow,
+	// that doesn't involve the ClickInHotSpot function.
+	_zoomOutSpot = zoomOutSpot;
+
+	if (zoomOutSpot->getObjectID() == kCaldoriaDrawersOutSpotID) {
+		if (_privateFlags.getFlag(kCaloriaPrivateLeftDrawerOpenFlag)) {
+			_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, false);
+			startExtraSequence(kLeftDrawerClose, kExtraCompletedFlag, kFilterNoInput);
+		} else if (_privateFlags.getFlag(kCaldoriaPrivateRightDrawerOpenFlag)) {
+			_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
+			if (GameState.isTakenItemID(kKeyCard))
+				startExtraSequence(kRightDrawerCloseNoKeys, kExtraCompletedFlag, false);
+			else
+				startExtraSequence(kRightDrawerCloseWithKeys, kExtraCompletedFlag, false);
+		} else {
+			Neighborhood::zoomTo(zoomOutSpot);
+		}
+	} else {
+		Neighborhood::zoomTo(zoomOutSpot);
+	}
+}
+
+void Caldoria::setUpSinclairLoops() {
+	_navMovie.stop();
+	scheduleNavCallBack(kSinclairLoopDoneFlag);
+	_sinclairLoopCount = 0;
+	_numSinclairLoops = 2;
+	_navMovie.start();
+}
+
+void Caldoria::zoomToSinclair() {
+	// TODO
+}
+
+void Caldoria::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+	Neighborhood::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		InventoryItem *item;
+		_interruptionFilter = kFilterAllInput;
+
+		switch (_lastExtra) {
+		case kCaldoria00WakeUp2:
+			makeContinuePoint();
+			// Force ArriveAt to do its thing...
+			GameState.setCurrentRoom(kNoRoomID);
+			arriveAt(kCaldoria00, kEast);
+			break;
+		case k4DEnvironOpenToINN:
+			GameState.setCaldoriaSeenINN(true);
+			GameState.setScoringSawINN(true);
+			// Fall through to k4DEnvironOpen...
+		case k4DEnvironOpen:
+			_privateFlags.setFlag(kCaldoriaPrivate4DSystemOpenFlag, true);
+			setCurrentActivation(kActivate4DOpen);
+			newInteraction(kCaldoria4DInteractionID);
+			break;
+		case kCaldoriaShowerUp:
+			GameState.setScoringTookShower(true);
+			GameState.setCaldoriaDoneHygiene(true);
+			break;
+		case kLeftDrawerClose:
+		case kRightDrawerCloseNoKeys:
+		case kRightDrawerCloseWithKeys:
+			if (_zoomOutSpot && _zoomOutSpot->getObjectID() == kCaldoriaDrawersOutSpotID) {
+				Input input;
+				clickInHotspot(input, _zoomOutSpot);
+			}
+			break;
+		case kCreateOrangeJuice:
+			setCurrentActivation(kActivateOJOnThePad);
+			requestSpotSound(kCaldoriaReplicatorOJChoiceIn, kCaldoriaReplicatorOJChoiceOut, kFilterNoInput, 0);
+			break;
+		case kCaldoria00SitDown:
+			arriveAt(kCaldoria00, kEast);
+			break;
+		case kCaldoria16ElevatorUp:
+			startExtraSequence(kCaldoria16ElevatorDown, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kCaldoria16ElevatorDown:
+			GameState.setCaldoriaSeenSinclairInElevator(true);
+			_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
+			openDoor();
+			break;
+		case kCaldoriaFourthToGround:
+		case kCaldoriaRoofToGround:
+			arriveAt(kCaldoria28, GameState.getCurrentDirection());
+			break;
+		case kCaldoriaFourthToRoof:
+		case kCaldoriaGroundToRoof:
+			arriveAt(kCaldoria45, GameState.getCurrentDirection());
+			break;
+		case kCaldoriaGroundToFourth:
+		case kCaldoriaRoofToFourth:
+			arriveAt(kCaldoria27, GameState.getCurrentDirection());
+			break;
+		case kCaGTCardSwipe:
+			item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+			_vm->addItemToInventory(item);
+			setCurrentActivation(kActivateReadyToTransport);
+			break;
+		case kCaGTFryTheFly:
+		case kCaGTGoToTSA:
+			_vm->jumpToNewEnvironment(kFullTSAID, kTSA00, kNorth);
+			break;
+		case kCaGTGoToTokyo:
+			playDeathExtra(kCaGTArriveAtTokyo, kDeathUncreatedInCaldoria);
+			break;
+		case kCaGTGoToBeach:
+			playDeathExtra(kCaGTArriveAtBeach, kDeathUncreatedInCaldoria);
+			break;
+		case kCa48NorthExplosion:
+			// Current biochip must be the shield if we got here.
+			_vm->getCurrentBiochip()->setItemState(kShieldNormal);
+			break;
+		case kBinocularsZoomInOnShip:
+			setCurrentActivation(kActivateFocusedOnShip);
+			break;
+		case kCa49NorthVoiceAnalysis:
+			_utilityFuse.primeFuse(kSinclairShootsTimeLimit);
+			_utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void*) this);
+			_utilityFuse.lightFuse();
+			GameState.setCaldoriaSawVoiceAnalysis(true);
+			break;
+		case kCa53EastZoomToSinclair:
+			if (GameState.getCaldoriaSinclairShot()) {
+				delete _gunSprite;
+				_gunSprite = 0;
+				startExtraSequence(kCa53EastShootSinclair, kExtraCompletedFlag, false);
+			} else {
+				playDeathExtra(kCa53EastDeath2, kDeathSinclairShotDelegate);
+			}
+			break;
+		case kCa53EastShootSinclair:
+			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kStunGun));
+			startExtraSequence(kCa53EastZoomOutFromSinclair, kExtraCompletedFlag, false);
+			GameState.setScoringStunnedSinclair(true);
+			break;
+		case kCa53EastZoomOutFromSinclair:
+			setCurrentAlternate(kAltCaldoriaSinclairDown);
+			updateViewFrame();
+			makeContinuePoint();
+			break;
+		}
+	} else if ((flags & kSpotSoundCompletedFlag) != 0) {
+		switch (GameState.getCurrentRoom()) {
+		case kCaldoria20:
+		case kCaldoria21:
+		case kCaldoria26:
+		case kCaldoria29:
+		case kCaldoria34:
+		case kCaldoria35:
+			updateViewFrame();
+			break;
+		case kCaldoria27:
+		case kCaldoria28:
+		case kCaldoria45:
+			updateElevatorMovie();
+			break;
+		case kCaldoriaReplicator:
+			emptyOJGlass();
+			break;
+		}
+	} else if ((flags & kSinclairLoopDoneFlag) != 0) {
+		if (++_sinclairLoopCount == _numSinclairLoops) {
+			switch (GameState.getCurrentRoom()) {
+			case kCaldoria50:
+				playDeathExtra(kCa50SinclairShoots, kDeathShotBySinclair);
+				break;
+			case kCaldoria54:
+				playDeathExtra(kCa54SouthDeath, kDeathShotBySinclair);
+				break;
+			}
+		} else {
+			_navMovie.stop();
+			scheduleNavCallBack(kSinclairLoopDoneFlag);
+			_navMovie.start();
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+tInputBits Caldoria::getInputFilter() {
+	tInputBits result = Neighborhood::getInputFilter();
+
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria00:
+		if (_privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag))
+			result &= ~kFilterAllDirections;
+		break;
+	case kCaldoriaBinoculars:
+		if (getCurrentActivation() == kActivateNotFocusedOnShip)
+			result &= ~(kFilterDownButton | kFilterDownAuto);
+		break;
+	case kCaldoria53:
+		if (_privateFlags.getFlag(kCaldoriaPrivateReadyToShootFlag) && !GameState.getCaldoriaSinclairShot())
+			result &= ~kFilterAllDirections;
+		break;
+	case kCaldoria48:
+		if (GameState.getCaldoriaDoorBombed())
+			result &= ~kFilterAllDirections;
+	}
+
+	return result;
+}
+
+void Caldoria::activateHotspots() {
+	Neighborhood::activateHotspots();
+
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoriaDrawers:
+		if (getCurrentActivation() == kActivateRightOpen)
+			if (GameState.isTakenItemID(kKeyCard)) {
+				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
+				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
+			} else {
+				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
+				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
+			}
+	case kCaldoriaReplicator:
+		if (GameState.getCaldoriaMadeOJ())
+			g_allHotspots.deactivateOneHotspot(kCaldoriaMakeOJSpotID);
+		break;
+	case kCaldoria27:
+		if (GameState.isCurrentDoorOpen()) {
+			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator1);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator2);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator3);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator4);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator5);
+		}
+		break;
+	case kCaldoria28:
+		if (GameState.isCurrentDoorOpen()) {
+			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator1);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator2);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator3);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator4);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator5);
+		}
+		break;
+	case kCaldoria45:
+		if (GameState.isCurrentDoorOpen()) {
+			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator1);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator2);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator3);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator4);
+			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator5);
+		}
+		break;
+	}
+}
+
+void Caldoria::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kCa4DEnvironOpenSpotID:
+		if (!GameState.getCaldoriaINNAnnouncing() || GameState.getCaldoriaSeenINN()) {
+			startExtraSequence(k4DEnvironOpen, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			// This trick depends on the following sequences being in order in the
+			// world movie:
+			// k4DEnvironOpenToINN
+			// k4DINNInterruption
+			// k4DINNIntro
+			// k4DINNMarkJohnson
+			// k4DINNMeganLove
+			// k4DINNFadeOut
+			// k4DEnvironOpenFromINN
+			loadLoopSound1("");
+			loadLoopSound2("");
+			startExtraLongSequence(k4DEnvironOpenToINN, k4DEnvironOpenFromINN, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kCa4DEnvironCloseSpotID:
+		((Caldoria4DSystem *)_currentInteraction)->shutDown4DSystem();
+		break;
+	case kCaBathroomMirrorSpotID:
+		newInteraction(kCaldoriaMirrorInteractionID);
+		break;
+	case kCaShowerSpotID:
+		requestExtraSequence(kCaldoriaShowerTitle, 0, kFilterNoInput);
+		requestExtraSequence(kCaldoriaShowerButton, 0, kFilterNoInput);
+		requestExtraSequence(kCaldoriaShowerDown, 0, kFilterNoInput);
+		requestExtraSequence(kCaldoriaShowerUp, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaLeftDrawerOpenSpotID:
+		_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, true);
+		setCurrentActivation(kActivateLeftOpen);
+		startExtraSequence(kLeftDrawerOpen, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaLeftDrawerCloseSpotID:
+		_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, false);
+		setCurrentActivation(kActivateDrawersClosed);
+		startExtraSequence(kLeftDrawerClose, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaRightDrawerOpenSpotID:
+		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, true);
+		setCurrentActivation(kActivateRightOpen);
+		if (GameState.isTakenItemID(kKeyCard))
+			startExtraSequence(kRightDrawerOpenNoKeys, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kRightDrawerOpenWithKeys, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaRightDrawerWithKeysCloseSpotID:
+		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
+		setCurrentActivation(kActivateDrawersClosed);
+		startExtraSequence(kRightDrawerCloseWithKeys, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaRightDrawerNoKeysCloseSpotID:
+		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
+		setCurrentActivation(kActivateDrawersClosed);
+		startExtraSequence(kRightDrawerCloseNoKeys, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaMakeStickyBunsSpotID:
+		requestSpotSound(kCaldoriaReplicatorWrongChoiceIn, kCaldoriaReplicatorWrongChoiceOut, kFilterNoInput, 0);
+		break;
+	case kCaldoriaMakeOJSpotID:
+		GameState.setCaldoriaMadeOJ(true);
+		startExtraSequence(kCreateOrangeJuice, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaBedroomVidPhoneActivationSpotID:
+		newInteraction(kCaldoriaMessagesInteractionID);
+		break;
+	case kCaldoriaFourthFloorElevatorSpotID:
+		if (!GameState.getCaldoriaSeenSinclairInElevator()) {
+			startExtraSequence(kCaldoria16ElevatorUp, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
+			openDoor();
+		}
+		break;
+	case kCaldoriaGroundElevatorSpotID:
+		_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
+		openDoor();
+		break;
+	case kCaldoriaRoofElevatorSpotID:
+		_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
+		openDoor();
+		break;
+	case kCaldoriaFourthFloorElevator1:
+	case kCaldoriaFourthFloorElevator2:
+	case kCaldoriaFourthFloorElevator3:
+	case kCaldoriaFourthFloorElevator4:
+	case kCaldoriaFourthFloorElevator5:
+		// Assumes that elevator hot spots are consecutive.
+		takeElevator(4, spot->getObjectID() - kCaldoriaFourthFloorElevator1 + 1);
+		break;
+	case kCaldoriaGroundElevator1:
+	case kCaldoriaGroundElevator2:
+	case kCaldoriaGroundElevator3:
+	case kCaldoriaGroundElevator4:
+	case kCaldoriaGroundElevator5:
+		// Assumes that elevator hot spots are consecutive.
+		takeElevator(1, spot->getObjectID() - kCaldoriaGroundElevator1 + 1);
+		break;
+	case kCaldoriaRoofElevator1:
+	case kCaldoriaRoofElevator2:
+	case kCaldoriaRoofElevator3:
+	case kCaldoriaRoofElevator4:
+	case kCaldoriaRoofElevator5:
+		// Assumes that elevator hot spots are consecutive.
+		takeElevator(5, spot->getObjectID() - kCaldoriaRoofElevator1 + 1);
+		break;
+	case kCaldoriaGTTokyoSpotID:
+		startExtraSequence(kCaGTGoToTokyo, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaGTTSASpotID:
+		GameState.setScoringGoToTSA(true);
+		startExtraLongSequence(kCaGTFryTheFly, kCaGTGoToTSA, kExtraCompletedFlag, false);
+		break;
+	case kCaldoriaGTBeachSpotID:
+		startExtraSequence(kCaGTGoToBeach, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaGTOtherSpotID:
+		showExtraView(kCaGTOtherChoice);
+		playSpotSoundSync(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut);
+		showExtraView(kCaGTCardSwipe);
+		break;
+	case kCaldoriaZoomInOnShipSpotID:
+		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoriaRoofDoorSpotID:
+		startExtraSequence(kCa48NorthRooftopClosed, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaldoria20DoorbellSpotID:
+	case kCaldoria21DoorbellSpotID:
+	case kCaldoria26DoorbellSpotID:
+	case kCaldoria29DoorbellSpotID:
+	case kCaldoria34DoorbellSpotID:
+	case kCaldoria35DoorbellSpotID:
+		clickOnDoorbell(spot->getObjectID());
+		break;
+	default:
+		Neighborhood::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void Caldoria::clickOnDoorbell(const tHotSpotID doorBellSpotID) {
+	uint32 extra;
+	ExtraTable::Entry entry;
+
+	switch (doorBellSpotID) {
+	case kCaldoria20DoorbellSpotID:
+		extra = kCaldoria20Doorbell;
+		break;
+	case kCaldoria21DoorbellSpotID:
+		extra = kCaldoria21Doorbell;
+		break;
+	case kCaldoria26DoorbellSpotID:
+		extra = kCaldoria26Doorbell;
+		break;
+	case kCaldoria29DoorbellSpotID:
+		extra = kCaldoria29Doorbell;
+		break;
+	case kCaldoria34DoorbellSpotID:
+		extra = kCaldoria34Doorbell;
+		break;
+	case kCaldoria35DoorbellSpotID:
+		extra = kCaldoria35Doorbell;
+		break;
+	}
+
+	getExtraEntry(extra, entry);
+	showViewFrame(entry.movieStart);
+	requestSpotSound(kCaldoriaNobodyHomeIn, kCaldoriaNobodyHomeOut, kFilterNoInput, kSpotSoundCompletedFlag);
+}
+
+tCanOpenDoorReason Caldoria::canOpenDoor(DoorTable::Entry &entry) {
+	switch (GameState.getCurrentRoom()) {
+	case kCaldoria16:
+	case kCaldoria38:
+	case kCaldoria46:
+		if (GameState.getCurrentDirection() == kSouth && !_privateFlags.getFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag))
+			return kCantOpenLocked;
+		break;
+	}
+
+	return Neighborhood::canOpenDoor(entry);
+}
+
+void Caldoria::doorOpened() {
+	Neighborhood::doorOpened();
+	_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, false);
+}
+
+GameInteraction *Caldoria::makeInteraction(const tInteractionID interactionID) {
+	switch (interactionID) {
+	case kCaldoria4DInteractionID:
+		return new Caldoria4DSystem(this);
+		break;
+	case kCaldoriaBombInteractionID:
+		// TODO
+		error("STUB: Bomb game");
+		break;
+	case kCaldoriaMessagesInteractionID:
+		return new CaldoriaMessages(this, kCaldoriaMessagesNotificationID, _vm);
+		break;
+	case kCaldoriaMirrorInteractionID:
+		return new CaldoriaMirror(this);
+		break;
+	}
+
+	return 0;
+}
+
+void Caldoria::newInteraction(const tInteractionID interactionID) {
+	Neighborhood::newInteraction(interactionID);
+
+	if (!_currentInteraction) {
+		if (_privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag)) {
+			_privateFlags.setFlag(kCaldoriaPrivate4DSystemOpenFlag, false);
+			setCurrentActivation(kActivate4DClosed);
+			startExtraSequence(k4DEnvironClose, kExtraCompletedFlag, kFilterNoInput);
+		} else if (GameState.getCaldoriaBombDisarmed()) {
+			turnLeft();
+		}
+	}
+}
+
+//	Only called when trying to pick up an item and the player can't (because
+//	the inventory is too full or because the player lets go of the item before
+//	dropping it into the inventory).
+Hotspot *Caldoria::getItemScreenSpot(Item *item, DisplayElement *element) {
+	tHotSpotID destSpotID = kNoHotSpotID;
+	
+	switch (item->getObjectID()) {
+	case kKeyCard:
+		destSpotID = kCaldoriaKeyCardSpotID;
+		break;
+	case kOrangeJuiceGlassEmpty:
+	case kOrangeJuiceGlassFull:
+		destSpotID = kCaldoriaOrangeJuiceSpotID;
+		break;
+	}
+
+	if (destSpotID == kNoHotSpotID)
+		return Neighborhood::getItemScreenSpot(item, element);
+
+	return g_allHotspots.findHotspotByID(destSpotID);
+}
+
+void Caldoria::pickedUpItem(Item *item) {
+	switch (item->getObjectID()) {
+	case kKeyCard:
+		GameState.setScoringGotKeyCard(true);
+		break;
+	case kOrangeJuiceGlassFull:
+		setCurrentActivation(kActivateReplicatorReady);
+		requestSpotSound(kCaldoriaDrinkOJIn, kCaldoriaDrinkOJOut, kFilterNoInput, kSpotSoundCompletedFlag);
+		break;
+	case kStunGun:
+		GameState.setCaldoriaGunAimed(false);
+		break;
+	}
+}
+
+void Caldoria::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {	
+	switch (item->getObjectID()) {
+	case kKeyCard:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		if (dropSpot->getObjectID() == kCaldoriaGTCardDropSpotID)
+			startExtraSequence(kCaGTCardSwipe, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kOrangeJuiceGlassEmpty:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		if (dropSpot->getObjectID() == kCaldoriaOrangeJuiceDropSpotID) {
+			GameState.setCaldoriaMadeOJ(false);
+			startExtraSequence(kDisposeOrangeJuice, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kCardBomb:
+		GameState.setCaldoriaDoorBombed(true);
+		setCurrentActivation(kActivateHotSpotAlways);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		// Long enough for AI hints...?
+		_utilityFuse.primeFuse(kCardBombCountDownTime);
+		_utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
+		_utilityFuse.lightFuse();
+		GameState.setCaldoriaFuseTimeLimit(kCardBombCountDownTime);
+		loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
+		GameState.setScoringUsedCardBomb(true);
+		break;
+	case kStunGun:
+		GameState.setCaldoriaGunAimed(true);
+		GameState.setCaldoriaSinclairShot(true);
+		_gunSprite = item->getDragSprite(0);
+		_gunSprite->setCurrentFrameIndex(1);
+		_gunSprite->setDisplayOrder(kDragSpriteOrder);
+		_gunSprite->moveElementTo(kCaldoriaGunSpriteLeft, kCaldoriaGunSpriteTop);
+		_gunSprite->startDisplaying();
+		_gunSprite->show();
+		break;
+	default:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	}
+}
+
+void Caldoria::takeElevator(uint startFloor, uint endFloor) {
+	_croppedMovie.stop();
+	_croppedMovie.setSegment(0, _croppedMovie.getDuration());
+
+	switch (startFloor) {
+	case 1:
+		switch (endFloor) {
+		case 1:
+			// Do nothing.
+			break;
+		case 2:
+			_croppedMovie.setTime(k1To2Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 3:
+			_croppedMovie.setTime(k1To3Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 4:
+			_croppedMovie.setSegment(k1To4Start, k1To4Stop);
+			_croppedMovie.setTime(k1To4Start);
+			startExtraSequence(kCaldoriaGroundToFourth, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		case 5:
+			_croppedMovie.setSegment(k1To5Start, k1To5Stop);
+			_croppedMovie.setTime(k1To5Start);
+			startExtraSequence(kCaldoriaGroundToRoof, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		}
+		break;
+	case 4:
+		switch (endFloor) {
+		case 1:
+			_croppedMovie.setSegment(k4To1Start, k4To1Stop);
+			_croppedMovie.setTime(k4To1Start);
+			startExtraSequence(kCaldoriaFourthToGround, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		case 2:
+			_croppedMovie.setTime(k4To2Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 3:
+			_croppedMovie.setTime(k4To3Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 4:
+			// Do nothing.
+			break;
+		case 5:
+			_croppedMovie.setSegment(k4To5Start, k4To5Stop);
+			_croppedMovie.setTime(k4To5Start);
+			startExtraSequence(kCaldoriaFourthToRoof, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		}
+		break;
+	case 5:
+		switch (endFloor) {
+		case 1:
+			_croppedMovie.setSegment(k5To1Start, k5To1Stop);
+			_croppedMovie.setTime(k5To1Start);
+			startExtraSequence(kCaldoriaRoofToGround, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		case 2:
+			_croppedMovie.setTime(k5To2Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 3:
+			_croppedMovie.setTime(k5To3Time);
+			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			break;
+		case 4:
+			_croppedMovie.setSegment(k5To4Start, k5To4Stop);
+			_croppedMovie.setTime(k5To4Start);
+			startExtraSequence(kCaldoriaRoofToFourth, kExtraCompletedFlag, false);
+			_croppedMovie.start();
+			break;
+		case 5:
+			// Do nothing.
+			break;
+		}
+		break;
+	};
+}
+
+void Caldoria::updateElevatorMovie() {
+	TimeValue time = 0xffffffff;
+
+	if (GameState.getCurrentDirection() == kNorth) {
+		switch (GameState.getCurrentRoom()) {
+		case kCaldoria27:
+			time = k4FloorTime;
+			break;
+		case kCaldoria28:
+			time = k1FloorTime;
+			break;
+		case kCaldoria45:
+			time = k5FloorTime;
+			break;
+		}
+	}
+
+	_croppedMovie.stop();
+
+	if (time == 0xffffffff) {
+		_croppedMovie.hide();
+	} else {
+		_croppedMovie.stop();
+		_croppedMovie.setSegment(0, _croppedMovie.getDuration());
+		_croppedMovie.setTime(time);
+		_croppedMovie.redrawMovieWorld();
+		_croppedMovie.show();
+		
+		// *** Why do I need this?
+		// clone2727: "don't ask me!"
+		_navMovie.redrawMovieWorld();
+	}
+}
+
+void Caldoria::openElevatorMovie() {
+	if (!_croppedMovie.isSurfaceValid())
+		openCroppedMovie("Images/Caldoria/Caldoria Elevator.movie", kCaldoriaElevatorLeft, kCaldoriaElevatorTop);
+
+	updateElevatorMovie();
+}
+
+void Caldoria::emptyOJGlass() {
+	GameState.setTakenItemID(kOrangeJuiceGlassFull, false);
+	GameState.setTakenItemID(kOrangeJuiceGlassEmpty, true);
+	_vm->removeItemFromInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassFull));
+	_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassEmpty));
+}
+
+void Caldoria::doorBombTimerExpired() {
+	closeCroppedMovie();
+
+	if (GameState.getShieldOn()) {
+		_vm->getCurrentBiochip()->setItemState(kShieldCardBomb);
+		setCurrentAlternate(kAltCaldoriaRoofDoorBlown);
+		startExtraSequence(kCa48NorthExplosion, kExtraCompletedFlag, kFilterNoInput);
+		GameState.setScoringShieldedCardBomb(true);
+		GameState.setCaldoriaDoorBombed(false);
+		GameState.setCaldoriaRoofDoorOpen(true);
+	} else {
+		playDeathExtra(kCa48NorthExplosionDeath, kDeathCardBomb);
+	}
+}
+
+void Caldoria::sinclairTimerExpired() {
+	_privateFlags.setFlag(kCaldoriaPrivateSinclairTimerExpiredFlag, true);
+	checkSinclairShootsOS();
+}
+
+void Caldoria::checkSinclairShootsOS() {
+	if (_privateFlags.getFlag(kCaldoriaPrivateSinclairTimerExpiredFlag))
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kCaldoria49, kNorth):
+		case MakeRoomView(kCaldoria49, kSouth):
+		case MakeRoomView(kCaldoria49, kEast):
+		case MakeRoomView(kCaldoria49, kWest):
+		case MakeRoomView(kCaldoria50, kSouth):
+		case MakeRoomView(kCaldoria50, kEast):
+		case MakeRoomView(kCaldoria50, kWest):
+		case MakeRoomView(kCaldoria51, kNorth):
+		case MakeRoomView(kCaldoria51, kSouth):
+		case MakeRoomView(kCaldoria51, kWest):
+		case MakeRoomView(kCaldoria52, kNorth):
+		case MakeRoomView(kCaldoria52, kSouth):
+		case MakeRoomView(kCaldoria52, kWest):
+		case MakeRoomView(kCaldoria53, kNorth):
+		case MakeRoomView(kCaldoria53, kSouth):
+		case MakeRoomView(kCaldoria53, kWest):
+		case MakeRoomView(kCaldoria54, kNorth):
+		case MakeRoomView(kCaldoria54, kEast):
+		case MakeRoomView(kCaldoria54, kWest):
+			playSpotSoundSync(kCaldoriaSinclairShootsOSIn, kCaldoriaSinclairShootsOSOut);
+			playSpotSoundSync(kCaldoriaScreamingAfterIn, kCaldoriaScreamingAfterOut);
+			die(kDeathSinclairShotDelegate);
+			break;
+		}
+}
+
+void Caldoria::checkInterruptSinclair() {
+	if (GameState.getCaldoriaSinclairShot()) {
+		_navMovie.stop();
+		_neighborhoodNotification.setNotificationFlags(kExtraCompletedFlag, kExtraCompletedFlag);
+		g_AIArea->unlockAI();
+	} else {
+		// TODO
+	}
+}
+
+Common::String Caldoria::getBriefingMovie() {
+	Common::String movieName = Neighborhood::getBriefingMovie();
+
+	if (movieName.empty()) {
+		if (GameState.allTimeZonesFinished())
+			return "Images/AI/Caldoria/XA02";
+
+		return "Images/AI/Caldoria/XA01";
+	}
+
+	return movieName;
+}
+
+Common::String Caldoria::getEnvScanMovie() {	
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		tRoomID room = GameState.getCurrentRoom();
+
+		if (room >= kCaldoria00 && room <= kCaldoria14) {
+			// Inside apartment.
+			if (GameState.getCaldoriaDoneHygiene())
+				return "Images/AI/Caldoria/XAE2";
+
+			return "Images/AI/Caldoria/XAE1";
+		} else if (room >= kCaldoria15 && room <= kCaldoria48) {
+			// Wandering the halls...
+			return "Images/AI/Caldoria/XAE3";
+		} else {
+			// Must be the roof.
+			return "Images/AI/Caldoria/XAEH2";
+		}
+	}
+
+	return movieName;
+}
+
+uint Caldoria::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kCaldoria44, kEast):
+			if (!GameState.isTakenItemID(kKeyCard) && GameState.getOpenDoorRoom() == kNoRoomID)
+				numHints = 1;
+			break;
+		case MakeRoomView(kCaldoria48, kNorth):
+			if (!GameState.getCaldoriaRoofDoorOpen()) {
+				if (_croppedMovie.isRunning()) // Bomb must be looping.
+					numHints = 3;
+				else if (GameState.isTakenItemID(kCardBomb))
+					numHints = 1;
+			}
+			break;
+		case MakeRoomView(kCaldoria49, kEast):
+		case MakeRoomView(kCaldoria54, kEast):
+			numHints = 1;
+			break;
+		case MakeRoomView(kCaldoria49, kNorth):
+			numHints = 1;
+			break;
+		}
+	}
+	
+	return numHints;
+}
+
+Common::String Caldoria::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kCaldoria44, kEast):
+			return "Images/AI/Caldoria/X42WH2";
+		case MakeRoomView(kCaldoria48, kNorth):
+			if (_croppedMovie.isRunning()) { // Bomb must be looping.
+				if (hintNum == 1)
+					return "Images/AI/Caldoria/X48ND1";
+				else if (hintNum == 2)
+					return "Images/AI/Caldoria/X48ND2";
+				else if (GameState.isTakenItemID(kShieldBiochip))
+					return "Images/AI/Caldoria/X48ND3";
+
+				//	*** Doesn't work yet, need global movies.
+				break;
+			} 
+
+			return "Images/AI/Globals/XGLOB1A";
+		case MakeRoomView(kCaldoria49, kEast):
+		case MakeRoomView(kCaldoria54, kEast):
+			return "Images/AI/Caldoria/X49E";
+		case MakeRoomView(kCaldoria49, kNorth):
+			return "Images/AI/Caldoria/X49NB2";
+		}
+	}
+
+	return movieName;
+}
+
+void Caldoria::updateCursor(const Common::Point where, const Hotspot *cursorSpot) {
+	switch (cursorSpot->getObjectID()) {
+	case kCa4DEnvironCloseSpotID:
+		_vm->_cursor->setCurrentFrameIndex(2);
+		break;
+	case kCaldoriaKioskSpotID:
+		_vm->_cursor->setCurrentFrameIndex(3);
+		break;
+	default:
+		Neighborhood::updateCursor(where, cursorSpot);
+		break;
+	}
+}
+
+Common::String Caldoria::getNavMovieName() {
+	return "Images/Caldoria/Caldoria.movie";
+}
+
+Common::String Caldoria::getSoundSpotsName() {
+	return "Sounds/Caldoria/Caldoria Spots";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
new file mode 100755
index 0000000..f2e3775
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -0,0 +1,509 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIA_H
+#define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIA_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+const TimeScale kCaldoriaMovieScale = 600;
+const TimeScale kCaldoriaFramesPerSecond = 15;
+const TimeScale kCaldoriaFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltCaldoriaNormal = 0;
+const tAlternateID kAltCaldoriaRoofDoorBlown = 2;
+const tAlternateID kAltCaldoriaSinclairDown = 3;
+
+//	Room IDs.
+
+const tRoomID kCaldoria00 = 1;
+const tRoomID kCaldoria01 = 2;
+const tRoomID kCaldoria02 = 3;
+const tRoomID kCaldoria03 = 4;
+const tRoomID kCaldoria04 = 5;
+const tRoomID kCaldoria05 = 6;
+const tRoomID kCaldoria06 = 7;
+const tRoomID kCaldoria07 = 8;
+const tRoomID kCaldoria08 = 9;
+const tRoomID kCaldoria09 = 10;
+const tRoomID kCaldoria10 = 11;
+const tRoomID kCaldoriaToilet = 12;
+const tRoomID kCaldoria11 = 13;
+const tRoomID kCaldoria12 = 14;
+const tRoomID kCaldoriaVidPhone = 15;
+const tRoomID kCaldoriaReplicator = 16;
+const tRoomID kCaldoriaDrawers = 17;
+const tRoomID kCaldoria13 = 18;
+const tRoomID kCaldoria14 = 19;
+const tRoomID kCaldoria15 = 20;
+const tRoomID kCaldoria16 = 21;
+const tRoomID kCaldoria17 = 22;
+const tRoomID kCaldoria18 = 23;
+const tRoomID kCaldoria19 = 24;
+const tRoomID kCaldoria20 = 25;
+const tRoomID kCaldoria21 = 26;
+const tRoomID kCaldoria22 = 27;
+const tRoomID kCaldoria23 = 28;
+const tRoomID kCaldoria24 = 29;
+const tRoomID kCaldoria25 = 30;
+const tRoomID kCaldoria26 = 31;
+const tRoomID kCaldoria27 = 32;
+const tRoomID kCaldoria28 = 33;
+const tRoomID kCaldoria29 = 34;
+const tRoomID kCaldoria30 = 35;
+const tRoomID kCaldoria31 = 36;
+const tRoomID kCaldoria32 = 37;
+const tRoomID kCaldoria33 = 38;
+const tRoomID kCaldoria34 = 39;
+const tRoomID kCaldoria35 = 40;
+const tRoomID kCaldoria36 = 41;
+const tRoomID kCaldoria37 = 42;
+const tRoomID kCaldoria38 = 43;
+const tRoomID kCaldoria39 = 44;
+const tRoomID kCaldoria40 = 45;
+const tRoomID kCaldoria41 = 46;
+const tRoomID kCaldoriaBinoculars = 47;
+const tRoomID kCaldoria42 = 48;
+const tRoomID kCaldoriaKiosk = 49;
+const tRoomID kCaldoria44 = 50;
+const tRoomID kCaldoria45 = 51;
+const tRoomID kCaldoria46 = 52;
+const tRoomID kCaldoria47 = 53;
+const tRoomID kCaldoria48 = 54;
+const tRoomID kCaldoria49 = 55;
+const tRoomID kCaldoria50 = 56;
+const tRoomID kCaldoria51 = 57;
+const tRoomID kCaldoria52 = 58;
+const tRoomID kCaldoria53 = 59;
+const tRoomID kCaldoria54 = 60;
+const tRoomID kCaldoria55 = 61;
+const tRoomID kCaldoria56 = 62;
+const tRoomID kCaldoriaDeathRoom = 0;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivate4DClosed = 1;
+const tHotSpotActivationID kActivate4DOpen = 2;
+const tHotSpotActivationID kActivateMirrorReady = 3;
+const tHotSpotActivationID kActivateStylistReady = 4;
+const tHotSpotActivationID kActivateReplicatorReady = 5;
+const tHotSpotActivationID kActivateOJOnThePad = 6;
+const tHotSpotActivationID kActivateDrawersClosed = 7;
+const tHotSpotActivationID kActivateRightOpen = 8;
+const tHotSpotActivationID kActivateLeftOpen = 9;
+const tHotSpotActivationID kActivateFocusedOnShip = 10;
+const tHotSpotActivationID kActivateNotFocusedOnShip = 11;
+const tHotSpotActivationID kActivateReadyForCard = 12;
+const tHotSpotActivationID kActivateReadyToTransport = 13;
+const tHotSpotActivationID kActivateRoofSlotEmpty = 14;
+const tHotSpotActivationID kActivateZoomedOnSinclair = 15;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kCa4DEnvironOpenSpotID = 5000;
+const tHotSpotID kCa4DEnvironCloseSpotID = 5001;
+const tHotSpotID kCa4DVisualSpotID = 5002;
+const tHotSpotID kCa4DAudioSpotID = 5003;
+const tHotSpotID kCa4DChoice1SpotID = 5004;
+const tHotSpotID kCa4DChoice2SpotID = 5005;
+const tHotSpotID kCa4DChoice3SpotID = 5006;
+const tHotSpotID kCa4DChoice4SpotID = 5007;
+const tHotSpotID kCaBathroomMirrorSpotID = 5008;
+const tHotSpotID kCaHairStyle1SpotID = 5009;
+const tHotSpotID kCaHairStyle2SpotID = 5010;
+const tHotSpotID kCaHairStyle3SpotID = 5011;
+const tHotSpotID kCaShowerSpotID = 5012;
+const tHotSpotID kCaBathroomToiletSpotID = 5013;
+const tHotSpotID kCaldoriaVidPhoneSpotID = 5014;
+const tHotSpotID kCaldoriaReplicatorSpotID = 5015;
+const tHotSpotID kCaldoriaDrawersSpotID = 5016;
+const tHotSpotID kCaldoriaVidPhoneOutSpotID = 5017;
+const tHotSpotID kCaBedroomVidPhoneActivationSpotID = 5018;
+const tHotSpotID kCaldoriaReplicatorOutSpotID = 5019;
+const tHotSpotID kCaldoriaMakeOJSpotID = 5020;
+const tHotSpotID kCaldoriaMakeStickyBunsSpotID = 5021;
+const tHotSpotID kCaldoriaOrangeJuiceSpotID = 5022;
+const tHotSpotID kCaldoriaOrangeJuiceDropSpotID = 5023;
+const tHotSpotID kCaldoriaDrawersOutSpotID = 5024;
+const tHotSpotID kCaldoriaLeftDrawerOpenSpotID = 5025;
+const tHotSpotID kCaldoriaRightDrawerOpenSpotID = 5026;
+const tHotSpotID kCaldoriaKeyCardSpotID = 5027;
+const tHotSpotID kCaldoriaLeftDrawerCloseSpotID = 5028;
+const tHotSpotID kCaldoriaRightDrawerWithKeysCloseSpotID = 5029;
+const tHotSpotID kCaldoriaRightDrawerNoKeysCloseSpotID = 5030;
+const tHotSpotID kCaldoriaFourthFloorElevatorSpotID = 5031;
+const tHotSpotID kCaldoria20DoorbellSpotID = 5032;
+const tHotSpotID kCaldoria21DoorbellSpotID = 5033;
+const tHotSpotID kCaldoria26DoorbellSpotID = 5034;
+const tHotSpotID kCaldoriaFourthFloorElevator1 = 5035;
+const tHotSpotID kCaldoriaFourthFloorElevator2 = 5036;
+const tHotSpotID kCaldoriaFourthFloorElevator3 = 5037;
+const tHotSpotID kCaldoriaFourthFloorElevator4 = 5038;
+const tHotSpotID kCaldoriaFourthFloorElevator5 = 5039;
+const tHotSpotID kCaldoriaGroundElevator1 = 5040;
+const tHotSpotID kCaldoriaGroundElevator2 = 5041;
+const tHotSpotID kCaldoriaGroundElevator3 = 5042;
+const tHotSpotID kCaldoriaGroundElevator4 = 5043;
+const tHotSpotID kCaldoriaGroundElevator5 = 5044;
+const tHotSpotID kCaldoria29DoorbellSpotID = 5045;
+const tHotSpotID kCaldoria34DoorbellSpotID = 5046;
+const tHotSpotID kCaldoria35DoorbellSpotID = 5047;
+const tHotSpotID kCaldoriaGroundElevatorSpotID = 5048;
+const tHotSpotID kCaldoriaBinocularZoomInSpotID = 5049;
+const tHotSpotID kCaldoriaBinocularsOutSpotID = 5050;
+const tHotSpotID kCaldoriaZoomInOnShipSpotID = 5051;
+const tHotSpotID kCaldoriaKioskSpotID = 5052;
+const tHotSpotID kCaldoriaKioskOutSpotID = 5053;
+const tHotSpotID kCaldoriaKioskInfoSpotID = 5054;
+const tHotSpotID kCaldoriaGTCardDropSpotID = 5055;
+const tHotSpotID kCaldoriaGTTokyoSpotID = 5056;
+const tHotSpotID kCaldoriaGTTSASpotID = 5057;
+const tHotSpotID kCaldoriaGTBeachSpotID = 5058;
+const tHotSpotID kCaldoriaGTOtherSpotID = 5059;
+const tHotSpotID kCaldoriaRoofElevator1 = 5060;
+const tHotSpotID kCaldoriaRoofElevator2 = 5061;
+const tHotSpotID kCaldoriaRoofElevator3 = 5062;
+const tHotSpotID kCaldoriaRoofElevator4 = 5063;
+const tHotSpotID kCaldoriaRoofElevator5 = 5064;
+const tHotSpotID kCaldoriaRoofElevatorSpotID = 5065;
+const tHotSpotID kCaldoriaRoofDoorSpotID = 5066;
+const tHotSpotID kCaldoriaRoofCardDropSpotID = 5067;
+const tHotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
+
+//	Extra sequence IDs.
+
+const tExtraID kCaldoriaWakeUpView1 = 0;
+const tExtraID kCaldoria00WakeUp1 = 1;
+const tExtraID kCaldoria00WakeUp2 = 2;
+const tExtraID kCaldoria00SitDown = 3;
+const tExtraID k4DEnvironOpenToINN = 4;
+const tExtraID k4DINNInterruption = 5;
+const tExtraID k4DINNIntro = 6;
+const tExtraID k4DINNMarkJohnson = 7;
+const tExtraID k4DINNMeganLove = 8;
+const tExtraID k4DINNFadeOut = 9;
+const tExtraID k4DEnvironOpenFromINN = 10;
+const tExtraID k4DEnvironOpen = 11;
+const tExtraID k4DEnvironOpenView = 12;
+const tExtraID k4DEnvironClose = 13;
+const tExtraID k4DIslandLoop = 14;
+const tExtraID k4DDesertLoop = 15;
+const tExtraID k4DMountainLoop = 16;
+const tExtraID k4DIsland1ToIsland0 = 17;
+const tExtraID k4DIsland2ToIsland0 = 18;
+const tExtraID k4DIsland0ToDesert0 = 19;
+const tExtraID k4DIsland1ToDesert0 = 20;
+const tExtraID k4DIsland2ToDesert0 = 21;
+const tExtraID k4DIsland0ToMountain0 = 22;
+const tExtraID k4DIsland1ToMountain0 = 23;
+const tExtraID k4DIsland2ToMountain0 = 24;
+const tExtraID k4DDesert0ToIsland0 = 25;
+const tExtraID k4DDesert1ToIsland0 = 26;
+const tExtraID k4DDesert2ToIsland0 = 27;
+const tExtraID k4DDesert0ToMountain0 = 28;
+const tExtraID k4DDesert1ToMountain0 = 29;
+const tExtraID k4DDesert2ToMountain0 = 30;
+const tExtraID k4DMountain0ToIsland0 = 31;
+const tExtraID k4DMountain1ToIsland0 = 32;
+const tExtraID k4DMountain2ToIsland0 = 33;
+const tExtraID k4DMountain0ToDesert0 = 34;
+const tExtraID k4DMountain1ToDesert0 = 35;
+const tExtraID k4DMountain2ToDesert0 = 36;
+const tExtraID kCaBathroomGreeting = 37;
+const tExtraID kCaBathroomBodyFat = 38;
+const tExtraID kCaBathroomStylistIntro = 39;
+const tExtraID kCaBathroomRetrothrash = 40;
+const tExtraID kCaBathroomRetrothrashReturn = 41;
+const tExtraID kCaBathroomGeoWave = 42;
+const tExtraID kCaBathroomGeoWaveReturn = 43;
+const tExtraID kCaBathroomAgencyStandard = 44;
+const tExtraID kCaldoriaShowerTitle = 45;
+const tExtraID kCaldoriaShowerButton = 46;
+const tExtraID kCaldoriaShowerDown = 47;
+const tExtraID kCaldoriaShowerUp = 48;
+const tExtraID kCaBedroomVidPhone = 49;
+const tExtraID kCaBedroomMessage1 = 50;
+const tExtraID kCaBedroomMessage2 = 51;
+const tExtraID kCreateOrangeJuice = 52;
+const tExtraID kDisposeOrangeJuice = 53;
+const tExtraID kReplicatorNorthViewWithOJ = 54;
+const tExtraID kLeftDrawerOpen = 55;
+const tExtraID kLeftDrawerClose = 56;
+const tExtraID kRightDrawerOpenWithKeys = 57;
+const tExtraID kRightDrawerCloseWithKeys = 58;
+const tExtraID kRightDrawerOpenNoKeys = 59;
+const tExtraID kRightDrawerCloseNoKeys = 60;
+const tExtraID kRightDrawerOpenViewWithKeys = 61;
+const tExtraID kRightDrawerOpenViewNoKeys = 62;
+const tExtraID kCaldoria16ElevatorUp = 63;
+const tExtraID kCaldoria16ElevatorDown = 64;
+const tExtraID kCaldoria16SouthViewWithElevator = 65;
+const tExtraID kCaldoria20Doorbell = 66;
+const tExtraID kCaldoria21Doorbell = 67;
+const tExtraID kCaldoria26Doorbell = 68;
+const tExtraID kCaldoriaFourthToGround = 69;
+const tExtraID kCaldoriaRoofToFourth = 70;
+const tExtraID kCaldoriaRoofToGround = 71;
+const tExtraID kCaldoriaGroundToFourth = 72;
+const tExtraID kCaldoriaGroundToRoof = 73;
+const tExtraID kCaldoriaFourthToRoof = 74;
+const tExtraID kCaldoria29Doorbell = 75;
+const tExtraID kCaldoria34Doorbell = 76;
+const tExtraID kCaldoria35Doorbell = 77;
+const tExtraID kBinocularsZoomInOnShip = 78;
+const tExtraID kCaldoriaKioskVideo = 79;
+const tExtraID kCaldoriaTransporterArrowLoop = 80;
+const tExtraID kArriveAtCaldoriaFromTSA = 81;
+const tExtraID kCaGTOtherChoice = 82;
+const tExtraID kCaGTCardSwipe = 83;
+const tExtraID kCaGTSelectTSA = 84;
+const tExtraID kCaGTFryTheFly = 85;
+const tExtraID kCaGTGoToTSA = 86;
+const tExtraID kCaGTSelectBeach = 87;
+const tExtraID kCaGTGoToBeach = 88;
+const tExtraID kCaGTArriveAtBeach = 89;
+const tExtraID kCaGTSelectTokyo = 90;
+const tExtraID kCaGTGoToTokyo = 91;
+const tExtraID kCaGTArriveAtTokyo = 92;
+const tExtraID kCa48NorthRooftopClosed = 93;
+const tExtraID kCa48NorthExplosion = 94;
+const tExtraID kCa48NorthExplosionDeath = 95;
+const tExtraID kCa49NorthVoiceAnalysis = 96;
+const tExtraID kCa50SinclairShoots = 97;
+const tExtraID kCa53EastZoomToSinclair = 98;
+const tExtraID kCa53EastDeath2 = 99;
+const tExtraID kCa53EastShootSinclair = 100;
+const tExtraID kCa53EastZoomOutFromSinclair = 101;
+const tExtraID kCa54SouthDeath = 102;
+const tExtraID kCaldoria56BombStage1 = 103;
+const tExtraID kCaldoria56BombStage2 = 104;
+const tExtraID kCaldoria56BombStage3 = 105;
+const tExtraID kCaldoria56BombStage4 = 106;
+const tExtraID kCaldoria56BombStage5 = 107;
+const tExtraID kCaldoria56BombStage6 = 108;
+const tExtraID kCaldoria56BombStage7 = 109;
+const tExtraID kCaldoria56BombExplodes = 110;
+
+//	Caldoria interactions.
+
+const tInteractionID kCaldoria4DInteractionID = 0;
+const tInteractionID kCaldoriaBombInteractionID = 1;
+const tInteractionID kCaldoriaMessagesInteractionID = 2;
+const tInteractionID kCaldoriaMirrorInteractionID = 3;
+
+//	Caldoria:
+
+const tDisplayOrder kVidPhoneOrder = kMonitorLayer;
+const tDisplayOrder k4DSpritesOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaMessagesOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaElevatorOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaA05LightLoopOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaA07LightLoopOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaBombGridOrder = kMonitorLayer;
+const tDisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
+
+/////////////////////////////////////////////
+//
+//	Caldoria
+
+const tCoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
+const tCoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
+
+const tCoordType kCaldoria4DSpritesLeft = kNavAreaLeft + 10;
+const tCoordType kCaldoria4DSpritesTop = kNavAreaTop + 142;
+
+const tCoordType kCaldoriaMessageLeft = kNavAreaLeft + 202;
+const tCoordType kCaldoriaMessageTop = kNavAreaTop + 26;
+
+const tCoordType kCaldoriaElevatorLeft = kNavAreaLeft + 407;
+const tCoordType kCaldoriaElevatorTop = kNavAreaTop + 138;
+
+const tCoordType kCaldoriaA05LightLoopLeft = kNavAreaLeft + 213;
+const tCoordType kCaldoriaA05LightLoopTop = kNavAreaTop + 215;
+
+const tCoordType kCaldoriaA07LightLoopLeft = kNavAreaLeft + 414;
+const tCoordType kCaldoriaA07LightLoopTop = kNavAreaTop + 215;
+
+const tCoordType kCaldoriaGunSpriteLeft = kNavAreaLeft + 276;
+const tCoordType kCaldoriaGunSpriteTop = kNavAreaTop + 115;
+
+const tCoordType kCaldoria11MessageLoopLeft = kNavAreaLeft + 135;
+const tCoordType kCaldoria11MessageLoopTop = kNavAreaTop + 214;
+
+const tCoordType kCaldoria12MessageLoopLeft = kNavAreaLeft + 209;
+const tCoordType kCaldoria12MessageLoopTop = kNavAreaTop + 170;
+
+const tCoordType kCaldoria13MessageLoopLeft = kNavAreaLeft + 480;
+const tCoordType kCaldoria13MessageLoopTop = kNavAreaTop + 191;
+
+const tCoordType kCaldoria14MessageLoopLeft = kNavAreaLeft + 248;
+const tCoordType kCaldoria14MessageLoopTop = kNavAreaTop + 191;
+
+const tCoordType kCaldoria48CardBombLoopLeft = kNavAreaLeft + 337;
+const tCoordType kCaldoria48CardBombLoopTop = kNavAreaTop + 205;
+
+const tCoordType kCaldoriaBombGridLeft = kNavAreaLeft + 290;
+const tCoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
+
+const tCoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
+const tCoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
+
+//	Caldoria display IDs.
+
+const tDisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
+const tDisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
+const tDisplayElementID kCaldoriaMessagesID = kCaldoria4DSpritesID + 1;
+const tDisplayElementID kCaldoriaUtilityID = kCaldoriaMessagesID + 1;
+const tDisplayElementID kCaldoriaBombGridID = kCaldoriaUtilityID + 1;
+const tDisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
+
+const TimeValue kCaldoria4DBlankChoiceIn = 29730;
+const TimeValue kCaldoria4DBlankChoiceOut = 33910;
+
+class Caldoria : public Neighborhood {
+friend void doorBombTimerExpiredFunction(FunctionPtr *, void *);
+friend void sinclairTimerExpiredFunction(FunctionPtr *, void *);
+
+public:
+	Caldoria(InputHandler *, PegasusEngine *);
+	virtual ~Caldoria();
+	
+	virtual uint16 getDateResID() const;
+	
+	void pickedUpItem(Item *);
+	
+	virtual GameInteraction *makeInteraction(const tInteractionID);
+	
+	virtual Common::String getBriefingMovie();
+	virtual Common::String getEnvScanMovie();
+	virtual uint getNumHints();
+	virtual Common::String getHintMovie(uint);
+	void loadAmbientLoops();
+	bool wantsCursor();
+	void flushGameState();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+protected:
+	enum {
+		kCaldoriaPrivate4DSystemOpenFlag,
+		kCaloriaPrivateLeftDrawerOpenFlag,
+		kCaldoriaPrivateRightDrawerOpenFlag,
+		kCaldoriaPrivateReadyToShootFlag,
+		kCaldoriaPrivateZoomingToBombFlag,
+		kCaldoriaPrivateCanOpenElevatorDoorFlag,
+		kCaldoriaPrivateSinclairTimerExpiredFlag,
+		kCaldoriaPrivateSeen13CarFlag,
+		kCaldoriaPrivateSeen14CarFlag,
+		kCaldoriaPrivateSeen18CarFlag,
+		kCaldoriaPrivateSeen23CarFlag,
+		kCaldoriaPrivateSeen33CarFlag,
+		kCaldoriaPrivateSeen36CarFlag,
+		kCaldoriaPrivateSeen41NorthCarFlag,
+		kCaldoriaPrivateSeen41EastCarFlag,
+		kCaldoriaPrivateSeen41WestCarFlag,
+		kNumCaldoriaPrivateFlags
+	};
+	
+	void init();
+	void start();
+	
+	void setUpRoofTop();
+
+	void setUpAIRules();
+	void doAIRecalibration();
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	void startSpotOnceOnly(TimeValue, TimeValue);
+	void startExitMovie(const ExitTable::Entry &);
+	void startZoomMovie(const ZoomTable::Entry &);
+	void startDoorOpenMovie(const TimeValue, const TimeValue);
+	void startTurnPush(const tTurnDirection, const TimeValue, const tDirectionConstant);
+	void bumpIntoWall();
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec &);
+	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
+	void spotCompleted();
+	void arriveAt(const tRoomID, const tDirectionConstant);
+	void arriveAtCaldoria00();
+	void arriveAtCaldoriaToilet();
+	void arriveAtCaldoria44();
+	void arriveAtCaldoria49();
+	void arriveAtCaldoria56();
+	void arriveAtCaldoriaDeath();
+	void turnTo(const tDirectionConstant);
+	void zoomTo(const Hotspot *);
+	void downButton(const Input &);
+	void receiveNotification(Notification *, const tNotificationFlags);
+	tInputBits getInputFilter();
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	void newInteraction(const tInteractionID);
+	
+	void clickOnDoorbell(const tHotSpotID);
+	
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void takeElevator(uint, uint);
+	void updateElevatorMovie();
+	void openElevatorMovie();
+	void emptyOJGlass();
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	void doorBombTimerExpired();
+	void sinclairTimerExpired();
+	void checkSinclairShootsOS();
+	void setUpSinclairLoops();
+	void zoomToSinclair();
+	void playEndMessage();
+	void checkInterruptSinclair();
+	
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	void doorOpened();
+	
+	void updateCursor(const Common::Point, const Hotspot *);
+
+	FlagsArray<uint16, kNumCaldoriaPrivateFlags> _privateFlags;
+
+	const Hotspot *_zoomOutSpot;
+	
+	FuseFunction _utilityFuse;
+
+	long _sinclairLoopCount;
+	long _numSinclairLoops;
+
+	Sprite *_gunSprite;
+
+	Common::String getSoundSpotsName();
+	Common::String getNavMovieName();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
new file mode 100755
index 0000000..f6fa399
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -0,0 +1,369 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
+
+namespace Pegasus {
+
+const TimeValue kSwitchableSlop = 3 * kCaldoriaFrameDuration;
+//	Two seconds - some slop
+const TimeValue kSwitchableDuration = kCaldoriaMovieScale * 2 - kSwitchableSlop;
+//	Twelve frames + some slop
+const TimeValue kNonswitchableDuration = kCaldoriaFrameDuration * 12 + kSwitchableSlop;
+
+const TimeValue kSwitchable1Start = 0;
+const TimeValue kSwitchable1Stop = kSwitchable1Start + kSwitchableDuration;
+
+const TimeValue kSwitchable2Start = kSwitchable1Stop + kNonswitchableDuration;
+const TimeValue kSwitchable2Stop = kSwitchable2Start + kSwitchableDuration;
+
+const TimeValue kSwitchable3Start = kSwitchable2Stop + kNonswitchableDuration;
+const TimeValue kSwitchable3Stop = kSwitchable3Start + kSwitchableDuration;
+
+const tNotificationFlags kVidPhoneDoneFlag = 1;
+
+const TimeValue kRockMusicLoopIn = 0;
+const TimeValue kRockMusicLoopOut = 2088;
+
+const TimeValue kOrchestralMusicLoopIn = 2088;
+const TimeValue kOrchestralMusicLoopOut = 4985;
+
+const TimeValue kRhythmsMusicLoopIn = 4985;
+const TimeValue kRhythmsMusicLoopOut = 6824;
+
+const TimeValue kAcousticMusicLoopIn = 6824;
+const TimeValue kAcousticMusicLoopOut = 9387;
+
+enum {
+	k4DVideoMenu,
+	k4DAudioMenu,
+	k4DShuttingDown,
+
+	// These constants are the exact frame numbers of the sprite movie.
+	k4DRockChoice = 0,
+	k4DOrchestralChoice,
+	k4DRhythmsChoice,
+	k4DAcousticChoice,
+	k4DIslandChoice,
+	k4DDesertChoice,
+	k4DMountainChoice,
+
+	k4DFirstVideoChoice = k4DIslandChoice
+};
+
+tExtraID s_transitionExtras0[3][3] = {
+	{0xffffffff, k4DIsland0ToDesert0, k4DIsland0ToMountain0},
+	{k4DDesert0ToIsland0, 0xffffffff, k4DDesert0ToMountain0},
+	{k4DMountain0ToIsland0, k4DMountain0ToDesert0, 0xffffffff}
+};
+
+tExtraID s_transitionExtras1[3][3] = {
+	{0xffffffff, k4DIsland1ToDesert0, k4DIsland1ToMountain0},
+	{k4DDesert1ToIsland0, 0xffffffff, k4DDesert1ToMountain0},
+	{k4DMountain1ToIsland0, k4DMountain1ToDesert0, 0xffffffff}
+};
+
+tExtraID s_transitionExtras2[3][3] = {
+	{0xffffffff, k4DIsland2ToDesert0, k4DIsland2ToMountain0},
+	{k4DDesert2ToIsland0, 0xffffffff, k4DDesert2ToMountain0},
+	{k4DMountain2ToIsland0, k4DMountain2ToDesert0, 0xffffffff}
+};
+
+tExtraID s_shutDownExtras[3][3] = {
+	{0xffffffff, k4DIsland1ToIsland0, k4DIsland2ToIsland0},
+	{k4DDesert0ToIsland0, k4DDesert1ToIsland0, k4DDesert2ToIsland0},
+	{k4DMountain0ToIsland0, k4DMountain1ToIsland0, k4DMountain2ToIsland0}
+};
+
+Caldoria4DSystem::Caldoria4DSystem(Neighborhood *owner) : GameInteraction(kCaldoria4DInteractionID, owner),
+		_4DSpritesMovie(kCaldoria4DSpritesID) {
+	g_AIArea->lockAIOut();
+}
+
+Caldoria4DSystem::~Caldoria4DSystem() {
+	g_AIArea->unlockAI();
+}
+
+void Caldoria4DSystem::openInteraction() {
+	_whichMenu = k4DVideoMenu;
+	_videoChoice = k4DIslandChoice;
+	_audioChoice = k4DRockChoice;
+	_clickedHotspotID = kNoHotSpotID;
+
+	_4DSpritesMovie.initFromMovieFile("Images/Caldoria/4D Sprites", true);
+	_4DSpritesMovie.moveElementTo(kCaldoria4DSpritesLeft, kCaldoria4DSpritesTop);
+	_4DSpritesMovie.setDisplayOrder(k4DSpritesOrder);
+	_4DSpritesMovie.startDisplaying();
+	_4DSpritesMovie.show();
+	
+	_4DSpritesScale = _4DSpritesMovie.getScale();
+
+	_neighborhoodNotification = _owner->getNeighborhoodNotification();
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+
+	startIdling();
+}
+
+void Caldoria4DSystem::loopExtra(const tExtraID extraID) {
+	ExtraTable::Entry extraEntry;
+	
+	_owner->getExtraEntry(extraID, extraEntry);
+	_loopStart = extraEntry.movieStart;
+	_owner->loopExtraSequence(extraID);
+}
+
+void Caldoria4DSystem::useIdleTime() {
+	if (_whichMenu == k4DShuttingDown) {
+		TimeValue movieTime = _owner->getNavMovie()->getTime() - _loopStart;
+		tExtraID extraID;
+
+		if (movieTime < kSwitchable1Stop)
+			extraID = s_shutDownExtras[_videoChoice - k4DFirstVideoChoice][0];
+		else if (movieTime >= kSwitchable2Start && movieTime < kSwitchable2Stop)
+			extraID = s_shutDownExtras[_videoChoice - k4DFirstVideoChoice][1];
+		else if (movieTime >= kSwitchable3Start && movieTime < kSwitchable3Stop)
+			extraID = s_shutDownExtras[_videoChoice - k4DFirstVideoChoice][2];
+		else
+			extraID = 0xffffffff;
+
+		if (extraID != 0xffffffff) {
+			setSpritesMovie();
+			_loopStart = 0;
+			_owner->startExtraSequence(extraID, kExtraCompletedFlag, kFilterNoInput);
+		}
+	} else if (_clickedHotspotID != kNoHotSpotID) {
+		TimeValue movieTime = _owner->getNavMovie()->getTime() - _loopStart;
+		tExtraID extraID;
+
+		if (movieTime < kSwitchable1Stop) {
+			extraID = s_transitionExtras0[_videoChoice - k4DFirstVideoChoice][_clickedHotspotID - kCa4DChoice1SpotID];
+			_clickedHotspotID = kNoHotSpotID;
+		} else if (movieTime >= kSwitchable2Start && movieTime < kSwitchable2Stop) {
+			extraID = s_transitionExtras1[_videoChoice - k4DFirstVideoChoice][_clickedHotspotID - kCa4DChoice1SpotID];
+			_clickedHotspotID = kNoHotSpotID;
+		} else if (movieTime >= kSwitchable3Start && movieTime < kSwitchable3Stop) {
+			extraID = s_transitionExtras2[_videoChoice - k4DFirstVideoChoice][_clickedHotspotID - kCa4DChoice1SpotID];
+			_clickedHotspotID = kNoHotSpotID;
+		} else
+			extraID = 0xffffffff;
+
+		if (extraID != 0xffffffff) {
+			switch (extraID) {
+			case k4DDesert0ToIsland0:
+			case k4DMountain0ToIsland0:
+			case k4DDesert1ToIsland0:
+			case k4DMountain1ToIsland0:
+			case k4DDesert2ToIsland0:
+			case k4DMountain2ToIsland0:
+				_videoChoice = k4DIslandChoice;
+				break;
+			case k4DIsland0ToDesert0:
+			case k4DMountain0ToDesert0:
+			case k4DIsland1ToDesert0:
+			case k4DMountain1ToDesert0:
+			case k4DIsland2ToDesert0:
+			case k4DMountain2ToDesert0:
+				_videoChoice = k4DDesertChoice;
+				break;
+			case k4DDesert0ToMountain0:
+			case k4DIsland0ToMountain0:
+			case k4DIsland1ToMountain0:
+			case k4DDesert1ToMountain0:
+			case k4DIsland2ToMountain0:
+			case k4DDesert2ToMountain0:
+				_videoChoice = k4DMountainChoice;
+				break;
+			}
+
+			setSpritesMovie();
+			_loopStart = 0;
+			_owner->startExtraSequence(extraID, kExtraCompletedFlag, kFilterNoInput);
+		}
+	}
+}
+
+void Caldoria4DSystem::initInteraction() {
+	setSpritesMovie();
+	
+	_owner->loadLoopSound1("Sounds/Caldoria/Rock.aiff");
+	loopExtra(k4DIslandLoop);
+}
+
+void Caldoria4DSystem::closeInteraction() {
+	stopIdling();
+	_neighborhoodNotification->cancelNotification(this);
+	_4DSpritesMovie.releaseMovie();
+	_owner->loadAmbientLoops();
+}
+
+void Caldoria4DSystem::setSpritesMovie() {
+	if (_whichMenu == k4DShuttingDown)
+		_4DSpritesMovie.setTime(_4DSpritesScale * k4DIslandChoice);
+	else if (_whichMenu == k4DVideoMenu)
+		_4DSpritesMovie.setTime(_4DSpritesScale * _videoChoice);
+	else if (_whichMenu == k4DAudioMenu)
+		_4DSpritesMovie.setTime(_4DSpritesScale * _audioChoice);
+	_4DSpritesMovie.triggerRedraw();
+}
+
+void Caldoria4DSystem::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (input.downButtonAnyDown())
+		return;
+	if (input.anyDirectionInput())
+		shutDown4DSystem();
+	else
+		GameInteraction::handleInput(input, cursorSpot);
+}
+
+void Caldoria4DSystem::activateHotspots() {
+	GameInteraction::activateHotspots();
+	if (_whichMenu == k4DAudioMenu)
+		g_allHotspots.activateOneHotspot(kCa4DChoice4SpotID);
+}
+
+void Caldoria4DSystem::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kCa4DVisualSpotID:
+		if (_whichMenu == k4DAudioMenu) {
+			_whichMenu = k4DVideoMenu;
+			setSpritesMovie();
+		}
+		break;
+	case kCa4DAudioSpotID:
+		if (_whichMenu == k4DVideoMenu) {
+			_whichMenu = k4DAudioMenu;
+			setSpritesMovie();
+		}
+		break;
+	case kCa4DChoice1SpotID:
+		if (_whichMenu == k4DVideoMenu)
+			makeIslandChoice();
+		else if (_whichMenu == k4DAudioMenu)
+			makeRockChoice();
+		break;
+	case kCa4DChoice2SpotID:
+		if (_whichMenu == k4DVideoMenu)
+			makeDesertChoice();
+		else if (_whichMenu == k4DAudioMenu)
+			makeOrchestralChoice();
+		break;
+	case kCa4DChoice3SpotID:
+		if (_whichMenu == k4DVideoMenu)
+			makeMountainChoice();
+		else if (_whichMenu == k4DAudioMenu)
+			makeRhythmsChoice();
+		break;
+	case kCa4DChoice4SpotID:
+		if (_whichMenu == k4DAudioMenu)
+			makeAcousticChoice();
+		else
+			_owner->playSpotSoundSync(kCaldoria4DBlankChoiceIn, kCaldoria4DBlankChoiceOut);
+		break;
+	default:
+		GameInteraction::clickInHotspot(input, spot);
+	}
+}
+
+void Caldoria4DSystem::receiveNotification(Notification *, const tNotificationFlags) {
+	if (_whichMenu == k4DShuttingDown) {
+		_owner->requestDeleteCurrentInteraction();
+	} else {
+		uint32 extraID;
+
+		switch (_videoChoice) {
+		case k4DIslandChoice:
+			extraID = k4DIslandLoop;
+			break;
+		case k4DDesertChoice:
+			extraID = k4DDesertLoop;
+			break;
+		case k4DMountainChoice:
+			extraID = k4DMountainLoop;
+			break;
+		default:
+			extraID = 0xffffffff;
+			break;
+		}
+
+		if (extraID != 0xffffffff)
+			loopExtra(extraID);
+	}
+}
+
+void Caldoria4DSystem::makeIslandChoice() {
+	if (_videoChoice != k4DIslandChoice && _clickedHotspotID == kNoHotSpotID)
+		_clickedHotspotID = kCa4DChoice1SpotID;
+}
+
+void Caldoria4DSystem::makeDesertChoice() {
+	if (_videoChoice != k4DDesertChoice && _clickedHotspotID == kNoHotSpotID)
+		_clickedHotspotID = kCa4DChoice2SpotID;
+}
+
+void Caldoria4DSystem::makeMountainChoice() {
+	if (_videoChoice != k4DMountainChoice && _clickedHotspotID == kNoHotSpotID)
+		_clickedHotspotID = kCa4DChoice3SpotID;
+}
+
+void Caldoria4DSystem::makeRockChoice() {
+	if (_audioChoice != k4DRockChoice) {
+		_audioChoice = k4DRockChoice;
+		setSpritesMovie();
+		_owner->loadLoopSound1("Sounds/Caldoria/Rock.aiff");
+	}
+}
+
+void Caldoria4DSystem::makeOrchestralChoice() {
+	if (_audioChoice != k4DOrchestralChoice) {
+		_audioChoice = k4DOrchestralChoice;
+		setSpritesMovie();
+		_owner->loadLoopSound1("Sounds/Caldoria/Orchestral.aiff");
+	}
+}
+
+void Caldoria4DSystem::makeRhythmsChoice() {
+	if (_audioChoice != k4DRhythmsChoice) {
+		_audioChoice = k4DRhythmsChoice;
+		setSpritesMovie();
+		_owner->loadLoopSound1("Sounds/Caldoria/Rhythms.aiff");
+	}
+}
+
+void Caldoria4DSystem::makeAcousticChoice() {
+	if (_audioChoice != k4DAcousticChoice) {
+		_audioChoice = k4DAcousticChoice;
+		setSpritesMovie();
+		_owner->loadLoopSound1("Sounds/Caldoria/Acoustic.aiff");
+	}
+}
+
+void Caldoria4DSystem::shutDown4DSystem() {
+	_whichMenu = k4DShuttingDown;
+
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
new file mode 100755
index 0000000..e021791
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIA4DSYSTEM_H
+#define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIA4DSYSTEM_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class Neighborhood;
+
+class Caldoria4DSystem : public GameInteraction, private Idler, public NotificationReceiver {
+public:
+	Caldoria4DSystem(Neighborhood *);
+	virtual ~Caldoria4DSystem();
+
+	void shutDown4DSystem();
+
+protected:
+	void openInteraction();
+	void initInteraction();
+	void closeInteraction();
+	
+	void handleInput(const Input &, const Hotspot *);
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void setSpritesMovie();
+	void makeIslandChoice();
+	void makeRockChoice();
+	void makeMountainChoice();
+	void makeOrchestralChoice();
+	void makeDesertChoice();
+	void makeRhythmsChoice();
+	void makeAcousticChoice();
+	
+	void useIdleTime();
+	void loopExtra(const tExtraID);
+	
+	Movie _4DSpritesMovie;
+	TimeScale _4DSpritesScale;
+	uint _whichMenu;
+	uint _videoChoice;
+	uint _audioChoice;
+	Notification *_neighborhoodNotification;
+	TimeValue _loopStart;
+	tHotSpotID _clickedHotspotID;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
new file mode 100755
index 0000000..bd5480d
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
@@ -0,0 +1,115 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/caldoria/caldoriamessages.h"
+
+namespace Pegasus {
+
+const tNotificationFlags kMessageDoneFlag = 1;
+
+CaldoriaMessages::CaldoriaMessages(Neighborhood *owner, const tNotificationID id, NotificationManager *manager) :
+		GameInteraction(kCaldoriaMessagesInteractionID, owner), Notification(id, manager), _messageMovie(kCaldoriaMessagesID) {
+}
+
+void CaldoriaMessages::openInteraction() {
+	_neighborhoodNotification = GameInteraction::_owner->getNeighborhoodNotification();
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+	_messageCallBack.setNotification(this);
+	notifyMe(this, kMessageDoneFlag, kMessageDoneFlag);
+	_messageCallBack.setCallBackFlag(kMessageDoneFlag);
+	_messageNumber = 1;
+}
+
+void CaldoriaMessages::initInteraction() {
+	GameInteraction::_owner->startExtraSequence(kCaBedroomVidPhone, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void CaldoriaMessages::closeInteraction() {
+	cancelNotification(this);
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void CaldoriaMessages::receiveNotification(Notification *notification, const tNotificationFlags) {	
+	if (notification == _neighborhoodNotification) {
+		switch (GameInteraction::_owner->getLastExtra()) {
+		case kCaBedroomVidPhone:
+			GameInteraction::_owner->showExtraView(kCaBedroomMessage1);
+			break;
+		case kCaBedroomMessage1:
+			play1Message(1);
+			break;
+		case kCaBedroomMessage2:
+			play1Message(2);
+			break;
+		}
+	} else {
+		_messageCallBack.releaseCallBack();
+		_messageMovie.releaseMovie();
+
+		uint32 extraID = (_messageNumber == 1) ? kCaBedroomMessage1 : kCaBedroomMessage2;
+		GameInteraction::_owner->showExtraView(extraID);
+		allowInput(true);
+	}
+}
+
+void CaldoriaMessages::clickInHotspot(const Input &input, const Hotspot *spot) {
+	uint32 extraID;
+
+	switch (spot->getObjectID()) {
+	case kCaBedroomVidPhoneActivationSpotID:
+		extraID = (_messageNumber == 1) ? kCaBedroomMessage1 : kCaBedroomMessage2;
+		GameInteraction::_owner->startExtraSequence(extraID, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		GameInteraction::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void CaldoriaMessages::play1Message(uint messageNumber) {	
+	if (messageNumber == 1) {
+		_messageMovie.initFromMovieFile("Images/Caldoria/A12NVA.movie");
+		_messageNumber = 2;
+	} else {
+		_messageMovie.initFromMovieFile("Images/Caldoria/A12NVB.movie");
+		_messageNumber = 1;
+		GameState.setCaldoriaSeenMessages(true);
+	}
+
+	_messageMovie.moveElementTo(kCaldoriaMessageLeft, kCaldoriaMessageTop);
+	_messageMovie.setDisplayOrder(kCaldoriaMessagesOrder);
+	_messageMovie.startDisplaying();
+	_messageCallBack.initCallBack(&_messageMovie, kCallBackAtExtremes);
+	_messageCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	allowInput(false);
+	_messageMovie.show();
+	_messageMovie.redrawMovieWorld();
+	_messageMovie.start();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
new file mode 100755
index 0000000..1ef0ab0
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIAMESSAGES_H
+#define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIAMESSAGES_H
+
+#include "pegasus/input.h"
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class Neighborhood;
+
+class CaldoriaMessages : public GameInteraction, public Notification, public NotificationReceiver {
+public:
+	CaldoriaMessages(Neighborhood *, const tNotificationID, NotificationManager *);
+	virtual ~CaldoriaMessages() {}
+
+protected:
+	void openInteraction();
+	void initInteraction();
+	void closeInteraction();
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void clickInHotspot(const Input &, const Hotspot *);
+	void play1Message(uint);
+	
+	Movie _messageMovie;
+	NotificationCallBack _messageCallBack;
+	Notification *_neighborhoodNotification;
+	uint _messageNumber;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
new file mode 100755
index 0000000..4d6dc6b
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/caldoria/caldoriamirror.h"
+
+namespace Pegasus {
+
+CaldoriaMirror::CaldoriaMirror(Neighborhood *owner) : GameInteraction(kCaldoriaMirrorInteractionID, owner) {
+}
+
+void CaldoriaMirror::openInteraction() {
+	_neighborhoodNotification = _owner->getNeighborhoodNotification();
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+}
+
+void CaldoriaMirror::initInteraction() {
+	_owner->setCurrentActivation(kActivateMirrorReady);
+	_owner->startExtraSequence(kCaBathroomGreeting, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void CaldoriaMirror::closeInteraction() {
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void CaldoriaMirror::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (_owner->getLastExtra() == (uint32)kCaBathroomAgencyStandard || !input.anyDirectionInput())
+		GameInteraction::handleInput(input, cursorSpot);
+}
+
+void CaldoriaMirror::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	switch (_owner->getLastExtra()) {
+	case kCaBathroomGreeting:
+	case kCaBathroomBodyFat:
+	case kCaBathroomRetrothrash:
+	case kCaBathroomGeoWave:
+		g_allHotspots.activateOneHotspot(kCaBathroomMirrorSpotID);
+		g_allHotspots.deactivateOneHotspot(kCaHairStyle1SpotID);
+		g_allHotspots.deactivateOneHotspot(kCaHairStyle2SpotID);
+		g_allHotspots.deactivateOneHotspot(kCaHairStyle3SpotID);
+		break;
+	case kCaBathroomStylistIntro:
+	case kCaBathroomRetrothrashReturn:
+	case kCaBathroomGeoWaveReturn:
+		g_allHotspots.activateOneHotspot(kCaHairStyle1SpotID);
+		g_allHotspots.activateOneHotspot(kCaHairStyle2SpotID);
+		g_allHotspots.activateOneHotspot(kCaHairStyle3SpotID);
+		g_allHotspots.deactivateOneHotspot(kCaBathroomMirrorSpotID);
+		break;
+	}
+}
+
+void CaldoriaMirror::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kCaBathroomMirrorSpotID:
+		switch (_owner->getLastExtra()) {
+		case kCaBathroomGreeting:
+			_owner->startExtraSequence(kCaBathroomBodyFat, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kCaBathroomBodyFat:
+			_owner->startExtraSequence(kCaBathroomStylistIntro, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kCaBathroomRetrothrash:
+			_owner->startExtraSequence(kCaBathroomRetrothrashReturn, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kCaBathroomGeoWave:
+			_owner->startExtraSequence(kCaBathroomGeoWaveReturn, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+		break;
+	case kCaHairStyle1SpotID:
+		_owner->startExtraSequence(kCaBathroomRetrothrash, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaHairStyle2SpotID:
+		_owner->startExtraSequence(kCaBathroomAgencyStandard, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kCaHairStyle3SpotID:
+		_owner->startExtraSequence(kCaBathroomGeoWave, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		GameInteraction::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void CaldoriaMirror::receiveNotification(Notification *, const tNotificationFlags) {
+	switch (_owner->getLastExtra()) {
+	case kCaBathroomRetrothrash:
+	case kCaBathroomGeoWave:
+		_owner->setCurrentActivation(kActivateMirrorReady);
+		break;
+	case kCaBathroomStylistIntro:
+	case kCaBathroomRetrothrashReturn:
+	case kCaBathroomGeoWaveReturn:
+		_owner->setCurrentActivation(kActivateStylistReady);
+		break;
+	case kCaBathroomAgencyStandard:
+		_owner->setCurrentActivation(kActivateHotSpotAlways);
+		_owner->requestDeleteCurrentInteraction();
+		GameState.setScoringFixedHair(true);
+		GameState.setCaldoriaDoneHygiene(true);
+		break;
+	}
+
+	allowInput(true);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.h b/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
new file mode 100755
index 0000000..6b4339e
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIAMIRROR_H
+#define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIAMIRROR_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+class CaldoriaMirror : public GameInteraction, public NotificationReceiver {
+public:
+	CaldoriaMirror(Neighborhood *);
+	virtual ~CaldoriaMirror() {}
+
+protected:
+	void openInteraction();
+	void initInteraction();
+	void closeInteraction();
+
+	void handleInput(const Input &, const Hotspot *);
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	void receiveNotification(Notification *, const tNotificationFlags);
+
+	Notification *_neighborhoodNotification;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index f0e9f49..e1aa814 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -92,6 +92,7 @@ bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
 bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
 
 class GameInteraction;
+class Item;
 class Neighborhood;
 
 class StriderCallBack : public TimeBaseCallBack {
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 71e4ca0..7dac148 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -31,6 +31,7 @@
 #include "common/savefile.h"
 #include "common/textconsole.h"
 #include "common/translation.h"
+#include "common/random.h"
 #include "base/plugins.h"
 #include "base/version.h"
 #include "gui/saveload.h"
@@ -58,6 +59,7 @@
 #include "pegasus/items/inventory/inventoryitem.h"
 #include "pegasus/items/inventory/keycard.h"
 #include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 
 namespace Pegasus {
@@ -85,6 +87,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _continuePoint;
 	delete _gameMenu;
 	delete _neighborhood;
+	delete _rnd;
 
 	// NOTE: This must be deleted last!
 	delete _gfx;
@@ -95,6 +98,7 @@ Common::Error PegasusEngine::run() {
 	_gfx = new GraphicsManager(this);
 	_resFork = new Common::MacResManager();
 	_cursor = new Cursor();
+	_rnd = new Common::RandomSource("Pegasus");
 	
 	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 		error("Could not load JMP PP Resources");
@@ -532,32 +536,6 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 	if (&_shellNotification == notification) {
 		switch (flags) {
 		case kGameStartingFlag: {
-#if 0
-			// This is just some graphical test that I wrote; I'll
-			// keep it around for reference.
-			Movie opening(1);
-			opening.initFromMovieFile(_introDirectory + "/Big Movie.movie");
-			opening.setTime(10, 1);
-			opening.setStart(10, 1);
-			opening.startDisplaying();
-			opening.show();
-			opening.start();
-			opening.setFlags(kLoopTimeBase);
-
-			Input input;
-			InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
-
-			while (opening.isRunning() && !shouldQuit()) {
-				checkCallBacks();
-				_gfx->updateDisplay();
-
-				InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
-				if (input.anyInput())
-					break;
-
-				_system->delayMillis(10);
-			}
-#else
 			if (!isDemo())
 				runIntro();
 			else
@@ -570,7 +548,6 @@ void PegasusEngine::receiveNotification(Notification *notification, const tNotif
 			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 			_gfx->updateDisplay();
 			((MainMenu *)_gameMenu)->startMainMenuLoop();
-#endif
 			break;
 		}
 		case kPlayerDiedFlag:
@@ -638,13 +615,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 	switch (command) {
 	case kMenuCmdStartAdventure:
 		GameState.setWalkthroughMode(false);
-
-		// Only start the game in the demo for now
-		// (until it works and I implement Caldoria)
-		if (isDemo())
-			startNewGame();
-		else
-			error("Start new game (adventure mode)");
+		startNewGame();
 		break;
 	case kMenuCmdCredits:
 		if (isDemo()) {
@@ -673,7 +644,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		break;
 	case kMenuCmdStartWalkthrough:
 		GameState.setWalkthroughMode(true);
-		error("Start new game (walkthrough mode)");
+		startNewGame();
 		break;
 	case kMenuCmdRestore:
 	case kMenuCmdDeathRestore:
@@ -1371,6 +1342,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	// TODO: CD check
 	
 	switch (neighborhoodID) {
+	case kCaldoriaID:
+		neighborhood = new Caldoria(g_AIArea, this);
+		break;
 	case kPrehistoricID:
 		neighborhood = new Prehistoric(g_AIArea, this);
 		break;
@@ -1869,4 +1843,18 @@ void PegasusEngine::pauseEngineIntern(bool pause) {
 	}
 }
 
+uint PegasusEngine::getRandomBit() {
+	return _rnd->getRandomBit();
+}
+
+void PegasusEngine::playEndMessage() {
+	if (g_interface) {
+		allowInput(false);
+		g_interface->playEndMessage();
+		allowInput(true);
+	}
+
+	die(kPlayerWonGame);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 13e975e..0dd0a2a 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -28,9 +28,9 @@
 
 #include "common/list.h"
 #include "common/macresman.h"
+#include "common/rect.h"
 #include "common/scummsys.h"
 #include "common/system.h"
-#include "common/rect.h"
 #include "common/util.h"
 
 #include "engines/engine.h"
@@ -44,6 +44,10 @@
 #include "pegasus/items/itemdragger.h"
 #include "pegasus/neighborhood/neighborhood.h"
 
+namespace Common {
+	class RandomSource;
+}
+
 namespace Video {
 	class SeekableVideoDecoder;
 }
@@ -102,6 +106,7 @@ public:
 	void createInterface();
 	void setGameMode(const tGameMode);
 	tGameMode getGameMode() const { return _gameMode; }
+	uint getRandomBit();
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
@@ -112,6 +117,7 @@ public:
 	tDeathReason getEnergyDeathReason() { return _deathReason; }
 	void resetEnergyDeathReason();
 	void die(const tDeathReason);
+	void playEndMessage();
 
 	// Volume
 	uint16 getSoundFXLevel() { return _FXLevel; }
@@ -234,6 +240,7 @@ private:
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 	void throwAwayEverything();
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
+	Common::RandomSource *_rnd;
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: b31efb02b58e6f36807a5d98241fb9737e734300
    https://github.com/scummvm/scummvm/commit/b31efb02b58e6f36807a5d98241fb9737e734300
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T18:22:14-07:00

Commit Message:
PEGASUS: Fix draw sync functions

Changed paths:
    engines/pegasus/interface.cpp



diff --git a/engines/pegasus/interface.cpp b/engines/pegasus/interface.cpp
index 4f9183b..e9daecb 100755
--- a/engines/pegasus/interface.cpp
+++ b/engines/pegasus/interface.cpp
@@ -574,6 +574,7 @@ void Interface::raiseInventoryDrawerSync() {
 	raiseInventoryDrawer(false);
 
 	while (_inventoryLid.isRunning()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -582,6 +583,7 @@ void Interface::raiseInventoryDrawerSync() {
 	inventoryLidOpen(false);
 
 	while (_inventoryPush.isFading()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -596,6 +598,7 @@ void Interface::lowerInventoryDrawerSync() {
 	lowerInventoryDrawer(false);
 
 	while (_inventoryPush.isFading()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -604,6 +607,7 @@ void Interface::lowerInventoryDrawerSync() {
 	inventoryDrawerDown(false);
 
 	while (_inventoryLid.isRunning()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -618,6 +622,7 @@ void Interface::raiseBiochipDrawerSync() {
 	raiseBiochipDrawer(false);
 
 	while (_biochipLid.isRunning()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -626,6 +631,7 @@ void Interface::raiseBiochipDrawerSync() {
 	biochipLidOpen(false);
 
 	while (_biochipPush.isFading()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -640,6 +646,7 @@ void Interface::lowerBiochipDrawerSync() {
 	lowerBiochipDrawer(false);
 
 	while (_biochipPush.isFading()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
@@ -648,6 +655,7 @@ void Interface::lowerBiochipDrawerSync() {
 	biochipDrawerDown(false);
 
 	while (_biochipLid.isRunning()) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}


Commit: a57b1de6ee146e4722b86095eb1fe44afdc9bf0c
    https://github.com/scummvm/scummvm/commit/a57b1de6ee146e4722b86095eb1fe44afdc9bf0c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T18:22:52-07:00

Commit Message:
PEGASUS: Add a hack to skip energy bar calibration for now

Changed paths:
    engines/pegasus/energymonitor.cpp



diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index 9a82e36..94ac093 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -248,7 +248,7 @@ void EnergyMonitor::calibrateEnergyBar() {
 	
 	_calibrating = true;
 
-	// TODO: set death reason to -1
+	vm->setEnergyDeathReason(-1);
 
 	uint32 numFrames = _energyLight.getNumFrames();
 	for (uint32 i = 1; i < numFrames; i++) {
@@ -261,18 +261,25 @@ void EnergyMonitor::calibrateEnergyBar() {
 
 	_energyLight.setCurrentFrameIndex(0);
 	_energyLight.hide();
+
+#if 0
+	// FIXME: This doesn't work yet
 	show();
 	setEnergyValue(0);
 	setEnergyDrainRate(-kMaxJMPEnergy / 2);
 
 	//	Make sure warning light is hidden...
 	_energyLight.hide();
-	while (getCurrentEnergy() != (int32)kMaxJMPEnergy)
+	while (getCurrentEnergy() != (int32)kMaxJMPEnergy) {
+		vm->checkCallBacks();
 		vm->refreshDisplay();
+		g_system->delayMillis(10);
+	}
 
 	vm->refreshDisplay();
 	setEnergyDrainRate(0);
 	hide();
+#endif
 
 	_calibrating = false;
 }


Commit: a432e3af2942f94e6c22178c0f59c5247b99aa9b
    https://github.com/scummvm/scummvm/commit/a432e3af2942f94e6c22178c0f59c5247b99aa9b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T18:23:51-07:00

Commit Message:
PEGASUS: Fix Caldoria::updateCursor

This actually looks like an original game bug... The original does no checking for null here, but Neighborhood::updateCursor() clearly does

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoria.cpp



diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 7a5ec1b..b4df89a 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -682,7 +682,7 @@ void Caldoria::spotCompleted() {
 		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
 }
 
-void Caldoria::arriveAt(const tRoomID room, const tDirectionConstant direction) {	
+void Caldoria::arriveAt(const tRoomID room, const tDirectionConstant direction) {
 	switch (room) {
 	case kCaldoria56:
 		if (!GameState.getCaldoriaGunAimed())
@@ -798,6 +798,7 @@ void Caldoria::arriveAt(const tRoomID room, const tDirectionConstant direction)
 
 void Caldoria::doAIRecalibration() {
 	GameState.setCaldoriaDidRecalibration(true);
+
 	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB1", true, kRecalibrationInterruptFilter))
 		return;
 
@@ -1896,17 +1897,18 @@ Common::String Caldoria::getHintMovie(uint hintNum) {
 }
 
 void Caldoria::updateCursor(const Common::Point where, const Hotspot *cursorSpot) {
-	switch (cursorSpot->getObjectID()) {
-	case kCa4DEnvironCloseSpotID:
-		_vm->_cursor->setCurrentFrameIndex(2);
-		break;
-	case kCaldoriaKioskSpotID:
-		_vm->_cursor->setCurrentFrameIndex(3);
-		break;
-	default:
-		Neighborhood::updateCursor(where, cursorSpot);
-		break;
+	if (cursorSpot) {
+		switch (cursorSpot->getObjectID()) {
+		case kCa4DEnvironCloseSpotID:
+			_vm->_cursor->setCurrentFrameIndex(2);
+			return;
+		case kCaldoriaKioskSpotID:
+			_vm->_cursor->setCurrentFrameIndex(3);
+			return;
+		}
 	}
+
+	Neighborhood::updateCursor(where, cursorSpot);
 }
 
 Common::String Caldoria::getNavMovieName() {


Commit: 2b4bd019eef319300dc53ce82a30b8a8075023ef
    https://github.com/scummvm/scummvm/commit/2b4bd019eef319300dc53ce82a30b8a8075023ef
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T18:24:30-07:00

Commit Message:
PEGASUS: Fix extra sync

Caldoria now starts up

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 4ff762f..e5d29f09 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1299,6 +1299,7 @@ bool Neighborhood::waitMovieFinish(Movie *movie, const tInputBits interruptionFi
 			break;
 		}
 
+		_vm->checkCallBacks();
 		_vm->refreshDisplay();
 		_vm->_system->delayMillis(10);
 	}


Commit: cc7680364a1a2df79323b55766cd298a71b63add
    https://github.com/scummvm/scummvm/commit/cc7680364a1a2df79323b55766cd298a71b63add
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T19:51:34-07:00

Commit Message:
PEGASUS: Fix energy monitor calibration

Minus a quick flicker

Changed paths:
    engines/pegasus/energymonitor.cpp



diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index 94ac093..2076ae1 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -262,11 +262,9 @@ void EnergyMonitor::calibrateEnergyBar() {
 	_energyLight.setCurrentFrameIndex(0);
 	_energyLight.hide();
 
-#if 0
-	// FIXME: This doesn't work yet
 	show();
 	setEnergyValue(0);
-	setEnergyDrainRate(-kMaxJMPEnergy / 2);
+	setEnergyDrainRate(-(int32)kMaxJMPEnergy / 2);
 
 	//	Make sure warning light is hidden...
 	_energyLight.hide();
@@ -279,7 +277,6 @@ void EnergyMonitor::calibrateEnergyBar() {
 	vm->refreshDisplay();
 	setEnergyDrainRate(0);
 	hide();
-#endif
 
 	_calibrating = false;
 }


Commit: 5d8912a2ad6d685dc1c708b2cff3f0118adf8133
    https://github.com/scummvm/scummvm/commit/5d8912a2ad6d685dc1c708b2cff3f0118adf8133
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T20:16:30-07:00

Commit Message:
PEGASUS: Fix Caldoria wake up video 2

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index bd81f37..be3819e 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -138,6 +138,7 @@ void Movie::setTime(const TimeValue time, const TimeScale scale) {
 
 		_video->seekToTime(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator()));
 		_time = timeFrac;
+		_lastMillis = 0;
 	}
 }
 


Commit: 0756f72c202295dd8566753cd24f6d3db18d2d88
    https://github.com/scummvm/scummvm/commit/0756f72c202295dd8566753cd24f6d3db18d2d88
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T20:30:49-07:00

Commit Message:
PEGASUS: Remove a change I made for testing

Changed paths:
    engines/pegasus/energymonitor.h



diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
index cb1170c..cb5d449 100755
--- a/engines/pegasus/energymonitor.h
+++ b/engines/pegasus/energymonitor.h
@@ -53,7 +53,7 @@ protected:
 
 //	These are in seconds.
 //	Max is two hours
-static const uint32 kMaxJMPEnergy = 60 * 1;
+static const uint32 kMaxJMPEnergy = 7200;
 
 static const uint32 kCasualEnergy = kMaxJMPEnergy * 100 / 100;      // 100%
 static const uint32 kWorriedEnergy = kMaxJMPEnergy * 50 / 100;      // 50%


Commit: d2789a152f56120812b7f7c228eb35884ec817aa
    https://github.com/scummvm/scummvm/commit/d2789a152f56120812b7f7c228eb35884ec817aa
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-02T20:31:01-07:00

Commit Message:
PEGASUS: Fix idlers freeing themselves

Our idler handling is more like the original now

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 7dac148..4200147 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -78,6 +78,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_switchModesSync = false;
 	_draggingItem = 0;
 	_dragType = kDragNoDrag;
+	_idlerHead = 0;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -311,16 +312,27 @@ GUI::Debugger *PegasusEngine::getDebugger() {
 }
 
 void PegasusEngine::addIdler(Idler *idler) {
-	_idlers.push_back(idler);
+	idler->_nextIdler = _idlerHead;
+	if (_idlerHead)
+		_idlerHead->_prevIdler = idler;
+	idler->_prevIdler = 0;
+	_idlerHead = idler;
 }
 
 void PegasusEngine::removeIdler(Idler *idler) {
-	_idlers.remove(idler);
+	if (idler->_prevIdler)
+		idler->_prevIdler->_nextIdler = idler->_nextIdler;
+	if (idler->_nextIdler)
+		idler->_nextIdler->_prevIdler = idler->_prevIdler;
+	if (idler == _idlerHead)
+		_idlerHead = idler->_nextIdler;
+	idler->_nextIdler = 0;
+	idler->_prevIdler = 0;
 }
 
 void PegasusEngine::giveIdleTime() {
-	for (Common::List<Idler *>::iterator it = _idlers.begin(); it != _idlers.end(); it++)
-		(*it)->useIdleTime();
+	for (Idler *idler = _idlerHead; idler != 0; idler = idler->_nextIdler)
+		idler->useIdleTime();
 }
 
 void PegasusEngine::addTimeBase(TimeBase *timeBase) {
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 0dd0a2a..a09a923 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -211,7 +211,7 @@ private:
 	Common::String _introDirectory;
 
 	// Idlers
-	Common::List<Idler *> _idlers;
+	Idler *_idlerHead;
 	void giveIdleTime();
 
 	// Items
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 0b052b5..8ca7de9 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -31,6 +31,8 @@ namespace Pegasus {
 
 Idler::Idler() {
 	_isIdling = false;
+	_nextIdler = 0;
+	_prevIdler = 0;
 }
 
 Idler::~Idler() {
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 4ad2df0..65e7d21 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -50,6 +50,7 @@ protected:
 	virtual void useIdleTime() {}
 
 	bool _isIdling;
+	Idler *_nextIdler, *_prevIdler;
 };
 
 enum {


Commit: 327ce7c64b6dd5e572b9d14b001e4ad1808bc43f
    https://github.com/scummvm/scummvm/commit/327ce7c64b6dd5e572b9d14b001e4ad1808bc43f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-03T15:47:25-07:00

Commit Message:
VIDEO: Fix the first AI calibration video

Changed paths:
    video/codecs/cinepak.cpp



diff --git a/video/codecs/cinepak.cpp b/video/codecs/cinepak.cpp
index c8b23df..c197e0c 100644
--- a/video/codecs/cinepak.cpp
+++ b/video/codecs/cinepak.cpp
@@ -73,7 +73,8 @@ CinepakDecoder::~CinepakDecoder() {
 
 const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream *stream) {
 	_curFrame.flags = stream->readByte();
-	_curFrame.length = (stream->readByte() << 16) + stream->readUint16BE();
+	_curFrame.length = (stream->readByte() << 16);
+	_curFrame.length |= stream->readUint16BE();
 	_curFrame.width = stream->readUint16BE();
 	_curFrame.height = stream->readUint16BE();
 	_curFrame.stripCount = stream->readUint16BE();
@@ -86,8 +87,11 @@ const Graphics::Surface *CinepakDecoder::decodeImage(Common::SeekableReadStream
 	// Borrowed from FFMPEG. This should cut out the extra data Cinepak for Sega has (which is useless).
 	// The theory behind this is that this is here to confuse standard Cinepak decoders. But, we won't let that happen! ;)
 	if (_curFrame.length != (uint32)stream->size()) {
-		if (stream->readUint16BE() == 0xFE00)
+		uint16 temp = stream->readUint16BE();
+		if (temp == 0xFE00)
 			stream->readUint32BE();
+		else if (temp != _curFrame.width)
+			stream->seek(-2, SEEK_CUR);
 	}
 
 	if (!_curFrame.surface) {


Commit: 05668dd6846345b2fd3abd0fd4a6f6675c7095ca
    https://github.com/scummvm/scummvm/commit/05668dd6846345b2fd3abd0fd4a6f6675c7095ca
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-03T20:27:48-07:00

Commit Message:
PEGASUS: Fix moving forward

You know, actually initialize some variables :P

Changed paths:
    engines/pegasus/neighborhood/door.h



diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index d311656..c670c6b 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -59,8 +59,16 @@ public:
 	void clear();
 
 	struct Entry {
-		Entry() { movieStart = 0xffffffff; }
+		Entry() { clear(); }
 		bool isEmpty() { return movieStart == 0xffffffff; }
+		void clear() {
+			room = kNoRoomID;
+			direction = kNoDirection;
+			altCode = kNoAlternateID;
+			movieStart = 0xffffffff;
+			movieEnd = 0xffffffff;
+			flags = kNoDoorFlags;
+		}
 
 		tRoomID room;
 		tDirectionConstant direction;


Commit: cbca2812a8078e1d62dc55db5b6429908da3b9da
    https://github.com/scummvm/scummvm/commit/cbca2812a8078e1d62dc55db5b6429908da3b9da
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-04T08:34:15-07:00

Commit Message:
PEGASUS: Fix turning

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index e5d29f09..5076cf5 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -268,7 +268,7 @@ tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirecti
 	if (turnEntry.isEmpty())
 		turnEntry = _turnTable.findEntry(room, direction, turnDirection, kNoAlternateID);
 
-	return turnEntry.turnDirection;
+	return turnEntry.endDirection;
 }
 
 void Neighborhood::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {


Commit: 3ecc16c9aec6be1853e255f23c610a2dcaaa34d3
    https://github.com/scummvm/scummvm/commit/3ecc16c9aec6be1853e255f23c610a2dcaaa34d3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-04T09:16:59-07:00

Commit Message:
PEGASUS: Fix playSpotSoundSync playSoundSegment call

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 5076cf5..ed64b3e 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -462,7 +462,7 @@ void Neighborhood::playSpotSoundSync(const TimeValue in, const TimeValue out) {
 	}
 
 	_spotSounds.stopSound();
-	_spotSounds.playSoundSegment(in * 1000 / 600, out * 1000 / 600);
+	_spotSounds.playSoundSegment(in, out);
 
 	while (_spotSounds.isPlaying()) {
 		_vm->refreshDisplay();


Commit: 5381f5d56b24ed65e1a4eef32e4e749fb4f85022
    https://github.com/scummvm/scummvm/commit/5381f5d56b24ed65e1a4eef32e4e749fb4f85022
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-05T11:37:34-07:00

Commit Message:
PEGASUS: Implement basic jump console command

Changed paths:
    engines/pegasus/console.cpp
    engines/pegasus/console.h



diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
index 2c1a761..e6738bc 100644
--- a/engines/pegasus/console.cpp
+++ b/engines/pegasus/console.cpp
@@ -24,12 +24,18 @@
  */
 
 #include "pegasus/console.h"
+#include "pegasus/interface.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/neighborhood.h"
 
 namespace Pegasus {
 
 PegasusConsole::PegasusConsole(PegasusEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("die", WRAP_METHOD(PegasusConsole, Cmd_Die));
+
+	// These functions are non-demo specific
+	if (!_vm->isDemo())
+		DCmd_Register("jump", WRAP_METHOD(PegasusConsole, Cmd_Jump));
 }
 
 PegasusConsole::~PegasusConsole() {
@@ -59,4 +65,40 @@ bool PegasusConsole::Cmd_Die(int argc, const char **argv) {
 	return false;
 }
 
+bool PegasusConsole::Cmd_Jump(int argc, const char **argv) {
+	if (!g_interface) {
+		// TODO
+		DebugPrintf("Cannot jump without interface set up\n");
+		return true;
+	}
+
+	// TODO: Default room/direction for each neighborhood
+
+	if (argc < 4) {
+		DebugPrintf("Usage: jump <neighborhood> <room> <direction>\n");
+		return true;
+	}
+
+	tNeighborhoodID neighborhood = (tNeighborhoodID)atoi(argv[1]);
+	tRoomID room = (tRoomID)atoi(argv[2]);
+	tDirectionConstant direction = (tDirectionConstant)atoi(argv[3]);
+
+	if (neighborhood < kCaldoriaID || neighborhood > kNoradDeltaID || neighborhood == kFinalTSAID) {
+		DebugPrintf("Invalid neighborhood %d", neighborhood);
+		return true;
+	}
+
+	// No real way to check room validity at this point
+
+	if (direction > kWest) {
+		DebugPrintf("Invalid direction %d", direction);
+		return true;
+	}
+
+	// Here we go!
+	// TODO: Can't clear menu since the engine is paused
+	_vm->jumpToNewEnvironment(neighborhood, room, direction);
+	return false;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/console.h b/engines/pegasus/console.h
index 07adccd..b73b706 100644
--- a/engines/pegasus/console.h
+++ b/engines/pegasus/console.h
@@ -39,6 +39,7 @@ public:
 
 private:
 	bool Cmd_Die(int argc, const char **argv);
+	bool Cmd_Jump(int argc, const char **argv);
 
 	PegasusEngine *_vm;
 };


Commit: af248908073821b9907fcc04ac2420f985761638
    https://github.com/scummvm/scummvm/commit/af248908073821b9907fcc04ac2420f985761638
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-05T11:37:58-07:00

Commit Message:
PEGASUS: Add the Tiny TSA neighborhood

Changed paths:
  A engines/pegasus/neighborhood/tsa/tinytsa.cpp
  A engines/pegasus/neighborhood/tsa/tinytsa.h
    engines/pegasus/constants.h
    engines/pegasus/items/biochips/pegasuschip.cpp
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 5ab2baa..26d6b85 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -738,8 +738,10 @@ static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 // TODO: Remove me
 static const tRoomID kTSA37 = 42;
-static const tRoomID kTinyTSA37 = 0;
 static const tRoomID kTSA00 = 0;
+static const tRoomID kNorad01 = 0;
+static const tRoomID kMars0A = 0;
+static const tRoomID kWSC01 = 0;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
index 5d0c991..5645543 100755
--- a/engines/pegasus/items/biochips/pegasuschip.cpp
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -27,6 +27,7 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/items/biochips/pegasuschip.h"
+#include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 66cf70b..b4aba68 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -55,7 +55,8 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
-	neighborhood/prehistoric/prehistoric.o
+	neighborhood/prehistoric/prehistoric.o \
+	neighborhood/tsa/tinytsa.o
 
 
 # This module can be built as a plugin
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index ed64b3e..0582b78 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -36,6 +36,7 @@
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
 
@@ -139,8 +140,13 @@ void Neighborhood::init() {
 	_navMovie.initFromMovieFile(getNavMovieName());
 	_navMovie.setVolume(_vm->getSoundFXLevel());
 
-	_spotSounds.initFromQuickTime(getSoundSpotsName());
-	_spotSounds.setVolume(_vm->getSoundFXLevel());
+	Common::String soundSpotsName = getSoundSpotsName();
+	if (soundSpotsName.empty()) {
+		_spotSounds.disposeSound();
+	} else {
+		_spotSounds.initFromQuickTime(getSoundSpotsName());
+		_spotSounds.setVolume(_vm->getSoundFXLevel());
+	}
 
 	_navMovie.setDisplayOrder(kNavMovieOrder);
 	_navMovie.startDisplaying();
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
new file mode 100755
index 0000000..fa611bd
--- /dev/null
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -0,0 +1,454 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/aichip.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/neighborhood/tsa/tinytsa.h"
+
+namespace Pegasus {
+
+const short kCompassShift = 30;
+
+const TimeScale kTinyTSAMovieScale = 600;
+const TimeScale kTinyTSAFramesPerSecond = 15;
+const TimeScale kTinyTSAFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltTinyTSANormal = 0;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationTinyTSAJumpToNorad = 1;
+const tHotSpotActivationID kActivationTinyTSAJumpToMars = 2;
+const tHotSpotActivationID kActivationTinyTSAJumpToWSC = 3;
+const tHotSpotActivationID kActivationTinyTSAReadyForJumpMenu = 4;
+const tHotSpotActivationID kActivationTinyTSAMainJumpMenu = 5;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kTinyTSA37NorthJumpToNoradSpotID = 5000;
+const tHotSpotID kTinyTSA37NorthCancelNoradSpotID = 5001;
+const tHotSpotID kTinyTSA37NorthJumpToMarsSpotID = 5002;
+const tHotSpotID kTinyTSA37NorthCancelMarsSpotID = 5003;
+const tHotSpotID kTinyTSA37NorthJumpToWSCSpotID = 5004;
+const tHotSpotID kTinyTSA37NorthCancelWSCSpotID = 5005;
+const tHotSpotID kTinyTSA37NorthJumpMenuSpotID = 5006;
+const tHotSpotID kTinyTSA37NorthNoradMenuSpotID = 5007;
+const tHotSpotID kTinyTSA37NorthMarsMenuSpotID = 5008;
+const tHotSpotID kTinyTSA37NorthWSCMenuSpotID = 5009;
+
+//	Extra sequence IDs.
+
+const tExtraID kTinyTSA37PegasusDepart = 0;
+const tExtraID kTinyTSA37TimeJumpToPegasus = 1;
+const tExtraID kTinyTSA37RecallToDownload = 2;
+const tExtraID kTinyTSA37ExitHilited = 3;
+const tExtraID kTinyTSA37ExitToHorse = 4;
+const tExtraID kTinyTSA37JumpMenu000 = 5;
+const tExtraID kTinyTSA37JumpMenu001 = 6;
+const tExtraID kTinyTSA37JumpMenu010 = 7;
+const tExtraID kTinyTSA37JumpMenu011 = 8;
+const tExtraID kTinyTSA37JumpMenu100 = 9;
+const tExtraID kTinyTSA37JumpMenu101 = 10;
+const tExtraID kTinyTSA37JumpMenu110 = 11;
+const tExtraID kTinyTSA37JumpMenu111 = 12;
+const tExtraID kTinyTSA37JumpToWSCMenu = 13;
+const tExtraID kTinyTSA37CancelWSC = 14;
+const tExtraID kTinyTSA37JumpToWSC = 15;
+const tExtraID kTinyTSA37WSCToAI5 = 16;
+const tExtraID kTinyTSA37PegasusAI5 = 17;
+const tExtraID kTinyTSA37AI5ToWSC = 18;
+const tExtraID kTinyTSA37WSCToDepart = 19;
+const tExtraID kTinyTSA37JumpToMarsMenu = 20;
+const tExtraID kTinyTSA37CancelMars = 21;
+const tExtraID kTinyTSA37JumpToMars = 22;
+const tExtraID kTinyTSA37MarsToAI6 = 23;
+const tExtraID kTinyTSA37PegasusAI6 = 24;
+const tExtraID kTinyTSA37AI6ToMars = 25;
+const tExtraID kTinyTSA37MarsToDepart = 26;
+const tExtraID kTinyTSA37JumpToNoradMenu = 27;
+const tExtraID kTinyTSA37CancelNorad = 28;
+const tExtraID kTinyTSA37JumpToNorad = 29;
+const tExtraID kTinyTSA37NoradToAI7 = 30;
+const tExtraID kTinyTSA37PegasusAI7 = 31;
+const tExtraID kTinyTSA37AI7ToNorad = 32;
+const tExtraID kTinyTSA37NoradToDepart = 33;
+const tExtraID kTinyTSA37EnvironmentalScan = 34;
+const tExtraID kTinyTSA37DownloadToMainMenu = 35;
+const tExtraID kTinyTSA37DownloadToOpMemReview = 36;
+const tExtraID kTinyTSA37OpMemReviewToMainMenu = 37;
+
+TinyTSA::TinyTSA(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Tiny TSA", kTinyTSAID) {
+}
+
+void TinyTSA::start() {
+	g_energyMonitor->stopEnergyDraining();
+	Neighborhood::start();
+}
+
+Common::String TinyTSA::getBriefingMovie() {
+	Common::String movieName = Neighborhood::getBriefingMovie();
+
+	if (movieName.empty()) {
+		switch (getCurrentActivation()) {
+		case kActivationTinyTSAJumpToNorad:
+			g_AIChip->showBriefingClicked();
+			startExtraSequenceSync(kTinyTSA37PegasusAI7, kHintInterruption);
+			startExtraSequenceSync(kTinyTSA37AI7ToNorad, kFilterNoInput);
+			g_AIChip->clearClicked();
+			movieName = "";
+			break;
+		case kActivationTinyTSAJumpToMars:
+			g_AIChip->showBriefingClicked();
+			startExtraSequenceSync(kTinyTSA37PegasusAI6, kHintInterruption);
+			startExtraSequenceSync(kTinyTSA37AI6ToMars, kFilterNoInput);
+			g_AIChip->clearClicked();
+			movieName = "";
+			break;
+		case kActivationTinyTSAJumpToWSC:
+			g_AIChip->showBriefingClicked();
+			startExtraSequenceSync(kTinyTSA37PegasusAI5, kHintInterruption);
+			startExtraSequenceSync(kTinyTSA37AI5ToWSC, kFilterNoInput);
+			g_AIChip->clearClicked();
+			movieName = "";
+			break;
+		default:
+			movieName = "Images/AI/TSA/XT04";
+			break;
+		}
+	}
+
+	return movieName;
+}
+
+Common::String TinyTSA::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		g_AIChip->showEnvScanClicked();
+		startExtraSequenceSync(kTinyTSA37EnvironmentalScan, kHintInterruption);
+
+		switch (getCurrentActivation()) {
+		case kActivationTinyTSAJumpToNorad:
+			startExtraSequenceSync(kTinyTSA37AI7ToNorad, kFilterNoInput);
+			showExtraView(kTinyTSA37JumpToNoradMenu);
+			break;
+		case kActivationTinyTSAJumpToMars:
+			startExtraSequenceSync(kTinyTSA37AI6ToMars, kFilterNoInput);
+			showExtraView(kTinyTSA37JumpToMarsMenu);
+			break;
+		case kActivationTinyTSAJumpToWSC:
+			startExtraSequenceSync(kTinyTSA37AI5ToWSC, kFilterNoInput);
+			showExtraView(kTinyTSA37JumpToWSCMenu);
+			break;
+		default:
+			showMainJumpMenu();
+			break;
+		}
+
+		g_AIChip->clearClicked();
+	}
+
+	return movieName;
+}
+
+void TinyTSA::loadAmbientLoops() {
+	loadLoopSound1("Sounds/TSA/T01NAE.NEW.22K.AIFF");
+}
+
+int16 TinyTSA::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	return Neighborhood::getStaticCompassAngle(room, dir) - kCompassShift;
+}
+
+
+uint16 TinyTSA::getDateResID() const {
+	return kDate2318ID;
+}
+
+tInputBits TinyTSA::getInputFilter() {
+	// Can't move forward...
+	return Neighborhood::getInputFilter() & ~(kFilterUpButton | kFilterUpAuto);
+}
+
+void TinyTSA::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
+	if (clickedSpot) {
+		switch (clickedSpot->getObjectID()) {
+		case kTinyTSA37NorthJumpMenuSpotID:
+			warning("jump menu spot");
+			return;
+		case kTinyTSA37NorthJumpToNoradSpotID:
+			GameState.setTSAState(kPlayerOnWayToNorad);
+			requestExtraSequence(kTinyTSA37JumpToNorad, 0, kFilterNoInput);
+			if (!GameState.getBeenToNorad()) {
+				requestExtraSequence(kTinyTSA37NoradToAI7, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37PegasusAI7, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37AI7ToNorad, 0, kFilterNoInput);
+				GameState.setBeenToNorad(true);
+			}
+
+			requestExtraSequence(kTinyTSA37NoradToDepart, 0, kFilterNoInput);
+			requestExtraSequence(kTinyTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		case kTinyTSA37NorthJumpToMarsSpotID:
+			GameState.setTSAState(kPlayerOnWayToMars);
+			requestExtraSequence(kTinyTSA37JumpToMars, 0, kFilterNoInput);
+			if (!GameState.getBeenToMars()) {
+				requestExtraSequence(kTinyTSA37MarsToAI6, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37PegasusAI6, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37AI6ToMars, 0, kFilterNoInput);
+				GameState.setBeenToMars(true);
+			}
+
+			requestExtraSequence(kTinyTSA37MarsToDepart, 0, kFilterNoInput);
+			requestExtraSequence(kTinyTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		case kTinyTSA37NorthJumpToWSCSpotID:
+			GameState.setTSAState(kPlayerOnWayToWSC);
+			requestExtraSequence(kTinyTSA37JumpToWSC, 0, kFilterNoInput);
+			if (!GameState.getBeenToWSC()) {
+				requestExtraSequence(kTinyTSA37WSCToAI5, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37PegasusAI5, 0, kFilterNoInput);
+				requestExtraSequence(kTinyTSA37AI5ToWSC, 0, kFilterNoInput);
+				GameState.setBeenToWSC(true);
+			}
+
+			requestExtraSequence(kTinyTSA37WSCToDepart, 0, kFilterNoInput);
+			requestExtraSequence(kTinyTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		}
+	}
+
+	Neighborhood::clickInHotspot(input, clickedSpot);
+}
+
+void TinyTSA::showMainJumpMenu() {
+	tExtraID jumpMenuView = kTinyTSA37JumpMenu000;
+
+	if (GameState.getNoradFinished())
+		jumpMenuView += 4;
+	if (GameState.getMarsFinished())
+		jumpMenuView += 2;
+	if (GameState.getWSCFinished())
+		jumpMenuView += 1;
+
+	showExtraView(jumpMenuView);
+	setCurrentActivation(kActivationTinyTSAMainJumpMenu);
+}
+
+void TinyTSA::checkContinuePoint(const tRoomID, const tDirectionConstant) {
+	makeContinuePoint();
+}
+
+void TinyTSA::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	Neighborhood::arriveAt(room, direction);
+
+	switch (GameState.getTSAState()) {
+	case kPlayerOnWayToNorad:
+	case kPlayerOnWayToMars:
+	case kPlayerOnWayToWSC:
+		startExtraSequence(kTinyTSA37TimeJumpToPegasus, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kPlayerLockedInPegasus:
+		showMainJumpMenu();
+		break;
+	}
+}
+
+void TinyTSA::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	tExtraID lastExtra = _lastExtra;
+	
+	Neighborhood::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		// Only allow input if we're not in the middle of series of queue requests.
+		if (actionQueueEmpty())
+			_interruptionFilter = kFilterAllInput;
+
+		switch (lastExtra) {
+		case kTinyTSA37PegasusDepart:
+			_vm->setLastEnergyValue(kFullEnergy);
+
+			switch (GameState.getTSAState()) {
+			case kPlayerOnWayToNorad:
+				_vm->jumpToNewEnvironment(kNoradAlphaID, kNorad01, kSouth);
+				GameState.setNoradSeenTimeStream(false);
+				GameState.setNoradGassed(true);
+				GameState.setNoradFillingStationOn(false);
+				GameState.setNoradN22MessagePlayed(false);
+				GameState.setNoradPlayedGlobeGame(false);
+				GameState.setNoradBeatRobotWithClaw(false);
+				GameState.setNoradBeatRobotWithDoor(false);
+				GameState.setNoradRetScanGood(false);
+				GameState.setNoradWaitingForLaser(false);
+				GameState.setNoradSubRoomPressure(9);
+				GameState.setNoradSubPrepState(kSubNotPrepped);
+				break;
+			case kPlayerOnWayToMars:
+				_vm->jumpToNewEnvironment(kMarsID, kMars0A, kNorth);
+				GameState.setMarsSeenTimeStream(false);
+				GameState.setMarsHeardUpperPodMessage(false);
+				GameState.setMarsRobotThrownPlayer(false);
+				GameState.setMarsHeardCheckInMessage(false);
+				GameState.setMarsPodAtUpperPlatform(false);
+				GameState.setMarsSeenThermalScan(false);
+				GameState.setMarsArrivedBelow(false);
+				GameState.setMarsSeenRobotAtReactor(false);
+				GameState.setMarsAvoidedReactorRobot(false);
+				GameState.setMarsLockFrozen(false);
+				GameState.setMarsLockBroken(false);
+				GameState.setMarsSecurityDown(false);
+				GameState.setMarsAirlockOpen(false);
+				GameState.setMarsReadyForShuttleTransport(false);
+				GameState.setMarsFinishedCanyonChase(false);
+				GameState.setMarsThreadedMaze(false);
+				break;
+			case kPlayerOnWayToWSC:
+				_vm->jumpToNewEnvironment(kWSCID, kWSC01, kWest);
+				GameState.setWSCSeenTimeStream(false);
+				GameState.setWSCPoisoned(false);
+				GameState.setWSCAnsweredAboutDart(false);
+				GameState.setWSCDartInAnalyzer(false);
+				GameState.setWSCRemovedDart(false);
+				GameState.setWSCAnalyzerOn(false);
+				GameState.setWSCAnalyzedDart(false);
+				GameState.setWSCPickedUpAntidote(false);
+				GameState.setWSCSawMorph(false);
+				GameState.setWSCDesignedAntidote(false);
+				GameState.setWSCOfficeMessagesOpen(false);
+				GameState.setWSCSeenNerd(false);
+				GameState.setWSCHeardPage1(false);
+				GameState.setWSCHeardPage2(false);
+				GameState.setWSCHeardCheckIn(false);
+				GameState.setWSCDidPlasmaDodge(false);
+				GameState.setWSCSeenSinclairLecture(false);
+				GameState.setWSCBeenAtWSC93(false);
+				GameState.setWSCCatwalkDark(false);
+				GameState.setWSCRobotDead(false);
+				GameState.setWSCRobotGone(false);
+				break;
+			};
+			break;
+		case kTinyTSA37TimeJumpToPegasus:
+			if (g_energyMonitor)
+				g_energyMonitor->stopEnergyDraining();
+
+			switch (GameState.getTSAState()) {
+			case kPlayerOnWayToNorad:
+				arriveFromNorad();
+				break;
+			case kPlayerOnWayToMars:
+				arriveFromMars();
+				break;
+			case kPlayerOnWayToWSC:
+				arriveFromWSC();
+				break;
+			default:
+				break;
+			}
+			break;
+		case kTinyTSA37DownloadToOpMemReview:
+			switch (GameState.getTSAState()) {
+			case kPlayerOnWayToNorad:
+				g_opticalChip->playOpMemMovie(kPoseidonSpotID);
+				break;
+			case kPlayerOnWayToMars:
+				g_opticalChip->playOpMemMovie(kAriesSpotID);
+				break;
+			case kPlayerOnWayToWSC:
+				g_opticalChip->playOpMemMovie(kMercurySpotID);
+				break;
+			}
+
+			requestExtraSequence(kTinyTSA37OpMemReviewToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kTinyTSA37DownloadToMainMenu:
+		case kTinyTSA37OpMemReviewToMainMenu:
+			GameState.setTSAState(kPlayerLockedInPegasus);
+			showMainJumpMenu();
+			makeContinuePoint();
+			break;
+		case kTinyTSA37JumpToNoradMenu:
+			setCurrentActivation(kActivationTinyTSAJumpToNorad);
+			break;
+		case kTinyTSA37JumpToMarsMenu:
+			setCurrentActivation(kActivationTinyTSAJumpToMars);
+			break;
+		case kTinyTSA37JumpToWSCMenu:
+			setCurrentActivation(kActivationTinyTSAJumpToWSC);
+			break;
+		case kTinyTSA37CancelNorad:
+		case kTinyTSA37CancelMars:
+		case kTinyTSA37CancelWSC:
+			showMainJumpMenu();
+			break;
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+void TinyTSA::arriveFromNorad() {
+	requestExtraSequence(kTinyTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getNoradFinished() && !GameState.getScoringFinishedNorad()) {
+		GameState.setScoringFinishedNorad();
+		requestExtraSequence(kTinyTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTinyTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void TinyTSA::arriveFromMars() {
+	requestExtraSequence(kTinyTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getMarsFinished() && !GameState.getScoringFinishedMars()) {
+		GameState.setScoringFinishedMars();
+		requestExtraSequence(kTinyTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTinyTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void TinyTSA::arriveFromWSC() {
+	requestExtraSequence(kTinyTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getWSCFinished() && !GameState.getScoringFinishedWSC()) {
+		GameState.setScoringFinishedWSC();
+		requestExtraSequence(kTinyTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTinyTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+Common::String TinyTSA::getNavMovieName() {
+	return "Images/TSA/Tiny TSA.movie";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.h b/engines/pegasus/neighborhood/tsa/tinytsa.h
new file mode 100755
index 0000000..705010e
--- /dev/null
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.h
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_TSA_TINYTSA_H
+#define PEGASUS_NEIGHBORHOOD_TSA_TINYTSA_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+//	Room IDs.
+
+const tRoomID kTinyTSA37 = 0;
+
+class TinyTSA : public Neighborhood {
+public:
+	TinyTSA(InputHandler *, PegasusEngine *);
+	virtual ~TinyTSA() {}
+	
+	virtual uint16 getDateResID() const;
+	
+	void start();
+	
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+protected:
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	void loadAmbientLoops();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	
+	virtual int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	
+	void arriveFromNorad();
+	void arriveFromMars();
+	void arriveFromWSC();
+	
+	tInputBits getInputFilter();
+	void arriveAt(const tRoomID, const tDirectionConstant);
+	void showMainJumpMenu();
+	void receiveNotification(Notification *, const tNotificationFlags);
+
+	Common::String getNavMovieName();
+	Common::String getSoundSpotsName() { return ""; }
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 4200147..c50f7a6 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -61,6 +61,7 @@
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
+#include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
 
@@ -1360,6 +1361,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kPrehistoricID:
 		neighborhood = new Prehistoric(g_AIArea, this);
 		break;
+	case kTinyTSAID:
+		neighborhood = new TinyTSA(g_AIArea, this);
+		break;
 	}
 }
 


Commit: a80af5eb4da6181df614d2d989f89c5ae988bb5e
    https://github.com/scummvm/scummvm/commit/a80af5eb4da6181df614d2d989f89c5ae988bb5e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-06T20:53:53-07:00

Commit Message:
PEGASUS: Add the Full TSA neighborhood

Changed paths:
  A engines/pegasus/neighborhood/tsa/fulltsa.cpp
  A engines/pegasus/neighborhood/tsa/fulltsa.h
    engines/pegasus/constants.h
    engines/pegasus/items/biochips/pegasuschip.cpp
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 26d6b85..20a7f69 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -737,8 +737,6 @@ static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
 static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 // TODO: Remove me
-static const tRoomID kTSA37 = 42;
-static const tRoomID kTSA00 = 0;
 static const tRoomID kNorad01 = 0;
 static const tRoomID kMars0A = 0;
 static const tRoomID kWSC01 = 0;
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
index 5645543..8d369c1 100755
--- a/engines/pegasus/items/biochips/pegasuschip.cpp
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -27,6 +27,7 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/items/biochips/pegasuschip.h"
+#include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index b4aba68..9f1265c 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -56,6 +56,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/prehistoric/prehistoric.o \
+	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o
 
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index b4df89a..9e8717b 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -37,6 +37,7 @@
 #include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
 #include "pegasus/neighborhood/caldoria/caldoriamessages.h"
 #include "pegasus/neighborhood/caldoria/caldoriamirror.h"
+#include "pegasus/neighborhood/tsa/fulltsa.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 0582b78..e17e100 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -36,6 +36,7 @@
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
new file mode 100755
index 0000000..1656e9f
--- /dev/null
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -0,0 +1,3016 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/cursor.h"
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/aichip.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/prehistoric/prehistoric.h"
+#include "pegasus/neighborhood/tsa/fulltsa.h"
+
+namespace Pegasus {
+
+// TSA PICTs:
+
+const tResIDType kTBPCloseBoxPICTID = 800;
+const tResIDType kTBPRewindPICTID = 801;
+const tResIDType kUnresolvedPICTID = 802;
+const tResIDType kResolvedPICTID = 803;
+const tResIDType kJumpMenuPICTID = 804;
+const tResIDType kJumpMenuHilitedPICTID = 805;
+const tResIDType kExitPICTID = 806;
+const tResIDType kExitHilitedPICTID = 807;
+const tResIDType kLeftRipPICTID = 808;
+const tResIDType kComparisonCloseBoxPICTID = 809;
+const tResIDType kComparisonLeftRewindPICTID = 810;
+const tResIDType kComparisonRightRewindPICTID = 811;
+const tResIDType kComparisonHiliteNoradPICTID = 812;
+const tResIDType kComparisonHiliteMarsPICTID = 813;
+const tResIDType kComparisonHiliteCaldoriaPICTID = 814;
+const tResIDType kComparisonHiliteWSCPICTID = 815;
+const tResIDType kComparisonChancesNoradPICTID = 816;
+const tResIDType kComparisonChancesMarsPICTID = 817;
+const tResIDType kComparisonChancesCaldoriaPICTID = 818;
+const tResIDType kComparisonChancesWSCPICTID = 819;
+const tResIDType kRedirectionCCRolloverPICTID = 820;
+const tResIDType kRedirectionRRRolloverPICTID = 821;
+const tResIDType kRedirectionFDRolloverPICTID = 822;
+const tResIDType kRedirectionCCDoorPICTID = 823;
+const tResIDType kRedirectionRRDoorPICTID = 824;
+const tResIDType kRedirectionFDDoorPICTID = 825;
+const tResIDType kRedirectionSecuredPICTID = 826;
+const tResIDType kRedirectionNewTargetPICTID = 827;
+const tResIDType kRedirectionClosePICTID = 828;
+
+const short kCompassShift = 15;
+
+const TimeScale kFullTSAMovieScale = 600;
+const TimeScale kFullTSAFramesPerSecond = 15;
+const TimeScale kFullTSAFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltTSANormal = 0;
+const tAlternateID kAltTSARobotsAtReadyRoom = 1;
+const tAlternateID kAltTSARobotsAtFrontDoor = 2;
+const tAlternateID kAltTSARedAlert = 3;
+
+//	Room IDs.
+
+const tRoomID kTSA01 = 1;
+const tRoomID kTSA02 = 2;
+const tRoomID kTSA03 = 3;
+const tRoomID kTSA04 = 4;
+const tRoomID kTSA05 = 5;
+const tRoomID kTSA0A = 6;
+const tRoomID kTSA06 = 7;
+const tRoomID kTSA07 = 8;
+const tRoomID kTSA08 = 9;
+const tRoomID kTSA09 = 10;
+const tRoomID kTSA10 = 11;
+const tRoomID kTSA11 = 12;
+const tRoomID kTSA12 = 13;
+const tRoomID kTSA13 = 14;
+const tRoomID kTSA14 = 15;
+const tRoomID kTSA15 = 16;
+const tRoomID kTSA16 = 17;
+const tRoomID kTSA17 = 18;
+const tRoomID kTSA18 = 19;
+const tRoomID kTSA19 = 20;
+const tRoomID kTSA0B = 21;
+const tRoomID kTSA21Cyan = 22;
+const tRoomID kTSA22Cyan = 23;
+const tRoomID kTSA23Cyan = 24;
+const tRoomID kTSA24Cyan = 25;
+const tRoomID kTSA25Cyan = 26;
+const tRoomID kTSA21Red = 27;
+const tRoomID kTSA22Red = 28;
+const tRoomID kTSA23Red = 29;
+const tRoomID kTSA24Red = 30;
+const tRoomID kTSA25Red = 31;
+const tRoomID kTSA26 = 32;
+const tRoomID kTSA27 = 33;
+const tRoomID kTSA28 = 34;
+const tRoomID kTSA29 = 35;
+const tRoomID kTSA30 = 36;
+const tRoomID kTSA31 = 37;
+const tRoomID kTSA32 = 38;
+const tRoomID kTSA33 = 39;
+const tRoomID kTSA34 = 40;
+const tRoomID kTSA35 = 41;
+const tRoomID kTSADeathRoom = 43;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivateTSAReadyForCard = 1;
+const tHotSpotActivationID kActivateTSAReadyToTransport = 2;
+const tHotSpotActivationID kActivateTSARobotsAwake = 3;
+const tHotSpotActivationID kActivateTSA0BZoomedOut = 4;
+const tHotSpotActivationID kActivateTSA0BZoomedIn = 5;
+const tHotSpotActivationID kActivateTSA0BComparisonVideo = 6;
+const tHotSpotActivationID kActivationLogReaderOpen = 7;
+const tHotSpotActivationID kActivateTSA0BTBPVideo = 8;
+const tHotSpotActivationID kActivationDoesntHaveKey = 9;
+const tHotSpotActivationID kActivationKeyVaultOpen = 10;
+const tHotSpotActivationID kActivationDoesntHaveChips = 11;
+const tHotSpotActivationID kActivationChipVaultOpen = 12;
+const tHotSpotActivationID kActivationJumpToPrehistoric = 13;
+const tHotSpotActivationID kActivationJumpToNorad = 14;
+const tHotSpotActivationID kActivationJumpToMars = 15;
+const tHotSpotActivationID kActivationJumpToWSC = 16;
+const tHotSpotActivationID kActivationReadyToExit = 17;
+const tHotSpotActivationID kActivationReadyForJumpMenu = 18;
+const tHotSpotActivationID kActivationMainJumpMenu = 19;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kTSAGTCardDropSpotID = 5000;
+const tHotSpotID kTSAGTTokyoSpotID = 5001;
+const tHotSpotID kTSAGTCaldoriaSpotID = 5002;
+const tHotSpotID kTSAGTBeachSpotID = 5003;
+const tHotSpotID kTSAGTOtherSpotID = 5004;
+const tHotSpotID kTSA02DoorSpotID = 5005;
+const tHotSpotID kTSA03EastJimenezSpotID = 5006;
+const tHotSpotID kTSA03WestCrenshawSpotID = 5007;
+const tHotSpotID kTSA04EastMatsumotoSpotID = 5008;
+const tHotSpotID kTSA04WestCastilleSpotID = 5009;
+const tHotSpotID kTSA05EastSinclairSpotID = 5010;
+const tHotSpotID kTSA05WestWhiteSpotID = 5011;
+const tHotSpotID kTSA0AEastSpotID = 5012;
+const tHotSpotID kTSA0AWastSpotID = 5013;
+const tHotSpotID kTSA0BEastMonitorSpotID = 5014;
+const tHotSpotID kTSA0BEastMonitorOutSpotID = 5015;
+const tHotSpotID kTSA0BEastCompareNoradSpotID = 5016;
+const tHotSpotID kTSA0BEastCompareMarsSpotID = 5017;
+const tHotSpotID kTSA0BEastCompareCaldoriaSpotID = 5018;
+const tHotSpotID kTSA0BEastCompareWSCSpotID = 5019;
+const tHotSpotID kTSA0BEastLeftRewindSpotID = 5020;
+const tHotSpotID kTSA0BEastLeftPlaySpotID = 5021;
+const tHotSpotID kTSA0BEastRightRewindSpotID = 5022;
+const tHotSpotID kTSA0BEastRightPlaySpotID = 5023;
+const tHotSpotID kTSA0BEastCloseVideoSpotID = 5024;
+const tHotSpotID kTSA0BNorthMonitorSpotID = 5025;
+const tHotSpotID kTSA0BNorthMonitorOutSpotID = 5026;
+const tHotSpotID kTSA0BNorthHistLogSpotID = 5027;
+const tHotSpotID kTSA0BNorthRobotsToCommandCenterSpotID = 5028;
+const tHotSpotID kTSA0BNorthRobotsToReadyRoomSpotID = 5029;
+const tHotSpotID kTSA0BNorthRobotsToFrontDoorSpotID = 5030;
+const tHotSpotID kTSA0BWestMonitorSpotID = 5031;
+const tHotSpotID kTSA0BWestMonitorOutSpotID = 5032;
+const tHotSpotID kTSA0BWestTheorySpotID = 5033;
+const tHotSpotID kTSA0BWestBackgroundSpotID = 5034;
+const tHotSpotID kTSA0BWestProcedureSpotID = 5035;
+const tHotSpotID kTSA0BWestCloseVideoSpotID = 5036;
+const tHotSpotID kTSA0BWestPlayVideoSpotID = 5037;
+const tHotSpotID kTSA0BWestRewindVideoSpotID = 5038;
+const tHotSpotID kTSA22EastMonitorSpotID = 5039;
+const tHotSpotID kTSA22EastKeySpotID = 5040;
+const tHotSpotID kTSA23WestMonitorSpotID = 5041;
+const tHotSpotID kTSA23WestChipsSpotID = 5042;
+const tHotSpotID kTSA34NorthDoorSpotID = 5043;
+const tHotSpotID kTSA37NorthJumpToPrehistoricSpotID = 5044;
+const tHotSpotID kTSA37NorthJumpToNoradSpotID = 5045;
+const tHotSpotID kTSA37NorthCancelNoradSpotID = 5046;
+const tHotSpotID kTSA37NorthJumpToMarsSpotID = 5047;
+const tHotSpotID kTSA37NorthCancelMarsSpotID = 5048;
+const tHotSpotID kTSA37NorthJumpToWSCSpotID = 5049;
+const tHotSpotID kTSA37NorthCancelWSCSpotID = 5050;
+const tHotSpotID kTSA37NorthExitSpotID = 5051;
+const tHotSpotID kTSA37NorthJumpMenuSpotID = 5052;
+const tHotSpotID kTSA37NorthNoradMenuSpotID = 5053;
+const tHotSpotID kTSA37NorthMarsMenuSpotID = 5054;
+const tHotSpotID kTSA37NorthWSCMenuSpotID = 5055;
+
+//	Extra sequence IDs.
+
+const tExtraID kTSATransporterArrowLoop = 0;
+const tExtraID kTSAArriveFromCaldoria = 1;
+const tExtraID kTSAGTOtherChoice = 2;
+const tExtraID kTSAGTCardSwipe = 3;
+const tExtraID kTSAGTSelectCaldoria = 4;
+const tExtraID kTSAGTGoToCaldoria = 5;
+const tExtraID kTSAGTSelectBeach = 6;
+const tExtraID kTSAGTGoToBeach = 7;
+const tExtraID kTSAGTArriveAtBeach = 8;
+const tExtraID kTSAGTSelectTokyo = 9;
+const tExtraID kTSAGTGoToTokyo = 10;
+const tExtraID kTSAGTArriveAtTokyo = 11;
+const tExtraID kTSA02NorthZoomIn = 12;
+const tExtraID kTSA02NorthTenSecondDoor = 13;
+const tExtraID kTSA02NorthZoomOut = 14;
+const tExtraID kTSA02NorthDoorWithAgent3 = 15;
+const tExtraID kTSA03JimenezZoomIn = 16;
+const tExtraID kTSA03JimenezSpeech = 17;
+const tExtraID kTSA03JimenezZoomOut = 18;
+const tExtraID kTSA03CrenshawZoomIn = 19;
+const tExtraID kTSA03CrenshawSpeech = 20;
+const tExtraID kTSA03CrenshawZoomOut = 21;
+const tExtraID kTSA03SouthRobotDeath = 22;
+const tExtraID kTSA04NorthRobotGreeting = 23;
+const tExtraID kTSA04MatsumotoZoomIn = 24;
+const tExtraID kTSA04MatsumotoSpeech = 25;
+const tExtraID kTSA04MatsumotoZoomOut = 26;
+const tExtraID kTSA04CastilleZoomIn = 27;
+const tExtraID kTSA04CastilleSpeech = 28;
+const tExtraID kTSA04CastilleZoomOut = 29;
+const tExtraID kTSA05SinclairZoomIn = 30;
+const tExtraID kTSA05SinclairSpeech = 31;
+const tExtraID kTSA05SinclairZoomOut = 32;
+const tExtraID kTSA05WhiteZoomIn = 33;
+const tExtraID kTSA05WhiteSpeech = 34;
+const tExtraID kTSA05WhiteZoomOut = 35;
+const tExtraID kTSA0AEastRobot = 36;
+const tExtraID kTSA0AWestRobot = 37;
+const tExtraID kTSA16NorthRobotDeath = 38;
+const tExtraID kTSA0BEastZoomIn = 39;
+const tExtraID kTSA0BEastZoomedView = 40;
+const tExtraID kTSA0BEastZoomOut = 41;
+const tExtraID kTSA0BEastTurnLeft = 42;
+const tExtraID kTSA0BComparisonStartup = 43;
+const tExtraID kTSA0BComparisonView0000 = 44;
+const tExtraID kTSA0BComparisonView0002 = 45;
+const tExtraID kTSA0BComparisonView0020 = 46;
+const tExtraID kTSA0BComparisonView0022 = 47;
+const tExtraID kTSA0BComparisonView0200 = 48;
+const tExtraID kTSA0BComparisonView0202 = 49;
+const tExtraID kTSA0BComparisonView0220 = 50;
+const tExtraID kTSA0BComparisonView0222 = 51;
+const tExtraID kTSA0BComparisonView2000 = 52;
+const tExtraID kTSA0BComparisonView2002 = 53;
+const tExtraID kTSA0BComparisonView2020 = 54;
+const tExtraID kTSA0BComparisonView2022 = 55;
+const tExtraID kTSA0BComparisonView2200 = 56;
+const tExtraID kTSA0BComparisonView2202 = 57;
+const tExtraID kTSA0BComparisonView2220 = 58;
+const tExtraID kTSA0BComparisonView2222 = 59;
+const tExtraID kTSA0BNoradComparisonView = 60;
+const tExtraID kTSA0BNoradUnaltered = 61;
+const tExtraID kTSA0BNoradAltered = 62;
+const tExtraID kTSA0BMarsComparisonView = 63;
+const tExtraID kTSA0BMarsUnaltered = 64;
+const tExtraID kTSA0BMarsAltered = 65;
+const tExtraID kTSA0BWSCComparisonView = 66;
+const tExtraID kTSA0BWSCUnaltered = 67;
+const tExtraID kTSA0BWSCAltered = 68;
+const tExtraID kTSA0BCaldoriaComparisonView = 69;
+const tExtraID kTSA0BCaldoriaUnaltered = 70;
+const tExtraID kTSA0BCaldoriaAltered = 71;
+const tExtraID kTSA0BNorthZoomIn = 72;
+const tExtraID kTSA0BNorthZoomedView = 73;
+const tExtraID kTSA0BNorthZoomOut = 74;
+const tExtraID kTSA0BNorthTurnLeft = 75;
+const tExtraID kTSA0BNorthTurnRight = 76;
+const tExtraID kTSA0BNorthHistLogOpen = 77;
+const tExtraID kTSA0BNorthHistLogClose = 78;
+const tExtraID kTSA0BNorthHistLogCloseWithLog = 79;
+const tExtraID kTSA0BNorthCantChangeHistory = 80;
+const tExtraID kTSA0BNorthYoureBusted = 81;
+const tExtraID kTSA0BNorthFinallyHappened = 82;
+const tExtraID kTSA0BShowRip1 = 83;
+const tExtraID kTSA0BNorthRipView1 = 84;
+const tExtraID kTSA0BShowRip2 = 85;
+const tExtraID kTSA0BShowGuardRobots = 86;
+const tExtraID kTSA0BAIInterruption = 87;
+const tExtraID kTSA0BRobotsToCommandCenter = 88;
+const tExtraID kTSA0BNorthRobotsAtCCView = 89;
+const tExtraID kTSA0BNorthRobotsAtRRView = 90;
+const tExtraID kTSA0BNorthRobotsAtFDView = 91;
+const tExtraID kTSA0BRobotsFromCommandCenterToReadyRoom = 92;
+const tExtraID kTSA0BRobotsFromReadyRoomToCommandCenter = 93;
+const tExtraID kTSA0BRobotsFromCommandCenterToFrontDoor = 94;
+const tExtraID kTSA0BRobotsFromFrontDoorToCommandCenter = 95;
+const tExtraID kTSA0BRobotsFromFrontDoorToReadyRoom = 96;
+const tExtraID kTSA0BRobotsFromReadyRoomToFrontDoor = 97;
+const tExtraID kTSA0BWestZoomIn = 98;
+const tExtraID kTSA0BWestZoomedView = 99;
+const tExtraID kTSA0BWestZoomOut = 100;
+const tExtraID kTSA0BWestTurnRight = 101;
+const tExtraID kTSA0BTBPTheoryHighlight = 102;
+const tExtraID kTSA0BTBPBackgroundHighlight = 103;
+const tExtraID kTSA0BTBPProcedureHighlight = 104;
+const tExtraID kTSA0BTBPTheory = 105;
+const tExtraID kTSA0BTBPBackground = 106;
+const tExtraID kTSA0BTBPProcedure = 107;
+const tExtraID kTSA0BRipAlarmScreen = 108;
+const tExtraID kTSA22RedEastZoomInSequence = 109;
+const tExtraID kTSA22RedEastVaultViewWithKey = 110;
+const tExtraID kTSA22RedEastVaultViewNoKey = 111;
+const tExtraID kTSA23RedWestVaultZoomInSequence = 112;
+const tExtraID kTSA23RedWestVaultViewWithChips = 113;
+const tExtraID kTSA23RedWestVaultViewNoChips = 114;
+const tExtraID kTSA25NorthDeniedNoKey = 115;
+const tExtraID kTSA25NorthDeniedNoChip = 116;
+const tExtraID kTSA25NorthPutOnSuit = 117;
+const tExtraID kTSA25NorthAlreadyHaveSuit = 118;
+const tExtraID kTSA25NorthDescending1 = 119;
+const tExtraID kTSA25NorthDescending2 = 120;
+const tExtraID kTSA37HorseToAI1 = 121;
+const tExtraID kTSA37PegasusAI1 = 122;
+const tExtraID kTSA37AI1ToCommissioner1 = 123;
+const tExtraID kTSA37Commissioner1 = 124;
+const tExtraID kTSA37Commissioner1ToZoom = 125;
+const tExtraID kTSA37ZoomToPrehistoric = 126;
+const tExtraID kTSA37PrehistoricToAI2 = 127;
+const tExtraID kTSA37PegasusAI2 = 128;
+const tExtraID kTSA37AI2ToPrehistoric = 129;
+const tExtraID kTSA37PrehistoricToDepart = 130;
+const tExtraID kTSA37PegasusDepart = 131;
+const tExtraID kTSA37TimeJumpToPegasus = 132;
+const tExtraID kTSA37RecallToDownload = 133;
+const tExtraID kTSA37DownloadToColonel1 = 134;
+const tExtraID kTSA37Colonel1 = 135;
+const tExtraID kTSA37Colonel1ToReviewRequired = 136;
+const tExtraID kTSA37ReviewRequiredToExit = 137;
+const tExtraID kTSA37ExitHilited = 138;
+const tExtraID kTSA37ExitToHorse = 139;
+const tExtraID kTSA37HorseToColonel2 = 140;
+const tExtraID kTSA37Colonel2 = 141;
+const tExtraID kTSA37PegasusAI3 = 142;
+const tExtraID kTSA37AI3ToHorse = 143;
+const tExtraID kTSA37HorseToZoom = 144;
+const tExtraID kTSA37ZoomToMainMenu = 145;
+const tExtraID kTSA37MainMenuToAI4 = 146;
+const tExtraID kTSA37PegasusAI4 = 147;
+const tExtraID kTSA37AI4ToMainMenu = 148;
+const tExtraID kTSA37JumpMenu000 = 149;
+const tExtraID kTSA37JumpMenu001 = 150;
+const tExtraID kTSA37JumpMenu010 = 151;
+const tExtraID kTSA37JumpMenu011 = 152;
+const tExtraID kTSA37JumpMenu100 = 153;
+const tExtraID kTSA37JumpMenu101 = 154;
+const tExtraID kTSA37JumpMenu110 = 155;
+const tExtraID kTSA37JumpMenu111 = 156;
+const tExtraID kTSA37JumpToWSCMenu = 157;
+const tExtraID kTSA37CancelWSC = 158;
+const tExtraID kTSA37JumpToWSC = 159;
+const tExtraID kTSA37WSCToAI5 = 160;
+const tExtraID kTSA37PegasusAI5 = 161;
+const tExtraID kTSA37AI5ToWSC = 162;
+const tExtraID kTSA37WSCToDepart = 163;
+const tExtraID kTSA37JumpToMarsMenu = 164;
+const tExtraID kTSA37CancelMars = 165;
+const tExtraID kTSA37JumpToMars = 166;
+const tExtraID kTSA37MarsToAI6 = 167;
+const tExtraID kTSA37PegasusAI6 = 168;
+const tExtraID kTSA37AI6ToMars = 169;
+const tExtraID kTSA37MarsToDepart = 170;
+const tExtraID kTSA37JumpToNoradMenu = 171;
+const tExtraID kTSA37CancelNorad = 172;
+const tExtraID kTSA37JumpToNorad = 173;
+const tExtraID kTSA37NoradToAI7 = 174;
+const tExtraID kTSA37PegasusAI7 = 175;
+const tExtraID kTSA37AI7ToNorad = 176;
+const tExtraID kTSA37NoradToDepart = 177;
+const tExtraID kTSA37EnvironmentalScan = 178;
+const tExtraID kTSA37DownloadToMainMenu = 179;
+const tExtraID kTSA37DownloadToOpMemReview = 180;
+const tExtraID kTSA37OpMemReviewToMainMenu = 181;
+const tExtraID kTSA37OpMemReviewToAllClear = 182;
+const tExtraID kTSA37AllClearToCongratulations = 183;
+const tExtraID kTSA37Congratulations = 184;
+const tExtraID kTSA37CongratulationsToExit = 185;
+
+const tDisplayOrder kRipTimerOrder = kMonitorLayer;
+
+
+const tCoordType kUnresolvedLeft = kNavAreaLeft + 14;
+const tCoordType kUnresolvedTop = kNavAreaTop + 236;
+
+const tCoordType kResolvedLeft = kNavAreaLeft + 36;
+const tCoordType kResolvedTop = kNavAreaTop + 236;
+
+const tCoordType kJumpMenuLeft = kNavAreaLeft + 360;
+const tCoordType kJumpMenuTop = kNavAreaTop + 202;
+
+const tCoordType kJumpMenuHilitedLeft = kNavAreaLeft + 354;
+const tCoordType kJumpMenuHilitedTop = kNavAreaTop + 196;
+
+const tCoordType kExitLeft = kNavAreaLeft + 360;
+const tCoordType kExitTop = kNavAreaTop + 216;
+
+const tCoordType kExitHilitedLeft = kNavAreaLeft + 354;
+const tCoordType kExitHilitedTop = kNavAreaTop + 210;
+
+const tCoordType kRipTimerLeft = kNavAreaLeft + 95;
+const tCoordType kRipTimerTop = kNavAreaTop + 87;
+
+const tCoordType kTBPCloseLeft = kNavAreaLeft + 30;
+const tCoordType kTBPCloseTop = kNavAreaTop + 16;
+
+const tCoordType kTBPRewindLeft = kNavAreaLeft + 86;
+const tCoordType kTBPRewindTop = kNavAreaTop + 218;
+
+const tCoordType kComparisonCloseLeft = kNavAreaLeft + 50;
+const tCoordType kComparisonCloseTop = kNavAreaTop + 14;
+
+const tCoordType kComparisonLeftRewindLeft = kNavAreaLeft + 96;
+const tCoordType kComparisonLeftRewindTop = kNavAreaTop + 190;
+
+const tCoordType kComparisonRightRewindLeft = kNavAreaLeft + 282;
+const tCoordType kComparisonRightRewindTop = kNavAreaTop + 190;
+
+const tCoordType kComparisonHiliteSpriteLeft = kNavAreaLeft + 45;
+const tCoordType kComparisonHiliteSpriteTop = kNavAreaTop + 65;
+
+const tCoordType kComparisonHiliteNoradLeft = kNavAreaLeft + 45;
+const tCoordType kComparisonHiliteNoradTop = kNavAreaTop + 65;
+
+const tCoordType kComparisonHiliteMarsLeft = kNavAreaLeft + 45 + 4;
+const tCoordType kComparisonHiliteMarsTop = kNavAreaTop + 65 + 23;
+
+const tCoordType kComparisonHiliteCaldoriaLeft = kNavAreaLeft + 45 + 7;
+const tCoordType kComparisonHiliteCaldoriaTop = kNavAreaTop + 65 + 46;
+
+const tCoordType kComparisonHiliteWSCLeft = kNavAreaLeft + 45 + 11;
+const tCoordType kComparisonHiliteWSCTop = kNavAreaTop + 65 + 68;
+
+const tCoordType kComparisonChancesSpriteLeft = kNavAreaLeft + 148;
+const tCoordType kComparisonChancesSpriteTop = kNavAreaTop + 162;
+
+const tCoordType kComparisonChancesNoradLeft = kNavAreaLeft + 148;
+const tCoordType kComparisonChancesNoradTop = kNavAreaTop + 162;
+
+const tCoordType kComparisonChancesMarsLeft = kNavAreaLeft + 148;
+const tCoordType kComparisonChancesMarsTop = kNavAreaTop + 162;
+
+const tCoordType kComparisonChancesCaldoriaLeft = kNavAreaLeft + 148;
+const tCoordType kComparisonChancesCaldoriaTop = kNavAreaTop + 162 + 1;
+
+const tCoordType kComparisonChancesWSCLeft = kNavAreaLeft + 148;
+const tCoordType kComparisonChancesWSCTop = kNavAreaTop + 162;
+
+const tCoordType kRedirectionSprite1Left = kNavAreaLeft + 58;
+const tCoordType kRedirectionSprite1Top = kNavAreaTop + 16;
+
+const tCoordType kRedirectionSprite2Left = kNavAreaLeft + 36;
+const tCoordType kRedirectionSprite2Top = kNavAreaTop + 166;
+
+const tCoordType kRedirectionCCRolloverLeft = kNavAreaLeft + 58;
+const tCoordType kRedirectionCCRolloverTop = kNavAreaTop + 16;
+
+const tCoordType kRedirectionRRRolloverLeft = kNavAreaLeft + 430;
+const tCoordType kRedirectionRRRolloverTop = kNavAreaTop + 30;
+
+const tCoordType kRedirectionFDRolloverLeft = kNavAreaLeft + 278;
+const tCoordType kRedirectionFDRolloverTop = kNavAreaTop + 160;
+
+const tCoordType kRedirectionCCDoorLeft = kNavAreaLeft + 174;
+const tCoordType kRedirectionCCDoorTop = kNavAreaTop + 36;
+
+const tCoordType kRedirectionRRDoorLeft = kNavAreaLeft + 418;
+const tCoordType kRedirectionRRDoorTop = kNavAreaTop + 32;
+
+const tCoordType kRedirectionFDDoorLeft = kNavAreaLeft + 298;
+const tCoordType kRedirectionFDDoorTop = kNavAreaTop + 240;
+
+const tCoordType kRedirectionSecuredLeft = kNavAreaLeft + 36;
+const tCoordType kRedirectionSecuredTop = kNavAreaTop + 166;
+
+const tCoordType kRedirectionNewTargetLeft = kNavAreaLeft + 36;
+const tCoordType kRedirectionNewTargetTop = kNavAreaTop + 166;
+
+const tCoordType kRedirectionCloseLeft = kNavAreaLeft + 56;
+const tCoordType kRedirectionCloseTop = kNavAreaTop + 220;
+
+const TimeValue kTSABumpIntoWallIn = 0;
+const TimeValue kTSABumpIntoWallOut = 148;
+
+const TimeValue kTSAGTDoorCloseIn = 148;
+const TimeValue kTSAGTDoorCloseOut = 1570;
+
+const TimeValue kTSANoOtherDestinationIn = 1570;
+const TimeValue kTSANoOtherDestinationOut = 3601;
+
+const TimeValue kTSAEntryDoorCloseIn = 3601;
+const TimeValue kTSAEntryDoorCloseOut = 4200;
+
+const TimeValue kTSAInsideDoorCloseIn = 4200;
+const TimeValue kTSAInsideDoorCloseOut = 4800;
+
+const TimeValue kTSAVaultCloseIn = 4800;
+const TimeValue kTSAVaultCloseOut = 5388;
+
+const TimeValue kTSAPegasusDoorCloseIn = 5388;
+const TimeValue kTSAPegasusDoorCloseOut = 6457;
+
+const bool kPegasusUnresolved = false;
+const bool kPegasusResolved = true;
+const bool kPegasusCantExit = false;
+const bool kPegasusCanExit = true;
+
+// Monitor modes
+enum {
+	kMonitorNeutral = 0,
+	kMonitorTheory = 1,
+	kMonitorProcedure = 2,
+	kMonitorBackground = 3,
+	kMonitorNoradComparison = 4,
+	kMonitorMarsComparison = 5,
+	kMonitorCaldoriaComparison = 6,
+	kMonitorWSCComparison = 7,
+	
+	kRawModeMask = 0x0F,
+	kPlayingTBPMask = 0x10,
+	kPlayingLeftComparisonMask = 0x20,
+	kPlayingRightComparisonMask = 0x40,
+	
+	kPlayingAnyMask = kPlayingTBPMask |
+						kPlayingLeftComparisonMask |
+						kPlayingRightComparisonMask,
+	
+	kMonitorPlayingTheory = kMonitorTheory | kPlayingTBPMask,
+	kMonitorPlayingProcedure = kMonitorProcedure | kPlayingTBPMask,
+	kMonitorPlayingBackground = kMonitorBackground | kPlayingTBPMask,
+	
+	kMonitorPlayingLeftNoradComparison = kMonitorNoradComparison |
+											kPlayingLeftComparisonMask,
+	kMonitorPlayingRightNoradComparison = kMonitorNoradComparison |
+											kPlayingRightComparisonMask,
+	kMonitorPlayingLeftMarsComparison = kMonitorMarsComparison |
+										kPlayingLeftComparisonMask,
+	kMonitorPlayingRightMarsComparison = kMonitorMarsComparison |
+											kPlayingRightComparisonMask,
+	kMonitorPlayingLeftCaldoriaComparison = kMonitorCaldoriaComparison |
+											kPlayingLeftComparisonMask,
+	kMonitorPlayingRightCaldoriaComparison = kMonitorCaldoriaComparison |
+												kPlayingRightComparisonMask,
+	kMonitorPlayingLeftWSCComparison = kMonitorWSCComparison |
+										kPlayingLeftComparisonMask,
+	kMonitorPlayingRightWSCComparison = kMonitorWSCComparison |
+										kPlayingRightComparisonMask
+};
+
+static const tExtraID s_historicalLogViews[16] = {
+	kTSA0BComparisonView0000,
+	kTSA0BComparisonView0002,
+	kTSA0BComparisonView0020,
+	kTSA0BComparisonView0022,
+	kTSA0BComparisonView0200,
+	kTSA0BComparisonView0202,
+	kTSA0BComparisonView0220,
+	kTSA0BComparisonView0222,
+	kTSA0BComparisonView2000,
+	kTSA0BComparisonView2002,
+	kTSA0BComparisonView2020,
+	kTSA0BComparisonView2022,
+	kTSA0BComparisonView2200,
+	kTSA0BComparisonView2202,
+	kTSA0BComparisonView2220,
+	kTSA0BComparisonView2222
+};
+
+const long kRedirectionCCRolloverSprite = 0;
+const long kRedirectionRRRolloverSprite = 1;
+const long kRedirectionFDRolloverSprite = 2;
+const long kRedirectionCCDoorSprite = 3;
+const long kRedirectionRRDoorSprite = 4;
+const long kRedirectionFDDoorSprite = 5;
+const long kRedirectionCloseSprite = 6;
+const long kRedirectionSecuredSprite = 0;
+const long kRedirectionNewTargetSprite = 1;
+
+void RipTimer::initImage() {
+	_middle = -1;
+	
+	_timerImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLeftRipPICTID);
+
+	Common::Rect r;
+	_timerImage.getSurfaceBounds(r);
+	setBounds(r);
+}
+
+void RipTimer::releaseImage() {
+	_timerImage.deallocateSurface();
+}
+
+void RipTimer::draw(const Common::Rect &updateRect) {
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	Common::Rect r1 = bounds;
+	r1.right = _middle;
+	r1 = updateRect.findIntersectingRect(r1);
+
+	if (!r1.isEmpty()) {
+		Common::Rect r2 = r1;
+		r2.moveTo(r1.left - _bounds.left, r1.top - bounds.top);
+		_timerImage.copyToCurrentPort(r2, r1);
+	}
+}
+
+void RipTimer::timeChanged(const TimeValue newTime) {
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	tCoordType newMiddle = bounds.left + bounds.width() * newTime / getDuration();
+
+	if (newMiddle != _middle) {
+		_middle = newMiddle;
+		triggerRedraw();
+	}
+
+	if (newTime == getStop())
+		((PegasusEngine *)g_engine)->die(kDeathUncreatedInTSA);
+}
+
+FullTSA::FullTSA(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Full TSA", kFullTSAID),
+		_ripTimer(kNoDisplayElement), _sprite1(kNoDisplayElement), _sprite2(kNoDisplayElement), _sprite3(kNoDisplayElement) {
+	setIsItemTaken(kJourneymanKey);
+	setIsItemTaken(kPegasusBiochip);
+	setIsItemTaken(kMapBiochip);
+}
+
+void FullTSA::init() {	
+	Neighborhood::init();
+	_ripTimer.setDisplayOrder(kRipTimerOrder);
+	_ripTimer.startDisplaying();
+
+	if (!GameState.getTSASeenRobotGreeting())
+		forceStridingStop(kTSA03, kNorth, kNoAlternateID);
+
+	_sprite1.setDisplayOrder(kMonitorLayer);
+	_sprite1.startDisplaying();
+	_sprite2.setDisplayOrder(kMonitorLayer);
+	_sprite2.startDisplaying();
+	_sprite3.setDisplayOrder(kMonitorLayer);
+	_sprite3.startDisplaying();
+	
+	// Fix a mistake in the world builder tables.
+	HotspotInfoTable::Entry *entry = findHotspotEntry(kTSA23WestChipsSpotID);
+	entry->hotspotItem = kPegasusBiochip;
+}
+
+void uncreatedInTSAFunction(FunctionPtr *, void *tsa) {
+	((FullTSA *)tsa)->die(kDeathUncreatedInTSA);
+}
+
+void FullTSA::start() {
+	g_energyMonitor->stopEnergyDraining();
+
+	if (!GameState.getScoringEnterTSA()) {
+		_utilityFuse.primeFuse(GameState.getTSAFuseTimeLimit());
+		_utilityFuse.setFunctionPtr(&uncreatedInTSAFunction, (void *)this);
+		_utilityFuse.lightFuse();
+	} else if (GameState.getTSAState() == kTSAPlayerDetectedRip || GameState.getTSAState() == kTSAPlayerNeedsHistoricalLog) {
+		_ripTimer.initImage();
+		_ripTimer.moveElementTo(kRipTimerLeft, kRipTimerTop);
+		_ripTimer.setSegment(0, kRipTimeLimit, kRipTimeScale);
+		_ripTimer.setTime(GameState.getRipTimerTime());
+		_ripTimer.start();
+	}
+
+	Neighborhood::start();
+}
+
+void FullTSA::flushGameState() {
+	GameState.setRipTimerTime(_ripTimer.getTime());
+	GameState.setTSAFuseTimeLimit(_utilityFuse.getTimeRemaining());
+}
+
+Common::String FullTSA::getBriefingMovie() {	
+	Common::String movieName = getBriefingMovie();
+
+	if (movieName.empty()) {
+		tRoomID room = GameState.getCurrentRoom();
+
+		switch (GameState.getTSAState()) {
+		case kTSAPlayerNotArrived:
+		case kTSAPlayerForcedReview:
+			if (room >= kTSA16 && room <= kTSA0B)
+				return "Images/AI/TSA/XT01A";
+
+			return "Images/AI/TSA/XT01";
+		case kTSAPlayerDetectedRip:
+		case kTSAPlayerNeedsHistoricalLog:
+			return "Images/AI/TSA/XT02";
+		case kTSAPlayerGotHistoricalLog:
+		case kTSAPlayerInstalledHistoricalLog:
+			return "Images/AI/TSA/XT03";
+		default:
+			switch (getCurrentActivation()) {
+			case kActivationJumpToPrehistoric:
+				g_AIChip->showBriefingClicked();
+				startExtraSequenceSync(kTSA37PegasusAI2, kHintInterruption);
+				startExtraSequenceSync(kTSA37AI2ToPrehistoric, kFilterNoInput);
+				g_AIChip->clearClicked();
+				break;
+			case kActivationJumpToNorad:
+				g_AIChip->showBriefingClicked();
+				startExtraSequenceSync(kTSA37PegasusAI7, kHintInterruption);
+				startExtraSequenceSync(kTSA37AI7ToNorad, kFilterNoInput);
+				g_AIChip->clearClicked();
+				break;
+			case kActivationJumpToMars:
+				g_AIChip->showBriefingClicked();
+				startExtraSequenceSync(kTSA37PegasusAI6, kHintInterruption);
+				startExtraSequenceSync(kTSA37AI6ToMars, kFilterNoInput);
+				g_AIChip->clearClicked();
+				break;
+			case kActivationJumpToWSC:
+				g_AIChip->showBriefingClicked();
+				startExtraSequenceSync(kTSA37PegasusAI5, kHintInterruption);
+				startExtraSequenceSync(kTSA37AI5ToWSC, kFilterNoInput);
+				g_AIChip->clearClicked();
+				break;
+			default:
+				if (GameState.allTimeZonesFinished())
+					return "Images/AI/TSA/XT05";
+
+				return "Images/AI/TSA/XT04";
+			}
+			break;
+		}
+	}
+
+	return movieName;
+}
+
+Common::String FullTSA::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		switch (GameState.getTSAState()) {
+		case kTSAPlayerNotArrived:
+		case kTSAPlayerForcedReview:
+		case kTSAPlayerDetectedRip:
+		case kTSAPlayerNeedsHistoricalLog:
+			return "Images/AI/TSA/XTE1";
+		default:
+			if (GameState.getCurrentRoom() == kTSA37) {
+				g_AIChip->showEnvScanClicked();
+				startExtraSequenceSync(kTSA37EnvironmentalScan, kHintInterruption);
+	
+				switch (getCurrentActivation()) {
+				case kActivationJumpToPrehistoric:
+					startExtraSequenceSync(kTSA37AI2ToPrehistoric, kFilterNoInput);
+					break;
+				case kActivationJumpToNorad:
+					startExtraSequenceSync(kTSA37AI7ToNorad, kFilterNoInput);
+					showExtraView(kTSA37JumpToNoradMenu);
+					break;
+				case kActivationJumpToMars:
+					startExtraSequenceSync(kTSA37AI6ToMars, kFilterNoInput);
+					showExtraView(kTSA37JumpToMarsMenu);
+					break;
+				case kActivationJumpToWSC:
+					startExtraSequenceSync(kTSA37AI5ToWSC, kFilterNoInput);
+					showExtraView(kTSA37JumpToWSCMenu);
+					break;
+				default:
+					startExtraSequenceSync(kTSA37AI4ToMainMenu, kFilterNoInput);
+					break;
+				}
+
+				g_AIChip->clearClicked();
+			} else if (GameState.allTimeZonesFinished()) {
+				return "Images/AI/TSA/XTE1";
+			} else {
+				return "Images/AI/TSA/XTE2";
+			}
+			break;
+		}
+	}
+
+	return movieName;
+}
+
+uint FullTSA::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+
+	if (numHints == 0) {
+		switch (GameState.getTSAState()) {
+		case kRobotsAtCommandCenter:
+		case kRobotsAtFrontDoor:
+		case kRobotsAtReadyRoom:
+			if (GameState.getCurrentRoom() == kTSA0B && GameState.getTSA0BZoomedIn())
+				numHints = 3;
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String FullTSA::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty())
+		movieName = Common::String::format("Images/AI/TSA/XT20NH%d", hintNum);
+		
+	return movieName;
+}
+
+void FullTSA::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+
+	switch (GameState.getTSAState()) {
+	case kTSAPlayerDetectedRip:
+	case kTSAPlayerNeedsHistoricalLog:
+		if ((room >= kTSA16 && room <= kTSA0B) || (room >= kTSA21Cyan && room <= kTSA24Cyan) || (room >= kTSA21Red && room <= kTSA24Red))
+			loadLoopSound1("Sounds/TSA/TSA CLAXON.22K.AIFF", 0x100 / 4, 0, 0);
+		else if (room == kTSA25Cyan || room == kTSA25Red)
+			loadLoopSound1("Sounds/TSA/TSA CLAXON.22K.AIFF", 0x100 / 6, 0, 0);
+		else
+			loadLoopSound1("Sounds/TSA/TSA EchoClaxon.22K.AIFF", 0x100 / 4, 0, 0);
+		break;
+	default:
+		if (room >= kTSA00 && room <= kTSA02)
+			loadLoopSound1("Sounds/TSA/T01NAE.NEW.22K.AIFF");
+		else if (room >= kTSA03 && room <= kTSA15)
+			loadLoopSound1("Sounds/TSA/T01NAE.NEW.22K.AIFF");
+		else if (room >= kTSA16 && room <= kTSA0B)
+			loadLoopSound1("Sounds/TSA/T14SAEO1.22K.AIFF");
+		else if (room >= kTSA21Cyan && room <= kTSA25Red)
+			loadLoopSound1("Sounds/TSA/T15SAE01.22K.AIFF");
+		else if (room >= kTSA26 && room <= kTSA37)
+			loadLoopSound1("Sounds/TSA/T01NAE.NEW.22K.AIFF");
+		break;
+	}
+}
+
+short FullTSA::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	int16 result = Neighborhood::getStaticCompassAngle(room, dir);
+
+	switch (room) {
+	case kTSA08:
+		result += kCompassShift;
+		break;
+	case kTSA09:
+		result -= kCompassShift;
+		break;
+	case kTSA10:
+		result += kCompassShift * 2;
+		break;
+	case kTSA11:
+	case kTSA22Cyan:
+	case kTSA22Red:
+		result -= kCompassShift * 2;
+		break;
+	case kTSA12:
+		result += kCompassShift * 3;
+		break;
+	case kTSA13:
+		result -= kCompassShift * 3;
+		break;
+	case kTSA14:
+	case kTSA16:
+	case kTSA17:
+	case kTSA18:
+	case kTSA19:
+		result += kCompassShift * 4;
+		break;
+	case kTSA0B:
+		result += kCompassShift * 4;
+
+		if (dir == kWest)
+			result += 30;
+		else if (dir == kEast)
+			result -= 30;
+		break;
+	case kTSA33:
+		result += kCompassShift * 4;
+		break;
+	case kTSA15:
+	case kTSA21Cyan:
+	case kTSA24Cyan:
+	case kTSA25Cyan:
+	case kTSA21Red:
+	case kTSA24Red:
+	case kTSA25Red:
+	case kTSA26:
+	case kTSA27:
+	case kTSA28:
+	case kTSA29:
+	case kTSA30:
+		result -= kCompassShift * 4;
+		break;
+	case kTSA23Cyan:
+	case kTSA23Red:
+		result -= kCompassShift * 6;
+		break;
+	case kTSA32:
+		result -= kCompassShift * 8;
+		break;
+	case kTSA34:
+		result -= kCompassShift * 12;
+		break;
+	case kTSA35:
+		result += kCompassShift * 8;
+		break;
+	case kTSA37:
+		result -= kCompassShift * 2;
+		break;
+	}
+
+	return result;
+}
+
+void FullTSA::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
+	case MakeRoomView(kTSA01, kSouth):
+		compassMove.insertFaderKnot(exitEntry.movieStart, -180);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 3, -180);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 33,
+				getStaticCompassAngle(exitEntry.exitRoom, exitEntry.exitDirection));
+		break;
+	case MakeRoomView(kTSA11, kEast):
+		if (getCurrentAlternate() == kAltTSARobotsAtReadyRoom) {
+			compassMove.makeTwoKnotFaderSpec(kFullTSAMovieScale, exitEntry.movieStart,
+					getStaticCompassAngle(kTSA11, kEast), exitEntry.movieEnd,
+					getStaticCompassAngle(kTSA13, kEast));
+			compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 13, compassMove.getNthKnotValue(1));
+		}
+		break;
+	case MakeRoomView(kTSA34, kNorth):
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 48,
+				getStaticCompassAngle(exitEntry.room, exitEntry.direction));
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 68,
+				getStaticCompassAngle(exitEntry.exitRoom, exitEntry.exitDirection));
+		break;
+	case MakeRoomView(kTSA37, kNorth):
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 38,
+				getStaticCompassAngle(exitEntry.room, exitEntry.direction));
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 64,
+				getStaticCompassAngle(exitEntry.room, exitEntry.direction) + kCompassShift * 3 / 2);
+		compassMove.insertFaderKnot(exitEntry.movieStart + kFullTSAFrameDuration * 105,
+				getStaticCompassAngle(exitEntry.exitRoom, exitEntry.exitDirection));
+		break;
+	}
+}
+
+void FullTSA::getExtraCompassMove(const ExtraTable::Entry &extraEntry, FaderMoveSpec &compassMove) {
+	int16 angle;
+	
+	switch (extraEntry.extra) {
+	case kTSA0BEastTurnLeft:
+	case kTSA0BNorthTurnLeft:
+		angle =getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), extraEntry.movieStart, angle,
+				extraEntry.movieEnd, angle - 60);
+		break;
+	case kTSA0BNorthTurnRight:
+	case kTSA0BWestTurnRight:
+		angle = getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), extraEntry.movieStart, angle,
+				extraEntry.movieEnd, angle + 60);
+		break;
+	case kTSA22RedEastZoomInSequence:
+		angle = getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), extraEntry.movieStart, angle,
+				extraEntry.movieEnd, angle);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 1200, angle - kCompassShift * 2);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 8160, angle - kCompassShift * 2);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 9840, angle);
+		break;
+	case kTSA23RedWestVaultZoomInSequence:
+		angle = getStaticCompassAngle(GameState.getCurrentRoom(), GameState.getCurrentDirection());
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), extraEntry.movieStart, angle,
+				extraEntry.movieEnd, angle);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 1200, angle - kCompassShift * 2);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 10100, angle - kCompassShift * 2);
+		compassMove.insertFaderKnot(extraEntry.movieStart + 11880, angle);
+		break;
+	default:
+		Neighborhood::getExtraCompassMove(extraEntry, compassMove);
+		break;
+	}
+}
+
+uint16 FullTSA::getDateResID() const {
+	return kDate2318ID;
+}
+
+TimeValue FullTSA::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	tExtraID extraID = 0xffffffff;
+	
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn())
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerInstalledHistoricalLog:
+			case kTSABossSawHistoricalLog:
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				extraID = s_historicalLogViews[getHistoricalLogIndex()];
+				break;
+			default:
+				extraID = kTSA0BEastZoomedView;
+				break;
+			}
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn())
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerNeedsHistoricalLog:
+				extraID = kTSA0BNorthRipView1;
+				break;
+			default:
+				extraID = kTSA0BNorthZoomedView;
+				break;
+			}
+		break;
+	case MakeRoomView(kTSA0B, kWest):
+		if (GameState.getTSA0BZoomedIn())
+			extraID = kTSA0BWestZoomedView;
+		break;
+	case MakeRoomView(kTSA22Red, kEast):
+		if (_privateFlags.getFlag(kTSAPrivateKeyVaultOpenFlag)) {
+			if (_vm->itemInLocation(kJourneymanKey, kFullTSAID, kTSA22Red, kEast))
+				extraID = kTSA22RedEastVaultViewWithKey;
+			else
+				extraID = kTSA22RedEastVaultViewNoKey;
+		}
+		break;
+	case MakeRoomView(kTSA23Red, kWest):
+		if (_privateFlags.getFlag(kTSAPrivateChipVaultOpenFlag)) {
+			if (_vm->itemInLocation(kPegasusBiochip, kFullTSAID, kTSA23Red, kWest))
+				extraID = kTSA23RedWestVaultViewWithChips;
+			else
+				extraID = kTSA23RedWestVaultViewNoChips;
+		}
+		break;
+	case MakeRoomView(kTSA37, kNorth):
+		switch (GameState.getTSAState()) {
+		case kTSAPlayerGotHistoricalLog:
+			extraID = kTSA37ReviewRequiredToExit;
+			break;
+		case kPlayerFinishedWithTSA:
+			extraID = kTSA37CongratulationsToExit;
+			break;
+		default:
+			extraID = kTSA37AI3ToHorse;
+			break;
+		}
+		break;
+	}
+
+	if (extraID != 0xffffffff) {
+		ExtraTable::Entry entry;
+		getExtraEntry(extraID, entry);
+		return entry.movieEnd - 1;
+	}
+
+	return Neighborhood::getViewTime(room, direction);
+}
+
+void FullTSA::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kTSA0B, kNorth):
+	case MakeRoomView(kTSA0B, kEast):
+	case MakeRoomView(kTSA0B, kWest):
+		if (!GameState.getTSA0BZoomedIn())
+			Neighborhood::findSpotEntry(room, direction, flags, entry);
+		break;
+	default:
+		Neighborhood::findSpotEntry(room, direction, flags, entry);
+		break;
+	}
+}
+
+void FullTSA::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry) {
+	Neighborhood::getExtraEntry(id, extraEntry);
+
+	if (id == kTSA0BShowGuardRobots)
+		extraEntry.movieStart += kFullTSAFrameDuration * 3;
+}
+
+void FullTSA::pickedUpItem(Item *item) {
+	BiochipItem *biochip;
+	
+	switch (item->getObjectID()) {
+	case kJourneymanKey:
+		GameState.setScoringGotJourneymanKey(true);
+		break;
+	case kPegasusBiochip:
+		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
+		_vm->addItemToBiochips(biochip);
+		GameState.setScoringGotPegasusBiochip(true);
+		break;
+	}
+}
+
+void FullTSA::playExtraMovie(const ExtraTable::Entry &extraEntry, const tNotificationFlags flags, const tInputBits interruptionInput) {
+	switch (extraEntry.extra) {
+	case kTSA0BNorthZoomIn:
+		if (_privateFlags.getFlag(kTSAPrivateLogReaderOpenFlag)) {
+			_privateFlags.setFlag(kTSAPrivateLogReaderOpenFlag, false);
+			requestExtraSequence(kTSA0BNorthHistLogClose, 0, kFilterNoInput);
+			requestExtraSequence(kTSA0BNorthZoomIn, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			Neighborhood::playExtraMovie(extraEntry, flags, interruptionInput);
+		}
+		break;
+	case kTSA0BNorthZoomOut:
+		if (_ripTimer.isVisible())
+			_ripTimer.hide();
+
+		shutDownRobotMonitor();
+		Neighborhood::playExtraMovie(extraEntry, flags, interruptionInput);
+		break;
+	case kTSA0BEastZoomOut:
+		shutDownComparisonMonitor();
+		Neighborhood::playExtraMovie(extraEntry, flags, interruptionInput);
+		break;
+	default:
+		Neighborhood::playExtraMovie(extraEntry, flags, interruptionInput);
+		break;
+	}
+}
+
+void FullTSA::startDoorOpenMovie(const TimeValue startTime, const TimeValue stopTime) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA00, kNorth):
+		if (GameState.getLastNeighborhood() != kFullTSAID) {
+			startExtraSequence(kTSAArriveFromCaldoria, kDoorOpenCompletedFlag, kFilterNoInput);
+			return;
+		}
+		break;
+	case MakeRoomView(kTSA02, kNorth):
+		if (!GameState.getTSAIDedAtDoor()) {
+			GameState.setTSAIDedAtDoor(true);
+			requestExtraSequence(kTSA02NorthZoomIn, 0, kFilterNoInput);
+			requestExtraSequence(kTSA02NorthTenSecondDoor, 0, kFilterNoInput);
+
+			if (GameState.getTSASeenAgent3AtDoor()) {
+				requestExtraSequence(kTSA02NorthZoomOut, kExtraCompletedFlag, kFilterNoInput);
+			} else {
+				GameState.setTSASeenAgent3AtDoor(true);
+				requestExtraSequence(kTSA02NorthZoomOut, 0, kFilterNoInput);
+				requestExtraSequence(kTSA02NorthDoorWithAgent3, kDoorOpenCompletedFlag, kFilterNoInput);
+			}
+			return;
+		}
+		break;
+	case MakeRoomView(kTSA03, kSouth):
+		if (GameState.getTSAState() == kRobotsAtFrontDoor) {
+			playDeathExtra(kTSA03SouthRobotDeath, kDeathShotByTSARobots);
+			return;
+		}
+		break;
+	case MakeRoomView(kTSA16, kNorth):
+		if (GameState.getTSAState() == kRobotsAtCommandCenter) {
+			playDeathExtra(kTSA16NorthRobotDeath, kDeathShotByTSARobots);
+			return;
+		}
+		break;
+	}
+
+	Neighborhood::startDoorOpenMovie(startTime, stopTime);
+}
+
+tInputBits FullTSA::getInputFilter() {
+	tInputBits result = Neighborhood::getInputFilter();
+
+	switch (GameState.getCurrentRoom()) {
+	case kTSA0B:
+		if (GameState.getT0BMonitorMode() != kMonitorNeutral)
+			// Only allow a click.
+			result &= JMPPPInput::getClickInputFilter();
+		break;
+	case kTSA37:
+		// Can't move forward in Pegasus. Only press the exit button.
+		result &= ~(kFilterUpButton | kFilterUpAuto);
+		break;
+	}
+
+	return result;
+}
+
+void FullTSA::turnLeft() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA15, kNorth):
+		if (GameState.getTSAState() == kTSAPlayerNeedsHistoricalLog)
+			setCurrentAlternate(kAltTSANormal);
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (_ripTimer.isVisible())
+			_ripTimer.hide();
+		releaseSprites();
+		break;
+	case MakeRoomView(kTSA0B, kEast):
+		shutDownComparisonMonitor();
+		break;
+	}
+
+	Neighborhood::turnLeft();
+}
+
+void FullTSA::turnRight() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA15, kSouth):
+		if (GameState.getTSAState() == kTSAPlayerNeedsHistoricalLog)
+			setCurrentAlternate(kAltTSANormal);
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (_ripTimer.isVisible())
+			_ripTimer.hide();
+		releaseSprites();
+		break;
+	case MakeRoomView(kTSA0B, kEast):
+		shutDownComparisonMonitor();
+		break;
+	}
+
+	Neighborhood::turnRight();
+}
+
+void FullTSA::openDoor() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA15, kSouth):
+		if (GameState.getTSAState() == kTSAPlayerNeedsHistoricalLog || GameState.getTSAState() == kRobotsAtFrontDoor)
+			setCurrentAlternate(kAltTSARedAlert);
+		break;
+	}
+
+	Neighborhood::openDoor();
+}
+
+tCanMoveForwardReason FullTSA::canMoveForward(ExitTable::Entry &entry) {
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kTSA25Red, kNorth))
+		return kCantMoveBlocked;
+
+	return Neighborhood::canMoveForward(entry);
+}
+
+tCanOpenDoorReason FullTSA::canOpenDoor(DoorTable::Entry &entry) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA02, kNorth):
+		if (!GameState.getTSAFrontDoorUnlockedOutside())
+			return kCantOpenLocked;
+	case MakeRoomView(kTSA03, kSouth):
+		if (!GameState.getTSAFrontDoorUnlockedInside())
+			return kCantOpenLocked;
+	case MakeRoomView(kTSA16, kNorth):
+		if (GameState.getTSACommandCenterLocked())
+			return kCantOpenLocked;
+	}
+
+	return Neighborhood::canOpenDoor(entry);
+}
+
+void FullTSA::bumpIntoWall() {
+	requestSpotSound(kTSABumpIntoWallIn, kTSABumpIntoWallOut, kFilterAllInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+void FullTSA::downButton(const Input &input) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn())
+			startExtraSequence(kTSA0BEastZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn())
+			startExtraSequence(kTSA0BNorthZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kTSA0B, kWest):
+		if (GameState.getTSA0BZoomedIn() && GameState.getT0BMonitorMode() == kMonitorNeutral)
+			startExtraSequence(kTSA0BWestZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Neighborhood::downButton(input);
+	}
+}
+
+void FullTSA::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kTSA0BEastLeftRewindSpotID:
+	case kTSA0BEastLeftPlaySpotID:
+		if (_privateFlags.getFlag(kTSAPrivatePlayingRightComparisonFlag))
+			spot->setInactive();
+		else
+			Neighborhood::activateOneHotspot(entry, spot);
+		break;
+	case kTSA0BEastRightRewindSpotID:
+	case kTSA0BEastRightPlaySpotID:
+		if (_privateFlags.getFlag(kTSAPrivatePlayingLeftComparisonFlag))
+			spot->setInactive();
+		else
+			Neighborhood::activateOneHotspot(entry, spot);
+		break;
+	default:
+		Neighborhood::activateOneHotspot(entry, spot);
+		break;
+	}
+}
+
+void FullTSA::activateHotspots() {
+	Neighborhood::activateHotspots();
+
+	switch (MakeRoomView(GameState.getCurrentRoom(), GameState.getCurrentDirection())) {
+	case MakeRoomView(kTSA02, kNorth):
+		if (!GameState.getTSAFrontDoorUnlockedOutside())
+			g_allHotspots.activateOneHotspot(kTSA02DoorSpotID);
+		break;
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn())
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerInstalledHistoricalLog:
+			case kTSABossSawHistoricalLog:
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				if (getCurrentActivation() != kActivateTSA0BComparisonVideo) {
+					g_allHotspots.activateOneHotspot(kTSA0BEastCompareNoradSpotID);
+					g_allHotspots.activateOneHotspot(kTSA0BEastCompareMarsSpotID);
+					g_allHotspots.activateOneHotspot(kTSA0BEastCompareCaldoriaSpotID);
+					g_allHotspots.activateOneHotspot(kTSA0BEastCompareWSCSpotID);
+				}
+				break;
+			}
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn())
+			switch (GameState.getTSAState()) {
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToCommandCenterSpotID);
+				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToReadyRoomSpotID);
+				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToFrontDoorSpotID);
+				break;
+			}
+		break;
+	}
+}
+
+void FullTSA::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {	
+	switch (clickedSpot->getObjectID()) {
+	case kTSAGTOtherSpotID:
+		showExtraView(kTSAGTOtherChoice);
+		playSpotSoundSync(kTSANoOtherDestinationIn, kTSANoOtherDestinationOut);
+		showExtraView(kTSAGTCardSwipe);
+		break;
+	case kTSA02DoorSpotID:
+		GameState.setTSAFrontDoorUnlockedOutside(true);
+		Neighborhood::clickInHotspot(input, clickedSpot);
+		break;
+	case kTSA03EastJimenezSpotID:
+		startExtraLongSequence(kTSA03JimenezZoomIn, kTSA03JimenezZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA03WestCrenshawSpotID:
+		startExtraLongSequence(kTSA03CrenshawZoomIn, kTSA03CrenshawZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA04EastMatsumotoSpotID:
+		startExtraLongSequence(kTSA04MatsumotoZoomIn, kTSA04MatsumotoZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA04WestCastilleSpotID:
+		startExtraLongSequence(kTSA04CastilleZoomIn, kTSA04CastilleZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA05EastSinclairSpotID:
+		startExtraLongSequence(kTSA05SinclairZoomIn, kTSA05SinclairZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA05WestWhiteSpotID:
+		startExtraLongSequence(kTSA05WhiteZoomIn, kTSA05WhiteZoomOut, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA0BEastCompareNoradSpotID:
+		initializeComparisonMonitor(kMonitorNoradComparison, kTSA0BNoradComparisonView);
+		break;
+	case kTSA0BEastCompareMarsSpotID:
+		initializeComparisonMonitor(kMonitorMarsComparison, kTSA0BMarsComparisonView);
+		break;
+	case kTSA0BEastCompareCaldoriaSpotID:
+		initializeComparisonMonitor(kMonitorCaldoriaComparison, kTSA0BCaldoriaComparisonView);
+		break;
+	case kTSA0BEastCompareWSCSpotID:
+		initializeComparisonMonitor(kMonitorWSCComparison, kTSA0BWSCComparisonView);
+		break;
+	case kTSA0BEastCloseVideoSpotID:
+		_navMovie.stop();
+		_sprite3.show();
+		_vm->delayShell(1, 2);
+		_sprite3.hide();
+		initializeComparisonMonitor(kMonitorNeutral, 0);
+		break;
+	case kTSA0BEastLeftPlaySpotID:
+		playLeftComparison();
+		break;
+	case kTSA0BEastRightPlaySpotID:
+		playRightComparison();
+		break;
+		
+	// Command center
+	case kTSA0BWestTheorySpotID:
+		initializeTBPMonitor(kMonitorTheory, kTSA0BTBPTheoryHighlight);
+		break;
+	case kTSA0BWestBackgroundSpotID:
+		initializeTBPMonitor(kMonitorBackground, kTSA0BTBPBackgroundHighlight);
+		break;
+	case kTSA0BWestProcedureSpotID:
+		initializeTBPMonitor(kMonitorProcedure, kTSA0BTBPProcedureHighlight);
+		break;
+	case kTSA0BWestCloseVideoSpotID:
+		_navMovie.stop();
+		_sprite2.show();
+		_vm->delayShell(1, 2);
+		_sprite2.hide();
+		initializeTBPMonitor(kMonitorNeutral, 0);
+		break;
+	case kTSA0BWestPlayVideoSpotID:
+		playTBPMonitor();
+		break;
+	case kTSA0BEastLeftRewindSpotID:
+	case kTSA0BEastRightRewindSpotID:
+	case kTSA0BWestRewindVideoSpotID:
+		if ((GameState.getT0BMonitorMode() & kPlayingAnyMask) != 0) {
+			bool playing = _navMovie.isRunning();
+			if (playing)
+				_navMovie.stop();
+
+			if (clickedSpot->getObjectID() == kTSA0BEastRightRewindSpotID)
+				_sprite2.show();
+			else
+				_sprite1.show();
+
+			_vm->delayShell(1, 2);
+
+			if (clickedSpot->getObjectID() == kTSA0BEastRightRewindSpotID)
+				_sprite2.hide();
+			else
+				_sprite1.hide();
+
+			_navMovie.setTime(GameState.getT0BMonitorStart());
+
+			if (playing) {
+				_navMovie.start();
+			} else {
+				_privateFlags.setFlag(kTSAPrivatePlayingLeftComparisonFlag, false);
+				_privateFlags.setFlag(kTSAPrivatePlayingRightComparisonFlag, false);
+			}
+		}
+		break;
+	case kTSA22EastMonitorSpotID:
+		requestExtraSequence(kTSA22RedEastZoomInSequence, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA23WestMonitorSpotID:
+		requestExtraSequence(kTSA23RedWestVaultZoomInSequence, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA0BNorthRobotsToCommandCenterSpotID:
+		_sprite1.setCurrentFrameIndex(kRedirectionCCDoorSprite);
+		_sprite1.show();
+		_vm->delayShell(1, 2);
+		_sprite1.hide();
+
+		switch (GameState.getTSAState()) {
+		case kRobotsAtCommandCenter:
+			// Nothing
+			break;
+		case kRobotsAtFrontDoor:
+			GameState.setTSAState(kRobotsAtCommandCenter);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromFrontDoorToCommandCenter, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kRobotsAtReadyRoom:
+			GameState.setTSAState(kRobotsAtCommandCenter);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromReadyRoomToCommandCenter, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+		break;
+	case kTSA0BNorthRobotsToReadyRoomSpotID:
+		_sprite1.setCurrentFrameIndex(kRedirectionRRDoorSprite);
+		_sprite1.show();
+		_vm->delayShell(1, 2);
+		_sprite1.hide();
+
+		switch (GameState.getTSAState()) {
+		case kRobotsAtCommandCenter:
+			GameState.setTSAState(kRobotsAtReadyRoom);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromCommandCenterToReadyRoom, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kRobotsAtFrontDoor:
+			GameState.setTSAState(kRobotsAtReadyRoom);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromFrontDoorToReadyRoom, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kRobotsAtReadyRoom:
+			// Nothing
+			break;
+		}
+		break;
+	case kTSA0BNorthRobotsToFrontDoorSpotID:
+		_sprite1.setCurrentFrameIndex(kRedirectionFDDoorSprite);
+		_sprite1.show();
+		_vm->delayShell(1, 2);
+		_sprite1.hide();
+
+		switch (GameState.getTSAState()) {
+		case kRobotsAtCommandCenter:
+			GameState.setTSAState(kRobotsAtFrontDoor);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromCommandCenterToFrontDoor, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kRobotsAtFrontDoor:
+			// Nothing
+			break;
+		case kRobotsAtReadyRoom:
+			GameState.setTSAState(kRobotsAtFrontDoor);
+			_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+			startExtraSequence(kTSA0BRobotsFromReadyRoomToFrontDoor, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+		break;
+
+	// Pegasus
+	case kTSA37NorthJumpToPrehistoricSpotID:
+		startExtraSequence(kTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA37NorthExitSpotID:
+		_sprite2.setCurrentFrameIndex(1);
+		_vm->delayShell(1, 2);
+		releaseSprites();
+		moveForward();
+		break;
+	case kTSA37NorthJumpMenuSpotID:
+		_sprite2.setCurrentFrameIndex(1);
+		_vm->delayShell(1, 2);
+		releaseSprites();
+		break;			
+	case kTSA37NorthJumpToNoradSpotID:
+		GameState.setTSAState(kPlayerOnWayToNorad);
+		requestExtraSequence(kTSA37JumpToNorad, 0, kFilterNoInput);
+
+		if (!GameState.getBeenToNorad()) {
+			requestExtraSequence(kTSA37NoradToAI7, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37PegasusAI7, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37AI7ToNorad, 0, kFilterNoInput);
+			GameState.setBeenToNorad(true);
+		}
+
+		requestExtraSequence(kTSA37NoradToDepart, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA37NorthJumpToMarsSpotID:
+		GameState.setTSAState(kPlayerOnWayToMars);
+		requestExtraSequence(kTSA37JumpToMars, 0, kFilterNoInput);
+
+		if (!GameState.getBeenToMars()) {
+			requestExtraSequence(kTSA37MarsToAI6, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37PegasusAI6, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37AI6ToMars, 0, kFilterNoInput);
+			GameState.setBeenToMars(true);
+		}
+
+		requestExtraSequence(kTSA37MarsToDepart, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTSA37NorthJumpToWSCSpotID:
+		GameState.setTSAState(kPlayerOnWayToWSC);
+		requestExtraSequence(kTSA37JumpToWSC, 0, kFilterNoInput);
+
+		if (!GameState.getBeenToWSC()) {
+			requestExtraSequence(kTSA37WSCToAI5, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37PegasusAI5, 0, kFilterNoInput);
+			requestExtraSequence(kTSA37AI5ToWSC, 0, kFilterNoInput);
+			GameState.setBeenToWSC(true);
+		}
+
+		requestExtraSequence(kTSA37WSCToDepart, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37PegasusDepart, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Neighborhood::clickInHotspot(input, clickedSpot);
+		break;
+	}
+}
+
+void FullTSA::showMainJumpMenu() {
+	tExtraID jumpMenuView = kTSA37JumpMenu000;
+
+	if (GameState.getNoradFinished())
+		jumpMenuView += 4;
+	if (GameState.getMarsFinished())
+		jumpMenuView += 2;
+	if (GameState.getWSCFinished())
+		jumpMenuView += 1;
+
+	showExtraView(jumpMenuView);
+	setCurrentActivation(kActivationMainJumpMenu);
+}
+
+void FullTSA::playTBPMonitor() {
+	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+	
+	if ((GameState.getT0BMonitorMode() & kPlayingTBPMask) == 0) {
+		tExtraID extra;
+
+		switch (GameState.getT0BMonitorMode() & kRawModeMask) {
+		case kMonitorTheory:
+			GameState.setTSASeenTheory(true);
+			extra = kTSA0BTBPTheory;
+			GameState.setScoringSawTheory(true);
+			break;
+		case kMonitorBackground:
+			GameState.setTSASeenBackground(true);
+			extra = kTSA0BTBPBackground;
+			GameState.setScoringSawBackground(true);
+			break;
+		case kMonitorProcedure:
+			GameState.setTSASeenProcedure(true);
+			extra = kTSA0BTBPProcedure;
+			GameState.setScoringSawProcedure(true);
+			break;
+		}
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingTBPMask);
+
+		ExtraTable::Entry entry;
+		getExtraEntry(extra, entry);
+		_lastExtra = extra;
+
+		GameState.setT0BMonitorStart(entry.movieStart + kFullTSAFrameDuration * 5);
+		startMovieSequence(GameState.getT0BMonitorStart(), entry.movieEnd, kExtraCompletedFlag, false, kFilterAllInput);
+	} else if (_navMovie.isRunning()) {
+		_navMovie.stop();
+	} else {
+		_navMovie.start();
+	}
+}
+
+void FullTSA::initializeTBPMonitor(const int newMode, const tExtraID highlightExtra) {
+	GameState.setT0BMonitorMode(newMode);
+
+	if (newMode != kMonitorNeutral) {
+		showExtraView(highlightExtra);
+		_vm->delayShell(1, 2);
+		setCurrentActivation(kActivateTSA0BTBPVideo);
+		_sprite1.addPICTResourceFrame(kTBPRewindPICTID, false, 0, 0);
+		_sprite1.moveElementTo(kTBPRewindLeft, kTBPRewindTop);
+		_sprite1.setCurrentFrameIndex(0);
+		_sprite2.addPICTResourceFrame(kTBPCloseBoxPICTID, false, 0, 0);
+		_sprite2.moveElementTo(kTBPCloseLeft, kTBPCloseTop);
+		_sprite2.setCurrentFrameIndex(0);
+		playTBPMonitor();
+	} else {
+		if (GameState.getTSAState() == kTSAPlayerForcedReview && GameState.getTSASeenTheory() &&
+				GameState.getTSASeenBackground() && GameState.getTSASeenProcedure()) {
+			setOffRipAlarm();
+		} else {
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+			updateViewFrame();
+		}
+
+		releaseSprites();
+	}
+
+	_interruptionFilter = kFilterAllInput;
+}
+
+void FullTSA::startUpComparisonMonitor() {
+	releaseSprites();
+
+	_sprite1.addPICTResourceFrame(kComparisonHiliteNoradPICTID, false,
+			kComparisonHiliteNoradLeft - kComparisonHiliteSpriteLeft,
+			kComparisonHiliteNoradTop - kComparisonHiliteSpriteTop);
+	_sprite1.addPICTResourceFrame(kComparisonHiliteMarsPICTID, false,
+			kComparisonHiliteMarsLeft - kComparisonHiliteSpriteLeft,
+			 kComparisonHiliteMarsTop - kComparisonHiliteSpriteTop);
+	_sprite1.addPICTResourceFrame(kComparisonHiliteCaldoriaPICTID, false,
+			kComparisonHiliteCaldoriaLeft - kComparisonHiliteSpriteLeft,
+			kComparisonHiliteCaldoriaTop - kComparisonHiliteSpriteTop);
+	_sprite1.addPICTResourceFrame(kComparisonHiliteWSCPICTID, false,
+			kComparisonHiliteWSCLeft - kComparisonHiliteSpriteLeft,
+			kComparisonHiliteWSCTop - kComparisonHiliteSpriteTop);
+
+	_sprite1.setCurrentFrameIndex(0);
+	_sprite1.moveElementTo(kComparisonHiliteSpriteLeft, kComparisonHiliteSpriteTop);
+	
+	_sprite2.addPICTResourceFrame(kComparisonChancesNoradPICTID, false,
+			kComparisonChancesNoradLeft - kComparisonChancesSpriteLeft,
+			kComparisonChancesNoradTop - kComparisonChancesSpriteTop);
+	_sprite2.addPICTResourceFrame(kComparisonChancesMarsPICTID, false,
+			kComparisonChancesMarsLeft - kComparisonChancesSpriteLeft,
+			kComparisonChancesMarsTop - kComparisonChancesSpriteTop);
+	_sprite2.addPICTResourceFrame(kComparisonChancesCaldoriaPICTID, false,
+			kComparisonChancesCaldoriaLeft - kComparisonChancesSpriteLeft,
+			kComparisonChancesCaldoriaTop - kComparisonChancesSpriteTop);
+	_sprite2.addPICTResourceFrame(kComparisonChancesWSCPICTID, false,
+			kComparisonChancesWSCLeft - kComparisonChancesSpriteLeft,
+			kComparisonChancesWSCTop - kComparisonChancesSpriteTop);
+
+	_sprite2.setCurrentFrameIndex(0);
+	_sprite2.moveElementTo(kComparisonChancesSpriteLeft, kComparisonChancesSpriteTop);
+	updateViewFrame();
+}
+
+void FullTSA::shutDownComparisonMonitor() {
+	releaseSprites();
+}
+
+void FullTSA::initializeComparisonMonitor(const int newMode, const tExtraID comparisonView) {
+	GameState.setT0BMonitorMode(newMode);
+	_privateFlags.setFlag(kTSAPrivatePlayingLeftComparisonFlag, false);
+	_privateFlags.setFlag(kTSAPrivatePlayingRightComparisonFlag, false);
+
+	if (newMode != kMonitorNeutral) {
+		shutDownComparisonMonitor();
+		setCurrentActivation(kActivateTSA0BComparisonVideo);
+		_sprite1.addPICTResourceFrame(kComparisonLeftRewindPICTID, false, 0, 0);
+		_sprite1.moveElementTo(kComparisonLeftRewindLeft, kComparisonLeftRewindTop);
+		_sprite1.setCurrentFrameIndex(0);
+		_sprite2.addPICTResourceFrame(kComparisonRightRewindPICTID, false, 0, 0);
+		_sprite2.moveElementTo(kComparisonRightRewindLeft, kComparisonRightRewindTop);
+		_sprite2.setCurrentFrameIndex(0);
+		_sprite3.addPICTResourceFrame(kComparisonCloseBoxPICTID, false, 0, 0);
+		_sprite3.moveElementTo(kComparisonCloseLeft, kComparisonCloseTop);
+		_sprite3.setCurrentFrameIndex(0);
+		showExtraView(comparisonView);
+	} else {
+		if (GameState.getTSAState() == kTSAPlayerInstalledHistoricalLog &&
+				GameState.getTSASeenNoradNormal() &&
+				GameState.getTSASeenNoradAltered() &&
+				GameState.getTSASeenMarsNormal() &&
+				GameState.getTSASeenMarsAltered() &&
+				GameState.getTSASeenCaldoriaNormal() &&
+				GameState.getTSASeenCaldoriaAltered() &&
+				GameState.getTSASeenWSCNormal() &&
+				GameState.getTSASeenWSCAltered()) {
+			GameState.setTSAState(kTSABossSawHistoricalLog);
+			requestExtraSequence(kTSA0BEastZoomOut, kExtraCompletedFlag, kFilterNoInput);
+			requestExtraSequence(kTSA0BEastTurnLeft, kExtraCompletedFlag, kFilterNoInput);
+			requestExtraSequence(kTSA0BNorthZoomIn, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+			releaseSprites();
+			startUpComparisonMonitor();
+		}
+	}
+
+	_interruptionFilter = kFilterAllInput;
+}
+
+void FullTSA::playLeftComparison() {
+	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+
+	if ((GameState.getT0BMonitorMode() & kPlayingLeftComparisonMask) == 0) {
+		tExtraID extra;
+
+		switch (GameState.getT0BMonitorMode() & kRawModeMask) {
+		case kMonitorNoradComparison:
+			GameState.setTSASeenNoradAltered(true);
+			extra = kTSA0BNoradAltered;
+			GameState.setScoringSawNoradAltered(true);
+			break;
+		case kMonitorMarsComparison:
+			GameState.setTSASeenMarsAltered(true);
+			extra = kTSA0BMarsAltered;
+			GameState.setScoringSawMarsAltered(true);
+			break;
+		case kMonitorCaldoriaComparison:
+			GameState.setTSASeenCaldoriaAltered(true);
+			extra = kTSA0BCaldoriaAltered;
+			GameState.setScoringSawCaldoriaAltered(true);
+			break;
+		case kMonitorWSCComparison:
+			GameState.setTSASeenWSCAltered(true);
+			extra = kTSA0BWSCAltered;
+			GameState.setScoringSawWSCAltered(true);
+			break;
+		}
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingLeftComparisonMask);
+
+		ExtraTable::Entry entry;
+		getExtraEntry(extra, entry);
+		_lastExtra = extra;
+
+		// skip first five frames of movie
+		// (this is a dissolve that doesn't belong...)
+		GameState.setT0BMonitorStart(entry.movieStart + kFullTSAFrameDuration * 5);
+		_privateFlags.setFlag(kTSAPrivatePlayingLeftComparisonFlag);
+
+		// Allow clicking...
+		startMovieSequence(GameState.getT0BMonitorStart(), entry.movieEnd,
+				kExtraCompletedFlag, false, JMPPPInput::getClickInputFilter());
+	} else if (_navMovie.isRunning()) {
+		_navMovie.stop();
+	} else {
+		_navMovie.start();
+	}
+}
+
+void FullTSA::playRightComparison() {	
+	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+	
+	if ((GameState.getT0BMonitorMode() & kPlayingRightComparisonMask) == 0) {
+		tExtraID extra;
+
+		switch (GameState.getT0BMonitorMode() & kRawModeMask) {
+		case kMonitorNoradComparison:
+			GameState.setTSASeenNoradNormal(true);
+			extra = kTSA0BNoradUnaltered;
+			GameState.setScoringSawNoradNormal(true);
+			break;
+		case kMonitorMarsComparison:
+			GameState.setTSASeenMarsNormal(true);
+			extra = kTSA0BMarsUnaltered;
+			GameState.setScoringSawMarsNormal(true);
+			break;
+		case kMonitorCaldoriaComparison:
+			GameState.setTSASeenCaldoriaNormal(true);
+			extra = kTSA0BCaldoriaUnaltered;
+			GameState.setScoringSawCaldoriaNormal(true);
+			break;
+		case kMonitorWSCComparison:
+			GameState.setTSASeenWSCNormal(true);
+			extra = kTSA0BWSCUnaltered;
+			GameState.setScoringSawWSCNormal(true);
+			break;
+		}
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingRightComparisonMask);
+
+		ExtraTable::Entry entry;
+		getExtraEntry(extra, entry);
+		_lastExtra = extra;
+
+		// skip first five frames of movie
+		// (this is a dissolve that doesn't belong...)
+		GameState.setT0BMonitorStart(entry.movieStart + kFullTSAFrameDuration * 5);
+		_privateFlags.setFlag(kTSAPrivatePlayingRightComparisonFlag);
+
+		// Allow clicking...
+		startMovieSequence(GameState.getT0BMonitorStart(), entry.movieEnd,
+				kExtraCompletedFlag, false, JMPPPInput::getClickInputFilter());
+	} else if (_navMovie.isRunning()) {
+		_navMovie.stop();
+	} else {
+		_navMovie.start();
+	}
+}
+
+// When this function is called, the player is zoomed up on the center monitor, and the
+// TSA state is kTSABossSawHistoricalLog.
+void FullTSA::startRobotGame() {
+	requestExtraSequence(kTSA0BNorthCantChangeHistory, 0, kFilterNoInput);
+	requestExtraSequence(kTSA0BAIInterruption, 0, kFilterNoInput);
+	requestExtraSequence(kTSA0BShowGuardRobots, 0, kFilterNoInput);
+	requestExtraSequence(kTSA0BRobotsToCommandCenter, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void FullTSA::startUpRobotMonitor() {
+	releaseSprites();
+
+	_sprite1.addPICTResourceFrame(kRedirectionCCRolloverPICTID, true,
+			kRedirectionCCRolloverLeft - kRedirectionSprite1Left,
+			kRedirectionCCRolloverTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionRRRolloverPICTID, true,
+			kRedirectionRRRolloverLeft - kRedirectionSprite1Left,
+			kRedirectionRRRolloverTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionFDRolloverPICTID, false,
+			kRedirectionFDRolloverLeft - kRedirectionSprite1Left,
+			kRedirectionFDRolloverTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionCCDoorPICTID, true,
+			kRedirectionCCDoorLeft - kRedirectionSprite1Left,
+			kRedirectionCCDoorTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionRRDoorPICTID, true,
+			kRedirectionRRDoorLeft - kRedirectionSprite1Left,
+			kRedirectionRRDoorTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionFDDoorPICTID, false,
+			kRedirectionFDDoorLeft - kRedirectionSprite1Left,
+			kRedirectionFDDoorTop - kRedirectionSprite1Top);
+	_sprite1.addPICTResourceFrame(kRedirectionClosePICTID, false,
+			kRedirectionCloseLeft - kRedirectionSprite1Left,
+			kRedirectionCloseTop - kRedirectionSprite1Top);
+	_sprite1.moveElementTo(kRedirectionSprite1Left, kRedirectionSprite1Top);
+
+	_sprite2.addPICTResourceFrame(kRedirectionSecuredPICTID, false,
+			kRedirectionSecuredLeft - kRedirectionSprite2Left,
+			kRedirectionSecuredTop - kRedirectionSprite2Top);
+	_sprite2.addPICTResourceFrame(kRedirectionNewTargetPICTID, false,
+			kRedirectionNewTargetLeft - kRedirectionSprite2Left,
+			kRedirectionNewTargetTop - kRedirectionSprite2Top);
+	_sprite2.moveElementTo(kRedirectionSprite2Left, kRedirectionSprite2Top);
+
+	switch (GameState.getTSAState()) {
+	case kRobotsAtCommandCenter:
+		showExtraView(kTSA0BNorthRobotsAtCCView);
+		break;
+	case kRobotsAtFrontDoor:
+		showExtraView(kTSA0BNorthRobotsAtFDView);
+		break;
+	case kRobotsAtReadyRoom:
+		showExtraView(kTSA0BNorthRobotsAtRRView);
+		break;
+	}
+}
+
+void FullTSA::shutDownRobotMonitor() {
+	releaseSprites();
+}
+
+// Assume this is called only when zoomed in at T0B west
+void FullTSA::setOffRipAlarm() {
+	GameState.setTSAState(kTSAPlayerDetectedRip);
+	_ripTimer.initImage();
+	_ripTimer.moveElementTo(kRipTimerLeft, kRipTimerTop);
+	_ripTimer.setSegment(0, kRipTimeLimit, kRipTimeScale);
+	_ripTimer.start();
+	loadAmbientLoops();
+	startExtraSequenceSync(kTSA0BRipAlarmScreen, kFilterNoInput);
+	_vm->delayShell(2, 1); // Two seconds..
+	requestExtraSequence(kTSA0BWestZoomOut, kExtraCompletedFlag, kFilterNoInput);
+	requestExtraSequence(kTSA0BWestTurnRight, 0, kFilterNoInput);
+	requestExtraSequence(kTSA0BNorthZoomIn, kExtraCompletedFlag, kFilterNoInput);
+	requestExtraSequence(kTSA0BNorthFinallyHappened, 0, kFilterNoInput);
+	requestExtraSequence(kTSA0BShowRip1, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void FullTSA::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kTSA04, kNorth):
+	case MakeRoomView(kTSA14, kEast):
+	case MakeRoomView(kTSA15, kWest):
+	case MakeRoomView(kTSA16, kNorth):
+	case MakeRoomView(kTSA16, kSouth):
+	case MakeRoomView(kTSA21Cyan, kSouth):
+	case MakeRoomView(kTSA21Red, kSouth):
+	case MakeRoomView(kTSA26, kNorth):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void FullTSA::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	checkRobotLocations(room, direction);
+	Neighborhood::arriveAt(room, direction);
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kTSADeathRoom, kNorth):
+	case MakeRoomView(kTSADeathRoom, kSouth):
+	case MakeRoomView(kTSADeathRoom, kEast):
+	case MakeRoomView(kTSADeathRoom, kWest):
+		die(kDeathShotByTSARobots);
+		break;
+	case MakeRoomView(kTSA00, kNorth):
+		if (GameState.getLastNeighborhood() != kFullTSAID) {
+			makeContinuePoint();
+			openDoor();
+		} else {
+			setCurrentActivation(kActivateTSAReadyForCard);
+			loopExtraSequence(kTSATransporterArrowLoop, 0);
+		}
+		break;
+	case MakeRoomView(kTSA03, kNorth):
+	case MakeRoomView(kTSA05, kNorth):
+	case MakeRoomView(kTSA0A, kNorth):
+	case MakeRoomView(kTSA06, kNorth):
+	case MakeRoomView(kTSA07, kNorth):
+		if (_utilityFuse.isFuseLit())
+			_utilityFuse.stopFuse();
+		GameState.setScoringEnterTSA(true);
+		break;
+	case MakeRoomView(kTSA04, kNorth):
+		if (_utilityFuse.isFuseLit())
+			_utilityFuse.stopFuse();
+		if (!GameState.getTSASeenRobotGreeting())
+			startExtraSequence(kTSA04NorthRobotGreeting, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kTSA03, kSouth):
+		GameState.setTSAFrontDoorUnlockedInside(GameState.getTSAState() == kRobotsAtFrontDoor || GameState.allTimeZonesFinished());
+		break;
+	case MakeRoomView(kTSA0A, kEast):
+	case MakeRoomView(kTSA0A, kWest):
+		if (GameState.getTSAState() == kTSAPlayerNotArrived)
+			setCurrentActivation(kActivateTSARobotsAwake);
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn()) {
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerNeedsHistoricalLog:
+				_ripTimer.show();
+				break;
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				startUpRobotMonitor();
+				break;
+			}
+		} else {
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerNotArrived:
+				requestExtraSequence(kTSA0BNorthZoomIn, kExtraCompletedFlag, kFilterNoInput);
+				requestExtraSequence(kTSA0BNorthYoureBusted, 0, kFilterNoInput);
+				requestExtraSequence(kTSA0BNorthZoomOut, kExtraCompletedFlag, kFilterNoInput);
+				requestExtraSequence(kTSA0BNorthTurnLeft, 0, kFilterNoInput);
+				requestExtraSequence(kTSA0BWestZoomIn, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case kTSAPlayerGotHistoricalLog:
+				startExtraSequence(kTSA0BNorthHistLogOpen, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			}
+		}
+		break;
+	case MakeRoomView(kTSA0B, kSouth):
+		GameState.setTSA0BZoomedIn(false);
+		setCurrentActivation(kActivateTSA0BZoomedOut);
+		break;
+	case MakeRoomView(kTSA0B, kWest):
+		if (GameState.getTSA0BZoomedIn()) {
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+			initializeTBPMonitor(kMonitorNeutral, 0);
+		} else {
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+		}
+		break;
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn()) {
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerInstalledHistoricalLog:
+			case kTSABossSawHistoricalLog:
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				initializeComparisonMonitor(kMonitorNeutral, 0);
+				break;
+			}
+		} else {
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+		}
+		break;
+	case MakeRoomView(kTSA21Red, kSouth):
+		if (GameState.getTSAState() == kRobotsAtFrontDoor)
+			GameState.setScoringWentToReadyRoom2(true);
+		break;
+	case MakeRoomView(kTSA22Red, kEast):
+		if (!_vm->playerHasItemID(kJourneymanKey))
+			setCurrentActivation(kActivationDoesntHaveKey);
+		break;
+	case MakeRoomView(kTSA23Red, kWest):
+		if (!_vm->playerHasItemID(kPegasusBiochip))
+			setCurrentActivation(kActivationDoesntHaveChips);
+		break;
+	case MakeRoomView(kTSA25Red, kNorth):
+		arriveAtTSA25Red();
+		break;
+	case MakeRoomView(kTSA34, kSouth):
+		if (GameState.getLastRoom() == kTSA37)
+			closeDoorOffScreen(kTSA37, kNorth);
+		break;
+	case MakeRoomView(kTSA37, kNorth):
+		arriveAtTSA37();
+		break;
+	}
+}
+
+void FullTSA::checkRobotLocations(const tRoomID room, const tDirectionConstant dir) {
+	switch (room) {
+	case kTSA03:
+	case kTSA04:
+	case kTSA05:
+	case kTSA06:
+	case kTSA0A:
+	case kTSA07:
+	case kTSA08:
+	case kTSA09:
+	case kTSA10:
+	case kTSA11:
+	case kTSA12:
+	case kTSA13:
+	case kTSA14:
+	case kTSA15:
+		switch (GameState.getTSAState()) {
+		case kRobotsAtFrontDoor:
+			setCurrentAlternate(kAltTSARobotsAtFrontDoor);
+			break;
+		case kRobotsAtReadyRoom:
+			setCurrentAlternate(kAltTSARobotsAtReadyRoom);
+			break;
+		}
+		break;
+	case kTSA16:
+		if (dir == kNorth) {
+			switch (GameState.getTSAState()) {
+			case kRobotsAtCommandCenter:
+				if (!_privateFlags.getFlag(kTSAPrivateSeenRobotWarningFlag)) {
+					g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/TSA/XT11WB", false, kWarningInterruption);
+					_privateFlags.setFlag(kTSAPrivateSeenRobotWarningFlag, true);
+				}
+				break;
+			case kRobotsAtFrontDoor:
+				setCurrentAlternate(kAltTSARobotsAtFrontDoor);
+				break;
+			case kRobotsAtReadyRoom:
+				setCurrentAlternate(kAltTSARobotsAtReadyRoom);
+				break;
+			}
+		}
+		break;
+	}
+}
+
+void FullTSA::arriveAtTSA25Red() {
+	if (!_vm->playerHasItemID(kJourneymanKey))
+		startExtraSequence(kTSA25NorthDeniedNoKey, kExtraCompletedFlag, kFilterNoInput);
+	else if (!_vm->playerHasItemID(kPegasusBiochip))
+		startExtraSequence(kTSA25NorthDeniedNoChip, kExtraCompletedFlag, kFilterNoInput);
+	else if (GameState.getTSABiosuitOn())
+		startExtraSequence(kTSA25NorthAlreadyHaveSuit, kExtraCompletedFlag, kFilterNoInput);
+	else
+		startExtraSequence(kTSA25NorthPutOnSuit, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void FullTSA::arriveAtTSA37() {
+	_ripTimer.stop();
+	_ripTimer.releaseImage();
+
+	switch (GameState.getTSAState()) {
+	case kTSAPlayerNeedsHistoricalLog:
+		startExtraLongSequence(kTSA37HorseToAI1, kTSA37AI2ToPrehistoric, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kPlayerOnWayToPrehistoric:
+		setCurrentActivation(kActivationJumpToPrehistoric);
+		showExtraView(kTSA37AI2ToPrehistoric);
+		break;
+	case kTSAPlayerGotHistoricalLog:
+		initializePegasusButtons(false, true);
+		break;
+	case kPlayerWentToPrehistoric:
+	case kPlayerOnWayToNorad:
+	case kPlayerOnWayToMars:
+	case kPlayerOnWayToWSC:
+		startExtraSequence(kTSA37TimeJumpToPegasus, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kRobotsAtFrontDoor:
+		startExtraLongSequence(kTSA37HorseToColonel2, kTSA37AI4ToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kPlayerLockedInPegasus:
+		showMainJumpMenu();
+		break;
+	case kPlayerFinishedWithTSA:
+		initializePegasusButtons(true, true);
+		break;
+	}
+}
+
+void FullTSA::turnTo(const tDirectionConstant newDirection) {
+	Neighborhood::turnTo(newDirection);
+
+	switch (MakeRoomView(GameState.getCurrentRoom(), newDirection)) {
+	case MakeRoomView(kTSA03, kSouth):
+		if (GameState.getTSAState() == kRobotsAtFrontDoor || GameState.allTimeZonesFinished())
+			GameState.setTSAFrontDoorUnlockedInside(true);
+		else
+			GameState.setTSAFrontDoorUnlockedInside(false);
+		break;
+	case MakeRoomView(kTSA0A, kEast):
+	case MakeRoomView(kTSA0A, kWest):
+		setCurrentActivation(kActivateTSARobotsAwake);
+		break;
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn())
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+		else
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() & ~kPlayingAnyMask);
+
+		if (_privateFlags.getFlag(kTSAPrivateLogReaderOpenFlag))
+			_privateFlags.setFlag(kTSAPrivateLogReaderOpenFlag, false);
+
+		switch (GameState.getTSAState()) {
+		case kTSAPlayerInstalledHistoricalLog:
+		case kTSABossSawHistoricalLog:
+		case kRobotsAtCommandCenter:
+		case kRobotsAtFrontDoor:
+		case kRobotsAtReadyRoom:
+			if (GameState.getTSA0BZoomedIn())
+				startUpComparisonMonitor();
+			break;
+		}
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn())
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+		else
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() & ~kPlayingAnyMask);
+
+		switch (GameState.getTSAState()) {
+		case kTSAPlayerNeedsHistoricalLog:
+			if (GameState.getTSA0BZoomedIn())
+				_ripTimer.show();
+			break;
+		case kTSAPlayerGotHistoricalLog:
+			if (!GameState.getTSA0BZoomedIn())
+				startExtraSequence(kTSA0BNorthHistLogOpen, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kTSAPlayerInstalledHistoricalLog:
+			if (GameState.getTSA0BZoomedIn()) {
+				if ((GameState.getTSASeenNoradNormal() || GameState.getTSASeenNoradAltered()) &&
+						(GameState.getTSASeenMarsNormal() || GameState.getTSASeenMarsAltered()) &&
+						(GameState.getTSASeenCaldoriaNormal() || GameState.getTSASeenCaldoriaAltered()) &&
+						(GameState.getTSASeenWSCNormal() || GameState.getTSASeenWSCAltered())) {
+					GameState.setTSAState(kTSABossSawHistoricalLog);
+					startRobotGame();
+				}
+			}
+			break;
+		case kRobotsAtCommandCenter:
+		case kRobotsAtFrontDoor:
+		case kRobotsAtReadyRoom:
+			if (GameState.getTSA0BZoomedIn())
+				startExtraSequence(kTSA0BShowGuardRobots, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+		break;
+	case MakeRoomView(kTSA0B, kWest):
+		if (GameState.getTSA0BZoomedIn())
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+		else
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+
+		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() & ~kPlayingAnyMask);
+
+		if (_privateFlags.getFlag(kTSAPrivateLogReaderOpenFlag))
+			_privateFlags.setFlag(kTSAPrivateLogReaderOpenFlag, false);
+
+		if (GameState.getTSA0BZoomedIn())
+			initializeTBPMonitor(kMonitorNeutral, 0);
+		break;
+	case MakeRoomView(kTSA0B, kSouth):
+		GameState.setTSA0BZoomedIn(false);
+		setCurrentActivation(kActivateTSA0BZoomedOut);
+		break;
+	case MakeRoomView(kTSA16, kNorth):
+		switch (GameState.getTSAState()) {
+		case kRobotsAtCommandCenter:
+			if (!_privateFlags.getFlag(kTSAPrivateSeenRobotWarningFlag)) {
+				g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/TSA/XT11WB", false, kWarningInterruption);
+				_privateFlags.setFlag(kTSAPrivateSeenRobotWarningFlag, true);
+			}
+			break;
+		case kRobotsAtFrontDoor:
+			setCurrentAlternate(kAltTSARobotsAtFrontDoor);
+			break;
+		case kRobotsAtReadyRoom:
+			setCurrentAlternate(kAltTSARobotsAtReadyRoom);
+			break;
+		}
+		break;
+	case MakeRoomView(kTSA22Red, kEast):
+		if (!_vm->playerHasItemID(kJourneymanKey))
+			setCurrentActivation(kActivationDoesntHaveKey);
+		break;
+	case MakeRoomView(kTSA22Red, kNorth):
+	case MakeRoomView(kTSA22Red, kSouth):
+		if (_privateFlags.getFlag(kTSAPrivateKeyVaultOpenFlag)) {
+			playSpotSoundSync(kTSAVaultCloseIn, kTSAVaultCloseOut);
+			_privateFlags.setFlag(kTSAPrivateKeyVaultOpenFlag, false);
+		}
+
+		setCurrentActivation(kActivateHotSpotAlways);
+		break;
+	case MakeRoomView(kTSA23Red, kWest):
+		if (!_vm->playerHasItemID(kPegasusBiochip))
+			setCurrentActivation(kActivationDoesntHaveChips);
+		break;
+	case MakeRoomView(kTSA23Red, kNorth):
+	case MakeRoomView(kTSA23Red, kSouth):
+		if (_privateFlags.getFlag(kTSAPrivateChipVaultOpenFlag)) {
+			playSpotSoundSync(kTSAVaultCloseIn, kTSAVaultCloseOut);
+			_privateFlags.setFlag(kTSAPrivateChipVaultOpenFlag, false);
+		}
+
+		setCurrentActivation(kActivateHotSpotAlways);
+		break;
+	}
+
+	// Make sure the TBP monitor is forced neutral.
+	GameState.setT0BMonitorMode(kMonitorNeutral);
+}
+
+void FullTSA::closeDoorOffScreen(const tRoomID room, const tDirectionConstant) {
+	switch (room) {
+	case kTSA00:
+	case kTSA01:
+		if (GameState.getCurrentRoom() == kTSA01 || GameState.getCurrentRoom() == kTSA02)
+			playSpotSoundSync(kTSAGTDoorCloseIn, kTSAGTDoorCloseOut);
+		break;
+	case kTSA02:
+	case kTSA03:
+		playSpotSoundSync(kTSAEntryDoorCloseIn, kTSAEntryDoorCloseOut);
+		break;
+	case kTSA14:
+	case kTSA15:
+	case kTSA16:
+	case kTSA21Cyan:
+	case kTSA21Red:
+		playSpotSoundSync(kTSAInsideDoorCloseIn, kTSAInsideDoorCloseOut);
+		break;
+	case kTSA34:
+	case kTSA37:
+		playSpotSoundSync(kTSAPegasusDoorCloseIn, kTSAPegasusDoorCloseOut);
+		break;
+	}
+}
+
+void FullTSA::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+	tExtraID lastExtra = _lastExtra;
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		switch (lastExtra) {
+		case kTSA0BEastTurnLeft:
+			// Need to check this here because turnTo will call _navMovie.stop,
+			// so it has to happen before Neighborhood::receiveNotification,
+			// which may end up starting another sequence...
+			turnTo(kNorth);
+			break;
+		}
+	}
+
+	Neighborhood::receiveNotification(notification, flags);
+
+	InventoryItem *item;
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		// Only allow input if we're not in the middle of series of queue requests.
+		if (actionQueueEmpty())
+			_interruptionFilter = kFilterAllInput;
+
+		switch (lastExtra) {
+		case kTSAGTCardSwipe:
+			item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+			_vm->addItemToInventory(item);
+			setCurrentActivation(kActivateTSAReadyToTransport);
+			break;
+		case kTSAGTGoToCaldoria:
+			_vm->jumpToNewEnvironment(kCaldoriaID, kCaldoria44, kEast);
+
+			if (GameState.allTimeZonesFinished())
+				GameState.setScoringWentAfterSinclair(true);
+			break;
+		case kTSAGTGoToTokyo:
+		case kTSAGTGoToBeach:
+			if (GameState.allTimeZonesFinished())
+				die(kDeathSinclairShotDelegate);
+			else
+				die(kDeathUncreatedInTSA);
+			break;
+		case kTSA02NorthZoomOut:
+			openDoor();
+			break;
+
+		// Hall of suspects.
+		case kTSA04NorthRobotGreeting:
+			GameState.setTSASeenRobotGreeting(true);
+			restoreStriding(kTSA03, kNorth, kNoAlternateID);
+			break;
+		case kTSA03JimenezZoomIn:
+			GameState.setScoringSawBust1(true);
+			break;
+		case kTSA03CrenshawZoomIn:
+			GameState.setScoringSawBust2(true);
+			break;
+		case kTSA04MatsumotoZoomIn:
+			GameState.setScoringSawBust3(true);
+			break;
+		case kTSA04CastilleZoomIn:
+			GameState.setScoringSawBust4(true);
+			break;
+		case kTSA05SinclairZoomIn:
+			GameState.setScoringSawBust5(true);
+			break;
+		case kTSA05WhiteZoomIn:
+			GameState.setScoringSawBust6(true);
+			break;
+			
+		// Command center
+		// Historical comparison...
+		case kTSA0BEastZoomIn:
+			GameState.setTSA0BZoomedIn(true);
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+			GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() & ~kPlayingAnyMask);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerInstalledHistoricalLog:
+			case kTSABossSawHistoricalLog:
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				startUpComparisonMonitor();
+				break;
+			}
+			break;
+		case kTSA0BEastZoomOut:
+			GameState.setTSA0BZoomedIn(false);
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+
+			switch (GameState.getTSAState()) {
+			case kTSABossSawHistoricalLog:
+				// Prevent current view from activating.
+				break;
+			default:
+				activateCurrentView(GameState.getCurrentRoom(), GameState.getCurrentDirection(),
+						kSpotOnTurnMask);
+				break;
+			}
+			break;
+		case kTSA0BComparisonStartup:
+			if ((flags & kActionRequestCompletedFlag) != 0) {
+				_privateFlags.setFlag(kTSAPrivateLogReaderOpenFlag, false);
+				GameState.setTSAState(kTSAPlayerInstalledHistoricalLog);
+				turnTo(kEast);
+			}
+
+			startUpComparisonMonitor();
+			break;
+		case kTSA0BNoradAltered:
+		case kTSA0BMarsAltered:
+		case kTSA0BCaldoriaAltered:
+		case kTSA0BWSCAltered:
+		case kTSA0BNoradUnaltered:
+		case kTSA0BMarsUnaltered:
+		case kTSA0BCaldoriaUnaltered:
+		case kTSA0BWSCUnaltered:
+			initializeComparisonMonitor(kMonitorNeutral, 0);
+			break;
+			
+		// Center monitor.
+		case kTSA0BNorthZoomIn:
+			GameState.setTSA0BZoomedIn(true);
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+			GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() & ~kPlayingAnyMask);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerNeedsHistoricalLog:
+				startExtraSequence(kTSA0BShowRip1, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case kTSABossSawHistoricalLog:
+			case kTSAPlayerInstalledHistoricalLog:
+				if ((GameState.getTSASeenNoradNormal() || GameState.getTSASeenNoradAltered()) &&
+						(GameState.getTSASeenMarsNormal() || GameState.getTSASeenMarsAltered()) &&
+						(GameState.getTSASeenCaldoriaNormal() || GameState.getTSASeenCaldoriaAltered()) &&
+						(GameState.getTSASeenWSCNormal() || GameState.getTSASeenWSCAltered())) {
+					GameState.setTSAState(kTSABossSawHistoricalLog);
+					startRobotGame();
+				}
+				break;
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				startExtraSequence(kTSA0BShowGuardRobots, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			}
+			break;
+		case kTSA0BNorthZoomOut:
+			GameState.setTSA0BZoomedIn(false);
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+			break;
+		case kTSA0BShowRip1:
+			GameState.setTSAState(kTSAPlayerNeedsHistoricalLog);
+			GameState.setTSACommandCenterLocked(false);
+
+			if ((flags & kActionRequestCompletedFlag) != 0)
+				turnTo(kNorth);
+
+			_ripTimer.show();
+			break;
+		case kTSA0BNorthHistLogOpen:
+			setCurrentActivation(kActivationLogReaderOpen);
+			_privateFlags.setFlag(kTSAPrivateLogReaderOpenFlag, true);
+			break;
+		case kTSA0BRobotsToCommandCenter:
+			GameState.setTSAState(kRobotsAtCommandCenter);
+			// Fall through
+		case kTSA0BShowGuardRobots:
+			startUpRobotMonitor();
+			// Fall through
+		case kTSA0BRobotsFromCommandCenterToReadyRoom:
+		case kTSA0BRobotsFromReadyRoomToCommandCenter:
+		case kTSA0BRobotsFromCommandCenterToFrontDoor:
+		case kTSA0BRobotsFromFrontDoorToCommandCenter:
+		case kTSA0BRobotsFromFrontDoorToReadyRoom:
+		case kTSA0BRobotsFromReadyRoomToFrontDoor:
+			_sprite2.setCurrentFrameIndex(kRedirectionSecuredSprite);
+			_sprite2.show();
+			break;
+			
+		// TBP monitor.
+		case kTSA0BWestZoomIn:
+			GameState.setTSA0BZoomedIn(true);
+			setCurrentActivation(kActivateTSA0BZoomedIn);
+
+			if (GameState.getTSAState() == kTSAPlayerNotArrived) {
+				turnTo(kWest);
+				GameState.setTSACommandCenterLocked(true);
+				GameState.setTSAState(kTSAPlayerForcedReview);
+			}
+
+			initializeTBPMonitor(kMonitorNeutral, 0);
+			break;
+		case kTSA0BWestZoomOut:
+			GameState.setTSA0BZoomedIn(false);
+			setCurrentActivation(kActivateTSA0BZoomedOut);
+			GameState.setT0BMonitorMode(kMonitorNeutral);
+
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerDetectedRip:
+				// Keep the current view from activating.
+				break;
+			default:
+				activateCurrentView(GameState.getCurrentRoom(), GameState.getCurrentDirection(),
+						kSpotOnTurnMask);
+				break;
+			}
+			break;
+		case kTSA0BTBPTheory:
+		case kTSA0BTBPBackground:
+		case kTSA0BTBPProcedure:
+			initializeTBPMonitor(kMonitorNeutral, 0);
+			break;
+			
+		// Ready room
+		case kTSA22RedEastZoomInSequence:
+			_privateFlags.setFlag(kTSAPrivateKeyVaultOpenFlag, true);
+			setCurrentActivation(kActivationKeyVaultOpen);
+			break;
+		case kTSA23RedWestVaultZoomInSequence:
+			_privateFlags.setFlag(kTSAPrivateChipVaultOpenFlag, true);
+			setCurrentActivation(kActivationChipVaultOpen);
+			break;
+		case kTSA25NorthPutOnSuit:
+			GameState.setTSABiosuitOn(true);
+			GameState.setScoringGotBiosuit(true);
+			// Fall through...
+		case kTSA25NorthAlreadyHaveSuit:
+			requestExtraSequence(kTSA25NorthDescending1, 0, kFilterNoInput);
+			requestExtraSequence(kTSA25NorthDescending2, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kTSA25NorthDescending2:
+			arriveAt(kTSA26, kNorth);
+			break;
+
+		// Pegasus.
+		case kTSA37HorseToAI1:
+		case kTSA37AI2ToPrehistoric:
+			setCurrentActivation(kActivationJumpToPrehistoric);
+			GameState.setTSAState(kPlayerOnWayToPrehistoric);
+			break;
+		case kTSA37PegasusDepart:
+			_vm->setLastEnergyValue(kFullEnergy);
+
+			switch (GameState.getTSAState()) {
+			case kPlayerOnWayToPrehistoric:
+				_vm->jumpToNewEnvironment(kPrehistoricID, kPrehistoric02, kSouth);
+				GameState.setPrehistoricSeenTimeStream(false);
+				GameState.setPrehistoricSeenFlyer1(false);
+				GameState.setPrehistoricSeenFlyer2(false);
+				GameState.setPrehistoricSeenBridgeZoom(false);
+				GameState.setPrehistoricBreakerThrown(false);
+				GameState.setScoringGoToPrehistoric(true);
+				GameState.setTSAState(kPlayerWentToPrehistoric);
+				break;
+			case kPlayerOnWayToNorad:
+				_vm->jumpToNewEnvironment(kNoradAlphaID, kNorad01, kSouth);
+				GameState.setNoradSeenTimeStream(false);
+				GameState.setNoradGassed(true);
+				GameState.setNoradFillingStationOn(false);
+				GameState.setNoradN22MessagePlayed(false);
+				GameState.setNoradPlayedGlobeGame(false);
+				GameState.setNoradBeatRobotWithClaw(false);
+				GameState.setNoradBeatRobotWithDoor(false);
+				GameState.setNoradRetScanGood(false);
+				GameState.setNoradWaitingForLaser(false);
+				GameState.setNoradSubRoomPressure(9);
+				GameState.setNoradSubPrepState(kSubNotPrepped);
+				break;
+			case kPlayerOnWayToMars:
+				_vm->jumpToNewEnvironment(kMarsID, kMars0A, kNorth);
+				GameState.setMarsSeenTimeStream(false);
+				GameState.setMarsHeardUpperPodMessage(false);
+				GameState.setMarsRobotThrownPlayer(false);
+				GameState.setMarsHeardCheckInMessage(false);
+				GameState.setMarsPodAtUpperPlatform(false);
+				GameState.setMarsSeenThermalScan(false);
+				GameState.setMarsArrivedBelow(false);
+				GameState.setMarsSeenRobotAtReactor(false);
+				GameState.setMarsAvoidedReactorRobot(false);
+				GameState.setMarsLockFrozen(false);
+				GameState.setMarsLockBroken(false);
+				GameState.setMarsSecurityDown(false);
+				GameState.setMarsAirlockOpen(false);
+				GameState.setMarsReadyForShuttleTransport(false);
+				GameState.setMarsFinishedCanyonChase(false);
+				GameState.setMarsThreadedMaze(false);
+				break;
+			case kPlayerOnWayToWSC:
+				_vm->jumpToNewEnvironment(kWSCID, kWSC01, kWest);
+				GameState.setWSCSeenTimeStream(false);
+				GameState.setWSCPoisoned(false);
+				GameState.setWSCAnsweredAboutDart(false);
+				GameState.setWSCRemovedDart(false);
+				GameState.setWSCAnalyzerOn(false);
+				GameState.setWSCDartInAnalyzer(false);
+				GameState.setWSCAnalyzedDart(false);
+				GameState.setWSCPickedUpAntidote(false);
+				GameState.setWSCSawMorph(false);
+				GameState.setWSCDesignedAntidote(false);
+				GameState.setWSCOfficeMessagesOpen(false);
+				GameState.setWSCSeenNerd(false);
+				GameState.setWSCHeardPage1(false);
+				GameState.setWSCHeardPage2(false);
+				GameState.setWSCHeardCheckIn(false);
+				GameState.setWSCDidPlasmaDodge(false);
+				GameState.setWSCSeenSinclairLecture(false);
+				GameState.setWSCBeenAtWSC93(false);
+				GameState.setWSCCatwalkDark(false);
+				GameState.setWSCRobotDead(false);
+				GameState.setWSCRobotGone(false);
+				break;
+			};
+			break;
+		case kTSA37TimeJumpToPegasus:
+			if (g_energyMonitor)
+				g_energyMonitor->stopEnergyDraining();
+
+			switch (GameState.getTSAState()) {
+			case kPlayerWentToPrehistoric:
+				arriveFromPrehistoric();
+				break;
+			case kPlayerOnWayToNorad:
+				arriveFromNorad();
+				break;
+			case kPlayerOnWayToMars:
+				arriveFromMars();
+				break;
+			case kPlayerOnWayToWSC:
+				arriveFromWSC();
+				break;
+			default:
+				break;
+			}
+			break;
+		case kTSA37DownloadToOpMemReview:
+			switch (GameState.getTSAState()) {
+			case kPlayerOnWayToNorad:
+				g_opticalChip->playOpMemMovie(kPoseidonSpotID);
+				break;
+			case kPlayerOnWayToMars:
+				g_opticalChip->playOpMemMovie(kAriesSpotID);
+				break;
+			case kPlayerOnWayToWSC:
+				g_opticalChip->playOpMemMovie(kMercurySpotID);
+				break;
+			}
+
+			if (GameState.allTimeZonesFinished()) {
+				requestExtraSequence(kTSA37OpMemReviewToAllClear, 0, kFilterNoInput);
+				requestExtraSequence(kTSA37AllClearToCongratulations, 0, kFilterNoInput);
+				requestExtraSequence(kTSA37Congratulations, 0, kFilterNoInput);
+				requestExtraSequence(kTSA37CongratulationsToExit, kExtraCompletedFlag, kFilterNoInput);
+			} else {
+				requestExtraSequence(kTSA37OpMemReviewToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+			}
+			break;
+		case kTSA37RecallToDownload:
+		case kTSA37ReviewRequiredToExit:
+			GameState.setTSAState(kTSAPlayerGotHistoricalLog);
+			initializePegasusButtons(kPegasusUnresolved, kPegasusCanExit);
+			break;
+		case kTSA37ZoomToMainMenu:
+		case kTSA37HorseToColonel2:
+		case kTSA37DownloadToMainMenu:
+		case kTSA37OpMemReviewToMainMenu:
+		case kTSA37AI4ToMainMenu:
+			GameState.setTSAState(kPlayerLockedInPegasus);
+			showMainJumpMenu();
+			makeContinuePoint();
+			break;
+		case kTSA37JumpToNoradMenu:
+			setCurrentActivation(kActivationJumpToNorad);
+			break;
+		case kTSA37JumpToMarsMenu:
+			setCurrentActivation(kActivationJumpToMars);
+			break;
+		case kTSA37JumpToWSCMenu:
+			setCurrentActivation(kActivationJumpToWSC);
+			break;
+		case kTSA37CancelNorad:
+		case kTSA37CancelMars:
+		case kTSA37CancelWSC:
+			showMainJumpMenu();
+			break;
+		case kTSA37CongratulationsToExit:
+			GameState.setTSAState(kPlayerFinishedWithTSA);
+			initializePegasusButtons(true, true);
+			break;
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+void FullTSA::arriveFromPrehistoric() {
+	if (_vm->playerHasItemID(kHistoricalLog)) {
+		GameState.setScoringFinishedPrehistoric();
+		requestExtraSequence(kTSA37RecallToDownload, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37DownloadToColonel1, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37Colonel1, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37Colonel1ToReviewRequired, 0, kFilterNoInput);
+		requestExtraSequence(kTSA37ReviewRequiredToExit, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		// Make sure rip timer is going...
+		startExtraSequence(kTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void FullTSA::arriveFromNorad() {
+	requestExtraSequence(kTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getNoradFinished() && !GameState.getScoringFinishedNorad()) {
+		GameState.setScoringFinishedNorad();
+		requestExtraSequence(kTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void FullTSA::arriveFromMars() {
+	requestExtraSequence(kTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getMarsFinished() && !GameState.getScoringFinishedMars()) {
+		GameState.setScoringFinishedMars();
+		requestExtraSequence(kTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void FullTSA::arriveFromWSC() {
+	requestExtraSequence(kTSA37RecallToDownload, 0, kFilterNoInput);
+
+	if (GameState.getWSCFinished() && !GameState.getScoringFinishedWSC()) {
+		GameState.setScoringFinishedWSC();
+		requestExtraSequence(kTSA37DownloadToOpMemReview, kExtraCompletedFlag, kFilterNoInput);
+	} else {
+		requestExtraSequence(kTSA37DownloadToMainMenu, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void FullTSA::initializePegasusButtons(bool resolved, bool exit) {
+	if (resolved) {
+		_sprite1.addPICTResourceFrame(kResolvedPICTID, false, 0, 0);
+		_sprite1.moveElementTo(kResolvedLeft, kResolvedTop);
+	} else {
+		_sprite1.addPICTResourceFrame(kUnresolvedPICTID, false, 0, 0);
+		_sprite1.moveElementTo(kUnresolvedLeft, kUnresolvedTop);
+	}
+
+	_sprite1.setCurrentFrameIndex(0);
+	_sprite1.show();
+
+	if (exit) {
+		_sprite2.addPICTResourceFrame(kExitPICTID, false, 0, 0);
+		_sprite2.addPICTResourceFrame(kExitHilitedPICTID, false, kExitHilitedLeft - kExitLeft, kExitHilitedTop - kExitTop);
+		_sprite2.moveElementTo(kExitLeft, kExitTop);
+		setCurrentActivation(kActivationReadyToExit);
+	} else {
+		_sprite2.addPICTResourceFrame(kJumpMenuPICTID, false, 0, 0);
+		_sprite2.addPICTResourceFrame(kJumpMenuHilitedPICTID, false, kJumpMenuHilitedLeft - kJumpMenuLeft, kJumpMenuHilitedTop - kJumpMenuTop);
+		_sprite2.moveElementTo(kJumpMenuLeft, kJumpMenuTop);
+		setCurrentActivation(kActivationReadyForJumpMenu);
+	}
+
+	_sprite2.setCurrentFrameIndex(0);
+	_sprite2.show();
+}
+
+Hotspot *FullTSA::getItemScreenSpot(Item *item, DisplayElement *element) {
+	switch (item->getObjectID()) {
+	case kJourneymanKey:
+		return g_allHotspots.findHotspotByID(kTSA22EastKeySpotID);
+		break;
+	case kPegasusBiochip:
+		return g_allHotspots.findHotspotByID(kTSA23WestChipsSpotID);
+		break;
+	}
+
+	return Neighborhood::getItemScreenSpot(item, element);
+}
+
+void FullTSA::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
+	Neighborhood::dropItemIntoRoom(item, dropSpot);
+
+	switch (item->getObjectID()) {
+	case kKeyCard:
+		if (dropSpot->getObjectID() == kTSAGTCardDropSpotID)
+			startExtraSequence(kTSAGTCardSwipe, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kHistoricalLog:
+		if (dropSpot->getObjectID() == kTSA0BNorthHistLogSpotID) {
+			requestExtraSequence(kTSA0BNorthHistLogCloseWithLog, 0, kFilterNoInput);
+			requestExtraSequence(kTSA0BNorthTurnRight, 0, kFilterNoInput);
+			requestExtraSequence(kTSA0BEastZoomIn, kExtraCompletedFlag, kFilterNoInput);
+			requestExtraSequence(kTSA0BComparisonStartup, kExtraCompletedFlag, kFilterNoInput);
+			GameState.setScoringPutLogInReader(true);
+		}
+		break;
+	}
+}
+
+uint FullTSA::getHistoricalLogIndex() {
+	uint index;
+	
+	if (GameState.getTSASeenNoradNormal() && GameState.getTSASeenNoradAltered())
+		index = 8;
+	else
+		index = 0;
+
+	if (GameState.getTSASeenMarsNormal() && GameState.getTSASeenMarsAltered())
+		index += 4;
+
+	if (GameState.getTSASeenCaldoriaNormal() && GameState.getTSASeenCaldoriaAltered())
+		index += 2;
+
+	if (GameState.getTSASeenWSCNormal() && GameState.getTSASeenWSCAltered())
+		index += 1;
+
+	return index;
+}
+
+void FullTSA::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	switch (MakeRoomView(GameState.getCurrentRoom(), GameState.getCurrentDirection())) {
+	case MakeRoomView(kTSA0B, kEast):
+		if (GameState.getTSA0BZoomedIn() && !_navMovie.isRunning() && GameState.getT0BMonitorMode() == kMonitorNeutral) {
+			switch (GameState.getTSAState()) {
+			case kTSAPlayerInstalledHistoricalLog:
+			case kTSABossSawHistoricalLog:
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				switch (cursorSpot->getObjectID()) {
+				case kTSA0BEastCompareNoradSpotID:
+					_sprite1.setCurrentFrameIndex(0);
+					_sprite2.setCurrentFrameIndex(0);
+					_sprite1.show();
+					_sprite2.show();
+					break;
+				case kTSA0BEastCompareMarsSpotID:
+					_sprite1.setCurrentFrameIndex(1);
+					_sprite2.setCurrentFrameIndex(1);
+					_sprite1.show();
+					_sprite2.show();
+					break;
+				case kTSA0BEastCompareCaldoriaSpotID:
+					_sprite1.setCurrentFrameIndex(2);
+					_sprite2.setCurrentFrameIndex(2);
+					_sprite1.show();
+					_sprite2.show();
+					break;
+				case kTSA0BEastCompareWSCSpotID:
+					_sprite1.setCurrentFrameIndex(3);
+					_sprite2.setCurrentFrameIndex(3);
+					_sprite1.show();
+					_sprite2.show();
+					break;
+				default:
+					_sprite1.hide();
+					_sprite2.hide();
+					break;
+				}
+				break;
+			}
+		}
+		break;
+	case MakeRoomView(kTSA0B, kNorth):
+		if (GameState.getTSA0BZoomedIn() && !_navMovie.isRunning()) {
+			switch (GameState.getTSAState()) {
+			case kRobotsAtCommandCenter:
+			case kRobotsAtFrontDoor:
+			case kRobotsAtReadyRoom:
+				switch (cursorSpot->getObjectID()) {
+				case kTSA0BNorthRobotsToCommandCenterSpotID:
+					_sprite1.setCurrentFrameIndex(kRedirectionCCRolloverSprite);
+					_sprite1.show();
+					break;
+				case kTSA0BNorthRobotsToReadyRoomSpotID:
+					_sprite1.setCurrentFrameIndex(kRedirectionRRRolloverSprite);
+					_sprite1.show();
+					break;
+				case kTSA0BNorthRobotsToFrontDoorSpotID:
+					_sprite1.setCurrentFrameIndex(kRedirectionFDRolloverSprite);
+					_sprite1.show();
+					break;
+				default:
+					_sprite1.hide();
+					break;
+				}
+				break;
+			}
+		}
+		break;
+	}
+
+	Neighborhood::handleInput(input, cursorSpot);
+}
+
+void FullTSA::releaseSprites() {
+	_sprite1.hide();
+	_sprite2.hide();
+	_sprite3.hide();
+	_sprite1.discardFrames();
+	_sprite2.discardFrames();
+	_sprite3.discardFrames();
+}
+
+bool FullTSA::canSolve() {
+	return GameState.getCurrentRoomAndView() == MakeRoomView(kTSA0B, kNorth) &&
+		   GameState.getTSA0BZoomedIn() &&
+		   (GameState.getTSAState() == kRobotsAtCommandCenter ||
+		   GameState.getTSAState() == kRobotsAtFrontDoor ||
+		   GameState.getTSAState() == kRobotsAtReadyRoom);
+}
+
+void FullTSA::doSolve() {
+	// REROUTING ROBOTS
+
+	_sprite1.setCurrentFrameIndex(kRedirectionFDDoorSprite);
+	_sprite1.show();
+	_vm->delayShell(1, 2);
+	_sprite1.hide();
+
+	switch (GameState.getTSAState()) {
+	case kRobotsAtCommandCenter:
+		GameState.setTSAState(kRobotsAtFrontDoor);
+		_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+		startExtraSequence(kTSA0BRobotsFromCommandCenterToFrontDoor, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kRobotsAtFrontDoor:
+		// Nothing
+		break;
+	case kRobotsAtReadyRoom:
+		GameState.setTSAState(kRobotsAtFrontDoor);
+		_sprite2.setCurrentFrameIndex(kRedirectionNewTargetSprite);
+		startExtraSequence(kTSA0BRobotsFromReadyRoomToFrontDoor, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	}
+}
+
+void FullTSA::updateCursor(const Common::Point where, const Hotspot *cursorSpot) {
+	if (cursorSpot) {
+		switch (cursorSpot->getObjectID()) {
+		case kTSA0BEastMonitorSpotID:
+		case kTSA0BNorthMonitorSpotID:
+		case kTSA0BWestMonitorSpotID:
+		case kTSA22EastMonitorSpotID:
+		case kTSA23WestMonitorSpotID:
+			_vm->_cursor->setCurrentFrameIndex(1);
+			return;
+		case kTSA0BEastMonitorOutSpotID:
+		case kTSA0BNorthMonitorOutSpotID:
+		case kTSA0BWestMonitorOutSpotID:
+			_vm->_cursor->setCurrentFrameIndex(2);
+			return;
+		}
+	}
+
+	Neighborhood::updateCursor(where, cursorSpot);
+}
+
+Common::String FullTSA::getNavMovieName() {
+	return "Images/TSA/Full TSA.movie";
+}
+
+Common::String FullTSA::getSoundSpotsName() {
+	return "Sounds/TSA/TSA Spots";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
new file mode 100755
index 0000000..447482f
--- /dev/null
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.h
@@ -0,0 +1,158 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_TSA_FULLTSA_H
+#define PEGASUS_NEIGHBORHOOD_TSA_FULLTSA_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+class RipTimer : public IdlerAnimation {
+public:
+	RipTimer(const tDisplayElementID id) : IdlerAnimation(id) {}
+	virtual ~RipTimer() {}
+
+	void initImage();
+	void releaseImage();
+
+	void draw(const Common::Rect &);
+
+protected:
+	void timeChanged(const TimeValue);
+	
+	tCoordType _middle;
+	Surface _timerImage;
+};
+
+//	Room IDs.
+
+const tRoomID kTSA00 = 0;
+const tRoomID kTSA37 = 42;
+
+class FullTSA : public Neighborhood {
+friend void uncreatedInTSAFunction(FunctionPtr *, void *tsa);
+
+public:
+	FullTSA(InputHandler *, PegasusEngine *);
+	virtual ~FullTSA() {}
+
+	virtual void init();
+
+	void start();
+
+	virtual uint16 getDateResID() const;
+
+	void flushGameState();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+	void updateCursor(const Common::Point, const Hotspot *);
+
+protected:
+	enum {
+		kTSAPrivateLogReaderOpenFlag,
+		kTSAPrivateKeyVaultOpenFlag,
+		kTSAPrivateChipVaultOpenFlag,
+		kTSAPrivatePlayingLeftComparisonFlag,
+		kTSAPrivatePlayingRightComparisonFlag,
+		kTSAPrivateSeenRobotWarningFlag,
+		kNumTSAPrivateFlags
+	};
+
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+	void loadAmbientLoops();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+
+	virtual int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *spot);
+	virtual void activateHotspots();
+	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void downButton(const Input &);
+	void startDoorOpenMovie(const TimeValue, const TimeValue);
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	void turnTo(const tDirectionConstant);
+	tCanMoveForwardReason canMoveForward(ExitTable::Entry &);
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	void bumpIntoWall();
+	void initializeTBPMonitor(const int, const tExtraID);
+	void playTBPMonitor();
+	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	void openDoor();
+	void turnRight();
+	void turnLeft();
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	void playExtraMovie(const ExtraTable::Entry &, const tNotificationFlags, const tInputBits interruptionInput);
+	void handleInput(const Input &, const Hotspot *);
+	void arriveAtTSA25Red();
+	void startUpComparisonMonitor();
+	void shutDownComparisonMonitor();
+	void initializeComparisonMonitor(const int, const tExtraID);
+	void playLeftComparison();
+	void playRightComparison();
+	void startRobotGame();
+	void setOffRipAlarm();
+	uint getHistoricalLogIndex();
+	void startUpRobotMonitor();
+	void shutDownRobotMonitor();
+	void pickedUpItem(Item *item);
+	void arriveFromPrehistoric();
+
+	void arriveFromNorad();
+	void arriveFromMars();
+	void arriveFromWSC();
+
+	tInputBits getInputFilter();
+	void arriveAt(const tRoomID, const tDirectionConstant);
+	void initializePegasusButtons(bool, bool);
+	void releaseSprites();
+	void showMainJumpMenu();
+	void arriveAtTSA37();
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void checkRobotLocations(const tRoomID, const tDirectionConstant);
+	void getExtraEntry(const uint32, ExtraTable::Entry &);
+
+	Sprite _sprite1, _sprite2, _sprite3;
+	FuseFunction _utilityFuse;
+	RipTimer _ripTimer;
+
+	FlagsArray<byte, kNumTSAPrivateFlags> _privateFlags;
+
+	Common::String getNavMovieName();
+	Common::String getSoundSpotsName();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index c50f7a6..e68861e 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -61,6 +61,7 @@
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
+#include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 
 namespace Pegasus {
@@ -1361,6 +1362,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kPrehistoricID:
 		neighborhood = new Prehistoric(g_AIArea, this);
 		break;
+	case kFullTSAID:
+		neighborhood = new FullTSA(g_AIArea, this);
+		break;
 	case kTinyTSAID:
 		neighborhood = new TinyTSA(g_AIArea, this);
 		break;


Commit: 172e97da155aecbbee77fcd68f8f0b089523dab7
    https://github.com/scummvm/scummvm/commit/172e97da155aecbbee77fcd68f8f0b089523dab7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-07T07:16:38-07:00

Commit Message:
VIDEO: Fix getNextFramePacket() to actually be efficient

Changed paths:
    video/qt_decoder.cpp



diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 2dfb56d..389acea 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -483,23 +483,18 @@ Common::SeekableReadStream *QuickTimeDecoder::getNextFramePacket(uint32 &descId)
 	int32 totalSampleCount = 0;
 	int32 sampleInChunk = 0;
 	int32 actualChunk = -1;
+	uint32 sampleToChunkIndex = 0;
 
 	for (uint32 i = 0; i < _tracks[_videoTrackIndex]->chunkCount; i++) {
-		int32 sampleToChunkIndex = -1;
+		if (i >= _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].first)
+			sampleToChunkIndex++;
 
-		for (uint32 j = 0; j < _tracks[_videoTrackIndex]->sampleToChunkCount; j++)
-			if (i >= _tracks[_videoTrackIndex]->sampleToChunk[j].first)
-				sampleToChunkIndex = j;
-
-		if (sampleToChunkIndex < 0)
-			error("This chunk (%d) is imaginary", sampleToChunkIndex);
-
-		totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count;
+		totalSampleCount += _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count;
 
 		if (totalSampleCount > getCurFrame()) {
 			actualChunk = i;
-			descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].id;
-			sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex].count - totalSampleCount + getCurFrame();
+			descId = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].id;
+			sampleInChunk = _tracks[_videoTrackIndex]->sampleToChunk[sampleToChunkIndex - 1].count - totalSampleCount + getCurFrame();
 			break;
 		}
 	}


Commit: deab5b28753155863062746ef1239535f562fd0b
    https://github.com/scummvm/scummvm/commit/deab5b28753155863062746ef1239535f562fd0b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-07T08:12:39-07:00

Commit Message:
GRAPHICS: Fix PICT buffer overflow

Changed paths:
    graphics/pict.cpp



diff --git a/graphics/pict.cpp b/graphics/pict.cpp
index b2d8140..0f4dcd4 100644
--- a/graphics/pict.cpp
+++ b/graphics/pict.cpp
@@ -337,7 +337,11 @@ void PictDecoder::unpackBitsRect(Common::SeekableReadStream *stream, bool hasPal
 
 	_outputSurface = new Graphics::Surface();
 	_outputSurface->create(width, height, (bytesPerPixel == 1) ? PixelFormat::createFormatCLUT8() : _pixelFormat);
-	byte *buffer = new byte[width * height * bytesPerPixel];
+
+	// Create an temporary buffer, but allocate a bit more than we need to avoid overflow
+	// (align it to the next highest two-byte packed boundary, which may be more unpacked,
+	// as m68k and therefore QuickDraw is word-aligned)
+	byte *buffer = new byte[width * height * bytesPerPixel + (8 * 2 / packBitsData.pixMap.pixelSize)];
 
 	// Read in amount of data per row
 	for (uint16 i = 0; i < packBitsData.pixMap.bounds.height(); i++) {


Commit: e1dc4db7aa53d1bbc4cdb03d1163c97d049702f5
    https://github.com/scummvm/scummvm/commit/e1dc4db7aa53d1bbc4cdb03d1163c97d049702f5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-07T11:34:22-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Conflicts:
	video/qt_decoder.cpp

Changed paths:
  A backends/events/maemosdl/maemosdl-events.cpp
  A backends/events/maemosdl/maemosdl-events.h
  A backends/platform/gph/gph.h
  A backends/platform/maemo/debian/changelog
  A backends/platform/maemo/debian/compat
  A backends/platform/maemo/debian/control
  A backends/platform/maemo/debian/copyright
  A backends/platform/maemo/debian/postinst
  A backends/platform/maemo/debian/rules
  A backends/platform/maemo/debian/scummvm.dirs
  A backends/platform/maemo/maemo.cpp
  A backends/platform/maemo/maemo.h
  A backends/platform/maemo/main.cpp
  A backends/platform/maemo/module.mk
  A doc/de/Neues
  A doc/fr/DemarrageRapide
  A doc/no-nb/HurtigStart
  A engines/agos/installshield_cab.cpp
  A engines/agos/installshield_cab.h
  A engines/cge/bitmap.cpp
  A engines/cge/bitmap.h
  A engines/cge/cge.cpp
  A engines/cge/cge.h
  A engines/cge/cge_main.cpp
  A engines/cge/cge_main.h
  A engines/cge/console.cpp
  A engines/cge/console.h
  A engines/cge/detection.cpp
  A engines/cge/events.cpp
  A engines/cge/events.h
  A engines/cge/fileio.cpp
  A engines/cge/fileio.h
  A engines/cge/game.cpp
  A engines/cge/game.h
  A engines/cge/general.h
  A engines/cge/module.mk
  A engines/cge/snail.cpp
  A engines/cge/snail.h
  A engines/cge/sound.cpp
  A engines/cge/sound.h
  A engines/cge/talk.cpp
  A engines/cge/talk.h
  A engines/cge/text.cpp
  A engines/cge/text.h
  A engines/cge/vga13h.cpp
  A engines/cge/vga13h.h
  A engines/cge/vmenu.cpp
  A engines/cge/vmenu.h
  A engines/cge/walk.cpp
  A engines/cge/walk.h
  A engines/dreamweb/use.cpp
  A engines/gob/anifile.cpp
  A engines/gob/anifile.h
  A engines/gob/aniobject.cpp
  A engines/gob/aniobject.h
  A engines/gob/decfile.cpp
  A engines/gob/decfile.h
  A engines/gob/minigames/geisha/diving.cpp
  A engines/gob/minigames/geisha/diving.h
  A engines/gob/minigames/geisha/evilfish.cpp
  A engines/gob/minigames/geisha/evilfish.h
  A engines/gob/minigames/geisha/penetration.cpp
  A engines/gob/minigames/geisha/penetration.h
  A engines/gob/rxyfile.cpp
  A engines/gob/rxyfile.h
  A engines/gob/save/saveload_geisha.cpp
  A engines/sci/graphics/text32.cpp
  A engines/sci/graphics/text32.h
  A engines/tsage/blue_force/blueforce_dialogs.cpp
  A engines/tsage/blue_force/blueforce_dialogs.h
  A engines/tsage/blue_force/blueforce_scenes2.cpp
  A engines/tsage/blue_force/blueforce_scenes2.h
  A engines/tsage/blue_force/blueforce_scenes4.cpp
  A engines/tsage/blue_force/blueforce_scenes4.h
  A engines/tsage/blue_force/blueforce_scenes5.cpp
  A engines/tsage/blue_force/blueforce_scenes5.h
  A engines/tsage/blue_force/blueforce_scenes6.cpp
  A engines/tsage/blue_force/blueforce_scenes6.h
  A engines/tsage/blue_force/blueforce_scenes7.cpp
  A engines/tsage/blue_force/blueforce_scenes7.h
  A engines/tsage/blue_force/blueforce_scenes8.cpp
  A engines/tsage/blue_force/blueforce_scenes8.h
  A engines/tsage/blue_force/blueforce_scenes9.cpp
  A engines/tsage/blue_force/blueforce_scenes9.h
  A engines/tsage/blue_force/blueforce_speakers.cpp
  A engines/tsage/blue_force/blueforce_speakers.h
  A engines/tsage/ringworld/ringworld_dialogs.cpp
  A engines/tsage/ringworld/ringworld_dialogs.h
  A engines/tsage/ringworld/ringworld_speakers.cpp
  A engines/tsage/ringworld/ringworld_speakers.h
  A test/cxxtest_mingw.h
  R backends/platform/gph/gph-sdl.h
  R backends/platform/maemo/scummvm-1.1.0-maemo.patch
  R devtools/create_drascula/Makefile
  R devtools/create_drascula/dists/msvc8/create_drascula.sln
  R devtools/create_drascula/dists/msvc8/create_drascula.vcproj
  R devtools/create_drascula/dists/msvc8_to_msvc9.bat
  R devtools/create_drascula/dists/msvc9/create_drascula.sln
  R devtools/create_drascula/dists/msvc9/create_drascula.vcproj
  R devtools/create_drascula/dists/msvc9_to_msvc8.bat
  R devtools/create_hugo/dists/msvc10/create_hugo.sln
  R devtools/create_hugo/dists/msvc10/create_hugo.vcxproj
  R devtools/create_hugo/dists/msvc9/create_hugo.sln
  R devtools/create_hugo/dists/msvc9/create_hugo.vcproj
  R devtools/create_lure/Makefile
  R devtools/create_lure/dists/msvc8/create_lure.sln
  R devtools/create_lure/dists/msvc8/create_lure.vcproj
  R devtools/create_lure/dists/msvc8_to_msvc9.bat
  R devtools/create_lure/dists/msvc9/create_lure.sln
  R devtools/create_lure/dists/msvc9/create_lure.vcproj
  R devtools/create_lure/dists/msvc9_to_msvc8.bat
  R devtools/create_mads/Makefile
  R devtools/create_mads/dists/msvc9/create_mads.sln
  R devtools/create_mads/dists/msvc9/create_mads.vcproj
  R devtools/create_toon/dists/msvc9/create_toon.sln
  R devtools/create_toon/dists/msvc9/create_toon.vcproj
  R devtools/skycpt/AsciiCptCompile.sln
  R devtools/skycpt/AsciiCptCompile.vcproj
  R doc/fr/QuickStart_fr
  R graphics/dither.cpp
  R graphics/dither.h
    AUTHORS
    NEWS
    README
    audio/softsynth/fmtowns_pc98/towns_midi.cpp
    audio/softsynth/opl/dbopl.cpp
    audio/softsynth/opl/dbopl.h
    backends/events/gph/gph-events.cpp
    backends/events/sdl/sdl-events.cpp
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/gph/gph-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/module.mk
    backends/platform/gph/build/gp2xwiz-bundle.sh
    backends/platform/gph/gph-backend.cpp
    backends/platform/gph/gph-hw.cpp
    backends/platform/gph/gph-hw.h
    backends/platform/gph/gph-main.cpp
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx.h
    backends/platform/sdl/main.cpp
    backends/platform/sdl/posix/posix-main.cpp
    base/main.cpp
    base/plugins.cpp
    common/config-file.cpp
    common/zlib.cpp
    common/zlib.h
    configure
    devtools/create_kyradat/create_kyradat.h
    devtools/create_project/codeblocks.cpp
    devtools/create_project/codeblocks.h
    devtools/create_project/create_project.cpp
    devtools/create_project/create_project.h
    devtools/create_project/msbuild.cpp
    devtools/create_project/msbuild.h
    devtools/create_project/msvc.cpp
    devtools/create_project/msvc.h
    devtools/create_project/visualstudio.cpp
    devtools/create_project/visualstudio.h
    devtools/credits.pl
    devtools/scumm-md5.txt
    devtools/tasmrecover/dreamweb/object.asm
    devtools/tasmrecover/tasm-recover
    dists/macosx/Info.plist
    dists/macosx/Info.plist.in
    dists/msvc10/create_msvc10.bat
    dists/msvc8/create_msvc8.bat
    dists/msvc9/create_msvc9.bat
    dists/win32/ScummVM.iss
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/detection.cpp
    engines/agi/detection_tables.h
    engines/agi/graphics.cpp
    engines/agi/keyboard.cpp
    engines/agi/objects.cpp
    engines/agi/op_cmd.cpp
    engines/agi/opcodes.cpp
    engines/agi/preagi.cpp
    engines/agi/preagi.h
    engines/agi/preagi_mickey.cpp
    engines/agi/preagi_troll.cpp
    engines/agi/preagi_winnie.cpp
    engines/agi/saveload.cpp
    engines/agi/sprite.cpp
    engines/agi/text.cpp
    engines/agos/agos.cpp
    engines/agos/agos.h
    engines/agos/animation.cpp
    engines/agos/animation.h
    engines/agos/debug.cpp
    engines/agos/detection.cpp
    engines/agos/detection_tables.h
    engines/agos/feeble.cpp
    engines/agos/intern.h
    engines/agos/midi.cpp
    engines/agos/module.mk
    engines/agos/res.cpp
    engines/agos/res_snd.cpp
    engines/agos/saveload.cpp
    engines/agos/string_pn.cpp
    engines/agos/subroutine.cpp
    engines/agos/verb_pn.cpp
    engines/cine/texte.cpp
    engines/cine/texte.h
    engines/composer/graphics.cpp
    engines/cruise/detection.cpp
    engines/dialogs.cpp
    engines/draci/detection.cpp
    engines/draci/game.cpp
    engines/draci/saveload.cpp
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/module.mk
    engines/dreamweb/pathfind.cpp
    engines/dreamweb/print.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp
    engines/dreamweb/stubs.h
    engines/dreamweb/vgagrafx.cpp
    engines/engines.mk
    engines/gob/detection_tables.h
    engines/gob/draw.cpp
    engines/gob/draw.h
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/game.cpp
    engines/gob/gob.cpp
    engines/gob/hotspots.cpp
    engines/gob/hotspots.h
    engines/gob/init.cpp
    engines/gob/init.h
    engines/gob/init_geisha.cpp
    engines/gob/init_v6.cpp
    engines/gob/inter.h
    engines/gob/inter_bargon.cpp
    engines/gob/inter_geisha.cpp
    engines/gob/inter_v6.cpp
    engines/gob/module.mk
    engines/gob/save/saveload.h
    engines/gob/sound/sound.cpp
    engines/gob/util.cpp
    engines/gob/util.h
    engines/gob/videoplayer.cpp
    engines/gob/videoplayer.h
    engines/groovie/roq.cpp
    engines/groovie/roq.h
    engines/hugo/object.cpp
    engines/hugo/parser.cpp
    engines/hugo/schedule.cpp
    engines/hugo/sound.cpp
    engines/kyra/animator_mr.cpp
    engines/kyra/detection.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_hof.h
    engines/kyra/kyra_mr.h
    engines/kyra/module.mk
    engines/kyra/sequences_mr.cpp
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_adlib.h
    engines/kyra/staticres.cpp
    engines/kyra/staticres_lol.cpp
    engines/kyra/text_hof.cpp
    engines/kyra/text_mr.cpp
    engines/lastexpress/entities/francois.cpp
    engines/lastexpress/game/entities.cpp
    engines/lure/hotspots.cpp
    engines/made/screenfx.cpp
    engines/made/screenfx.h
    engines/mohawk/cursors.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/graphics.cpp
    engines/mohawk/graphics.h
    engines/mohawk/myst_stacks/channelwood.cpp
    engines/mohawk/myst_stacks/demo.cpp
    engines/mohawk/myst_stacks/dni.cpp
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/preview.cpp
    engines/mohawk/myst_stacks/slides.cpp
    engines/parallaction/gfxbase.cpp
    engines/parallaction/objects.cpp
    engines/parallaction/parallaction.cpp
    engines/parallaction/parser_ns.cpp
    engines/queen/graphics.cpp
    engines/queen/input.cpp
    engines/queen/input.h
    engines/queen/musicdata.cpp
    engines/queen/resource.cpp
    engines/queen/resource.h
    engines/queen/sound.h
    engines/saga/interface.cpp
    engines/saga/script.cpp
    engines/saga/sthread.cpp
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kmath.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/savegame.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/static_selectors.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/view.cpp
    engines/sci/module.mk
    engines/sci/resource.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/drivers/gm_names.h
    engines/sci/sound/midiparser_sci.cpp
    engines/sci/sound/music.cpp
    engines/sci/sound/soundcmd.cpp
    engines/sci/sound/soundcmd.h
    engines/scumm/actor.cpp
    engines/scumm/charset.cpp
    engines/scumm/charset.h
    engines/scumm/costume.cpp
    engines/scumm/cursor.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/dialogs.cpp
    engines/scumm/gfx.cpp
    engines/scumm/he/intern_he.h
    engines/scumm/he/logic/basketball.cpp
    engines/scumm/he/resource_he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/palette.cpp
    engines/scumm/player_towns.cpp
    engines/scumm/resource.cpp
    engines/scumm/resource.h
    engines/scumm/room.cpp
    engines/scumm/saveload.cpp
    engines/scumm/saveload.h
    engines/scumm/script_v0.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/sound.cpp
    engines/scumm/verbs.cpp
    engines/sky/compact.cpp
    engines/sky/compact.h
    engines/sky/debug.cpp
    engines/sky/disk.cpp
    engines/sky/logic.cpp
    engines/sky/sound.cpp
    engines/sword1/animation.cpp
    engines/sword1/control.cpp
    engines/sword1/control.h
    engines/sword1/detection.cpp
    engines/sword1/eventman.cpp
    engines/sword1/logic.cpp
    engines/sword1/logic.h
    engines/sword1/memman.cpp
    engines/sword1/memman.h
    engines/sword1/menu.cpp
    engines/sword1/mouse.cpp
    engines/sword1/mouse.h
    engines/sword1/object.h
    engines/sword1/objectman.cpp
    engines/sword1/objectman.h
    engines/sword1/resman.cpp
    engines/sword1/resman.h
    engines/sword1/router.cpp
    engines/sword1/router.h
    engines/sword1/screen.cpp
    engines/sword1/screen.h
    engines/sword1/sound.cpp
    engines/sword1/sound.h
    engines/sword1/staticres.cpp
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h
    engines/sword1/sworddefs.h
    engines/sword1/text.cpp
    engines/sword1/text.h
    engines/tinsel/pcode.cpp
    engines/tinsel/tinsel.cpp
    engines/tinsel/tinsel.h
    engines/toon/anim.cpp
    engines/toon/audio.cpp
    engines/toon/picture.cpp
    engines/toon/resource.cpp
    engines/toon/script_func.cpp
    engines/toon/tools.cpp
    engines/toon/toon.cpp
    engines/tsage/blue_force/blueforce_logic.cpp
    engines/tsage/blue_force/blueforce_logic.h
    engines/tsage/blue_force/blueforce_scenes0.cpp
    engines/tsage/blue_force/blueforce_scenes0.h
    engines/tsage/blue_force/blueforce_scenes1.cpp
    engines/tsage/blue_force/blueforce_scenes1.h
    engines/tsage/blue_force/blueforce_scenes3.cpp
    engines/tsage/blue_force/blueforce_scenes3.h
    engines/tsage/blue_force/blueforce_ui.cpp
    engines/tsage/blue_force/blueforce_ui.h
    engines/tsage/converse.cpp
    engines/tsage/converse.h
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/debugger.h
    engines/tsage/detection.cpp
    engines/tsage/dialogs.cpp
    engines/tsage/dialogs.h
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/module.mk
    engines/tsage/resources.cpp
    engines/tsage/ringworld/ringworld_demo.cpp
    engines/tsage/ringworld/ringworld_logic.cpp
    engines/tsage/ringworld/ringworld_logic.h
    engines/tsage/ringworld/ringworld_scenes1.cpp
    engines/tsage/ringworld/ringworld_scenes1.h
    engines/tsage/ringworld/ringworld_scenes10.cpp
    engines/tsage/ringworld/ringworld_scenes10.h
    engines/tsage/ringworld/ringworld_scenes2.cpp
    engines/tsage/ringworld/ringworld_scenes2.h
    engines/tsage/ringworld/ringworld_scenes3.cpp
    engines/tsage/ringworld/ringworld_scenes3.h
    engines/tsage/ringworld/ringworld_scenes4.cpp
    engines/tsage/ringworld/ringworld_scenes4.h
    engines/tsage/ringworld/ringworld_scenes5.cpp
    engines/tsage/ringworld/ringworld_scenes5.h
    engines/tsage/ringworld/ringworld_scenes6.cpp
    engines/tsage/ringworld/ringworld_scenes6.h
    engines/tsage/ringworld/ringworld_scenes8.cpp
    engines/tsage/ringworld/ringworld_scenes8.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/scenes.h
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    engines/tucker/staticres.cpp
    engines/tucker/tucker.h
    graphics/module.mk
    gui/console.cpp
    gui/credits.h
    gui/saveload.cpp
    gui/themes/translations.dat
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    test/module.mk
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/qt_decoder.cpp





Commit: 8a717d28d82b0cd48a9dfdacd7686d88abcc09f2
    https://github.com/scummvm/scummvm/commit/8a717d28d82b0cd48a9dfdacd7686d88abcc09f2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-07T20:13:31-07:00

Commit Message:
PEGASUS: Fix frames after turning

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index be3819e..ec1b033 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -177,6 +177,17 @@ void Movie::pause() {
 	TimeBase::pause();
 }
 
+TimeValue Movie::getDuration(const TimeScale scale) const {
+	// Unlike TimeBase::getDuration(), this returns the whole duration of the movie
+	// The original source has a TODO to make this behave like TimeBase::getDuration(),
+	// but the problem is that too much code requires this function to behave this way...
+
+	if (_video)
+		return _video->getDuration() * ((scale == 0) ? getScale() : scale) / 1000;
+
+	return 0;
+}
+
 void Movie::checkCallBacks() {
 	TimeBase::checkCallBacks();
 
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 3983a6f..31b5674 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -64,6 +64,8 @@ public:
 
 	virtual void moveMovieBoxTo(const tCoordType, const tCoordType);
 
+	virtual TimeValue getDuration(const TimeScale = 0) const;
+
 	// *** HACK ALERT
 	Video::SeekableVideoDecoder *getMovie() { return _video; }
 	void setVolume(uint16);


Commit: 188d951cb4d040056098fc0d65ae8f9544a2fdfc
    https://github.com/scummvm/scummvm/commit/188d951cb4d040056098fc0d65ae8f9544a2fdfc
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-07T21:13:14-07:00

Commit Message:
PEGASUS: Remove unused movie direct draw mode

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index ec1b033..c3cfbfd 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -34,7 +34,6 @@ namespace Pegasus {
 
 Movie::Movie(const tDisplayElementID id) : Animation(id) {
 	_video = 0;
-	_directDraw = false;
 	setScale(600);
 }
 
@@ -50,7 +49,6 @@ void Movie::releaseMovie() {
 		_video = 0;
 		disposeAllCallBacks();
 		deallocateSurface();
-		// TODO: Decrease global direct draw counter
 	}
 }
 
@@ -75,11 +73,6 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 	setStop(_video->getDuration() * getScale() / 1000, getScale());
 }
 
-void Movie::setDirectDraw(const bool flag) {
-	_directDraw = flag;
-	// TODO: Increase/decrease the global direct draw counter
-}
-
 void Movie::redrawMovieWorld() {
 	if (_video) {
 		const Graphics::Surface *frame = _video->decodeNextFrame();
@@ -87,19 +80,12 @@ void Movie::redrawMovieWorld() {
 		if (!frame)
 			return;
 
-		if (_directDraw) {
-			// Copy to the screen
-			Common::Rect bounds;
-			getBounds(bounds);
-			g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, bounds.left, bounds.top, frame->w, frame->h);
-		} else {
-			// Copy to the surface using _movieBox
-			uint16 width = MIN<int>(frame->w, _movieBox.width());
-			uint16 height = MIN<int>(frame->h, _movieBox.height());
-
-			for (uint16 y = 0; y < height; y++)
-				memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
-		}
+		// Copy to the surface using _movieBox
+		uint16 width = MIN<int>(frame->w, _movieBox.width());
+		uint16 height = MIN<int>(frame->h, _movieBox.height());
+
+		for (uint16 y = 0; y < height; y++)
+			memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
 
 		triggerRedraw();
 	}
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 31b5674..12d1af9 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -45,18 +45,16 @@ public:
 	virtual void initFromMovieFile(const Common::String &fileName, bool transparent = false);
 
 	bool isMovieValid() { return _video != 0; }
-	
+
 	virtual void releaseMovie();
-	
+
 	virtual void draw(const Common::Rect &);
 	virtual void redrawMovieWorld();
-	
-	void setDirectDraw(const bool);
-	
+
 	virtual void setTime(const TimeValue, const TimeScale = 0);
-	
+
 	virtual void setRate(const Common::Rational);
-	
+
 	virtual void start();
 	virtual void stop();
 	virtual void resume();
@@ -74,7 +72,6 @@ public:
 
 protected:
 	Video::SeekableVideoDecoder *_video;
-	bool _directDraw;
 	Common::Rect _movieBox;
 };
 


Commit: 89773a90ce9208936a9b9c4543da52f83bb5d3ad
    https://github.com/scummvm/scummvm/commit/89773a90ce9208936a9b9c4543da52f83bb5d3ad
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-08T21:04:05-07:00

Commit Message:
PEGASUS: Only call callbacks once

Fixes final walk movie of a stride, among various other things

Changed paths:
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 8ca7de9..584ddfb 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -230,16 +230,25 @@ void TimeBase::checkCallBacks() {
 
 	// Check if we've triggered any callbacks
 	for (TimeBaseCallBack *runner = _callBackList; runner != 0; runner = runner->_nextCallBack) {
+		if (runner->_hasBeenTriggered)
+			continue;
+
 		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
-			if (getTime() >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0)
+			if (getTime() >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0) {
 				runner->callBack();
+				runner->_hasBeenTriggered = true;
+			}
 		} else if (runner->_type == kCallBackAtExtremes) {
 			if (runner->_trigger == kTriggerAtStop) {
-				if (time == stopTime)
+				if (time == stopTime) {
 					runner->callBack();
+					runner->_hasBeenTriggered = true;
+				}
 			} else if (runner->_trigger == kTriggerAtStart) {
-				if (time == startTime)
+				if (time == startTime) {
 					runner->callBack();
+					runner->_hasBeenTriggered = true;
+				}
 			}
 		}
 	}
@@ -292,6 +301,7 @@ TimeBaseCallBack::TimeBaseCallBack() {
 	_nextCallBack = 0;
 	_trigger = kTriggerNone;
 	_type = kCallBackNone;
+	_hasBeenTriggered = false;
 }
 
 TimeBaseCallBack::~TimeBaseCallBack() {
@@ -313,6 +323,7 @@ void TimeBaseCallBack::releaseCallBack() {
 
 void TimeBaseCallBack::disposeCallBack() {
 	_timeBase = 0;
+	_hasBeenTriggered = false;
 }
 
 void TimeBaseCallBack::scheduleCallBack(CallBackTrigger trigger, uint32 param2, uint32 param3) {
@@ -320,10 +331,12 @@ void TimeBaseCallBack::scheduleCallBack(CallBackTrigger trigger, uint32 param2,
 	_trigger = trigger;
 	_param2 = param2;
 	_param3 = param3;
+	_hasBeenTriggered = false;
 }
 
 void TimeBaseCallBack::cancelCallBack() {
 	_trigger = kTriggerNone;
+	_hasBeenTriggered = false;
 }
 
 IdlerTimeBase::IdlerTimeBase() {
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 65e7d21..0b2f59d 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -172,6 +172,7 @@ protected:
 	CallBackType _type;
 	CallBackTrigger _trigger;
 	uint32 _param2, _param3;
+	bool _hasBeenTriggered;
 
 private:
 	void disposeCallBack();


Commit: 09be0ed5c8732fb0fe430bc2824eb541f6f4738d
    https://github.com/scummvm/scummvm/commit/09be0ed5c8732fb0fe430bc2824eb541f6f4738d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-09T13:14:14-07:00

Commit Message:
PEGASUS: Fix movie end trigger not always being sent

The demo is now completable and the full game is playable up through the temporal rip in the TSA. Holy halibut, Batman!

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index c3cfbfd..75790ed 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -174,10 +174,8 @@ TimeValue Movie::getDuration(const TimeScale scale) const {
 	return 0;
 }
 
-void Movie::checkCallBacks() {
-	TimeBase::checkCallBacks();
-
-	// The reason why we overrode TimeBase's checkCallBacks():
+void Movie::updateTime() {
+	// The reason why we overrode TimeBase's updateTime():
 	// Again, avoiding timers and handling it here
 	if (_video && !_video->isPaused()) {
 		if (_video->needsUpdate())
@@ -187,17 +185,6 @@ void Movie::checkCallBacks() {
 		uint32 stopTime = _stopTime * getScale() / _stopScale;
 		uint32 actualTime = CLIP<int>(_video->getElapsedTime() * getScale() / 1000, startTime, stopTime);
 		_time = Common::Rational(actualTime, getScale());
-
-		// Stop the video when we go past our end
-		// TODO: Check if this should really be -1
-		if (actualTime >= stopTime - 1) {
-			// HACK: Handle looping here as well
-			// Should be handled like the rest of TimeBases
-			if (getFlags() & kLoopTimeBase)
-				setTime(_startTime, _startScale);
-			else
-				stop();
-		}
 	}
 }
 
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 12d1af9..704da0e 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -68,9 +68,9 @@ public:
 	Video::SeekableVideoDecoder *getMovie() { return _video; }
 	void setVolume(uint16);
 
-	virtual void checkCallBacks();
-
 protected:
+	void updateTime();
+
 	Video::SeekableVideoDecoder *_video;
 	Common::Rect _movieBox;
 };
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 584ddfb..c9be365 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -198,15 +198,7 @@ void TimeBase::setMasterTimeBase(TimeBase *tb) {
 		_master->_slaves.push_back(this);
 }
 
-void TimeBase::checkCallBacks() {
-	// Nothing to do if we're paused or not running
-	if (_paused || !isRunning())
-		return;
-
-	Common::Rational startTime = Common::Rational(_startTime, _startScale);
-	Common::Rational stopTime = Common::Rational(_stopTime, _stopScale);
-
-	// First step: update the times
+void TimeBase::updateTime() {
 	if (_lastMillis == 0) {
 		_lastMillis = g_engine->getTotalPlayTime();
 	} else {
@@ -216,13 +208,25 @@ void TimeBase::checkCallBacks() {
 
 		_time += Common::Rational(curTime - _lastMillis, 1000) * getEffectiveRate();
 		_lastMillis = curTime;
-
-		// Clip time to the boundaries
-		if (_time >= stopTime)
-			_time = stopTime;
-		else if (_time <= startTime)
-			_time = startTime;
 	}
+}
+
+void TimeBase::checkCallBacks() {
+	// Nothing to do if we're paused or not running
+	if (_paused || !isRunning())
+		return;
+
+	Common::Rational startTime = Common::Rational(_startTime, _startScale);
+	Common::Rational stopTime = Common::Rational(_stopTime, _stopScale);
+
+	// First step: update the times
+	updateTime();
+
+	// Clip time to the boundaries
+	if (_time >= stopTime)
+		_time = stopTime;
+	else if (_time <= startTime)
+		_time = startTime;
 
 	// TODO: Update the slaves?
 
@@ -253,12 +257,16 @@ void TimeBase::checkCallBacks() {
 		}
 	}
 
-	// Loop if necessary
 	if (getFlags() & kLoopTimeBase) {
+		// Loop if necessary
 		if (getRate() < 0 && time == startTime)
 			setTime(_stopTime, _stopScale);
 		else if (getRate() > 0 && time == stopTime)
 			setTime(_startTime, _startScale);
+	} else {
+		// Stop at the end
+		if ((getRate() > 0 && time == stopTime) || (getRate() < 0 && time == startTime))
+			stop();
 	}
 }
 
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 0b2f59d..80cec52 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -108,6 +108,7 @@ public:
 protected:
 	void addCallBack(TimeBaseCallBack *);
 	void removeCallBack(TimeBaseCallBack *);
+	virtual void updateTime();
 
 	TimeBase *_master;
 	TimeScale _preferredScale;


Commit: 5dd625ebfbfd3c79bf644b1234a1de5732c53980
    https://github.com/scummvm/scummvm/commit/5dd625ebfbfd3c79bf644b1234a1de5732c53980
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-09T13:28:30-07:00

Commit Message:
PEGASUS: Disable AI energy warnings in the demo

The videos don't exist, so you'd be in for a surprise after playing for an hour

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index e17e100..eb1d0df 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1348,8 +1348,8 @@ void Neighborhood::setUpAIRules() {
 	if (g_AIArea) {
 		g_AIArea->forceAIUnlocked();
 
-		if (getObjectID() == kPrehistoricID || getObjectID() == kNoradAlphaID ||
-				getObjectID() == kNoradDeltaID || getObjectID() == kMarsID || getObjectID() == kWSCID) {
+		if (!_vm->isDemo() && (getObjectID() == kPrehistoricID || getObjectID() == kNoradAlphaID ||
+				getObjectID() == kNoradDeltaID || getObjectID() == kMarsID || getObjectID() == kWSCID)) {
 
 			AIEnergyMonitorCondition *condition50 = new AIEnergyMonitorCondition(kWorriedEnergy);
 			AIPlayMessageAction *message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4A", false);


Commit: 82cadf68e8bcc4cb98af317ab31ad53928eac1b8
    https://github.com/scummvm/scummvm/commit/82cadf68e8bcc4cb98af317ab31ad53928eac1b8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-09T20:32:40-07:00

Commit Message:
PEGASUS: Fix the historical log comparison screen

Original code does not have cursorSpot null checks, so it looks like Codewarrior may have handled this strangely...

Changed paths:
    engines/pegasus/neighborhood/tsa/fulltsa.cpp



diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 1656e9f..aaa7cf1 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -2876,35 +2876,40 @@ void FullTSA::handleInput(const Input &input, const Hotspot *cursorSpot) {
 			case kRobotsAtCommandCenter:
 			case kRobotsAtFrontDoor:
 			case kRobotsAtReadyRoom:
-				switch (cursorSpot->getObjectID()) {
-				case kTSA0BEastCompareNoradSpotID:
-					_sprite1.setCurrentFrameIndex(0);
-					_sprite2.setCurrentFrameIndex(0);
-					_sprite1.show();
-					_sprite2.show();
-					break;
-				case kTSA0BEastCompareMarsSpotID:
-					_sprite1.setCurrentFrameIndex(1);
-					_sprite2.setCurrentFrameIndex(1);
-					_sprite1.show();
-					_sprite2.show();
-					break;
-				case kTSA0BEastCompareCaldoriaSpotID:
-					_sprite1.setCurrentFrameIndex(2);
-					_sprite2.setCurrentFrameIndex(2);
-					_sprite1.show();
-					_sprite2.show();
-					break;
-				case kTSA0BEastCompareWSCSpotID:
-					_sprite1.setCurrentFrameIndex(3);
-					_sprite2.setCurrentFrameIndex(3);
-					_sprite1.show();
-					_sprite2.show();
-					break;
-				default:
+				if (cursorSpot) {
+					switch (cursorSpot->getObjectID()) {
+					case kTSA0BEastCompareNoradSpotID:
+						_sprite1.setCurrentFrameIndex(0);
+						_sprite2.setCurrentFrameIndex(0);
+						_sprite1.show();
+						_sprite2.show();
+						break;
+					case kTSA0BEastCompareMarsSpotID:
+						_sprite1.setCurrentFrameIndex(1);
+						_sprite2.setCurrentFrameIndex(1);
+						_sprite1.show();
+						_sprite2.show();
+						break;
+					case kTSA0BEastCompareCaldoriaSpotID:
+						_sprite1.setCurrentFrameIndex(2);
+						_sprite2.setCurrentFrameIndex(2);
+						_sprite1.show();
+						_sprite2.show();
+						break;
+					case kTSA0BEastCompareWSCSpotID:
+						_sprite1.setCurrentFrameIndex(3);
+						_sprite2.setCurrentFrameIndex(3);
+						_sprite1.show();
+						_sprite2.show();
+						break;
+					default:
+						_sprite1.hide();
+						_sprite2.hide();
+						break;
+					}
+				} else {
 					_sprite1.hide();
 					_sprite2.hide();
-					break;
 				}
 				break;
 			}
@@ -2916,22 +2921,26 @@ void FullTSA::handleInput(const Input &input, const Hotspot *cursorSpot) {
 			case kRobotsAtCommandCenter:
 			case kRobotsAtFrontDoor:
 			case kRobotsAtReadyRoom:
-				switch (cursorSpot->getObjectID()) {
-				case kTSA0BNorthRobotsToCommandCenterSpotID:
-					_sprite1.setCurrentFrameIndex(kRedirectionCCRolloverSprite);
-					_sprite1.show();
-					break;
-				case kTSA0BNorthRobotsToReadyRoomSpotID:
-					_sprite1.setCurrentFrameIndex(kRedirectionRRRolloverSprite);
-					_sprite1.show();
-					break;
-				case kTSA0BNorthRobotsToFrontDoorSpotID:
-					_sprite1.setCurrentFrameIndex(kRedirectionFDRolloverSprite);
-					_sprite1.show();
-					break;
-				default:
+				if (cursorSpot) {
+					switch (cursorSpot->getObjectID()) {
+					case kTSA0BNorthRobotsToCommandCenterSpotID:
+						_sprite1.setCurrentFrameIndex(kRedirectionCCRolloverSprite);
+						_sprite1.show();
+						break;
+					case kTSA0BNorthRobotsToReadyRoomSpotID:
+						_sprite1.setCurrentFrameIndex(kRedirectionRRRolloverSprite);
+						_sprite1.show();
+						break;
+					case kTSA0BNorthRobotsToFrontDoorSpotID:
+						_sprite1.setCurrentFrameIndex(kRedirectionFDRolloverSprite);
+						_sprite1.show();
+						break;
+					default:
+						_sprite1.hide();
+						break;
+					}
+				} else {
 					_sprite1.hide();
-					break;
 				}
 				break;
 			}


Commit: 099f4ce9f5c2472e986709457e52be866459750b
    https://github.com/scummvm/scummvm/commit/099f4ce9f5c2472e986709457e52be866459750b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-09T21:00:06-07:00

Commit Message:
PEGASUS: Add some missing Neighborhood destructor code

Now AI rules don't carry over to the next neighborhood :P

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index eb1d0df..0c02030 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -75,6 +75,13 @@ Neighborhood::~Neighborhood() {
 
 	_neighborhoodHotspots.deleteHotspots();
 	g_neighborhood = 0;
+
+	loadLoopSound1("");
+	loadLoopSound2("");
+	newInteraction(kNoInteractionID);
+
+	if (g_AIArea)
+		g_AIArea->removeAllRules();
 }
 
 void Neighborhood::init() {


Commit: 85dc2e5c65563f1029e68b5694912e8c1c223a65
    https://github.com/scummvm/scummvm/commit/85dc2e5c65563f1029e68b5694912e8c1c223a65
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-10T07:04:47-07:00

Commit Message:
PEGASUS: Stub off map handling

Needed to be able to load saved games

Changed paths:
  A engines/pegasus/items/biochips/mapchip.cpp
  A engines/pegasus/items/biochips/mapchip.h
  A engines/pegasus/items/biochips/mapimage.cpp
  A engines/pegasus/items/biochips/mapimage.h
    engines/pegasus/constants.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 20a7f69..1d70c7d 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -739,6 +739,11 @@ static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 // TODO: Remove me
 static const tRoomID kNorad01 = 0;
 static const tRoomID kMars0A = 0;
+const tRoomID kMars35 = 38;
+const tRoomID kMars39 = 42;
+const tRoomID kMars60 = 58;
+const tRoomID kMarsMaze004 = 60;
+const tRoomID kMarsMaze200 = 224;
 static const tRoomID kWSC01 = 0;
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/mapchip.cpp b/engines/pegasus/items/biochips/mapchip.cpp
new file mode 100755
index 0000000..de6d4e2
--- /dev/null
+++ b/engines/pegasus/items/biochips/mapchip.cpp
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/mapchip.h"
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+MapChip *g_map = 0;
+
+MapChip::MapChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+		BiochipItem(id, neighborhood, room, direction) {
+	g_map = this;
+	setItemState(kMapUnavailable);
+}
+
+MapChip::~MapChip() {
+	g_map = 0;
+}
+
+void MapChip::writeToStream(Common::WriteStream *stream) {
+	return _image.writeToStream(stream);
+}
+
+void MapChip::readFromStream(Common::ReadStream *stream) {
+	return _image.readFromStream(stream);
+}
+
+void MapChip::select() {
+	BiochipItem::select();
+	moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
+	_image.show();
+}
+
+void MapChip::takeSharedArea() {
+	_image.show();
+}
+
+void MapChip::giveUpSharedArea() {
+	_image.hide();
+}
+
+void MapChip::deselect() {
+	BiochipItem::deselect();
+	_image.unloadImage();
+}
+
+void MapChip::moveToMapLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant dir) {
+	tAirQuality airQuality;
+
+	if (g_neighborhood)
+		airQuality = g_neighborhood->getAirQuality(room);
+	else
+		airQuality = kAirQualityGood;
+
+	switch (neighborhood) {
+	case kMarsID:
+		if (airQuality == kAirQualityVacuum) {
+			if (room >= kMars35 && room <= kMars39) {
+				setItemState(kMapEngaged);
+				if (isSelected() && g_AIArea && g_AIArea->getMiddleAreaOwner() == kBiochipSignature)
+					_image.loadGearRoomIfNecessary();
+			} else {
+				setItemState(kMapEngaged);
+				if (isSelected() && g_AIArea && g_AIArea->getMiddleAreaOwner() == kBiochipSignature)
+					_image.loadMazeIfNecessary();
+			}
+
+			_image.moveToMapLocation(neighborhood, room, dir);
+		} else {
+			_image.unloadImage();
+			setItemState(kMapUnavailable);
+		}
+		break;
+	default:
+		_image.unloadImage();
+		setItemState(kMapUnavailable);
+		break;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/mapchip.h b/engines/pegasus/items/biochips/mapchip.h
new file mode 100755
index 0000000..69bfabc
--- /dev/null
+++ b/engines/pegasus/items/biochips/mapchip.h
@@ -0,0 +1,64 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_MAPCHIP_H
+#define PEGASUS_ITEMS_BIOCHIPS_MAPCHIP_H
+
+#include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/biochips/mapimage.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class MapChip : public BiochipItem {
+public:
+	MapChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	virtual ~MapChip();
+
+	void select();
+	void deselect();
+	void takeSharedArea();
+	void giveUpSharedArea();
+
+	void moveToMapLocation(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+
+	void writeToStream(Common::WriteStream *);
+	void readFromStream(Common::ReadStream *);
+
+	bool beenToMaze() { return _image.anyFlagSet(); }
+
+protected:
+	MapImage _image;
+};
+
+extern MapChip *g_map;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/items/biochips/mapimage.cpp b/engines/pegasus/items/biochips/mapimage.cpp
new file mode 100755
index 0000000..c33bce3
--- /dev/null
+++ b/engines/pegasus/items/biochips/mapimage.cpp
@@ -0,0 +1,302 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/items/biochips/mapimage.h"
+
+namespace Pegasus {
+
+#define FLAG_TO_INDEX(flag) ((flag) >> 2)
+#define INDEX_TO_FLAG(index) ((index) << 2)
+
+#define ROOM_TO_INDEX(room) \
+	(((room) >= kMars35 && (room) <= kMars39) ? ((room) - kMars35) : \
+		(((room) == kMars60) ? (kMars39 - kMars35 + 1) : \
+			((room) - kMarsMaze004 + kMars39 - kMars35 + 2)))
+
+#define INDEX_TO_ROOM(index) \
+	(((index) <= ROOM_TO_INDEX(kMars39)) ? \
+	(((index) - ROOM_TO_INDEX(kMars35)) + kMars35) : \
+		((index) <= ROOM_TO_INDEX(kMars60,)) ? kMars60 : \
+			((((index) - ROOM_TO_INDEX(kMarsMaze004))) + kMarsMaze004))
+
+#define ROOM_TO_FLAG(room, dir) (INDEX_TO_FLAG(ROOM_TO_INDEX(room)) | (dir))
+
+#define FLAG_TO_ROOM(flag) (INDEX_TO_ROOM(FLAG_TO_INDEX(flag)))
+
+#define FLAG_TO_DIRECTION(flag) ((flag) & 3)
+
+static const long kGearRoomFlagLow = ROOM_TO_FLAG(kMars35, kNorth);
+static const long kGearRoomFlagHigh = ROOM_TO_FLAG(kMars39, kWest);
+
+static const long kMazeFlagLow = ROOM_TO_FLAG(kMars60, kNorth);
+static const long kMazeFlagHigh = ROOM_TO_FLAG(kMarsMaze200, kWest);
+
+static const tCoordType kGearRoomScreenOffsetX = 49;
+static const tCoordType kGearRoomScreenOffsetY = 47;
+
+static const tCoordType kGearRoomGridOriginX = 1;
+static const tCoordType kGearRoomGridOriginY = 4;
+
+static const tCoordType kMazeScreenOffsetX = 16;
+static const tCoordType kMazeScreenOffsetY = 20;
+
+static const tCoordType kMazeGridOriginX = 6;
+static const tCoordType kMazeGridOriginY = 1;
+
+static const tCoordType kGridWidth = 4;
+static const tCoordType kGridHeight = 4;
+
+static const int s_mapCoords[MapImage::kNumMappingRooms][2] = {
+	/* kMars35 */      { 0, 0 },
+	/* kMars36 */      { 1, 0 },
+	/* kMars37 */      { 2, 0 },
+	/* kMars38 */      { 3, 0 },
+	/* kMars39 */      { 4, 0 },
+	/* kMars60 */      { 19, 9 },
+	/* kMarsMaze004 */ { 18, 9 },
+	/* kMarsMaze005 */ { 18, 10 },
+	/* kMarsMaze006 */ { 17, 10 },
+	/* kMarsMaze007 */ { 16, 10 },
+	/* kMarsMaze008 */ { 15, 10 },
+	/* kMarsMaze009 */ { 14, 10 },
+	/* kMarsMaze010 */ { 14, 9 },
+	/* kMarsMaze011 */ { 14, 8 },
+	/* kMarsMaze012 */ { 14, 7 },
+	/* kMarsMaze015 */ { 16, 7 },
+	/* kMarsMaze016 */ { 14, 11 },
+	/* kMarsMaze017 */ { 14, 12 },
+	/* kMarsMaze018 */ { 15, 12 },
+	/* kMarsMaze019 */ { 16, 12 },
+	/* kMarsMaze020 */ { 16, 13 },
+	/* kMarsMaze021 */ { 16, 14 },
+	/* kMarsMaze022 */ { 16, 15 },
+	/* kMarsMaze023 */ { 17, 15 },
+	/* kMarsMaze024 */ { 18, 15 },
+	/* kMarsMaze025 */ { 18, 14 },
+	/* kMarsMaze026 */ { 18, 13 },
+	/* kMarsMaze027 */ { 18, 12 },
+	/* kMarsMaze028 */ { 18, 11 },
+	/* kMarsMaze031 */ { 19, 14 },
+	/* kMarsMaze032 */ { 20, 14 },
+	/* kMarsMaze033 */ { 20, 13 },
+	/* kMarsMaze034 */ { 20, 12 },
+	/* kMarsMaze035 */ { 20, 11 },
+	/* kMarsMaze036 */ { 21, 11 },
+	/* kMarsMaze037 */ { 15, 15 },
+	/* kMarsMaze038 */ { 14, 15 },
+	/* kMarsMaze039 */ { 13, 15 },
+	/* kMarsMaze042 */ { 10, 15 },
+	/* kMarsMaze043 */ { 9, 15 },
+	/* kMarsMaze044 */ { 8, 15 },
+	/* kMarsMaze045 */ { 7, 15 },
+	/* kMarsMaze046 */ { 6, 15 },
+	/* kMarsMaze047 */ { 5, 15 },
+	/* kMarsMaze049 */ { 13, 14 },
+	/* kMarsMaze050 */ { 12, 14 },
+	/* kMarsMaze051 */ { 11, 14 },
+	/* kMarsMaze052 */ { 10, 14 },
+	/* kMarsMaze053 */ { 10, 13 },
+	/* kMarsMaze054 */ { 9, 13 },
+	/* kMarsMaze055 */ { 8, 13 },
+	/* kMarsMaze056 */ { 8, 12 },
+	/* kMarsMaze057 */ { 7, 12 },
+	/* kMarsMaze058 */ { 12, 13 },
+	/* kMarsMaze059 */ { 12, 12 },
+	/* kMarsMaze060 */ { 12, 11 },
+	/* kMarsMaze061 */ { 12, 10 },
+	/* kMarsMaze063 */ { 12, 9 },
+	/* kMarsMaze064 */ { 12, 8 },
+	/* kMarsMaze065 */ { 12, 7 },
+	/* kMarsMaze066 */ { 13, 7 },
+	/* kMarsMaze067 */ { 15, 7 },
+	/* kMarsMaze068 */ { 17, 7 },
+	/* kMarsMaze069 */ { 18, 7 },
+	/* kMarsMaze070 */ { 19, 7 },
+	/* kMarsMaze071 */ { 20, 7 },
+	/* kMarsMaze072 */ { 20, 6 },
+	/* kMarsMaze074 */ { 20, 5 },
+	/* kMarsMaze076 */ { 20, 4 },
+	/* kMarsMaze078 */ { 20, 3 },
+	/* kMarsMaze079 */ { 20, 2 },
+	/* kMarsMaze081 */ { 20, 2 },
+	/* kMarsMaze083 */ { 20, 0 },
+	/* kMarsMaze084 */ { 19, 0 },
+	/* kMarsMaze085 */ { 18, 0 },
+	/* kMarsMaze086 */ { 17, 0 },
+	/* kMarsMaze087 */ { 16, 0 },
+	/* kMarsMaze088 */ { 15, 0 },
+	/* kMarsMaze089 */ { 14, 0 },
+	/* kMarsMaze090 */ { 13, 0 },
+	/* kMarsMaze091 */ { 12, 0 },
+	/* kMarsMaze092 */ { 11, 0 },
+	/* kMarsMaze093 */ { 10, 0 },
+	/* kMarsMaze098 */ { 10, 1 },
+	/* kMarsMaze099 */ { 8, 2 },
+	/* kMarsMaze100 */ { 9, 2 },
+	/* kMarsMaze101 */ { 10, 2 },
+	/* kMarsMaze104 */ { 13, 2 },
+	/* kMarsMaze105 */ { 13, 3 },
+	/* kMarsMaze106 */ { 13, 4 },
+	/* kMarsMaze107 */ { 13, 5 },
+	/* kMarsMaze108 */ { 14, 5 },
+	/* kMarsMaze111 */ { 15, 5 },
+	/* kMarsMaze113 */ { 16, 5 },
+	/* kMarsMaze114 */ { 17, 5 },
+	/* kMarsMaze115 */ { 18, 5 },
+	/* kMarsMaze116 */ { 18, 4 },
+	/* kMarsMaze117 */ { 18, 3 },
+	/* kMarsMaze118 */ { 19, 3 },
+	/* kMarsMaze119 */ { 18, 2 },
+	/* kMarsMaze120 */ { 17, 2 },
+	/* kMarsMaze121 */ { 16, 2 },
+	/* kMarsMaze122 */ { 15, 2 },
+	/* kMarsMaze123 */ { 15, 1 },
+	/* kMarsMaze124 */ { 12, 4 },
+	/* kMarsMaze125 */ { 11, 4 },
+	/* kMarsMaze126 */ { 10, 4 },
+	/* kMarsMaze127 */ { 10, 5 },
+	/* kMarsMaze128 */ { 10, 6 },
+	/* kMarsMaze129 */ { 9, 6 },
+	/* kMarsMaze130 */ { 8, 6 },
+	/* kMarsMaze131 */ { 7, 6 },
+	/* kMarsMaze132 */ { 7, 7 },
+	/* kMarsMaze133 */ { 7, 8 },
+	/* kMarsMaze136 */ { 7, 11 },
+	/* kMarsMaze137 */ { 6, 11 },
+	/* kMarsMaze138 */ { 5, 11 },
+	/* kMarsMaze139 */ { 5, 12 },
+	/* kMarsMaze140 */ { 4, 12 },
+	/* kMarsMaze141 */ { 5, 13 },
+	/* kMarsMaze142 */ { 5, 14 },
+	/* kMarsMaze143 */ { 4, 14 },
+	/* kMarsMaze144 */ { 3, 14 },
+	/* kMarsMaze145 */ { 3, 13 },
+	/* kMarsMaze146 */ { 2, 13 },
+	/* kMarsMaze147 */ { 1, 13 },
+	/* kMarsMaze148 */ { 1, 14 },
+	/* kMarsMaze149 */ { 1, 15 },
+	/* kMarsMaze152 */ { 1, 12 },
+	/* kMarsMaze153 */ { 1, 11 },
+	/* kMarsMaze154 */ { 1, 10 },
+	/* kMarsMaze155 */ { 1, 9 },
+	/* kMarsMaze156 */ { 1, 8 },
+	/* kMarsMaze157 */ { 2, 10 },
+	/* kMarsMaze159 */ { 2, 8 },
+	/* kMarsMaze160 */ { 2, 7 },
+	/* kMarsMaze161 */ { 2, 6 },
+	/* kMarsMaze162 */ { 3, 10 },
+	/* kMarsMaze163 */ { 3, 9 },
+	/* kMarsMaze164 */ { 3, 8 },
+	/* kMarsMaze165 */ { 4, 8 },
+	/* kMarsMaze166 */ { 5, 8 },
+	/* kMarsMaze167 */ { 6, 8 },
+	/* kMarsMaze168 */ { 3, 6 },
+	/* kMarsMaze169 */ { 4, 6 },
+	/* kMarsMaze170 */ { 5, 6 },
+	/* kMarsMaze171 */ { 5, 5 },
+	/* kMarsMaze172 */ { 5, 4 },
+	/* kMarsMaze173 */ { 4, 4 },
+	/* kMarsMaze174 */ { 3, 4 },
+	/* kMarsMaze175 */ { 3, 5 },
+	/* kMarsMaze177 */ { 8, 4 },
+	/* kMarsMaze178 */ { 8, 3 },
+	/* kMarsMaze179 */ { 7, 4 },
+	/* kMarsMaze180 */ { 6, 4 },
+	/* kMarsMaze181 */ { 6, 3 },
+	/* kMarsMaze182 */ { 6, 2 },
+	/* kMarsMaze183 */ { 6, 1 },
+	/* kMarsMaze184 */ { 6, 0 },
+	/* kMarsMaze187 */ { 3, 0 },
+	/* kMarsMaze188 */ { 2, 0 },
+	/* kMarsMaze189 */ { 1, 0 },
+	/* kMarsMaze190 */ { 1, 1 },
+	/* kMarsMaze191 */ { 1, 2 },
+	/* kMarsMaze192 */ { 5, 2 },
+	/* kMarsMaze193 */ { 4, 2 },
+	/* kMarsMaze194 */ { 3, 2 },
+	/* kMarsMaze195 */ { 3, 1 },
+	/* kMarsMaze198 */ { 1, 3 },
+	/* kMarsMaze199 */ { 1, 4 },
+	/* kMarsMaze200 */ { 0, 4 }
+};
+
+MapImage::MapImage() : DisplayElement(kNoDisplayElement) {
+	_whichArea = kMapNoArea;
+	setBounds(kAIMiddleAreaLeft, kAIMiddleAreaTop, kAIMiddleAreaLeft + kAIMiddleAreaWidth, kAIMiddleAreaTop + kAIMiddleAreaHeight);
+	setDisplayOrder(kAIMiddleAreaOrder + 10);
+	startDisplaying();
+
+	_darkGreen = g_system->getScreenFormat().RGBToColor(64, 150, 10);
+	_lightGreen = g_system->getScreenFormat().RGBToColor(102, 239, 0);
+}
+
+void MapImage::writeToStream(Common::WriteStream *stream) {
+	_mappedRooms.writeToStream(stream);
+}
+
+void MapImage::readFromStream(Common::ReadStream *stream) {
+	_mappedRooms.readFromStream(stream);
+}
+
+void MapImage::loadGearRoomIfNecessary() {
+	// TODO
+}
+
+void MapImage::loadMazeIfNecessary() {
+	// TODO
+}
+
+void MapImage::unloadImage() {
+	// TODO: Unload surfaces
+	hide();
+	_whichArea = kMapNoArea;
+}
+
+void MapImage::moveToMapLocation(const tNeighborhoodID, const tRoomID room, const tDirectionConstant dir) {
+	// TODO
+
+	if (isDisplaying())
+		triggerRedraw();
+}
+
+void MapImage::addFlagToMask(const int flag) {
+	// TODO
+}
+
+// This function can even be sensitive to open doors.
+void MapImage::getRevealedRects(const uint32 flag, Common::Rect &r1) {	
+	// TODO
+}
+
+void MapImage::drawPlayer() {
+	// TODO
+}
+
+void MapImage::draw(const Common::Rect &) {
+	// TODO
+	drawPlayer();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
new file mode 100755
index 0000000..5532aed
--- /dev/null
+++ b/engines/pegasus/items/biochips/mapimage.h
@@ -0,0 +1,80 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_ITEMS_BIOCHIPS_MAPIMAGE_H
+#define PEGASUS_ITEMS_BIOCHIPS_MAPIMAGE_H
+
+#include "pegasus/elements.h"
+#include "pegasus/util.h"
+
+namespace Common {
+	class ReadStream;
+	class WriteStream;
+}
+
+namespace Pegasus {
+
+class MapImage : public DisplayElement {
+public:
+	MapImage();
+	virtual ~MapImage() {}
+
+	void writeToStream(Common::WriteStream *);
+	void readFromStream(Common::ReadStream *);
+
+	void loadGearRoomIfNecessary();
+	void loadMazeIfNecessary();
+	void unloadImage();
+	void moveToMapLocation(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	
+	void draw(const Common::Rect &);
+	
+	bool anyFlagSet() { return _mappedRooms.anyFlagSet(); }
+
+	static const uint32 kNumMappingRooms = (kMars39 - kMars35 + 1) + (kMars60 - kMars60 + 1) +
+			(kMarsMaze200 - kMarsMaze004 + 1);
+	static const uint32 kNumMappingFlags = kNumMappingRooms * 4;
+
+protected:
+	enum tMapArea {
+		kMapNoArea,
+		kMapMaze,
+		kMapGearRoom
+	};
+
+	void addFlagToMask(const int flag);
+	void getRevealedRects(const uint32, Common::Rect &);
+	void drawPlayer();
+
+	tMapArea _whichArea;
+
+	FlagsArray<byte, kNumMappingFlags> _mappedRooms;
+
+	uint32 _darkGreen, _lightGreen;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 9f1265c..260fba2 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -34,6 +34,8 @@ MODULE_OBJS = \
 	items/itemlist.o \
 	items/biochips/aichip.o \
 	items/biochips/biochipitem.o \
+	items/biochips/mapchip.o \
+	items/biochips/mapimage.o \
 	items/biochips/opticalchip.o \
 	items/biochips/pegasuschip.o \
 	items/biochips/retscanchip.o \
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 0c02030..f6da386 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -35,6 +35,7 @@
 #include "pegasus/interface.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/mapchip.h"
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
@@ -208,7 +209,8 @@ void Neighborhood::receiveNotification(Notification *, const tNotificationFlags
 }
 
 void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
-	// TODO: Map
+	if (g_map)
+		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), room, direction);
 
 	GameState.setCurrentNeighborhood(getObjectID());
 
@@ -565,7 +567,9 @@ bool Neighborhood::stillMoveForward() {
 void Neighborhood::keepStriding(ExitTable::Entry &nextExitEntry) {
 	FaderMoveSpec compassMove;
 
-	// TODO: Map
+	if (g_map)
+		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getNextRoom(), GameState.getNextDirection());
+
 	if (g_compass)
 		getExitCompassMove(nextExitEntry, compassMove);
 
@@ -719,7 +723,8 @@ void Neighborhood::cantOpenDoor(tCanOpenDoorReason) {
 }
 
 void Neighborhood::turnTo(const tDirectionConstant direction) {
-	// TODO: Map
+	if (g_map)
+		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), direction);
 
 	_pushIn.copyToCurrentPort();
 	
@@ -779,7 +784,8 @@ void Neighborhood::doorOpened() {
 
 	loadAmbientLoops();
 
-	// TODO: Map
+	if (g_map)
+		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getNextRoom(), GameState.getNextDirection());
 
 	if (g_AIArea)
 		g_AIArea->checkMiddleArea();
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index e68861e..a53f376 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -50,6 +50,7 @@
 #include "pegasus/items/itemlist.h"
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/biochipitem.h"
+#include "pegasus/items/biochips/mapchip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/items/biochips/pegasuschip.h"
 #include "pegasus/items/biochips/retscanchip.h"
@@ -228,8 +229,7 @@ void PegasusEngine::createItem(tItemID itemID, tNeighborhoodID neighborhoodID, t
 		new OpticalChip(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kMapBiochip:
-		// TODO: Implement this biochip
-		new BiochipItem(itemID, neighborhoodID, roomID, direction);
+		new MapChip(itemID, neighborhoodID, roomID, direction);
 		break;
 	case kRetinalScanBiochip:
 		new RetScanChip(itemID, neighborhoodID, roomID, direction);


Commit: 11b92529b09bcb6210a673c89d77aa21147b43d4
    https://github.com/scummvm/scummvm/commit/11b92529b09bcb6210a673c89d77aa21147b43d4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-10T07:14:34-07:00

Commit Message:
PEGASUS: Fix loading continue points

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a53f376..62688cc 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -354,6 +354,9 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	_currentItemID = kNoItemID;
 	_currentBiochipID = kNoItemID;
 
+	if (!g_interface)
+		createInterface();
+
 	// Signature
 	uint32 creator = stream->readUint32BE();
 	if (creator != kPegasusPrimeCreator) {
@@ -396,9 +399,6 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	// Death reason
 	setEnergyDeathReason(stream->readByte());
 
-	// TODO: This is as far as we can go right now (until I implement the mapping biochip and AI rules loading)
-	return true;
-
 	// Items
 	g_allItems.readFromStream(stream);
 
@@ -448,9 +448,6 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 }
 
 bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
-	// Not ready yet! :P
-	return false;
-
 	// Signature
 	stream->writeUint32BE(kPegasusPrimeCreator);
 


Commit: 820e424e980107568142caf29862c2b4bf004706
    https://github.com/scummvm/scummvm/commit/820e424e980107568142caf29862c2b4bf004706
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-10T08:42:02-07:00

Commit Message:
PEGASUS: Fix saving/loading original-compatible saves

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 62688cc..3d1c4d5 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -27,6 +27,7 @@
 #include "common/error.h"
 #include "common/events.h"
 #include "common/fs.h"
+#include "common/file.h"
 #include "common/memstream.h"
 #include "common/savefile.h"
 #include "common/textconsole.h"
@@ -302,9 +303,8 @@ void PegasusEngine::showLoadDialog() {
 
 	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 
-	if (slot >= 0) {
-		warning("TODO: Load game");
-	}
+	if (slot >= 0)
+		loadGameState(slot);
 
 	slc.close();
 }
@@ -394,7 +394,7 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	GameState.readGameState(stream);
 
 	// Energy
-	setLastEnergyValue(stream->readUint32BE() >> 16);
+	setLastEnergyValue(stream->readUint32BE());
 
 	// Death reason
 	setEnergyDeathReason(stream->readByte());
@@ -403,10 +403,10 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	g_allItems.readFromStream(stream);
 
 	// Inventory
-	uint32 itemCount = stream->readUint32BE();
+	byte itemCount = stream->readByte();
 
 	if (itemCount > 0) {
-		for (uint32 i = 0; i < itemCount; i++) {
+		for (byte i = 0; i < itemCount; i++) {
 			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((tItemID)stream->readUint16BE());
 			addItemToInventory(inv);
 		}
@@ -415,10 +415,10 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	}
 
 	// Biochips
-	uint32 biochipCount = stream->readUint32BE();
+	byte biochipCount = stream->readByte();
 
 	if (biochipCount > 0) {
-		for (uint32 i = 0; i < biochipCount; i++) {
+		for (byte i = 0; i < biochipCount; i++) {
 			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((tItemID)stream->readUint16BE());
 			addItemToBiochips(biochip);
 		}
@@ -448,6 +448,9 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 }
 
 bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
+	if (g_neighborhood)
+		g_neighborhood->flushGameState();
+
 	// Signature
 	stream->writeUint32BE(kPegasusPrimeCreator);
 
@@ -464,7 +467,7 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	GameState.writeGameState(stream);
 
 	// Energy
-	stream->writeUint32BE(getSavedEnergyValue() << 16);
+	stream->writeUint32BE(getSavedEnergyValue());
 
 	// Death reason
 	stream->writeByte(getEnergyDeathReason());
@@ -473,8 +476,8 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	g_allItems.writeToStream(stream);
 
 	// Inventory
-	uint32 itemCount = _items.getNumItems();
-	stream->writeUint32BE(itemCount);
+	byte itemCount = _items.getNumItems();
+	stream->writeByte(itemCount);
 
 	if (itemCount > 0) {
 		for (uint32 i = 0; i < itemCount; i++)
@@ -484,8 +487,8 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	}
 
 	// Biochips
-	uint32 biochipCount = _biochips.getNumItems();
-	stream->writeUint32BE(biochipCount);
+	byte biochipCount = _biochips.getNumItems();
+	stream->writeByte(biochipCount);
 
 	if (itemCount > 0) {
 		for (uint32 i = 0; i < biochipCount; i++)
@@ -659,7 +662,7 @@ void PegasusEngine::doGameMenuCommand(const tGameMenuCommand command) {
 		break;
 	case kMenuCmdRestore:
 	case kMenuCmdDeathRestore:
-		error("Load game");
+		showLoadDialog();
 		break;
 	case kMenuCmdCreditsMainMenu:
 		_gfx->doFadeOutSync();


Commit: e998fb6c0e87bcdeb6240d3bf2c8b7e97b8a372f
    https://github.com/scummvm/scummvm/commit/e998fb6c0e87bcdeb6240d3bf2c8b7e97b8a372f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-10T10:12:15-07:00

Commit Message:
PEGASUS: Allow for loading games from the launcher/cli

Changed paths:
    engines/pegasus/detection.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index fe797b4..76455e9 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -111,6 +111,7 @@ public:
 bool PegasusMetaEngine::hasFeature(MetaEngineFeature f) const {
 	return
 		(f == kSupportsListSaves)
+		|| (f == kSupportsLoadingDuringStartup)
 		|| (f == kSupportsDeleteSave);
 }
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 3d1c4d5..a696eda 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -143,10 +143,6 @@ Common::Error PegasusEngine::run() {
 	_biochips.setWeightLimit(8);
 	_biochips.setOwnerID(kPlayerID);
 
-	// Start up the first notification
-	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
-	_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
-
 	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 	g_allHotspots.push_back(&_returnHotspot);
@@ -154,6 +150,19 @@ Common::Error PegasusEngine::run() {
 	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
 
+	// Load from the launcher/cli if requested (and don't show the intro in those cases)
+	bool doIntro = true;
+	if (ConfMan.hasKey("save_slot")) {
+		uint32 gameToLoad = ConfMan.getInt("save_slot");
+		doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError);
+	}
+
+	if (doIntro) {
+		// Start up the first notification
+		_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
+		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
+	}
+
 	while (!shouldQuit()) {
 		processShell();
 		_system->delayMillis(10); // Ease off the CPU


Commit: 5b62d069bc548bc33a1693ff538f0a1dd54ba612
    https://github.com/scummvm/scummvm/commit/5b62d069bc548bc33a1693ff538f0a1dd54ba612
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-10T10:17:35-07:00

Commit Message:
PEGASUS: Fix Full TSA briefing movies

Changed paths:
    engines/pegasus/neighborhood/tsa/fulltsa.cpp



diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index aaa7cf1..51404b4 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -694,7 +694,7 @@ void FullTSA::flushGameState() {
 }
 
 Common::String FullTSA::getBriefingMovie() {	
-	Common::String movieName = getBriefingMovie();
+	Common::String movieName = Neighborhood::getBriefingMovie();
 
 	if (movieName.empty()) {
 		tRoomID room = GameState.getCurrentRoom();


Commit: 5062aaffcaba2c564e1f3181e46a186b2744e036
    https://github.com/scummvm/scummvm/commit/5062aaffcaba2c564e1f3181e46a186b2744e036
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-11T16:45:36-07:00

Commit Message:
PEGASUS: Implement the sub chase

Changed paths:
    engines/pegasus/console.cpp
    engines/pegasus/constants.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
index e6738bc..f8008a0 100644
--- a/engines/pegasus/console.cpp
+++ b/engines/pegasus/console.cpp
@@ -83,7 +83,8 @@ bool PegasusConsole::Cmd_Jump(int argc, const char **argv) {
 	tRoomID room = (tRoomID)atoi(argv[2]);
 	tDirectionConstant direction = (tDirectionConstant)atoi(argv[3]);
 
-	if (neighborhood < kCaldoriaID || neighborhood > kNoradDeltaID || neighborhood == kFinalTSAID) {
+	if ((neighborhood < kCaldoriaID || neighborhood > kNoradDeltaID || neighborhood == kFinalTSAID) &&
+			neighborhood != kNoradSubChaseID) {
 		DebugPrintf("Invalid neighborhood %d", neighborhood);
 		return true;
 	}
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 1d70c7d..ef7e30c 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -738,6 +738,7 @@ static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 // TODO: Remove me
 static const tRoomID kNorad01 = 0;
+static const tRoomID kNorad41 = 0;
 static const tRoomID kMars0A = 0;
 const tRoomID kMars35 = 38;
 const tRoomID kMars39 = 42;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a696eda..a13a77d 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1091,34 +1091,8 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x
 		if (video->needsUpdate()) {
 			const Graphics::Surface *frame = video->decodeNextFrame();
 
-			// Scale up the frame doing some simple scaling
-			Graphics::Surface scaledFrame;
-			scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
-			const byte *src = (const byte *)frame->pixels;
-			byte *dst1 = (byte *)scaledFrame.pixels;
-			byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
-
-			for (int i = 0; i < frame->h; i++) {
-				for (int j = 0; j < frame->w; j++) {
-					memcpy(dst1, src, frame->format.bytesPerPixel);
-					dst1 += frame->format.bytesPerPixel;
-					memcpy(dst1, src, frame->format.bytesPerPixel);
-					dst1 += frame->format.bytesPerPixel;
-					memcpy(dst2, src, frame->format.bytesPerPixel);
-					dst2 += frame->format.bytesPerPixel;
-					memcpy(dst2, src, frame->format.bytesPerPixel);
-					dst2 += frame->format.bytesPerPixel;
-					src += frame->format.bytesPerPixel;
-				}
-
-				src += frame->pitch - frame->format.bytesPerPixel * frame->w;
-				dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-				dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-			}
-
-			_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
-			_system->updateScreen();
-			scaledFrame.free();
+			if (frame)
+				drawScaledFrame(frame, x, y);
 		}
 
 		Input input;
@@ -1280,8 +1254,13 @@ void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 }
 
 void PegasusEngine::performJump(const tNeighborhoodID neighborhoodID) {
-	if (neighborhoodID == kNoradSubChaseID)
-		error("TODO: Sub chase");
+	// Sub chase is special
+	if (neighborhoodID == kNoradSubChaseID) {
+		throwAwayEverything();
+		doSubChase();
+		jumpToNewEnvironment(kNoradDeltaID, kNorad41, kEast);
+		return;
+	}
 
 	if (_neighborhood)
 		useNeighborhood(0);
@@ -1377,6 +1356,8 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kTinyTSAID:
 		neighborhood = new TinyTSA(g_AIArea, this);
 		break;
+	default:
+		error("Unhandled neighborhood %d", neighborhoodID);
 	}
 }
 
@@ -1886,4 +1867,60 @@ void PegasusEngine::playEndMessage() {
 	die(kPlayerWonGame);
 }
 
+void PegasusEngine::doSubChase() {
+	static const uint32 endTime = 133200 * 1000 / 600;
+
+	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
+	if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie"))
+		error("Failed to load sub chase");
+
+	while (!shouldQuit() && !video->endOfVideo() && video->getElapsedTime() < endTime) {
+		if (video->needsUpdate()) {
+			const Graphics::Surface *frame = video->decodeNextFrame();
+
+			if (frame)
+				drawScaledFrame(frame, 0, 0);
+		}
+
+		Common::Event event;
+		while (_eventMan->pollEvent(event))
+			;
+
+		_system->delayMillis(10);
+	}
+
+	delete video;
+}
+
+void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y) {
+	// Scale up the frame doing some simple scaling
+	Graphics::Surface scaledFrame;
+	scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
+	const byte *src = (const byte *)frame->pixels;
+	byte *dst1 = (byte *)scaledFrame.pixels;
+	byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
+
+	for (int i = 0; i < frame->h; i++) {
+		for (int j = 0; j < frame->w; j++) {
+			memcpy(dst1, src, frame->format.bytesPerPixel);
+			dst1 += frame->format.bytesPerPixel;
+			memcpy(dst1, src, frame->format.bytesPerPixel);
+			dst1 += frame->format.bytesPerPixel;
+			memcpy(dst2, src, frame->format.bytesPerPixel);
+			dst2 += frame->format.bytesPerPixel;
+			memcpy(dst2, src, frame->format.bytesPerPixel);
+			dst2 += frame->format.bytesPerPixel;
+			src += frame->format.bytesPerPixel;
+		}
+
+		src += frame->pitch - frame->format.bytesPerPixel * frame->w;
+		dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+		dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
+	}
+
+	_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
+	_system->updateScreen();
+	scaledFrame.free();
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index a09a923..934d5c5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -241,6 +241,8 @@ private:
 	void throwAwayEverything();
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
 	Common::RandomSource *_rnd;
+	void doSubChase();
+	void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: 13fef21fed3631af3c8ebc5c34ccaf2d077af983
    https://github.com/scummvm/scummvm/commit/13fef21fed3631af3c8ebc5c34ccaf2d077af983
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-11T16:46:15-07:00

Commit Message:
PEGASUS: Fix shell notifications on loading games

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a13a77d..6536c30 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -157,11 +157,11 @@ Common::Error PegasusEngine::run() {
 		doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError);
 	}
 
-	if (doIntro) {
+	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
+
+	if (doIntro)
 		// Start up the first notification
-		_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
 		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
-	}
 
 	while (!shouldQuit()) {
 		processShell();


Commit: 753006ae1a89d2e54477e3782e72c187d90d4083
    https://github.com/scummvm/scummvm/commit/753006ae1a89d2e54477e3782e72c187d90d4083
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-13T17:59:20-07:00

Commit Message:
PEGASUS: Add the WSC neighborhood

Seems to be working fine, minus the molecule sprites (though the minigame is completable and the antidote can be found).

Changed paths:
  A engines/pegasus/neighborhood/wsc/moleculebin.cpp
  A engines/pegasus/neighborhood/wsc/moleculebin.h
  A engines/pegasus/neighborhood/wsc/wsc.cpp
  A engines/pegasus/neighborhood/wsc/wsc.h
    engines/pegasus/constants.h
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/util.cpp
    engines/pegasus/util.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index ef7e30c..6010ec6 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -745,7 +745,6 @@ const tRoomID kMars39 = 42;
 const tRoomID kMars60 = 58;
 const tRoomID kMarsMaze004 = 60;
 const tRoomID kMarsMaze200 = 224;
-static const tRoomID kWSC01 = 0;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 6906dd9..e11b40f 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -44,6 +44,7 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 
 	tInputBits currentBits = 0;
 	bool consoleRequested = false;
+	bool altDown = false;
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -104,13 +105,13 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 				break;
 			}
 
-#if 0
-			// FIXME: This is disabled for now because it interferes with
-			// the ScummVM alt combinations. It's only used for one easter egg
-			// anyway, so I'll come up with something when I get around to that.
+			// WORKAROUND: The original had a specific key for this, but
+			// pressing alt would count as an event (and mess up someone
+			// trying to do alt+enter or something). Since it's only used
+			// as an easter egg, I'm just going to handle it as a separate
+			// bool value.
 			if (event.kbd.flags & Common::KBD_ALT)
-				currentBits |= (kRawButtonDown << kMod2ButtonShift);
-#endif
+				altDown = true;
 		}
 	}
 
@@ -133,6 +134,9 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 
 	// Set the console to be requested or not
 	input.setConsoleRequested(consoleRequested);
+
+	// Same for alt
+	input.setAltDown(altDown);
 }
 
 //	Wait until the input device stops returning input allowed by filter...
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 96df249..8778ffb 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -358,6 +358,7 @@ public:
 	
 	bool anyInputBitSet(const tInputBits bits) const { return (_inputState & bits) != 0; }
 
+	bool isAltDown() const { return _altDown; }
 	bool isConsoleRequested() const { return _consoleRequested; }
 
 	void clearInput() {
@@ -365,16 +366,19 @@ public:
 		_inputLocation.x = 0;
 		_inputLocation.y = 0;
 		_consoleRequested = false;
+		_altDown = false;
 	}
 
 protected:
 	void setInputBits(const tInputBits state) { _inputState = state; }
 	void setInputLocation(const Common::Point &where) { _inputLocation = where; }
 	void setConsoleRequested(bool consoleRequested) { _consoleRequested = consoleRequested; }
+	void setAltDown(bool altDown) { _altDown = altDown; }
 	
 	tInputBits _inputState;
 	Common::Point _inputLocation;
 	bool _consoleRequested;
+	bool _altDown;
 };
 
 class InputHandler {
@@ -476,7 +480,7 @@ public:
 	static bool isToggleInfoInput(const Input &input) { return input.fourButtonDown(); }
 
 	// Hmmmmm....
-	static bool isEasterEggModifierInput(const Input &input) { return input.mod2ButtonAnyDown(); }
+	static bool isEasterEggModifierInput(const Input &input) { return input.isAltDown(); }
 	
 	static bool isTogglePauseInput(const Input &input) { return input.mod3ButtonDown(); }
 };
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 260fba2..cf1dcb8 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -59,7 +59,9 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
-	neighborhood/tsa/tinytsa.o
+	neighborhood/tsa/tinytsa.o \
+	neighborhood/wsc/moleculebin.o \
+	neighborhood/wsc/wsc.o
 
 
 # This module can be built as a plugin
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 51404b4..e5508ba 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -33,6 +33,7 @@
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
+#include "pegasus/neighborhood/wsc/wsc.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index fa611bd..419ecba 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -30,6 +30,7 @@
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
+#include "pegasus/neighborhood/wsc/wsc.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/neighborhood/wsc/moleculebin.cpp b/engines/pegasus/neighborhood/wsc/moleculebin.cpp
new file mode 100755
index 0000000..8785005
--- /dev/null
+++ b/engines/pegasus/neighborhood/wsc/moleculebin.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/graphics.h"
+#include "pegasus/neighborhood/wsc/moleculebin.h"
+#include "pegasus/neighborhood/wsc/wsc.h"
+
+namespace Pegasus {
+
+static const tCoordType kMoleculeBinWidth = 138;
+static const tCoordType kMoleculeBinHeight = 128;
+
+static const tCoordType kMoleculeWidth = 66;
+static const tCoordType kMoleculeHeight = 40;
+
+static const tCoordType kMoleculeBinLeft = kNavAreaLeft + 286;
+static const tCoordType kMoleculeBinTop = kNavAreaLeft + 96;
+
+//	Layouts:
+
+MoleculeBin::MoleculeBin() : DisplayElement(kNoDisplayElement) {
+	_highlightColor = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 102);
+	_selectedMolecule = -1;
+}
+
+void MoleculeBin::initMoleculeBin() {
+	if (!isDisplaying()) {
+		for (int i = 0; i < 6; i++)
+			_binLayout[i] = i;
+
+		resetBin();
+		_binImages.getImageFromPICTFile("Images/World Science Center/Molecules");
+		setDisplayOrder(kWSCMoleculeBinOrder);
+		setBounds(kMoleculeBinLeft, kMoleculeBinTop, kMoleculeBinLeft + kMoleculeBinWidth,
+				kMoleculeBinTop + kMoleculeBinHeight);
+		startDisplaying();
+		show();
+	}
+}
+
+void MoleculeBin::cleanUpMoleculeBin() {
+	if (isDisplaying()) {
+		stopDisplaying();
+		_binImages.deallocateSurface();
+	}
+}
+
+void MoleculeBin::setBinLayout(const uint32 *layout) {
+	for (int i = 0; i < 6; i++)
+		_binLayout[i] = layout[i];
+}
+
+void MoleculeBin::highlightMolecule(const uint32 whichMolecule) {
+	if (!_moleculeFlags.getFlag(whichMolecule)) {
+		_moleculeFlags.setFlag(whichMolecule, true);
+		triggerRedraw();
+	}
+}
+
+bool MoleculeBin::isMoleculeHighlighted(uint32 whichMolecule) {
+	return _moleculeFlags.getFlag(whichMolecule);
+}
+
+void MoleculeBin::selectMolecule(const int whichMolecule) {
+	if (_selectedMolecule != whichMolecule) {
+		_selectedMolecule = whichMolecule;
+		triggerRedraw();
+	}
+}
+
+void MoleculeBin::resetBin() {
+	_moleculeFlags.clearAllFlags();
+	_selectedMolecule = -1;
+	triggerRedraw();
+}
+
+void MoleculeBin::draw(const Common::Rect &) {
+	Common::Rect r1(0, 0, kMoleculeWidth, kMoleculeHeight);
+	Common::Rect r2 = r1;
+
+	for (int i = 0; i < 6; i++) {
+		r1.moveTo(i * (kMoleculeWidth * 2), 0);
+
+		if (_moleculeFlags.getFlag(_binLayout[i]))
+			r1.translate(kMoleculeWidth, 0);
+
+		r1.moveTo((_binLayout[i] & 1) * (kMoleculeWidth + 2) + _bounds.left + 2,
+				(_binLayout[i] >> 1) * (kMoleculeHeight + 2) + _bounds.top + 2);
+
+		_binImages.copyToCurrentPort(r1, r2);
+	}
+
+	if (_selectedMolecule >= 0) {
+		r2.moveTo((_selectedMolecule & 1) * (kMoleculeWidth + 2) + _bounds.left + 2,
+				(_selectedMolecule >> 1) * (kMoleculeHeight + 2) + _bounds.top + 2);
+
+		Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+
+		screen->frameRect(r2, _highlightColor);
+		r2.grow(1);
+		screen->frameRect(r2, _highlightColor);
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/wsc/moleculebin.h b/engines/pegasus/neighborhood/wsc/moleculebin.h
new file mode 100755
index 0000000..3de4b5e
--- /dev/null
+++ b/engines/pegasus/neighborhood/wsc/moleculebin.h
@@ -0,0 +1,72 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_WSC_MOLECULEBIN_H
+#define PEGASUS_NEIGHBORHOOD_WSC_MOLECULEBIN_H
+
+#include "pegasus/elements.h"
+#include "pegasus/surface.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+enum {
+	kMolecule1,
+	kMolecule2,
+	kMolecule3,
+	kMolecule4,
+	kMolecule5,
+	kMolecule6
+};
+
+class MoleculeBin : public DisplayElement {
+public:
+	MoleculeBin();
+	virtual ~MoleculeBin() {}
+
+	void initMoleculeBin();
+	void cleanUpMoleculeBin();
+
+	void setBinLayout(const uint32 *);
+
+	void highlightMolecule(const uint32 whichMolecule);
+	void selectMolecule(const int whichMolecule);
+	void resetBin();
+
+	bool isMoleculeHighlighted(uint32);
+
+protected:
+	void draw(const Common::Rect &);
+
+	Surface _binImages;
+	FlagsArray<byte, kMolecule6 + 1> _moleculeFlags;
+	int _selectedMolecule;
+	uint32 _binLayout[6];
+	uint32 _highlightColor;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
new file mode 100755
index 0000000..82fbdb8
--- /dev/null
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -0,0 +1,2544 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/items/biochips/shieldchip.h"
+#include "pegasus/neighborhood/wsc/wsc.h"
+
+namespace Pegasus {
+
+const tCanMoveForwardReason kCantMoveWatchingDiagnosis = kCantMoveLastReason + 1;
+
+const tCanTurnReason kCantTurnWatchingDiagnosis = kCantTurnLastReason + 1;
+const tCanTurnReason kCantTurnWatchingAnalysis = kCantTurnWatchingDiagnosis + 1;
+const tCanTurnReason kCantTurnInMoleculeGame = kCantTurnWatchingAnalysis + 1;
+
+const TimeScale kMoleculesMovieScale = 600;
+const TimeValue kMoleculeLoopTime = 4 * kMoleculesMovieScale;
+const TimeValue kMoleculeFailTime = 2 * kMoleculesMovieScale;
+
+enum {
+	kMoleculeLoop0Time = 0,
+	kMoleculeFail0Time = kMoleculeLoop0Time + kMoleculeLoopTime,
+	kMoleculeLoop1Time = kMoleculeFail0Time + kMoleculeFailTime,
+	kMoleculeFail1Time = kMoleculeLoop1Time + kMoleculeLoopTime,
+	kMoleculeLoop2Time = kMoleculeFail1Time + kMoleculeFailTime,
+	kMoleculeFail2Time = kMoleculeLoop2Time + kMoleculeLoopTime,
+	kMoleculeLoop3Time = kMoleculeFail2Time + kMoleculeFailTime,
+	kMoleculeFail3Time = kMoleculeLoop3Time + kMoleculeLoopTime,
+	kMoleculeLoop4Time = kMoleculeFail3Time + kMoleculeFailTime,
+	kMoleculeFail4Time = kMoleculeLoop4Time + kMoleculeLoopTime,
+	kMoleculeLoop5Time = kMoleculeFail4Time + kMoleculeFailTime,
+	kMoleculeFail5Time = kMoleculeLoop5Time + kMoleculeLoopTime,
+	kMoleculeLoop6Time = kMoleculeFail5Time + kMoleculeFailTime
+};
+
+const TimeValue s_moleculeLoopTimes[] = {
+	kMoleculeLoop0Time,
+	kMoleculeLoop1Time,
+	kMoleculeLoop2Time,
+	kMoleculeLoop3Time,
+	kMoleculeLoop4Time,
+	kMoleculeLoop5Time,
+	kMoleculeLoop6Time
+};
+
+const TimeValue s_moleculeFailTimes[] = {
+	kMoleculeFail0Time,
+	kMoleculeFail1Time,
+	kMoleculeFail2Time,
+	kMoleculeFail3Time,
+	kMoleculeFail4Time,
+	kMoleculeFail5Time
+};
+
+const short kAuditoriumAngleOffset = 5;
+
+const long kPlasmaEnergyWithShield = kMaxJMPEnergy * 10 / 100;
+const long kPlasmaEnergyNoShield = kMaxJMPEnergy * 20 / 100;
+
+const long kTimerEventPlasmaHit = 0;
+const long kTimerEventPlayerGawkingAtRobot = 1;
+const long kTimerEventPlayerGawkingAtRobot2 = 2;
+
+const TimeValue kWSCMolecule1In = 0;
+const TimeValue kWSCMolecule1Out = 937;
+
+const TimeValue kWSCMolecule2In = 937;
+const TimeValue kWSCMolecule2Out = 1864;
+
+const TimeValue kWSCMolecule3In = 1864;
+const TimeValue kWSCMolecule3Out = 2790;
+
+const TimeValue kWSCClick1In = 2790;
+const TimeValue kWSCClick1Out = 2890;
+
+const TimeValue kWSCClick2In = 2890;
+const TimeValue kWSCClick2Out = 3059;
+
+const TimeValue kWSCClick3In = 3059;
+const TimeValue kWSCClick3Out = 3156;
+
+const TimeValue kWSCFlashlightClickIn = 3156;
+const TimeValue kWSCFlashlightClickOut = 3211;
+
+const TimeValue kWSCBumpIntoWallIn = 3211;
+const TimeValue kWSCBumpIntoWallOut = 3514;
+
+const TimeValue kWSCCantTransportIn = 3514;
+const TimeValue kWSCCantTransportOut = 7791;
+
+const TimeValue kHernandezNotHomeIn = 7791;
+const TimeValue kHernandezNotHomeOut = 10199;
+
+const TimeValue kWashingtonNotHomeIn = 10199;
+const TimeValue kWashingtonNotHomeOut = 12649;
+
+const TimeValue kSullivanNotHomeIn = 12649;
+const TimeValue kSullivanNotHomeOut = 15031;
+
+const TimeValue kNakamuraNotHomeIn = 15031;
+const TimeValue kNakamuraNotHomeOut = 17545;
+
+const TimeValue kGrailisNotHomeIn = 17545;
+const TimeValue kGrailisNotHomeOut = 19937;
+
+const TimeValue kTheriaultNotHomeIn = 19937;
+const TimeValue kTheriaultNotHomeOut = 22395;
+
+const TimeValue kGlennerNotHomeIn = 22395;
+const TimeValue kGlennerNotHomeOut = 24770;
+
+const TimeValue kSinclairNotHomeIn = 24770;
+const TimeValue kSinclairNotHomeOut = 27328;
+
+const TimeValue kWSCLabClosedIn = 27328;
+const TimeValue kWSCLabClosedOut = 28904;
+
+const TimeValue kSlidingDoorCloseIn = 28904;
+const TimeValue kSlidingDoorCloseOut = 29295;
+
+const TimeValue kSlimyDoorCloseIn = 29295;
+const TimeValue kSlimyDoorCloseOut = 29788;
+
+const TimeValue kPaging1In = 29788;
+const TimeValue kPaging1Out = 32501;
+
+const TimeValue kPaging2In = 32501;
+const TimeValue kPaging2Out = 34892;
+
+const TimeValue kCheckInIn = 34892;
+const TimeValue kCheckInOut = 37789;
+
+const TimeValue kDrinkAntidoteIn = 37789;
+const TimeValue kDrinkAntidoteOut = 39725;
+
+const TimeScale kWSCMovieScale = 600;
+const TimeScale kWSCFramesPerSecond = 15;
+const TimeScale kWSCFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltWSCNormal = 0;
+const tAlternateID kAltWSCTookMachineGun = 1;
+const tAlternateID kAltWSCW0ZDoorOpen = 2;
+const tAlternateID kAltWSCPeopleAtW19North = 3;
+
+//	Room IDs.
+
+const tRoomID kWSC02 = 1;
+const tRoomID kWSC02Morph = 2;
+const tRoomID kWSC02Messages = 3;
+const tRoomID kWSC03 = 4;
+const tRoomID kWSC04 = 5;
+const tRoomID kWSC06 = 6;
+const tRoomID kWSC07 = 7;
+const tRoomID kWSC08 = 8;
+const tRoomID kWSC09 = 9;
+const tRoomID kWSC10 = 10;
+const tRoomID kWSC11 = 11;
+const tRoomID kWSC13 = 12;
+const tRoomID kWSC14 = 13;
+const tRoomID kWSC15 = 14;
+const tRoomID kWSC16 = 15;
+const tRoomID kWSC17 = 16;
+const tRoomID kWSC18 = 17;
+const tRoomID kWSC19 = 18;
+const tRoomID kWSC20 = 19;
+const tRoomID kWSC21 = 20;
+const tRoomID kWSC22 = 21;
+const tRoomID kWSC23 = 22;
+const tRoomID kWSC24 = 23;
+const tRoomID kWSC25 = 24;
+const tRoomID kWSC26 = 25;
+const tRoomID kWSC27 = 26;
+const tRoomID kWSC28 = 27;
+const tRoomID kWSC29 = 28;
+const tRoomID kWSC31 = 29;
+const tRoomID kWSC32 = 30;
+const tRoomID kWSC33 = 31;
+const tRoomID kWSC34 = 32;
+const tRoomID kWSC35 = 33;
+const tRoomID kWSC36 = 34;
+const tRoomID kWSC37 = 35;
+const tRoomID kWSC38 = 36;
+const tRoomID kWSC39 = 37;
+const tRoomID kWSC40 = 38;
+const tRoomID kWSC41 = 39;
+const tRoomID kWSC42 = 40;
+const tRoomID kWSC43 = 41;
+const tRoomID kWSC44 = 42;
+const tRoomID kWSC45 = 43;
+const tRoomID kWSC46 = 44;
+const tRoomID kWSC47 = 45;
+const tRoomID kWSC48 = 46;
+const tRoomID kWSC49 = 47;
+const tRoomID kWSC50 = 48;
+const tRoomID kWSC52 = 49;
+const tRoomID kWSC53 = 50;
+const tRoomID kWSC54 = 51;
+const tRoomID kWSC55 = 52;
+const tRoomID kWSC56 = 53;
+const tRoomID kWSC57 = 54;
+const tRoomID kWSC58 = 55;
+const tRoomID kWSC60 = 56;
+const tRoomID kWSC60East = 57;
+const tRoomID kWSC60North = 58;
+const tRoomID kWSC61 = 59;
+const tRoomID kWSC61South = 60;
+const tRoomID kWSC61West = 61;
+const tRoomID kWSC62 = 62;
+const tRoomID kWSC63 = 63;
+const tRoomID kWSC64 = 64;
+const tRoomID kWSC65 = 65;
+const tRoomID kWSC65Screen = 66;
+const tRoomID kWSC66 = 67;
+const tRoomID kWSC67 = 68;
+const tRoomID kWSC68 = 69;
+const tRoomID kWSC69 = 70;
+const tRoomID kWSC70 = 71;
+const tRoomID kWSC71 = 72;
+const tRoomID kWSC72 = 73;
+const tRoomID kWSC73 = 74;
+const tRoomID kWSC74 = 75;
+const tRoomID kWSC75 = 76;
+const tRoomID kWSC0Z = 77;
+const tRoomID kWSC76 = 78;
+const tRoomID kWSC77 = 79;
+const tRoomID kWSC78 = 80;
+const tRoomID kWSC79 = 81;
+const tRoomID kWSC80 = 82;
+const tRoomID kWSC81 = 83;
+const tRoomID kWSC82 = 84;
+const tRoomID kWSC83 = 85;
+const tRoomID kWSC84 = 86;
+const tRoomID kWSC85 = 87;
+const tRoomID kWSC86 = 88;
+const tRoomID kWSC87 = 89;
+const tRoomID kWSC88 = 90;
+const tRoomID kWSC89 = 91;
+const tRoomID kWSC90 = 92;
+const tRoomID kWSC91 = 93;
+const tRoomID kWSC92 = 94;
+const tRoomID kWSC93 = 95;
+const tRoomID kWSC94 = 96;
+const tRoomID kWSC95 = 97;
+const tRoomID kWSC96 = 98;
+const tRoomID kWSC97 = 99;
+const tRoomID kWSC98 = 100;
+const tRoomID kWSCDeathRoom = 101;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationZoomedInToAnalyzer = 1;
+const tHotSpotActivationID kActivationShotByRobot = 2;
+const tHotSpotActivationID kActivationWarnedAboutPoison = 3;
+const tHotSpotActivationID kActivationMorphScreenOff = 4;
+const tHotSpotActivationID kActivationReadyForMorph = 5;
+const tHotSpotActivationID kActivationMorphLooping = 6;
+const tHotSpotActivationID kActivationMorphInterrupted = 7;
+const tHotSpotActivationID kActivationW03NorthOff = 8;
+const tHotSpotActivationID kActivationW03NorthReadyForInstructions = 9;
+const tHotSpotActivationID kActivationW03NorthSawInstructions = 10;
+const tHotSpotActivationID kActivationW03NorthInGame = 11;
+const tHotSpotActivationID kActivationReadyForSynthesis = 12;
+const tHotSpotActivationID kActivationSynthesizerLooping = 13;
+const tHotSpotActivationID kActivationReadyForMap = 14;
+const tHotSpotActivationID kActivationSinclairOfficeLocked = 15;
+const tHotSpotActivationID kActivationW58SouthDoorLocked = 16;
+const tHotSpotActivationID kActivationW61SouthOff = 17;
+const tHotSpotActivationID kActivationW61SouthOn = 18;
+const tHotSpotActivationID kActivationW61MessagesOff = 19;
+const tHotSpotActivationID kActivationW61MessagesOn = 20;
+const tHotSpotActivationID kActivationWSCRobotHeadOpen = 21;
+const tHotSpotActivationID kActivationRobotTurning = 22;
+const tHotSpotActivationID kActivationRobotDead = 23;
+const tHotSpotActivationID kActivationRobotGone = 24;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kWSCDropDartSpotID = 5000;
+const tHotSpotID kWSCTurnOnAnalyzerSpotID = 5001;
+const tHotSpotID kWSCAnalyzerScreenSpotID = 5002;
+const tHotSpotID kWSCSpinRobotSpotID = 5003;
+const tHotSpotID kWSC01YesSpotID = 5004;
+const tHotSpotID kWSC01NoSpotID = 5005;
+const tHotSpotID kWSC01AcknowledgeWarningSpotID = 5006;
+const tHotSpotID kWSC02SouthMorphSpotID = 5007;
+const tHotSpotID kWSC02SouthMessagesSpotID = 5008;
+const tHotSpotID kWSC02SouthMorphOutSpotID = 5009;
+const tHotSpotID kWSC02ActivateMorphScreenSpotID = 5010;
+const tHotSpotID kWSC02SouthStartMorphSpotID = 5011;
+const tHotSpotID kWSC02SouthInterruptMorphSpotID = 5012;
+const tHotSpotID kWSC02SouthMorphFinishedSpotID = 5013;
+const tHotSpotID kWSC02SouthTakeArgonSpotID = 5014;
+const tHotSpotID kWSC02SouthMessagesOutSpotID = 5015;
+const tHotSpotID kWSC02SouthTakeNitrogenSpotID = 5016;
+const tHotSpotID kWSC02SouthPlayMessagesSpotID = 5017;
+const tHotSpotID kWSC03NorthActivateScreenSpotID = 5018;
+const tHotSpotID kWSC03NorthBuildMoleculeSpotID = 5019;
+const tHotSpotID kWSC03NorthProceedSpotID = 5020;
+const tHotSpotID kWSC03NorthMolecule1SpotID = 5021;
+const tHotSpotID kWSC03NorthMolecule2SpotID = 5022;
+const tHotSpotID kWSC03NorthMolecule3SpotID = 5023;
+const tHotSpotID kWSC03NorthMolecule4SpotID = 5024;
+const tHotSpotID kWSC03NorthMolecule5SpotID = 5025;
+const tHotSpotID kWSC03NorthMolecule6SpotID = 5026;
+const tHotSpotID kWSC03SouthActivateSynthesizerSpotID = 5027;
+const tHotSpotID kWSC03SouthPickUpAntidoteSpotID = 5028;
+const tHotSpotID kWSC07SouthMapSpotID = 5029;
+const tHotSpotID kW42EastUnlockDoorSpotID = 5030;
+const tHotSpotID kW56NorthMapSpotID = 5031;
+const tHotSpotID kW58SouthPryDoorSpotID = 5032;
+const tHotSpotID kWSC60EastSpotID = 5033;
+const tHotSpotID kWSC60NorthSpotID = 5034;
+const tHotSpotID kWSC60EastOutSpotID = 5035;
+const tHotSpotID kWSC60NorthOutSpotID = 5036;
+const tHotSpotID kWSC61EastSpotID = 5037;
+const tHotSpotID kWSC61SouthSpotID = 5038;
+const tHotSpotID kW61SouthMachineGunSpotID = 5039;
+const tHotSpotID kW61SouthDropMachineGunSpotID = 5040;
+const tHotSpotID kWSC61WestSpotID = 5041;
+const tHotSpotID kWSC61SouthOutSpotID = 5042;
+const tHotSpotID kW61SouthActivateSpotID = 5043;
+const tHotSpotID kW61SmartAlloysSpotID = 5044;
+const tHotSpotID kW61MorphingSpotID = 5045;
+const tHotSpotID kW61TimeBendingSpotID = 5046;
+const tHotSpotID kWSC61WestOutSpotID = 5047;
+const tHotSpotID kW61TurnOnMessagesSpotID = 5048;
+const tHotSpotID kW61WhiteMessageSpotID = 5049;
+const tHotSpotID kW61WalchekMessageSpotID = 5050;
+const tHotSpotID kWSC65SouthScreenSpotID = 5051;
+const tHotSpotID kWSC65SouthScreenOutSpotID = 5052;
+const tHotSpotID kW98RetinalChipSpotID = 5053;
+const tHotSpotID kW98MapChipSpotID = 5054;
+const tHotSpotID kW98OpticalChipSpotID = 5055;
+const tHotSpotID kW98DropArgonSpotID = 5056;
+const tHotSpotID kW98GrabCableSpotID = 5057;
+const tHotSpotID kW98OpenRobotSpotID = 5058;
+const tHotSpotID kW98StunGunSpotID = 5059;
+
+//	Extra sequence IDs.
+
+const tExtraID kWSCArrivalFromTSA = 0;
+const tExtraID kWSCShotByRobot = 1;
+const tExtraID kWSCDartScan1 = 2;
+const tExtraID kWSCDartScan2 = 3;
+const tExtraID kWSCDartScanNo = 4;
+const tExtraID kWSCDartScan3 = 5;
+const tExtraID kWSCAnalyzerPowerUp = 6;
+const tExtraID kWSCAnalyzerPowerUpWithDart = 7;
+const tExtraID kWSCDropDartIntoAnalyzer = 8;
+const tExtraID kWSCAnalyzeDart = 9;
+const tExtraID kWSCZoomOutFromAnalyzer = 10;
+const tExtraID kWSCSpinRobot = 11;
+const tExtraID kWSC02MorphZoomNoArgon = 12;
+const tExtraID kWSC02MessagesZoomNoNitrogen = 13;
+const tExtraID kWSC02ZoomOutNoArgon = 14;
+const tExtraID kWSC02TurnOnMorphScreen = 15;
+const tExtraID kWSC02DropToMorphExperiment = 16;
+const tExtraID kWSC02MorphLoop = 17;
+const tExtraID kWSC02MorphInterruption = 18;
+const tExtraID kWSC02MorphFinished = 19;
+const tExtraID kWSC02TurnOffMorphScreen = 20;
+const tExtraID kWSC02SouthViewNoArgon = 21;
+const tExtraID kMessagesMovedToOffice = 22;
+const tExtraID kMessagesOff = 23;
+const tExtraID kMessagesZoomOutNoNitrogen = 24;
+const tExtraID kMessagesMovedToOfficeNoNitrogen = 25;
+const tExtraID kMessagesOffNoNitrogen = 26;
+const tExtraID kMessagesViewNoNitrogen = 27;
+const tExtraID kMessagesViewMachineOnNoNitrogen = 28;
+const tExtraID kW03NorthActivate = 29;
+const tExtraID kW03NorthGetData = 30;
+const tExtraID kW03NorthInstructions = 31;
+const tExtraID kW03NorthPrepMolecule1 = 32;
+const tExtraID kW03NorthPrepMolecule2 = 33;
+const tExtraID kW03NorthPrepMolecule3 = 34;
+const tExtraID kW03NorthFinishSynthesis = 35;
+const tExtraID kW03SouthCreateAntidote = 36;
+const tExtraID kW03SouthAntidoteLoop = 37;
+const tExtraID kW03SouthDeactivate = 38;
+const tExtraID kW03SouthViewNoAntidote = 39;
+const tExtraID kWSC07SouthMap = 40;
+const tExtraID kW17WestPeopleCrossing = 41;
+const tExtraID kW17WestPeopleCrossingView = 42;
+const tExtraID kW21SouthPeopleCrossing = 43;
+const tExtraID kW24SouthPeopleCrossing = 44;
+const tExtraID kW34EastPeopleCrossing = 45;
+const tExtraID kW36WestPeopleCrossing = 46;
+const tExtraID kW38NorthPeopleCrossing = 47;
+const tExtraID kW46SouthPeopleCrossing = 48;
+const tExtraID kW49NorthPeopleCrossing = 49;
+const tExtraID kW49NorthPeopleCrossingView = 50;
+const tExtraID kWSC56SouthMap = 51;
+const tExtraID kNerdAtTheDoor1 = 52;
+const tExtraID kNerdAtTheDoor2 = 53;
+const tExtraID kW61SouthZoomInNoGun = 54;
+const tExtraID kW61Brochure = 55;
+const tExtraID kW61SouthScreenOnWithGun = 56;
+const tExtraID kW61SouthScreenOffWithGun = 57;
+const tExtraID kW61SouthSmartAlloysWithGun = 58;
+const tExtraID kW61SouthMorphingWithGun = 59;
+const tExtraID kW61SouthTimeBendingWithGun = 60;
+const tExtraID kW61SouthZoomOutNoGun = 61;
+const tExtraID kW61SouthScreenOnNoGun = 62;
+const tExtraID kW61SouthScreenOffNoGun = 63;
+const tExtraID kW61SouthSmartAlloysNoGun = 64;
+const tExtraID kW61SouthMorphingNoGun = 65;
+const tExtraID kW61SouthTimeBendingNoGun = 66;
+const tExtraID kW61MessagesOn = 67;
+const tExtraID kW61MessagesOff = 68;
+const tExtraID kW61WhiteMessage = 69;
+const tExtraID kW61WalchekMessage = 70;
+const tExtraID kW61WalchekEasterEgg1 = 71;
+const tExtraID kW62SouthPlasmaRobotAppears = 72;
+const tExtraID kW62ZoomToRobot = 73;
+const tExtraID kW62ZoomOutFromRobot = 74;
+const tExtraID kW62PlasmaDodgeSurvive = 75;
+const tExtraID kW62PlasmaDodgeDie = 76;
+const tExtraID kW65SouthSinclairLecture = 77;
+const tExtraID kW73WestPeopleCrossing = 78;
+const tExtraID kW73WestPeopleCrossingView = 79;
+const tExtraID kW0ZSpottedByWomen = 80;
+const tExtraID kW95RobotShoots = 81;
+const tExtraID kW98MorphsToRobot = 82;
+const tExtraID kW98RobotShoots = 83;
+const tExtraID kW98RobotShocked = 84;
+const tExtraID kW98RobotGassed = 85;
+const tExtraID kW98RobotHeadOpensDark = 86;
+const tExtraID kW98RobotHead000Dark = 87;
+const tExtraID kW98RobotHead001Dark = 88;
+const tExtraID kW98RobotHead010Dark = 89;
+const tExtraID kW98RobotHead011Dark = 90;
+const tExtraID kW98RobotHead100Dark = 91;
+const tExtraID kW98RobotHead101Dark = 92;
+const tExtraID kW98RobotHead110Dark = 93;
+const tExtraID kW98RobotHead111Dark = 94;
+const tExtraID kW98RobotHeadClosesDark = 95;
+const tExtraID kW98WestViewWithGunDark = 96;
+const tExtraID kW98WestViewNoGunDark = 97;
+const tExtraID kW98RobotHeadOpensLight = 98;
+const tExtraID kW98RobotHead000Light = 99;
+const tExtraID kW98RobotHead001Light = 100;
+const tExtraID kW98RobotHead010Light = 101;
+const tExtraID kW98RobotHead011Light = 102;
+const tExtraID kW98RobotHead100Light = 103;
+const tExtraID kW98RobotHead101Light = 104;
+const tExtraID kW98RobotHead110Light = 105;
+const tExtraID kW98RobotHead111Light = 106;
+const tExtraID kW98RobotHeadClosesLight = 107;
+const tExtraID kW98WestViewWithGunLight = 108;
+const tExtraID kW98WestViewNoGunLight = 109;
+
+const tCoordType kMoleculesMovieLeft = kNavAreaLeft + 112;
+const tCoordType kMoleculesMovieTop = kNavAreaTop + 40;
+
+WSC::WSC(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "WSC", kWSCID),
+		_moleculesMovie(kNoDisplayElement) {
+	setIsItemTaken(kArgonCanister);
+	setIsItemTaken(kSinclairKey);
+	setIsItemTaken(kNitrogenCanister);
+	setIsItemTaken(kPoisonDart);
+	setIsItemTaken(kAntidote);
+	setIsItemTaken(kMachineGun);
+	setIsItemTaken(kStunGun);
+	
+	GameState.setTakenItemID(kArgonPickup, GameState.isTakenItemID(kArgonCanister) &&
+			GameState.isTakenItemID(kSinclairKey));
+}
+
+uint16 WSC::getDateResID() const {
+	return kDate2310ID;
+}
+
+void WSC::init() {
+	Neighborhood::init();
+	
+	_cachedZoomSpot = 0;
+	_argonSprite = 0;
+	
+	// HACK: Fix the drag item for picking up the Sinclair Key Card
+	HotspotInfoTable::Entry *entry = findHotspotEntry(kWSC02SouthTakeArgonSpotID);
+	entry->hotspotItem = kArgonPickup;
+}
+
+void WSC::flushGameState() {
+	g_energyMonitor->saveCurrentEnergyValue();
+}
+
+void WSC::start() {
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->restoreLastEnergyValue();
+		_vm->resetEnergyDeathReason();
+		g_energyMonitor->startEnergyDraining();
+	}
+	
+	if (!GameState.getWSCDidPlasmaDodge())
+		forceStridingStop(kWSC58, kSouth, kAltWSCNormal);
+	
+	Neighborhood::start();
+}
+
+class PryDoorMessage : public AIPlayMessageAction {
+public:
+	PryDoorMessage() : AIPlayMessageAction("Images/AI/WSC/XW59SD3", false) {}
+
+protected:
+	virtual void performAIAction(AIRule *);
+};
+
+void PryDoorMessage::performAIAction(AIRule *rule) {
+	if (((PegasusEngine *)g_engine)->playerHasItemID(kShieldBiochip)
+			&& ((PegasusEngine *)g_engine)->getCurrentBiochip()->getObjectID() != kShieldBiochip)
+		AIPlayMessageAction::performAIAction(rule);
+}
+
+void WSC::setUpAIRules() {
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/WSC/XW1WB1", false);
+		AILastExtraCondition *extraCondition = new AILastExtraCondition(kWSCDartScan1);
+		AIRule *rule = new AIRule(extraCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		AILocationCondition *locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC06, kNorth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC10, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC28, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC49, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC65, kSouth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC73, kSouth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB5A", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC79, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/WSC/XW59SD1", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC58, kSouth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		PryDoorMessage *pryDoorMessage = new PryDoorMessage();
+		AIDoorOpenedCondition *doorCondition = new AIDoorOpenedCondition(MakeRoomView(kWSC58, kSouth));
+		rule = new AIRule(doorCondition, pryDoorMessage);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/WSC/XW61E", false);
+		AIHasItemCondition *itemCondition = new AIHasItemCondition(kMachineGun);
+		rule = new AIRule(itemCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+		
+		messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB1E", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kWSC95, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+	}
+}
+
+Common::String WSC::getBriefingMovie() {
+	return "Images/AI/WSC/XWO";
+}
+
+Common::String WSC::getEnvScanMovie() {
+	tRoomID room = GameState.getCurrentRoom();
+	
+	if (room >= kWSC01 && room <= kWSC04)
+		return "Images/AI/WSC/XWE1";
+	else if (room >= kWSC06 && room <= kWSC58)
+		return "Images/AI/WSC/XWE2";
+	else if (room >= kWSC60 && room <= kWSC61West)
+		return "Images/AI/WSC/XWE3";
+	else if (room >= kWSC64 && room <= kWSC98)
+		return "Images/AI/WSC/XWE4";
+
+	return "Images/AI/WSC/XWE5";
+}
+
+uint WSC::getNumHints() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC10, kWest):
+	case MakeRoomView(kWSC28, kWest):
+	case MakeRoomView(kWSC49, kWest):
+	case MakeRoomView(kWSC65, kSouth):
+	case MakeRoomView(kWSC75, kSouth):
+	case MakeRoomView(kWSC79, kWest):
+		return 2;
+	case MakeRoomView(kWSC02, kSouth):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			return 3;
+		else if (!GameState.getScoringGotNitrogenCanister() ||
+				!GameState.getScoringGotSinclairKey())
+			return 1;
+		break;
+	case MakeRoomView(kWSC03, kNorth):
+		if (inSynthesizerGame() || (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote()))
+			return 3;
+		break;
+	case MakeRoomView(kWSC01, kNorth):
+	case MakeRoomView(kWSC01, kSouth):
+	case MakeRoomView(kWSC01, kEast):
+	case MakeRoomView(kWSC01, kWest):
+	case MakeRoomView(kWSC02, kNorth):
+	case MakeRoomView(kWSC02, kEast):
+	case MakeRoomView(kWSC02, kWest):
+	case MakeRoomView(kWSC02Morph, kNorth):
+	case MakeRoomView(kWSC02Morph, kEast):
+	case MakeRoomView(kWSC02Morph, kWest):
+	case MakeRoomView(kWSC02Messages, kNorth):
+	case MakeRoomView(kWSC02Messages, kEast):
+	case MakeRoomView(kWSC02Messages, kWest):
+	case MakeRoomView(kWSC03, kSouth):
+	case MakeRoomView(kWSC03, kEast):
+	case MakeRoomView(kWSC03, kWest):
+	case MakeRoomView(kWSC04, kNorth):
+	case MakeRoomView(kWSC04, kSouth):
+	case MakeRoomView(kWSC04, kEast):
+	case MakeRoomView(kWSC04, kWest):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			return 3;
+		break;
+	case MakeRoomView(kWSC02Messages, kSouth):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			return 3;
+		else if (!GameState.getScoringGotNitrogenCanister())
+			return 1;
+		break;
+	case MakeRoomView(kWSC02Morph, kSouth):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			return 3;
+		else if (!GameState.getScoringGotSinclairKey())
+			return 1;
+		break;
+	case MakeRoomView(kWSC42, kEast):
+		if (!GameState.isCurrentDoorOpen())
+			return 1;
+		break;
+	case MakeRoomView(kWSC58, kSouth):
+		if (GameState.isCurrentDoorOpen()) {
+			if (GameState.getWSCDidPlasmaDodge())
+				return 0;
+			else
+				return 1;
+		} else if (_vm->playerHasItemID(kCrowbar))
+			return 2;
+
+		return 3;
+	case MakeRoomView(kWSC61, kEast):
+		if (!GameState.getScoringSawBrochure())
+			return 1;
+		break;
+	case MakeRoomView(kWSC61, kSouth):
+		if (!GameState.getScoringSawSinclairEntry1() ||
+				!GameState.getScoringSawSinclairEntry2() ||
+				!GameState.getScoringSawSinclairEntry3())
+			return 1;
+		break;
+	case MakeRoomView(kWSC98, kWest):
+		if (getCurrentActivation() == kActivationRobotTurning)
+			return 1;
+		break;
+	}
+
+	return 0;
+}
+
+Common::String WSC::getHintMovie(uint hintNum) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC10, kWest):
+	case MakeRoomView(kWSC28, kWest):
+	case MakeRoomView(kWSC49, kWest):
+	case MakeRoomView(kWSC65, kSouth):
+	case MakeRoomView(kWSC75, kSouth):
+	case MakeRoomView(kWSC79, kWest):
+		if (hintNum == 1)
+			return "Images/AI/Globals/XGLOB5B";
+
+		return "Images/AI/Globals/XGLOB5C";
+	case MakeRoomView(kWSC02, kSouth):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			return Common::String::format("Images/AI/WSC/XWPH%d", hintNum);
+
+		return "Images/AI/Globals/XGLOB1C";
+	case MakeRoomView(kWSC61, kEast):
+	case MakeRoomView(kWSC61, kSouth):
+		return "Images/AI/Globals/XGLOB1C";
+	case MakeRoomView(kWSC42, kEast):
+		if (_vm->playerHasItemID(kSinclairKey))
+			return "Images/AI/Globals/XGLOB1A";
+
+		return "Images/AI/Globals/XGLOB2C";
+	case MakeRoomView(kWSC58, kSouth):
+		switch (hintNum) {
+		case 1:
+			if (GameState.isCurrentDoorOpen()) {
+				// Only get here if we haven't done the plasma dodge game...
+				if (_vm->playerHasItemID(kShieldBiochip))
+					return "Images/AI/Globals/XGLOB1A";
+				else
+					return "Images/AI/Globals/XGLOB3F";
+			} else if (_vm->playerHasItemID(kCrowbar)) {
+				return "Images/AI/Globals/XGLOB1A";
+			}
+
+			return "Images/AI/Globals/XGLOB1B";
+		case 2:
+			// Only get here if the door is still locked...
+			if (_vm->playerHasItemID(kCrowbar))
+				return "Images/AI/WSC/XW59SD2";
+
+			return "Images/AI/Globals/XGLOB2D";
+		case 3:
+			// Only get here if the door is still locked and we don't have the
+			// crowbar...
+			return "Images/AI/WSC/XW59SD2";
+		}
+		break;
+	case MakeRoomView(kWSC03, kNorth):
+		if (inSynthesizerGame())
+			return Common::String::format("Images/AI/WSC/XW03NH%d", hintNum);
+
+		return Common::String::format("Images/AI/WSC/XWPH%d", hintNum);
+	case MakeRoomView(kWSC01, kNorth):
+	case MakeRoomView(kWSC01, kSouth):
+	case MakeRoomView(kWSC01, kEast):
+	case MakeRoomView(kWSC01, kWest):
+	case MakeRoomView(kWSC02, kNorth):
+	case MakeRoomView(kWSC02, kEast):
+	case MakeRoomView(kWSC02, kWest):
+	case MakeRoomView(kWSC02Morph, kNorth):
+	case MakeRoomView(kWSC02Morph, kEast):
+	case MakeRoomView(kWSC02Morph, kWest):
+	case MakeRoomView(kWSC02Messages, kNorth):
+	case MakeRoomView(kWSC02Messages, kEast):
+	case MakeRoomView(kWSC02Messages, kWest):
+	case MakeRoomView(kWSC03, kSouth):
+	case MakeRoomView(kWSC03, kEast):
+	case MakeRoomView(kWSC03, kWest):
+	case MakeRoomView(kWSC04, kNorth):
+	case MakeRoomView(kWSC04, kSouth):
+	case MakeRoomView(kWSC04, kEast):
+	case MakeRoomView(kWSC04, kWest):
+		// analyzer hint
+		return Common::String::format("Images/AI/WSC/XWPH%d", hintNum);
+	case MakeRoomView(kWSC02Messages, kSouth):
+	case MakeRoomView(kWSC02Morph, kSouth):
+		if (_vm->getEnergyDeathReason() == kDeathDidntStopPoison &&
+				!_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag) &&
+				!GameState.getWSCDesignedAntidote())
+			// analyzer hint
+			return Common::String::format("Images/AI/WSC/XWPH%d", hintNum);
+
+		return "Images/AI/Globals/XGLOB1C";
+	case MakeRoomView(kWSC98, kWest):
+		return "Images/AI/WSC/XW98WH2";
+	}
+
+	return "";
+}
+
+void WSC::prepareForAIHint(const Common::String &movieName) {
+	if (movieName == "Images/AI/WSC/XW98WH2" && isEventTimerRunning())
+		pauseTimer();
+}
+
+void WSC::cleanUpAfterAIHint(const Common::String &movieName) {
+	if (movieName == "Images/AI/WSC/XW98WH2" && isEventTimerRunning())
+		resumeTimer();
+}
+
+bool WSC::okayToJump() {	
+	if (GameState.getWSCPoisoned()) {
+		die(kDeathDidntStopPoison);
+		return false;
+	}
+
+	bool result = Neighborhood::okayToJump();
+	if (!result)
+		playSpotSoundSync(kWSCCantTransportIn, kWSCCantTransportOut);
+
+	return result;
+}
+
+TimeValue WSC::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	tExtraID viewExtra = 0xffffffff;
+	ExtraTable::Entry extra;
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kWSC01, kWest):
+		if (!GameState.getWSCSeenTimeStream()) {
+			getExtraEntry(kWSCArrivalFromTSA, extra);
+			return extra.movieStart;
+		} else if (GameState.getWSCPoisoned() && !GameState.getWSCAnsweredAboutDart()) {
+			viewExtra = kWSCDartScan1;
+		}
+		break;
+	case MakeRoomView(kWSC02Morph, kSouth):
+		if (GameState.isTakenItemID(kArgonPickup) || GameState.isTakenItemID(kArgonCanister))
+			viewExtra = kWSC02SouthViewNoArgon;
+		break;
+	case MakeRoomView(kWSC02Messages, kSouth):
+		if (GameState.isTakenItemID(kNitrogenCanister)) {
+			if (_privateFlags.getFlag(kWSCPrivateLabMessagesOpenFlag))
+				viewExtra = kMessagesViewMachineOnNoNitrogen;
+			else
+				viewExtra = kMessagesViewNoNitrogen;
+		}
+		break;
+	case MakeRoomView(kWSC03, kSouth):
+		if (_privateFlags.getFlag(kWSCDraggingAntidoteFlag))
+			viewExtra = kW03SouthViewNoAntidote;
+		break;
+	case MakeRoomView(kWSC17, kWest):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt17WestFlag))
+			viewExtra = kW17WestPeopleCrossingView;
+		break;
+	case MakeRoomView(kWSC49, kNorth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt49NorthFlag))
+			viewExtra = kW49NorthPeopleCrossingView;
+		break;
+	case MakeRoomView(kWSC73, kWest):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt73WestFlag))
+			viewExtra = kW73WestPeopleCrossingView;
+		break;
+	case MakeRoomView(kWSC98, kWest):
+		if (GameState.getWSCRobotDead()) {
+			if (GameState.getWSCRobotGone()) {
+				if (GameState.isTakenItemID(kStunGun)) {
+					if (GameState.getWSCCatwalkDark())
+						viewExtra = kW98WestViewNoGunDark;
+					else
+						viewExtra = kW98WestViewNoGunLight;
+				} else {
+					if (GameState.getWSCCatwalkDark())
+						viewExtra = kW98WestViewWithGunDark;
+					else
+						viewExtra = kW98WestViewWithGunLight;
+				}
+			} else if (_privateFlags.getFlag(kWSCPrivateRobotHeadOpenFlag)) {
+				if (GameState.getWSCCatwalkDark())
+					viewExtra = kW98RobotHead111Dark;
+				else
+					viewExtra = kW98RobotHead111Light;
+
+				if (_privateFlags.getFlag(kWSCPrivateGotRetScanChipFlag))
+					viewExtra -= 1;
+				if (_privateFlags.getFlag(kWSCPrivateGotMapChipFlag))
+					viewExtra -= 2;
+				if (_privateFlags.getFlag(kWSCPrivateGotOpticalChipFlag))
+					viewExtra -= 4;
+			} else if (GameState.getWSCRobotDead()) {
+				// Should only happen on loading a saved game, so it can take its time.
+				if (GameState.getWSCCatwalkDark())
+					viewExtra = kW98RobotShocked;
+				else
+					viewExtra = kW98RobotGassed;
+			}
+		}
+		break;
+	}
+
+	if (viewExtra != 0xffffffff) {
+		getExtraEntry(viewExtra, extra);
+		return extra.movieEnd - 1;
+	}
+
+	return Neighborhood::getViewTime(room, direction);
+}
+
+void WSC::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kWSC58, kSouth):
+	case MakeRoomView(kWSC79, kWest):
+		if ((flags & kSpotOnTurnMask) != 0) {
+			spotEntry.clear();
+			return;
+		}
+		break;
+	}
+
+	Neighborhood::findSpotEntry(room, direction, flags, spotEntry);
+}
+
+void WSC::getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry) {
+	Neighborhood::getZoomEntry(id, zoomEntry);
+
+	ExtraTable::Entry extra;
+	tExtraID zoomExtra = 0xffffffff;
+
+	switch (id) {
+	case kWSC02SouthMessagesSpotID:
+		if (GameState.isTakenItemID(kNitrogenCanister))
+			zoomExtra = kWSC02MessagesZoomNoNitrogen;
+		break;
+	case kWSC02SouthMessagesOutSpotID:
+		if (GameState.isTakenItemID(kNitrogenCanister))
+			zoomExtra = kMessagesZoomOutNoNitrogen;
+		break;
+	case kWSC02SouthMorphSpotID:
+		if (GameState.isTakenItemID(kArgonCanister))
+			zoomExtra = kWSC02MorphZoomNoArgon;
+		break;
+	case kWSC02SouthMorphOutSpotID:
+		if (GameState.isTakenItemID(kArgonCanister))
+			zoomExtra = kWSC02ZoomOutNoArgon;
+		break;
+	case kWSC61SouthSpotID:
+		if (GameState.isTakenItemID(kMachineGun))
+			zoomExtra = kW61SouthZoomInNoGun;
+		break;
+	case kWSC61SouthOutSpotID:
+		if (GameState.isTakenItemID(kMachineGun))
+			zoomExtra = kW61SouthZoomOutNoGun;
+		break;
+	}
+
+	if (zoomExtra != 0xffffffff) {
+		getExtraEntry(zoomExtra, extra);
+		zoomEntry.movieStart = extra.movieStart;
+		zoomEntry.movieEnd = extra.movieEnd;
+	}
+}
+
+void WSC::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry) {
+	switch (id) {
+	case kWSCZoomOutFromAnalyzer:
+		Neighborhood::getExtraEntry(kWSCZoomOutFromAnalyzer, extraEntry);
+		extraEntry.movieEnd = extraEntry.movieStart + 14 * kWSCFrameDuration;
+		break;
+	case kW61WalchekMessage:
+		if (GameState.getEasterEgg())
+			Neighborhood::getExtraEntry(kW61WalchekEasterEgg1, extraEntry);
+		else
+			Neighborhood::getExtraEntry(id, extraEntry);
+		break;
+	case kW61SouthScreenOnWithGun:
+		if (GameState.isTakenItemID(kMachineGun))
+			Neighborhood::getExtraEntry(id, extraEntry);
+		else
+			Neighborhood::getExtraEntry(kW61SouthScreenOnNoGun, extraEntry);
+		break;
+	case kW61SouthSmartAlloysWithGun:
+		if (GameState.isTakenItemID(kMachineGun))
+			Neighborhood::getExtraEntry(id, extraEntry);
+		else
+			Neighborhood::getExtraEntry(kW61SouthSmartAlloysNoGun, extraEntry);
+		break;
+	case kW61SouthMorphingWithGun:
+		if (GameState.isTakenItemID(kMachineGun))
+			Neighborhood::getExtraEntry(id, extraEntry);
+		else
+			Neighborhood::getExtraEntry(kW61SouthMorphingNoGun, extraEntry);
+		break;
+	case kW61SouthTimeBendingWithGun:
+		if (GameState.isTakenItemID(kMachineGun))
+			Neighborhood::getExtraEntry(id, extraEntry);
+		else
+			Neighborhood::getExtraEntry(kW61SouthTimeBendingNoGun, extraEntry);
+		break;
+	case kW98RobotHeadOpensLight:
+		if (GameState.getWSCCatwalkDark())
+			Neighborhood::getExtraEntry(kW98RobotHeadOpensDark, extraEntry);
+		else
+			Neighborhood::getExtraEntry(id, extraEntry);
+		break;
+	default:
+		Neighborhood::getExtraEntry(id, extraEntry);
+		break;
+	}
+}
+
+tCanMoveForwardReason WSC::canMoveForward(ExitTable::Entry &entry) {
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kWSC01, kWest) &&
+			getCurrentActivation() != kActivateHotSpotAlways)
+		return kCantMoveWatchingDiagnosis;
+
+	return Neighborhood::canMoveForward(entry);
+}
+
+// Also add cases here for compound analyzer...
+tCanTurnReason WSC::canTurn(tTurnDirection turnDirection, tDirectionConstant &nextDir) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC01, kWest):
+		if (getCurrentActivation() != kActivateHotSpotAlways)
+			return kCantTurnWatchingDiagnosis;
+		break;
+	case MakeRoomView(kWSC01, kEast):
+		if (getCurrentActivation() != kActivateHotSpotAlways)
+			return kCantTurnWatchingAnalysis;
+		break;
+	case MakeRoomView(kWSC03, kNorth):
+		if (_privateFlags.getFlag(kWSCPrivateInMoleculeGameFlag))
+			return kCantTurnInMoleculeGame;
+		break;
+	}
+
+	return Neighborhood::canTurn(turnDirection, nextDir);
+}
+
+tCanOpenDoorReason WSC::canOpenDoor(DoorTable::Entry &entry) {
+	switch (GameState.getCurrentRoom()) {
+	case kWSC42:
+		if (!_privateFlags.getFlag(kWSCPrivateSinclairOfficeOpenFlag))
+			return kCantOpenLocked;
+		break;
+	case kWSC58:
+		if (!_privateFlags.getFlag(kWSCPrivate58SouthOpenFlag))
+			return kCantOpenLocked;
+		break;
+	}
+
+	return Neighborhood::canOpenDoor(entry);
+}
+
+void WSC::bumpIntoWall() {
+	requestSpotSound(kWSCBumpIntoWallIn, kWSCBumpIntoWallOut, kFilterAllInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+void WSC::closeDoorOffScreen(const tRoomID room, const tDirectionConstant) {
+	Item *keyCard;
+
+	switch (room) {
+	case kWSC58:
+	case kWSC62:
+	case kWSC63:
+	case kWSC64:
+	case kWSC85:
+	case kWSC86:
+	case kWSC88:
+	case kWSC89:
+		playSpotSoundSync(kSlidingDoorCloseIn, kSlidingDoorCloseOut);
+		break;
+	case kWSC81:
+	case kWSC82:
+	case kWSC92:
+	case kWSC93:
+		keyCard = g_allItems.findItemByID(kKeyCard);
+		if (keyCard->getItemState() == kFlashlightOn && (GameState.getCurrentRoom() == kWSC81 ||
+				GameState.getCurrentRoom() == kWSC93)) {
+			keyCard->setItemState(kFlashlightOff);
+			playSpotSoundSync(kWSCFlashlightClickIn, kWSCFlashlightClickOut);
+		} else if (keyCard->getItemState() == kFlashlightOff && (GameState.getCurrentRoom() == kWSC82 ||
+				GameState.getCurrentRoom() == kWSC92)) {
+			keyCard->setItemState(kFlashlightOn);
+			playSpotSoundSync(kWSCFlashlightClickIn, kWSCFlashlightClickOut);
+		}
+
+		playSpotSoundSync(kSlimyDoorCloseIn, kSlimyDoorCloseOut);
+		break;
+	default:
+		playSpotSoundSync(kSlimyDoorCloseIn, kSlimyDoorCloseOut);
+		break;
+	}
+}
+
+void WSC::cantMoveThatWay(tCanMoveForwardReason reason) {
+	if (reason != kCantMoveWatchingDiagnosis)
+		Neighborhood::cantMoveThatWay(reason);
+}
+
+void WSC::cantOpenDoor(tCanOpenDoorReason reason) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC22, kWest):
+		playSpotSoundSync(kNakamuraNotHomeIn, kNakamuraNotHomeOut);
+		break;
+	case MakeRoomView(kWSC23, kEast):
+		playSpotSoundSync(kHernandezNotHomeIn, kHernandezNotHomeOut);
+		break;
+	case MakeRoomView(kWSC26, kWest):
+		playSpotSoundSync(kGrailisNotHomeIn, kGrailisNotHomeOut);
+		break;
+	case MakeRoomView(kWSC27, kEast):
+		playSpotSoundSync(kWashingtonNotHomeIn, kWashingtonNotHomeOut);
+		break;
+	case MakeRoomView(kWSC32, kWest):
+		playSpotSoundSync(kTheriaultNotHomeIn, kTheriaultNotHomeOut);
+		break;
+	case MakeRoomView(kWSC33, kEast):
+		playSpotSoundSync(kSullivanNotHomeIn, kSullivanNotHomeOut);
+		break;
+	case MakeRoomView(kWSC41, kWest):
+		playSpotSoundSync(kGlennerNotHomeIn, kGlennerNotHomeOut);
+		break;
+	case MakeRoomView(kWSC42, kEast):
+		playSpotSoundSync(kSinclairNotHomeIn, kSinclairNotHomeOut);
+		break;
+	case MakeRoomView(kWSC15, kWest):
+	case MakeRoomView(kWSC25, kWest):
+	case MakeRoomView(kWSC33, kWest):
+	case MakeRoomView(kWSC41, kEast):
+	case MakeRoomView(kWSC46, kWest):
+		playSpotSoundSync(kWSCLabClosedIn, kWSCLabClosedOut);
+		break;
+	default:
+		Neighborhood::cantOpenDoor(reason);
+		break;
+	}
+}
+
+void WSC::doorOpened() {
+	Neighborhood::doorOpened();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC42, kEast):
+		_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kSinclairKey));
+		break;
+	case MakeRoomView(kWSC58, kSouth):
+		GameState.setScoringUsedCrowBarInWSC();
+		_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kCrowbar));
+		break;
+	case MakeRoomView(kWSC06, kNorth):
+	case MakeRoomView(kWSC79, kWest):
+		die(kDeathArrestedInWSC);
+		break;
+	case MakeRoomView(kWSC60, kWest):
+		if (_vm->itemInInventory(kMachineGun))
+			startExtraSequence(kNerdAtTheDoor2, kExtraCompletedFlag, kFilterNoInput);
+		else if (!GameState.getWSCSeenNerd())
+			startExtraSequence(kNerdAtTheDoor1, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC95, kWest):
+		GameState.setScoringOpenedCatwalk();
+		scheduleEvent(kGawkAtRobotTime, 1, kTimerEventPlayerGawkingAtRobot);
+		break;
+	}
+}
+
+void WSC::turnLeft() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC17, kNorth):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt17WestFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt17WestFlag, true);
+		break;
+	case MakeRoomView(kWSC49, kEast):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt49NorthFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt49NorthFlag, true);
+		break;
+	case MakeRoomView(kWSC73, kNorth):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt73WestFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt73WestFlag, true);
+		break;
+	case MakeRoomView(kWSC73, kWest):
+		if (!GameState.getWSCBeenAtWSC93())
+			setCurrentAlternate(kAltWSCW0ZDoorOpen);
+		break;
+	case MakeRoomView(kWSC95, kWest):
+		cancelEvent();
+		break;
+	}
+
+	Neighborhood::turnLeft();
+}
+
+void WSC::turnRight() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC17, kSouth):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt17WestFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt17WestFlag, true);
+		break;
+	case MakeRoomView(kWSC49, kWest):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt49NorthFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt49NorthFlag, true);
+		break;
+	case MakeRoomView(kWSC73, kSouth):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt73WestFlag) && _vm->getRandomNumber(2) == 0)
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt73WestFlag, true);
+		break;
+	case MakeRoomView(kWSC73, kEast):
+		if (!GameState.getWSCBeenAtWSC93())
+			setCurrentAlternate(kAltWSCW0ZDoorOpen);
+		break;
+	case MakeRoomView(kWSC95, kWest):
+		cancelEvent();
+		break;
+	}
+
+	Neighborhood::turnRight();
+}
+
+void WSC::moveForward() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC19, kNorth):
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt19NorthFlag))
+			setCurrentAlternate(kAltWSCPeopleAtW19North);
+		break;
+	case MakeRoomView(kWSC95, kWest):
+		cancelEvent();
+		break;
+	}
+
+	Neighborhood::moveForward();
+}
+
+void WSC::zoomTo(const Hotspot *hotspot) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC02Messages, kSouth):
+		if (_privateFlags.getFlag(kWSCPrivateLabMessagesOpenFlag)) {
+			_cachedZoomSpot = hotspot;
+			if (GameState.isTakenItemID(kNitrogenCanister))
+				startExtraSequence(kMessagesOffNoNitrogen, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kMessagesOff, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		}
+		break;
+	case MakeRoomView(kWSC61West, kWest):
+		if (GameState.getWSCOfficeMessagesOpen()) {
+			_cachedZoomSpot = hotspot;
+			startExtraSequence(kW61MessagesOff, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		}
+		break;
+	case MakeRoomView(kWSC61South, kSouth):
+		if (_privateFlags.getFlag(kWSCPrivateOfficeLogOpenFlag)) {
+			_cachedZoomSpot = hotspot;
+			if (GameState.isTakenItemID(kMachineGun))
+				startExtraSequence(kW61SouthScreenOffNoGun, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kW61SouthScreenOffWithGun, kExtraCompletedFlag, kFilterNoInput);
+			return;
+		}
+		break;
+	}
+
+	Neighborhood::zoomTo(hotspot);
+}
+
+void WSC::startExtraSequence(const tExtraID extraID, const tNotificationFlags flags, const tInputBits interruptionFilter) {
+	if (extraID == kW61Brochure)
+		loadLoopSound1("");
+
+	Neighborhood::startExtraSequence(extraID, flags, interruptionFilter);
+}
+
+int16 WSC::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	int16 angle = Neighborhood::getStaticCompassAngle(room, dir);
+
+	switch (room) {
+	case kWSC02Messages:
+		angle -= 50;
+		break;
+	case kWSC02Morph:
+		angle += 5;
+		break;
+	case kWSC60East:
+		angle -= 10;
+		break;
+	case kWSC66:
+		angle -= kAuditoriumAngleOffset;
+		break;
+	case kWSC67:
+		angle += kAuditoriumAngleOffset;
+		break;
+	case kWSC68:
+		angle -= kAuditoriumAngleOffset * 2;
+		break;
+	case kWSC69:
+		angle += kAuditoriumAngleOffset * 2;
+		break;
+	case kWSC70:
+		angle -= kAuditoriumAngleOffset * 3;
+		break;
+	case kWSC71:
+		angle += kAuditoriumAngleOffset * 3;
+		break;
+	case kWSC72:
+		if (dir == kEast || dir == kWest)
+			angle -= kAuditoriumAngleOffset * 4;
+		break;
+	case kWSC73:
+		if (dir == kEast || dir == kWest)
+			angle += kAuditoriumAngleOffset * 4;
+		break;
+	}
+
+	return angle;
+}
+
+void WSC::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	if (exitEntry.room == kWSC65 && exitEntry.direction == kSouth) {
+		compassMove.insertFaderKnot(exitEntry.movieStart + 100 * kWSCFrameDuration, 180);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 108 * kWSCFrameDuration, 150);
+		compassMove.insertFaderKnot(exitEntry.movieEnd, 150);
+	}
+}
+
+void WSC::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
+	switch (entry.extra) {
+	case kW61Brochure:
+		compassMove.insertFaderKnot(entry.movieStart + 15 * kWSCFrameDuration, 85);
+		compassMove.insertFaderKnot(entry.movieEnd - 15 * kWSCFrameDuration, 85);
+		compassMove.insertFaderKnot(entry.movieEnd, 90);
+		break;
+	default:
+		Neighborhood::getExtraCompassMove(entry, compassMove);
+		break;
+	}
+}
+
+void WSC::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+
+	if (room >= kWSC01 && room <= kWSC04) {
+		if (GameState.getWSCSeenTimeStream())
+			loadLoopSound1("Sounds/World Science Center/WLabLoop.22K.AIFF", 0x100 / 2);
+	} else if ((room >= kWSC06 && room <= kWSC58) || (room >= kWSC62 && room <= kWSC63))
+		loadLoopSound1("Sounds/World Science Center/Organic Walls.22K.AIFF", 0x100 / 2);
+	else if (room >= kWSC82 && room <= kWSC92)
+		loadLoopSound1("Sounds/World Science Center/Creature Feature.22K.AIFF");
+	else if ((room >= kWSC60 && room <= kWSC61West) || (room >= kWSC64 && room <= kWSC81) ||
+			(room >= kWSC93 && room <= kWSC97))
+		loadLoopSound1("Sounds/World Science Center/The Other Side.22K.AIFF", 0x100 / 12);
+	else if (room == kWSC98)
+		loadLoopSound1("Sounds/World Science Center/WCatLoop.22K.AIFF");
+}
+
+void WSC::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kWSC07, kNorth):
+	case MakeRoomView(kWSC11, kSouth):
+	case MakeRoomView(kWSC13, kSouth):
+	case MakeRoomView(kWSC13, kWest):
+	case MakeRoomView(kWSC16, kWest):
+	case MakeRoomView(kWSC17, kEast):
+	case MakeRoomView(kWSC19, kWest):
+	case MakeRoomView(kWSC28, kNorth):
+	case MakeRoomView(kWSC28, kSouth):
+	case MakeRoomView(kWSC28, kEast):
+	case MakeRoomView(kWSC28, kWest):
+	case MakeRoomView(kWSC29, kNorth):
+	case MakeRoomView(kWSC29, kSouth):
+	case MakeRoomView(kWSC29, kEast):
+	case MakeRoomView(kWSC29, kWest):
+	case MakeRoomView(kWSC40, kEast):
+	case MakeRoomView(kWSC42, kEast):
+	case MakeRoomView(kWSC49, kWest):
+	case MakeRoomView(kWSC49, kNorth):
+	case MakeRoomView(kWSC50, kNorth):
+	case MakeRoomView(kWSC55, kEast):
+	case MakeRoomView(kWSC65, kSouth):
+	case MakeRoomView(kWSC65, kEast):
+	case MakeRoomView(kWSC65, kWest):
+	case MakeRoomView(kWSC72, kEast):
+	case MakeRoomView(kWSC72, kSouth):
+	case MakeRoomView(kWSC73, kWest):
+	case MakeRoomView(kWSC73, kSouth):
+	case MakeRoomView(kWSC79, kWest):
+	case MakeRoomView(kWSC81, kEast):
+	case MakeRoomView(kWSC93, kNorth):
+	case MakeRoomView(kWSC95, kWest):
+		makeContinuePoint();
+		break;
+	case MakeRoomView(kWSC58, kSouth):
+		if (!GameState.getWSCDidPlasmaDodge())
+			makeContinuePoint();
+		break;
+	case MakeRoomView(kWSC60, kWest):
+		if (_vm->playerHasItemID(kMachineGun))
+			makeContinuePoint();
+		break;
+	}
+}
+
+void WSC::arriveAt(const tRoomID room, const tDirectionConstant dir) {	
+	switch (MakeRoomView(room, dir)) {
+	case MakeRoomView(kWSC60, kNorth):
+	case MakeRoomView(kWSC60, kSouth):
+	case MakeRoomView(kWSC60, kEast):
+	case MakeRoomView(kWSC60, kWest):
+	case MakeRoomView(kWSC60East, kNorth):
+	case MakeRoomView(kWSC60East, kSouth):
+	case MakeRoomView(kWSC60East, kEast):
+	case MakeRoomView(kWSC60East, kWest):
+	case MakeRoomView(kWSC60North, kNorth):
+	case MakeRoomView(kWSC60North, kSouth):
+	case MakeRoomView(kWSC60North, kEast):
+	case MakeRoomView(kWSC60North, kWest):
+	case MakeRoomView(kWSC61, kNorth):
+	case MakeRoomView(kWSC61, kSouth):
+	case MakeRoomView(kWSC61, kEast):
+	case MakeRoomView(kWSC61, kWest):
+	case MakeRoomView(kWSC61South, kNorth):
+	case MakeRoomView(kWSC61South, kSouth):
+	case MakeRoomView(kWSC61South, kEast):
+	case MakeRoomView(kWSC61South, kWest):
+	case MakeRoomView(kWSC61West, kNorth):
+	case MakeRoomView(kWSC61West, kSouth):
+	case MakeRoomView(kWSC61West, kEast):
+	case MakeRoomView(kWSC61West, kWest):
+		if (GameState.isTakenItemID(kMachineGun))
+			setCurrentAlternate(kAltWSCTookMachineGun);
+		else
+			setCurrentAlternate(kAltWSCNormal);
+		break;
+	case MakeRoomView(kWSC73, kSouth):
+	case MakeRoomView(kWSC75, kNorth):
+	case MakeRoomView(kWSC75, kSouth):
+	case MakeRoomView(kWSC75, kEast):
+	case MakeRoomView(kWSC75, kWest):
+		if (!GameState.getWSCBeenAtWSC93())
+			setCurrentAlternate(kAltWSCW0ZDoorOpen);
+		break;
+	}
+
+	Neighborhood::arriveAt(room, dir);
+
+	switch (MakeRoomView(room, dir)) {
+	case MakeRoomView(kWSC01, kWest):
+		if (!GameState.getWSCSeenTimeStream()) {
+			requestExtraSequence(kWSCArrivalFromTSA, kExtraCompletedFlag, kFilterNoInput);
+			requestExtraSequence(kWSCShotByRobot, 0, kFilterNoInput);
+			requestExtraSequence(kWSCDartScan1, kExtraCompletedFlag, kFilterNoInput);
+		} else if (GameState.getWSCPoisoned() && !GameState.getWSCAnsweredAboutDart()) {
+			setCurrentActivation(kActivationShotByRobot);
+		}
+		break;
+	case MakeRoomView(kWSC01, kEast):
+		if (GameState.getWSCDartInAnalyzer())
+			requestExtraSequence(kWSCDropDartIntoAnalyzer, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC02Morph, kSouth):
+		setCurrentActivation(kActivationMorphScreenOff);
+		break;
+	case MakeRoomView(kWSC03, kNorth):
+		setCurrentActivation(kActivationW03NorthOff);
+		break;
+	case MakeRoomView(kWSC03, kSouth):
+		if (GameState.getWSCDesignedAntidote() && !GameState.getWSCPickedUpAntidote())
+			setCurrentActivation(kActivationReadyForSynthesis);
+		break;
+	case MakeRoomView(kWSC16, kNorth):
+		if (getCurrentAlternate() == kAltWSCPeopleAtW19North) {
+			setCurrentAlternate(kAltWSCNormal);
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt19NorthFlag, true);
+		}
+		break;
+	case MakeRoomView(kWSC07, kSouth):
+	case MakeRoomView(kWSC56, kNorth):
+		setCurrentActivation(kActivationReadyForMap);
+		break;
+	case MakeRoomView(kWSC42, kWest):
+		setCurrentAlternate(kAltWSCNormal);
+		break;
+	case MakeRoomView(kWSC42, kEast):
+		_privateFlags.setFlag(kWSCPrivateSinclairOfficeOpenFlag, false);
+		setCurrentActivation(kActivationSinclairOfficeLocked);
+		break;
+	case MakeRoomView(kWSC58, kSouth):
+		setCurrentActivation(kActivationW58SouthDoorLocked);
+		_privateFlags.setFlag(kWSCPrivate58SouthOpenFlag, false);
+		break;
+	case MakeRoomView(kWSC60, kEast):
+		GameState.setScoringEnteredSinclairOffice();
+		break;
+	case MakeRoomView(kWSC61West, kWest):
+		setCurrentActivation(kActivationW61MessagesOff);
+		break;
+	case MakeRoomView(kWSC61South, kSouth):
+		setCurrentActivation(kActivationW61SouthOff);
+		break;
+	case MakeRoomView(kWSC62, kSouth):
+		if (!GameState.getWSCDidPlasmaDodge()) {
+			g_AIArea->lockAIOut();
+			loadLoopSound1("Sounds/World Science Center/Plasma Rock.22K.AIFF");
+			requestExtraSequence(kW62SouthPlasmaRobotAppears, 0, kFilterNoInput);
+			requestExtraSequence(kW62ZoomToRobot, 0, kFilterNoInput);
+			requestExtraSequence(kW62ZoomOutFromRobot, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case MakeRoomView(kWSC65Screen, kSouth):
+		if (!GameState.getWSCSeenSinclairLecture()) {
+			GameState.setWSCSeenSinclairLecture(true);
+			startExtraSequence(kW65SouthSinclairLecture, kExtraCompletedFlag, kFilterAllInput);
+		}	
+		break;
+	case MakeRoomView(kWSC66, kWest):
+	case MakeRoomView(kWSC67, kEast):
+		if (!GameState.getWSCHeardPage2()) {
+			playSpotSoundSync(kPaging2In, kPaging2Out);
+			GameState.setWSCHeardPage2(true);
+		}
+	case MakeRoomView(kWSC10, kNorth):
+	case MakeRoomView(kWSC26, kSouth):
+	case MakeRoomView(kWSC72, kWest):
+	case MakeRoomView(kWSC83, kWest):
+		if (!GameState.getWSCHeardCheckIn()) {
+			playSpotSoundSync(kCheckInIn, kCheckInOut);
+			GameState.setWSCHeardCheckIn(true);
+		}
+		break;
+	case MakeRoomView(kWSC0Z, kSouth):
+		if (getCurrentAlternate() == kAltWSCW0ZDoorOpen)
+			turnLeft();
+		break;
+	case MakeRoomView(kWSC93, kEast):
+		GameState.setWSCBeenAtWSC93(true);
+		break;
+	case MakeRoomView(kWSC98, kWest):
+		if (!GameState.getWSCRobotDead()) {
+			scheduleEvent(kGawkAtRobotTime2, 1, kTimerEventPlayerGawkingAtRobot2);
+			setCurrentActivation(kActivationRobotTurning);
+			if (g_AIArea)
+				g_AIArea->checkMiddleArea();
+		} else if (!GameState.getWSCRobotGone()) {
+			setCurrentActivation(kActivationRobotDead);
+		} else {
+			if (GameState.getWSCCatwalkDark()) {
+				//	Change the gun hot spot...
+				g_allHotspots.setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft,
+						99 + kNavAreaTop,372 + kNavAreaLeft, 149 + kNavAreaTop));
+			}
+			setCurrentActivation(kActivationRobotGone);
+		}
+		break;
+	case MakeRoomView(kWSCDeathRoom, kNorth):
+	case MakeRoomView(kWSCDeathRoom, kSouth):
+	case MakeRoomView(kWSCDeathRoom, kEast):
+	case MakeRoomView(kWSCDeathRoom, kWest):
+		die(kDeathArrestedInWSC);
+		break;
+	}
+
+	checkPeopleCrossing();
+	setUpPoison();
+}
+
+void WSC::turnTo(const tDirectionConstant direction) {
+	Neighborhood::turnTo(direction);
+
+	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
+	case MakeRoomView(kWSC01, kNorth):
+	case MakeRoomView(kWSC01, kSouth):
+		GameState.setWSCAnalyzerOn(false);
+		break;
+	case MakeRoomView(kWSC03, kNorth):
+		setCurrentActivation(kActivationW03NorthOff);
+		break;
+	case MakeRoomView(kWSC03, kSouth):
+		if (GameState.getWSCDesignedAntidote() && !GameState.getWSCPickedUpAntidote())
+			setCurrentActivation(kActivationReadyForSynthesis);
+		break;
+	case MakeRoomView(kWSC07, kSouth):
+	case MakeRoomView(kWSC56, kNorth):
+		setCurrentActivation(kActivationReadyForMap);
+		break;
+	case MakeRoomView(kWSC18, kSouth):
+	case MakeRoomView(kWSC57, kEast):
+	case MakeRoomView(kWSC75, kEast):
+	case MakeRoomView(kWSC90, kSouth):
+		if (!GameState.getWSCHeardCheckIn()) {
+			playSpotSoundSync(kCheckInIn, kCheckInOut);
+			GameState.setWSCHeardCheckIn(true);
+		}
+		break;
+	case MakeRoomView(kWSC56, kSouth):
+		if (!GameState.getWSCHeardPage1()) {
+			playSpotSoundSync(kPaging1In, kPaging1Out);
+			GameState.setWSCHeardPage1(true);
+		}
+		// clone2727 says: This falls through?!??! WTF?
+	case MakeRoomView(kWSC42, kEast):
+		_privateFlags.setFlag(kWSCPrivateSinclairOfficeOpenFlag, false);
+		setCurrentActivation(kActivationSinclairOfficeLocked);
+		break;
+	case MakeRoomView(kWSC58, kSouth):
+		setCurrentActivation(kActivationW58SouthDoorLocked);
+		_privateFlags.setFlag(kWSCPrivate58SouthOpenFlag, false);
+		break;
+	case MakeRoomView(kWSC73, kWest):
+		setCurrentAlternate(kAltWSCNormal);
+		break;
+	case MakeRoomView(kWSC0Z, kEast):
+		if (getCurrentAlternate() == kAltWSCW0ZDoorOpen)
+			startExtraSequence(kW0ZSpottedByWomen, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	}
+
+	checkPeopleCrossing();
+}
+
+void WSC::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	int32 currentEnergy;
+	Item *item;
+	
+	if (flags & kExtraCompletedFlag) {
+		_interruptionFilter = kFilterAllInput;
+
+		switch (_lastExtra) {
+		case kWSCArrivalFromTSA:
+			GameState.setWSCSeenTimeStream(true);
+			loadAmbientLoops();
+			break;
+		case kWSCDartScan1:
+			setCurrentActivation(kActivationShotByRobot);
+			GameState.setWSCPoisoned(true);
+			setUpPoison();
+			makeContinuePoint();
+			break;
+		case kWSCDartScan2:
+			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kPoisonDart));
+			GameState.setScoringRemovedDart();
+			GameState.setWSCRemovedDart(true);
+			setUpPoison();
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XW1WB2", false, kHintInterruption);
+			// Fall through...
+		case kWSCDartScanNo:
+			GameState.setWSCAnsweredAboutDart(true);
+			startExtraSequence(kWSCDartScan3, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kWSCDartScan3:
+			setCurrentActivation(kActivateHotSpotAlways);
+			break;
+		case kWSCAnalyzerPowerUp:
+		case kWSCAnalyzerPowerUpWithDart:
+			GameState.setWSCAnalyzerOn(true);
+			break;
+		case kWSCDropDartIntoAnalyzer:
+			setCurrentActivation(kActivationZoomedInToAnalyzer);
+			break;
+		case kWSCAnalyzeDart:
+			GameState.setWSCAnalyzedDart(true);
+			GameState.setScoringAnalyzedDart();
+			break;
+		case kWSCZoomOutFromAnalyzer:
+			setCurrentActivation(kActivateHotSpotAlways);
+			GameState.setWSCAnalyzerOn(false);
+			GameState.setWSCDartInAnalyzer(false);
+			updateViewFrame();
+			break;
+		case kMessagesMovedToOffice:
+		case kMessagesMovedToOfficeNoNitrogen:
+			_privateFlags.setFlag(kWSCPrivateLabMessagesOpenFlag, true);
+			GameState.setScoringPlayedWithMessages();
+			break;
+		case kMessagesOff:
+		case kMessagesOffNoNitrogen:
+			_privateFlags.setFlag(kWSCPrivateLabMessagesOpenFlag, false);
+			if (_cachedZoomSpot) {
+				zoomTo(_cachedZoomSpot);
+				_cachedZoomSpot = 0;
+			}
+			break;
+		case kWSC02TurnOnMorphScreen:
+			setCurrentActivation(kActivationReadyForMorph);
+			break;
+		case kWSC02DropToMorphExperiment:
+			loopExtraSequence(kWSC02MorphLoop, kExtraCompletedFlag);
+			setCurrentActivation(kActivationMorphLooping);
+			break;
+		case kWSC02MorphLoop:
+			if (_privateFlags.getFlag(kWSCPrivateInterruptedMorphFlag))
+				startExtraSequence(kWSC02MorphInterruption, kExtraCompletedFlag, kFilterNoInput);
+			else
+				scheduleNavCallBack(kExtraCompletedFlag);
+			break;
+		case kWSC02MorphInterruption:
+			setCurrentActivation(kActivationMorphInterrupted);
+			GameState.setScoringSawMorphExperiment();
+			break;
+		case kWSC02TurnOffMorphScreen:
+			setCurrentActivation(kActivationMorphScreenOff);
+			GameState.setWSCSawMorph(true);
+			break;
+		case kW03NorthActivate:
+			if (GameState.getWSCAnalyzedDart() && !GameState.getWSCDesignedAntidote())
+				startExtraSequence(kW03NorthGetData, kExtraCompletedFlag, kFilterNoInput);
+			else
+				setCurrentActivation(kActivateHotSpotAlways);
+			break;
+		case kW03NorthGetData:
+			setCurrentActivation(kActivationW03NorthReadyForInstructions);
+			break;
+		case kW03NorthInstructions:
+			setCurrentActivation(kActivationW03NorthSawInstructions);
+			break;
+		case kW03NorthPrepMolecule1:
+			setUpMoleculeGame();
+			break;
+		case kW03NorthPrepMolecule2:
+		case kW03NorthPrepMolecule3:
+			nextMoleculeGameLevel();
+			break;
+		case kW03NorthFinishSynthesis:
+			setCurrentActivation(kActivateHotSpotAlways);
+			_privateFlags.setFlag(kWSCPrivateInMoleculeGameFlag, false);
+			GameState.setWSCDesignedAntidote(true);
+			GameState.setScoringBuiltAntidote();
+			break;
+		case kW03SouthCreateAntidote:
+			setCurrentActivation(kActivationSynthesizerLooping);
+			loopExtraSequence(kW03SouthAntidoteLoop);
+			break;
+		case kW03SouthDeactivate:
+			setCurrentActivation(kActivateHotSpotAlways);
+			break;
+		case kWSC07SouthMap:
+		case kWSC56SouthMap:
+			setCurrentActivation(kActivateHotSpotAlways);
+			GameState.setScoringSawWSCDirectory();
+			break;
+		case kNerdAtTheDoor1:
+			GameState.setWSCSeenNerd(true);
+			break;
+		case kNerdAtTheDoor2:
+			die(kDeathArrestedInWSC);
+			break;
+		case kW61Brochure:
+			GameState.setScoringSawBrochure();
+			loadAmbientLoops();
+			break;
+		case kW61SouthSmartAlloysWithGun:
+		case kW61SouthSmartAlloysNoGun:
+			GameState.setScoringSawSinclairEntry1();
+			break;
+		case kW61SouthMorphingWithGun:
+		case kW61SouthMorphingNoGun:
+			GameState.setScoringSawSinclairEntry2();
+			break;
+		case kW61SouthTimeBendingWithGun:
+		case kW61SouthTimeBendingNoGun:
+			GameState.setScoringSawSinclairEntry3();
+			break;
+		case kW61MessagesOn:
+			GameState.setWSCOfficeMessagesOpen(true);
+			setCurrentActivation(kActivationW61MessagesOn);
+			break;
+		case kW61MessagesOff:
+			GameState.setWSCOfficeMessagesOpen(false);
+			setCurrentActivation(kActivationW61MessagesOff);
+			if (_cachedZoomSpot) {
+				zoomTo(_cachedZoomSpot);
+				_cachedZoomSpot = 0;
+			}
+			break;
+		case kW61SouthScreenOnWithGun:
+		case kW61SouthScreenOnNoGun:
+			_privateFlags.setFlag(kWSCPrivateOfficeLogOpenFlag, true);
+			setCurrentActivation(kActivationW61SouthOn);
+			break;
+		case kW61SouthScreenOffWithGun:
+		case kW61SouthScreenOffNoGun:
+			_privateFlags.setFlag(kWSCPrivateOfficeLogOpenFlag, false);
+			setCurrentActivation(kActivationW61SouthOff);
+			if (_cachedZoomSpot) {
+				zoomTo(_cachedZoomSpot);
+				_cachedZoomSpot = 0;
+			}
+			break;
+		case kW62ZoomOutFromRobot:
+			// Handle action queue before starting new movie sequences.
+			Neighborhood::receiveNotification(notification, flags);
+			_energyDrainRate = g_energyMonitor->getEnergyDrainRate();
+			g_energyMonitor->setEnergyDrainRate(0);
+			currentEnergy = g_energyMonitor->getCurrentEnergy();
+			_vm->setEnergyDeathReason(kDeathHitByPlasma);
+
+			if (GameState.getShieldOn())
+				currentEnergy -= kPlasmaEnergyWithShield;
+			else
+				currentEnergy -= kPlasmaEnergyNoShield;
+
+			if (currentEnergy <= 0)
+				startExtraSequence(kW62PlasmaDodgeDie, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kW62PlasmaDodgeSurvive, kExtraCompletedFlag, kFilterNoInput);
+
+			scheduleEvent(kPlasmaImpactTime, kOneTickPerSecond, kTimerEventPlasmaHit);
+			break;
+		case kW62PlasmaDodgeDie:
+			g_energyMonitor->setEnergyValue(0);
+			break;
+		case kW62PlasmaDodgeSurvive:
+			if (GameState.getShieldOn()) {
+				g_shield->setItemState(kShieldNormal);
+				g_energyMonitor->drainEnergy(kPlasmaEnergyWithShield);
+			} else {
+				g_energyMonitor->drainEnergy(kPlasmaEnergyNoShield);
+			}
+
+			g_energyMonitor->setEnergyDrainRate(_energyDrainRate);
+			g_AIArea->unlockAI();
+			GameState.setScoringFinishedPlasmaDodge();
+			GameState.setWSCDidPlasmaDodge(true);
+			restoreStriding(kWSC58, kSouth, kAltWSCNormal);
+			loadAmbientLoops();
+			break;
+		case kW0ZSpottedByWomen:
+			die(kDeathArrestedInWSC);
+			break;
+		case kW17WestPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt17WestFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt17WestFlag, false);
+			break;
+		case kW21SouthPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt21SouthFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt21SouthFlag, true);
+			break;
+		case kW24SouthPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt24SouthFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt24SouthFlag, true);
+			break;
+		case kW34EastPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt34EastFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt34EastFlag, true);
+			break;
+		case kW36WestPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt36WestFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt36WestFlag, true);
+			break;
+		case kW38NorthPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt38NorthFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt38NorthFlag, true);
+			break;
+		case kW46SouthPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt46SouthFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt46SouthFlag, true);
+			break;
+		case kW49NorthPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt49NorthFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt49NorthFlag, false);
+			break;
+		case kW73WestPeopleCrossing:
+			_privateFlags.setFlag(kWSCPrivateSeenPeopleAt73WestFlag, true);
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt73WestFlag, false);
+			break;
+		case kW95RobotShoots:
+		case kW98RobotShoots:
+			die(kDeathShotOnCatwalk);
+			break;
+		case kW98MorphsToRobot:
+			if (_argonSprite) {
+				delete _argonSprite; _argonSprite = 0;
+				startExtraSequence(kW98RobotGassed, kExtraCompletedFlag, kFilterNoInput);
+			} else if (_privateFlags.getFlag(kWSCPrivateClickedCatwalkCableFlag)) {
+				startExtraSequence(kW98RobotShocked, kExtraCompletedFlag, kFilterNoInput);
+			} else {
+				startExtraSequence(kW98RobotShoots, kExtraCompletedFlag, kFilterNoInput);
+			}
+			break;
+		case kW98RobotShocked:
+			GameState.setWSCCatwalkDark(true);
+			// Change the gun hot spot...
+			g_allHotspots.setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft, 99 + kNavAreaTop,
+					372 + kNavAreaLeft, 149 + kNavAreaTop));
+			setCurrentActivation(kActivationRobotDead);
+			GameState.setWSCRobotDead(true);
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
+			break;
+		case kW98RobotGassed:
+			item = (Item *)g_allItems.findItemByID(kArgonCanister);
+			_vm->addItemToInventory((InventoryItem *)item);
+			setCurrentActivation(kActivationRobotDead);
+			GameState.setWSCRobotDead(true);
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
+			break;
+		case kW98RobotHeadOpensLight:
+		case kW98RobotHeadOpensDark:
+			setCurrentActivation(kActivationWSCRobotHeadOpen);
+			_privateFlags.setFlag(kWSCPrivateRobotHeadOpenFlag, true);
+			break;
+		case kW98RobotHeadClosesDark:
+		case kW98RobotHeadClosesLight:
+			setCurrentActivation(kActivationRobotGone);
+			_privateFlags.setFlag(kWSCPrivateRobotHeadOpenFlag, false);
+			GameState.setWSCRobotGone(true);
+			break;
+		}
+	}
+
+	Neighborhood::receiveNotification(notification, flags);
+	g_AIArea->checkMiddleArea();
+}
+
+void WSC::timerExpired(const uint32 event) {
+	switch (event) {
+	case kTimerEventPlasmaHit:
+		if (GameState.getShieldOn())
+			g_shield->setItemState(kShieldPlasma);
+		break;
+	case kTimerEventPlayerGawkingAtRobot:
+		startExtraSequence(kW95RobotShoots, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kTimerEventPlayerGawkingAtRobot2:
+		startExtraSequence(kW98MorphsToRobot, kExtraCompletedFlag, kFilterAllInput);
+		break;
+	}
+}
+
+void WSC::setUpMoleculeGame() {
+	_privateFlags.setFlag(kWSCPrivateInMoleculeGameFlag, true);
+	setCurrentActivation(kActivationW03NorthInGame);
+	initOneMovie(&_moleculesMovie, "Images/World Science Center/Molecules.movie",
+			kWSCMoleculesMovieOrder, kMoleculesMovieLeft, kMoleculesMovieTop, true);
+	_moleculesMovie.redrawMovieWorld();
+	_moleculeBin.initMoleculeBin();
+	_moleculeGameLevel = 0;
+	nextMoleculeGameLevel();
+}
+
+void WSC::nextMoleculeGameLevel() {
+	_moleculeGameLevel++;
+
+	for (byte i = 0; i < 6; ++i)
+		_levelArray[i] = i;
+
+	_vm->shuffleArray((int32 *)_levelArray, 6);
+	_moleculeBin.setBinLayout(_levelArray);
+	startMoleculeGameLevel();
+}
+
+void WSC::startMoleculeGameLevel() {
+	_moleculeBin.resetBin();
+	_numCorrect = 0;
+	_moleculesMovie.stop();
+	_moleculesMovie.setFlags(0);
+	_moleculesMovie.setSegment(s_moleculeLoopTimes[0], s_moleculeLoopTimes[0] + kMoleculeLoopTime);
+	_moleculesMovie.setTime(s_moleculeLoopTimes[0]);
+	_moleculesMovie.setFlags(kLoopTimeBase);
+	_moleculesMovie.show();
+
+	switch (_moleculeGameLevel) {
+	case 1:
+		playSpotSoundSync(kWSCMolecule1In, kWSCMolecule1Out);
+		break;
+	case 2:
+		playSpotSoundSync(kWSCMolecule2In, kWSCMolecule2Out);
+		break;
+	case 3:
+		playSpotSoundSync(kWSCMolecule3In, kWSCMolecule3Out);
+		break;
+	}
+
+	_moleculesMovie.start();
+}
+
+void WSC::moleculeGameClick(const tHotSpotID id) {
+	uint32 molecule = id - kWSC03NorthMolecule1SpotID;
+
+	_moleculeBin.highlightMolecule(molecule);
+	_moleculeBin.selectMolecule(molecule);
+
+	if (molecule == _levelArray[_numCorrect]) {
+		playSpotSoundSync(kWSCClick2In, kWSCClick2Out);
+		_numCorrect++;
+		_moleculesMovie.stop();
+		_moleculesMovie.setFlags(0);
+
+		TimeValue time = _moleculesMovie.getTime();
+		_moleculesMovie.setSegment(s_moleculeLoopTimes[_numCorrect], s_moleculeLoopTimes[_numCorrect] + kMoleculeLoopTime);
+		_moleculesMovie.setTime(s_moleculeLoopTimes[_numCorrect] + time - s_moleculeLoopTimes[_numCorrect - 1]);
+
+		if (_numCorrect == 6) {
+			_moleculesMovie.start();
+
+			while (_moleculesMovie.isRunning()) {
+				_vm->checkCallBacks();
+				_vm->refreshDisplay();
+				_vm->_system->delayMillis(10);
+			}
+
+			_moleculesMovie.stop();
+			_moleculesMovie.hide();
+
+			switch (_moleculeGameLevel) {
+			case 1:
+				startExtraSequence(kW03NorthPrepMolecule2, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 2:
+				startExtraSequence(kW03NorthPrepMolecule3, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 3:
+				_moleculesMovie.releaseMovie();
+				_moleculeBin.cleanUpMoleculeBin();
+				requestExtraSequence(kW03NorthFinishSynthesis, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			}
+		} else {
+			_moleculesMovie.setFlags(kLoopTimeBase);
+			_moleculesMovie.start();
+		}
+	} else {
+		// FAIL
+		playSpotSoundSync(kWSCClick3In, kWSCClick3Out);
+
+		_moleculesMovie.stop();
+		_moleculesMovie.setFlags(0);
+		_moleculesMovie.start();
+
+		while (_moleculesMovie.isRunning()) {
+			_vm->checkCallBacks();
+			_vm->refreshDisplay();
+			_vm->_system->delayMillis(10);
+		}
+
+		_moleculesMovie.stop();
+		_moleculesMovie.setFlags(0);
+		_moleculesMovie.setSegment(s_moleculeFailTimes[_numCorrect], s_moleculeFailTimes[_numCorrect] + kMoleculeFailTime);
+		_moleculesMovie.setTime(s_moleculeFailTimes[_numCorrect]);
+		_moleculesMovie.start();
+
+
+		while (_moleculesMovie.isRunning()) {
+			_vm->checkCallBacks();
+			_vm->refreshDisplay();
+			_vm->_system->delayMillis(10);
+		}
+
+		_moleculesMovie.stop();
+		startMoleculeGameLevel();
+	}
+}
+
+void WSC::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
+	Neighborhood::activateOneHotspot(entry, hotspot);
+
+	Item *argonCanister;
+
+	switch (hotspot->getObjectID()) {
+	case kWSCTurnOnAnalyzerSpotID:
+		if (GameState.getWSCAnalyzerOn())
+			hotspot->setInactive();
+		break;
+	case kWSC02SouthTakeArgonSpotID:
+		if (!GameState.getWSCSawMorph() || GameState.isTakenItemID(kArgonCanister))
+			hotspot->setInactive();
+		break;
+	case kWSC02ActivateMorphScreenSpotID:
+		if (GameState.getWSCSawMorph())
+			hotspot->setInactive();
+		break;
+	case kWSC03NorthMolecule1SpotID:
+	case kWSC03NorthMolecule2SpotID:
+	case kWSC03NorthMolecule3SpotID:
+	case kWSC03NorthMolecule4SpotID:
+	case kWSC03NorthMolecule5SpotID:
+	case kWSC03NorthMolecule6SpotID:
+		if (_moleculeBin.isMoleculeHighlighted(hotspot->getObjectID() - kWSC03NorthMolecule1SpotID))
+			hotspot->setInactive();
+		break;
+	case kWSC03SouthPickUpAntidoteSpotID:
+		if (getCurrentActivation() == kActivationSynthesizerLooping)
+			hotspot->setActive();
+		break;
+	case kW98DropArgonSpotID:
+		argonCanister = g_allItems.findItemByID(kArgonCanister);
+		if (argonCanister->getItemState() != kArgonFull)
+			hotspot->setInactive();
+		break;
+	}
+}
+
+void WSC::activateHotspots() {
+	Neighborhood::activateHotspots();
+
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kWSC98, kWest) && _privateFlags.getFlag(kWSCPrivateRobotHeadOpenFlag)) {
+		if (_privateFlags.getFlag(kWSCPrivateGotRetScanChipFlag))
+			g_allHotspots.deactivateOneHotspot(kW98RetinalChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kW98RetinalChipSpotID);
+
+		if (_privateFlags.getFlag(kWSCPrivateGotMapChipFlag))
+			g_allHotspots.deactivateOneHotspot(kW98MapChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kW98MapChipSpotID);
+
+		if (_privateFlags.getFlag(kWSCPrivateGotOpticalChipFlag))
+			g_allHotspots.deactivateOneHotspot(kW98OpticalChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kW98OpticalChipSpotID);
+	}
+}
+
+void WSC::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
+	if (JMPPPInput::isEasterEggModifierInput(input))
+		GameState.setEasterEgg(true);
+
+	if (clickedSpot) {
+		switch (clickedSpot->getObjectID()) {
+		case kWSCAnalyzerScreenSpotID:
+			requestExtraSequence(kWSCAnalyzeDart, kExtraCompletedFlag, kFilterNoInput);
+			requestExtraSequence(kWSCZoomOutFromAnalyzer, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kWSC02SouthPlayMessagesSpotID:
+			if (GameState.isTakenItemID(kNitrogenCanister)) {
+				if (_lastExtra == (uint32)kMessagesMovedToOfficeNoNitrogen)
+					startExtraSequence(kMessagesOffNoNitrogen, kExtraCompletedFlag, kFilterNoInput);
+				else
+					startExtraSequence(kMessagesMovedToOfficeNoNitrogen, kExtraCompletedFlag, kFilterNoInput);
+			} else {
+				if (_lastExtra == (uint32)kMessagesMovedToOffice)
+					startExtraSequence(kMessagesOff, kExtraCompletedFlag, kFilterNoInput);
+				else
+					startExtraSequence(kMessagesMovedToOffice, kExtraCompletedFlag, kFilterNoInput);
+			}
+			break;
+		case kWSC02SouthInterruptMorphSpotID:
+			_privateFlags.setFlag(kWSCPrivateInterruptedMorphFlag, true);
+			break;
+		case kWSC02SouthMorphFinishedSpotID:
+			requestExtraSequence(kWSC02MorphFinished, 0, kFilterNoInput);
+			requestExtraSequence(kWSC02TurnOffMorphScreen, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kWSC03NorthMolecule1SpotID:
+		case kWSC03NorthMolecule2SpotID:
+		case kWSC03NorthMolecule3SpotID:
+		case kWSC03NorthMolecule4SpotID:
+		case kWSC03NorthMolecule5SpotID:
+		case kWSC03NorthMolecule6SpotID:
+			moleculeGameClick(clickedSpot->getObjectID());
+			break;
+		case kW98GrabCableSpotID:
+			if (isEventTimerRunning()) {
+				cancelEvent();
+				startExtraSequence(kW98MorphsToRobot, kExtraCompletedFlag, kFilterAllInput);
+			}
+
+			_privateFlags.setFlag(kWSCPrivateClickedCatwalkCableFlag, true);
+			break;
+		default:
+			Neighborhood::clickInHotspot(input, clickedSpot);
+			break;
+		}
+	} else {
+		Neighborhood::clickInHotspot(input, clickedSpot);
+	}
+	
+	GameState.setEasterEgg(false);
+}
+
+void WSC::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
+	tCoordType h, v;
+
+	switch (item->getObjectID()) {
+	case kPoisonDart:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		GameState.setWSCDartInAnalyzer(true);
+		if (dropSpot && dropSpot->getObjectID() == kWSCDropDartSpotID) {
+			if (!GameState.getWSCAnalyzerOn())
+				requestExtraSequence(kWSCAnalyzerPowerUpWithDart, kExtraCompletedFlag, kFilterNoInput);
+
+			requestExtraSequence(kWSCDropDartIntoAnalyzer, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kAntidote:
+		_privateFlags.setFlag(kWSCDraggingAntidoteFlag, false);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		loopExtraSequence(kW03SouthAntidoteLoop);
+		break;
+	case kSinclairKey:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		_privateFlags.setFlag(kWSCPrivateSinclairOfficeOpenFlag, true);
+		openDoor();
+		break;
+	case kCrowbar:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		_privateFlags.setFlag(kWSCPrivate58SouthOpenFlag, true);
+		openDoor();
+		break;
+	case kMachineGun:
+		setCurrentAlternate(kAltWSCNormal);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	case kArgonCanister:
+		item->setItemState(kArgonEmpty);
+		_argonSprite = item->getDragSprite(0);
+		_argonSprite->setCurrentFrameIndex(1);
+		_argonSprite->setDisplayOrder(kDragSpriteOrder);
+		dropSpot->getCenter(h, v);
+		_argonSprite->centerElementAt(h, v);
+		_argonSprite->startDisplaying();
+		_argonSprite->show();
+
+		if (isEventTimerRunning()) {
+			cancelEvent();
+			startExtraSequence(kW98MorphsToRobot, kExtraCompletedFlag, kFilterAllInput);
+		}
+		break;
+	case kRetinalScanBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotRetScanChipFlag, false);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	case kMapBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotMapChipFlag, false);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	case kOpticalBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotOpticalChipFlag, false);
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	default:
+		Neighborhood::dropItemIntoRoom(item, dropSpot);
+		break;
+	}
+}
+
+void WSC::takeItemFromRoom(Item *item) {
+	switch (item->getObjectID()) {
+	case kAntidote:
+		_privateFlags.setFlag(kWSCDraggingAntidoteFlag, true);
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	case kMachineGun:
+		setCurrentAlternate(kAltWSCTookMachineGun);
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	case kRetinalScanBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotRetScanChipFlag, true);
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	case kMapBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotMapChipFlag, true);
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	case kOpticalBiochip:
+		_privateFlags.setFlag(kWSCPrivateGotOpticalChipFlag, true);
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	default:
+		Neighborhood::takeItemFromRoom(item);
+		break;
+	}
+}
+
+Hotspot *WSC::getItemScreenSpot(Item *item, DisplayElement *element) {
+	tHotSpotID destSpotID;
+	
+	switch (item->getObjectID()) {
+	case kNitrogenCanister:
+		destSpotID = kWSC02SouthTakeNitrogenSpotID;
+		break;
+	case kArgonPickup:
+		destSpotID = kWSC02SouthTakeArgonSpotID;
+		break;
+	case kAntidote:
+		destSpotID = kWSC03SouthPickUpAntidoteSpotID;
+		break;
+	case kMachineGun:
+		destSpotID = kW61SouthMachineGunSpotID;
+		break;
+	case kRetinalScanBiochip:
+		destSpotID = kW98RetinalChipSpotID;
+		break;
+	case kMapBiochip:
+		destSpotID = kW98MapChipSpotID;
+		break;
+	case kOpticalBiochip:
+		destSpotID = kW98OpticalChipSpotID;
+		break;
+	default:
+		destSpotID = kNoHotSpotID;
+		break;
+	}
+
+	if (destSpotID == kNoHotSpotID)
+		return Neighborhood::getItemScreenSpot(item, element);
+
+	return g_allHotspots.findHotspotByID(destSpotID);
+}
+
+void WSC::pickedUpItem(Item *item) {	
+	switch (item->getObjectID()) {
+	case kAntidote:
+		if (!GameState.getWSCPickedUpAntidote()) {
+			GameState.setWSCPoisoned(false);
+			GameState.setWSCRemovedDart(false);
+			GameState.setWSCPickedUpAntidote(true);
+			_privateFlags.setFlag(kWSCDraggingAntidoteFlag, false);
+			playSpotSoundSync(kDrinkAntidoteIn, kDrinkAntidoteOut);
+			setUpPoison();
+			startExtraSequence(kW03SouthDeactivate, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kArgonPickup:
+		_vm->removeItemFromInventory((InventoryItem *)item);
+		item = (Item *)g_allItems.findItemByID(kArgonCanister);
+		_vm->addItemToInventory((InventoryItem *)item);
+		item = (Item *)g_allItems.findItemByID(kSinclairKey);
+		_vm->addItemToInventory((InventoryItem *)item);
+		g_allHotspots.setHotspotRect(kWSC02SouthMorphOutSpotID,
+				Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
+		break;
+	case kArgonCanister:
+		GameState.setScoringGotArgonCanister();
+		break;
+	case kSinclairKey:
+		GameState.setScoringGotSinclairKey();
+		break;
+	case kNitrogenCanister:
+		GameState.setScoringGotNitrogenCanister();
+		break;
+	case kRetinalScanBiochip:
+		if (_privateFlags.getFlag(kWSCPrivateGotMapChipFlag) && _privateFlags.getFlag(kWSCPrivateGotOpticalChipFlag)) {
+			if (GameState.getWSCCatwalkDark())
+				startExtraSequence(kW98RobotHeadClosesDark, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kW98RobotHeadClosesLight, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kMapBiochip:
+		if (_privateFlags.getFlag(kWSCPrivateGotRetScanChipFlag) && _privateFlags.getFlag(kWSCPrivateGotOpticalChipFlag)) {
+			if (GameState.getWSCCatwalkDark())
+				startExtraSequence(kW98RobotHeadClosesDark, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kW98RobotHeadClosesLight, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kOpticalBiochip:
+		g_opticalChip->addMercury();
+		GameState.setScoringGotWSCOpMemChip();
+		if (_privateFlags.getFlag(kWSCPrivateGotRetScanChipFlag) && _privateFlags.getFlag(kWSCPrivateGotMapChipFlag)) {
+			if (GameState.getWSCCatwalkDark())
+				startExtraSequence(kW98RobotHeadClosesDark, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kW98RobotHeadClosesLight, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kStunGun:
+		GameState.setWSCFinished(true);
+
+		if (!GameState.getWSCCatwalkDark())
+			GameState.setScoringWSCGandhi();
+
+		recallToTSASuccess();
+		break;
+	}
+}
+
+void WSC::checkPeopleCrossing() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kWSC17, kWest):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt17WestFlag))
+			startExtraSequence(kW17WestPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC21, kSouth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt21SouthFlag))
+			startExtraSequence(kW21SouthPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC24, kSouth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt24SouthFlag))
+			startExtraSequence(kW24SouthPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC34, kEast):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt34EastFlag))
+			startExtraSequence(kW34EastPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC36, kWest):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt36WestFlag))
+			startExtraSequence(kW36WestPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC38, kNorth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt38NorthFlag))
+			startExtraSequence(kW38NorthPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC46, kSouth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt46SouthFlag))
+			startExtraSequence(kW46SouthPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC49, kNorth):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt49NorthFlag))
+			startExtraSequence(kW49NorthPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kWSC73, kWest):
+		if (_privateFlags.getFlag(kWSCPrivateNeedPeopleAt73WestFlag))
+			startExtraSequence(kW73WestPeopleCrossing, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt21SouthFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt21SouthFlag, true);
+			forceStridingStop(kWSC18, kSouth, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt21SouthFlag, false);
+			restoreStriding(kWSC18, kSouth, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt19NorthFlag) && _vm->getRandomNumber(2) == 0) {
+			forceStridingStop(kWSC22, kNorth, kAltWSCNormal);
+		} else {
+			restoreStriding(kWSC22, kNorth, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt24SouthFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt24SouthFlag, true);
+			forceStridingStop(kWSC22, kSouth, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt24SouthFlag, false);
+			restoreStriding(kWSC22, kSouth, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt34EastFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt34EastFlag, true);
+			forceStridingStop(kWSC28, kEast, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt34EastFlag, false);
+			restoreStriding(kWSC28, kEast, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt36WestFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt36WestFlag, true);
+			forceStridingStop(kWSC40, kWest, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt36WestFlag, false);
+			restoreStriding(kWSC40, kWest, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt38NorthFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt38NorthFlag, true);
+			forceStridingStop(kWSC42, kNorth, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt38NorthFlag, false);
+			restoreStriding(kWSC42, kNorth, kAltWSCNormal);
+		}
+
+		if (!_privateFlags.getFlag(kWSCPrivateSeenPeopleAt46SouthFlag) && _vm->getRandomNumber(2) == 0) {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt46SouthFlag, true);
+			forceStridingStop(kWSC44, kSouth, kAltWSCNormal);
+		} else {
+			_privateFlags.setFlag(kWSCPrivateNeedPeopleAt46SouthFlag, false);
+			restoreStriding(kWSC44, kSouth, kAltWSCNormal);
+		}
+		break;
+	}
+}
+
+void WSC::setUpPoison() {
+	if (GameState.getWSCPoisoned()) {
+		if (GameState.getWSCRemovedDart()) {
+			if (g_energyMonitor->getEnergyDrainRate() != kWSCPoisonEnergyDrainNoDart) {
+				g_energyMonitor->setEnergyDrainRate(kWSCPoisonEnergyDrainNoDart);
+				_vm->setEnergyDeathReason(kDeathDidntStopPoison);
+			}
+		} else {
+			if (g_energyMonitor->getEnergyDrainRate() != kWSCPoisonEnergyDrainWithDart) {
+				g_energyMonitor->setEnergyDrainRate(kWSCPoisonEnergyDrainWithDart);
+				_vm->setEnergyDeathReason(kDeathDidntStopPoison);
+			}
+		}
+	} else if (g_energyMonitor->getEnergyDrainRate() != kEnergyDrainNormal) {
+		g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
+		_vm->resetEnergyDeathReason();
+	}
+}
+
+bool WSC::inSynthesizerGame() {
+	return _moleculesMovie.isMovieValid();
+}
+
+bool WSC::canSolve() {
+	return (inSynthesizerGame() || (GameState.getCurrentRoom() == kWSC98 && !GameState.getWSCRobotDead()));
+}
+
+void WSC::doSolve() {
+	if (inSynthesizerGame()) {
+		_moleculesMovie.releaseMovie();
+		_moleculeBin.cleanUpMoleculeBin();
+		requestExtraSequence(kW03NorthFinishSynthesis, kExtraCompletedFlag, kFilterNoInput);
+	} else if (GameState.getCurrentRoom() == kWSC98 && !GameState.getWSCRobotDead()) {
+		cancelEvent();
+		startExtraSequence(kW98RobotShocked, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+Common::String WSC::getNavMovieName() {
+	return "Images/World Science Center/WSC.movie";
+}
+
+Common::String WSC::getSoundSpotsName() {
+	return "Sounds/World Science Center/WSC Spots";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/wsc/wsc.h b/engines/pegasus/neighborhood/wsc/wsc.h
new file mode 100755
index 0000000..554c2f7
--- /dev/null
+++ b/engines/pegasus/neighborhood/wsc/wsc.h
@@ -0,0 +1,163 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_WSC_WSC_H
+#define PEGASUS_NEIGHBORHOOD_WSC_WSC_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/wsc/moleculebin.h"
+
+namespace Pegasus {
+
+const tDisplayOrder kWSCMoleculeBinOrder = kMonitorLayer;
+const tDisplayOrder kWSCMoleculesMovieOrder = kWSCMoleculeBinOrder + 1;
+
+const tRoomID kWSC01 = 0;
+
+class WSC : public Neighborhood {
+public:
+	WSC(InputHandler *, PegasusEngine *);
+	virtual ~WSC() {}
+
+	void flushGameState();
+
+	virtual uint16 getDateResID() const;
+
+	bool okayToJump();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+	
+	bool inSynthesizerGame();
+	
+	bool canSolve();
+	void doSolve();
+	
+	virtual void prepareForAIHint(const Common::String &);
+	virtual void cleanUpAfterAIHint(const Common::String &);
+
+	void init();
+	void start();
+
+protected:
+	enum {
+		kWSCDraggingAntidoteFlag,
+		
+		kWSCPrivateLabMessagesOpenFlag,
+		kWSCPrivateInterruptedMorphFlag,
+		kWSCPrivateInMoleculeGameFlag,
+		kWSCPrivateSinclairOfficeOpenFlag,
+		kWSCPrivateOfficeLogOpenFlag,
+		kWSCPrivate58SouthOpenFlag,
+		kWSCPrivateClickedCatwalkCableFlag,
+		kWSCPrivateRobotHeadOpenFlag,
+		
+		kWSCPrivateSeenPeopleAt17WestFlag,
+		kWSCPrivateSeenPeopleAt19NorthFlag,
+		kWSCPrivateSeenPeopleAt21SouthFlag,
+		kWSCPrivateSeenPeopleAt24SouthFlag,
+		kWSCPrivateSeenPeopleAt34EastFlag,
+		kWSCPrivateSeenPeopleAt36WestFlag,
+		kWSCPrivateSeenPeopleAt38NorthFlag,
+		kWSCPrivateSeenPeopleAt46SouthFlag,
+		kWSCPrivateSeenPeopleAt49NorthFlag,
+		kWSCPrivateSeenPeopleAt73WestFlag,
+		
+		kWSCPrivateNeedPeopleAt17WestFlag,
+		kWSCPrivateNeedPeopleAt21SouthFlag,
+		kWSCPrivateNeedPeopleAt24SouthFlag,
+		kWSCPrivateNeedPeopleAt34EastFlag,
+		kWSCPrivateNeedPeopleAt36WestFlag,
+		kWSCPrivateNeedPeopleAt38NorthFlag,
+		kWSCPrivateNeedPeopleAt46SouthFlag,
+		kWSCPrivateNeedPeopleAt49NorthFlag,
+		kWSCPrivateNeedPeopleAt73WestFlag,
+		
+		kWSCPrivateGotRetScanChipFlag,
+		kWSCPrivateGotMapChipFlag,
+		kWSCPrivateGotOpticalChipFlag,
+		
+		kNumWSCPrivateFlags
+	};
+
+	void arriveAt(const tRoomID, const tDirectionConstant);
+	void turnTo(const tDirectionConstant);
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void clickInHotspot(const Input &, const Hotspot *);
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
+	tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
+	void cantMoveThatWay(tCanMoveForwardReason reason);
+	tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
+	void zoomTo(const Hotspot *hotspot);
+	void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
+	void setUpMoleculeGame();
+	void nextMoleculeGameLevel();
+	void startMoleculeGameLevel();
+	void moleculeGameClick(const tHotSpotID);
+	void loadAmbientLoops();
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	void cantOpenDoor(tCanOpenDoorReason);
+	void pickedUpItem(Item *);
+	void doorOpened();
+	void startExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits);
+	void getExtraEntry(const uint32, ExtraTable::Entry &);
+	void takeItemFromRoom(Item *item);
+	void checkPeopleCrossing();
+	void turnLeft();
+	void turnRight();
+	void moveForward();
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove);
+	void getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove);
+	void bumpIntoWall();
+	void activateHotspots();
+	void setUpAIRules();
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	void setUpPoison();
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	void timerExpired(const uint32);
+
+	Common::String getSoundSpotsName();
+	Common::String getNavMovieName();
+
+	FlagsArray<byte, kNumWSCPrivateFlags> _privateFlags;
+	const Hotspot *_cachedZoomSpot;
+	MoleculeBin _moleculeBin;
+	int32 _moleculeGameLevel, _numCorrect;
+	Movie _moleculesMovie;
+	uint32 _levelArray[6];
+	Common::Rational _energyDrainRate;
+	Sprite *_argonSprite;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 6536c30..ec7ed6c 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -65,6 +65,7 @@
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
+#include "pegasus/neighborhood/wsc/wsc.h"
 
 namespace Pegasus {
 
@@ -1356,6 +1357,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kTinyTSAID:
 		neighborhood = new TinyTSA(g_AIArea, this);
 		break;
+	case kWSCID:
+		neighborhood = new WSC(g_AIArea, this);
+		break;
 	default:
 		error("Unhandled neighborhood %d", neighborhoodID);
 	}
@@ -1857,6 +1861,20 @@ uint PegasusEngine::getRandomBit() {
 	return _rnd->getRandomBit();
 }
 
+uint PegasusEngine::getRandomNumber(uint max) {
+	return _rnd->getRandomNumber(max);
+}
+
+void PegasusEngine::shuffleArray(int32 *arr, int32 count) {	
+	if (count > 1) {
+		for (int32 i = 1; i < count; ++i) {
+			int32 j = _rnd->getRandomNumber(i);
+			if (j != i)
+				SWAP(arr[i], arr[j]);
+		}
+	}
+}
+
 void PegasusEngine::playEndMessage() {
 	if (g_interface) {
 		allowInput(false);
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 934d5c5..e3a933a 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -107,6 +107,8 @@ public:
 	void setGameMode(const tGameMode);
 	tGameMode getGameMode() const { return _gameMode; }
 	uint getRandomBit();
+	uint getRandomNumber(uint max);
+	void shuffleArray(int32 *arr, int32 count);
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
index a4c9a35..9f4ad57 100755
--- a/engines/pegasus/util.cpp
+++ b/engines/pegasus/util.cpp
@@ -87,14 +87,4 @@ int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1,
 		return start2 + pegasusRound((current1 - start1) * (stop2 - start2), (stop1 - start1));
 }
 
-void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random) {	
-	if (count > 1) {
-		for (int32 i = 1; i < count; ++i) {
-			int32 j = random.getRandomNumber(i);
-			if (j != i)
-				SWAP(arr[i], arr[j]);
-		}
-	}
-}
-
 } // End of namespace Pegasus
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index 6369c49..de2deb7 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -126,8 +126,6 @@ private:
 
 int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1, const int32 start2, const int32 stop2);
 
-void shuffleArray(int32 *arr, int32 count, Common::RandomSource &random);
-
 int32 pegasusRound(const int32 a, const int32 b);
 
 } // End of namespace Pegasus


Commit: c9f31d3c6ebe2776b117472d9e9603d70947d76f
    https://github.com/scummvm/scummvm/commit/c9f31d3c6ebe2776b117472d9e9603d70947d76f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-14T07:54:59-07:00

Commit Message:
PEGASUS: Fix drawing WSC molecules

Changed paths:
    engines/pegasus/neighborhood/wsc/moleculebin.cpp



diff --git a/engines/pegasus/neighborhood/wsc/moleculebin.cpp b/engines/pegasus/neighborhood/wsc/moleculebin.cpp
index 8785005..429902d 100755
--- a/engines/pegasus/neighborhood/wsc/moleculebin.cpp
+++ b/engines/pegasus/neighborhood/wsc/moleculebin.cpp
@@ -106,7 +106,7 @@ void MoleculeBin::draw(const Common::Rect &) {
 		if (_moleculeFlags.getFlag(_binLayout[i]))
 			r1.translate(kMoleculeWidth, 0);
 
-		r1.moveTo((_binLayout[i] & 1) * (kMoleculeWidth + 2) + _bounds.left + 2,
+		r2.moveTo((_binLayout[i] & 1) * (kMoleculeWidth + 2) + _bounds.left + 2,
 				(_binLayout[i] >> 1) * (kMoleculeHeight + 2) + _bounds.top + 2);
 
 		_binImages.copyToCurrentPort(r1, r2);


Commit: 64656342a999f2fcc6d4b0c8fd789e44aa2048ba
    https://github.com/scummvm/scummvm/commit/64656342a999f2fcc6d4b0c8fd789e44aa2048ba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-14T13:08:34-07:00

Commit Message:
PEGASUS: Add the Mars reactor element code

Changed paths:
  A engines/pegasus/neighborhood/mars/reactor.cpp
  A engines/pegasus/neighborhood/mars/reactor.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index cf1dcb8..0166443 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -57,6 +57,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
+	neighborhood/mars/reactor.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/neighborhood/mars/reactor.cpp b/engines/pegasus/neighborhood/mars/reactor.cpp
new file mode 100755
index 0000000..dd44fc4
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/reactor.cpp
@@ -0,0 +1,298 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * aint32 with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/reactor.h"
+
+namespace Pegasus {
+
+static const tCoordType kCurrentGuessWidth = 121;
+static const tCoordType kCurrentGuessHeight = 23;
+
+static const tCoordType kOneGuessWidth = 25;
+static const tCoordType kOneGuessHeight = 23;
+
+static const tResIDType kReactorChoicesPICTID = 905;
+
+static const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+static const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
+
+ReactorGuess::ReactorGuess(const tDisplayElementID id) : DisplayElement(id) {
+	setBounds(kCurrentGuessLeft, kCurrentGuessTop, kCurrentGuessLeft + kCurrentGuessWidth,
+			kCurrentGuessTop + kCurrentGuessHeight);
+	setDisplayOrder(kMonitorLayer);
+	_currentGuess[0] = -1;
+	_currentGuess[1] = -1;
+	_currentGuess[2] = -1;
+}
+
+void ReactorGuess::initReactorGuess() {
+	_colors.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kReactorChoicesPICTID);
+	startDisplaying();
+	show();
+}
+
+void ReactorGuess::disposeReactorGuess() {
+	stopDisplaying();
+	_colors.deallocateSurface();
+}
+
+void ReactorGuess::setGuess(int32 a, int32 b, int32 c) {
+	_currentGuess[0] = a;
+	_currentGuess[1] = b;
+	_currentGuess[2] = c;
+	triggerRedraw();
+}
+
+void ReactorGuess::draw(const Common::Rect &) {	
+	if (_colors.isSurfaceValid()) {
+		Common::Rect r1(0, 0, kOneGuessWidth, kOneGuessHeight);
+		Common::Rect r2 = r1;
+
+		for (int i = 0; i < 3; i++) {
+			if (_currentGuess[i] >= 0) {
+				r1.moveTo(kOneGuessWidth * _currentGuess[i], 0);
+				r2.moveTo(kCurrentGuessLeft + 48 * i, kCurrentGuessTop);
+				_colors.copyToCurrentPortTransparent(r1, r2);
+			}
+		}
+	}
+}
+
+static const tCoordType kReactorChoiceHiliteWidth = 166;
+static const tCoordType kReactorChoiceHiliteHeight = 26;
+
+static const tCoordType kChoiceHiliteLefts[6] = {
+	0,
+	34,
+	34 + 34,
+	34 + 34 + 32,
+	34 + 34 + 32 + 34,
+	34 + 34 + 32 + 34 + 32
+};
+
+static const tResIDType kReactorChoiceHilitePICTID = 901;
+
+static const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+static const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+
+ReactorChoiceHighlight::ReactorChoiceHighlight(const tDisplayElementID id) : DisplayElement(id) {
+	setBounds(kReactorChoiceHiliteLeft, kReactorChoiceHiliteTop, kReactorChoiceHiliteLeft + kReactorChoiceHiliteWidth,
+			kReactorChoiceHiliteTop + kReactorChoiceHiliteHeight);
+	setDisplayOrder(kMonitorLayer);
+}
+
+void ReactorChoiceHighlight::initReactorChoiceHighlight() {
+	_colors.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kReactorChoiceHilitePICTID);
+	startDisplaying();
+	show();
+}
+
+void ReactorChoiceHighlight::disposeReactorChoiceHighlight() {
+	stopDisplaying();
+	_colors.deallocateSurface();
+}
+
+void ReactorChoiceHighlight::draw(const Common::Rect &) {	
+	if (_colors.isSurfaceValid()) {
+		for (int i = 0; i < 5; ++i) {
+			if (_choices.getFlag(i)) {
+				Common::Rect r1(0, 0, kChoiceHiliteLefts[i + 1] - kChoiceHiliteLefts[i], kReactorChoiceHiliteHeight);
+				Common::Rect r2 = r1;
+				r1.moveTo(kChoiceHiliteLefts[i], 0);
+				r2.moveTo(kReactorChoiceHiliteLeft + kChoiceHiliteLefts[i], kReactorChoiceHiliteTop);
+				_colors.copyToCurrentPort(r1, r2);
+			}
+		}
+	}
+}
+
+static const tCoordType kReactorHistoryWidth = 128;
+static const tCoordType kReactorHistoryHeight = 168;
+
+static const tCoordType kColorWidths[5] = {24, 25, 25, 26, 27};
+static const tCoordType kColorHeights[5] = {14, 15, 17, 17, 19};
+
+// TODO: Remove global construction
+static const tCoordType kColorTops[5] = {
+	0,
+	kColorHeights[0],
+	kColorHeights[0] + kColorHeights[1],
+	kColorHeights[0] + kColorHeights[1] + kColorHeights[2],
+	kColorHeights[0] + kColorHeights[1] + kColorHeights[2] + kColorHeights[3],
+};
+
+static const tCoordType kHistoryLefts[5][3] = {
+	{ 302 + kNavAreaLeft, 329 + kNavAreaLeft, 357 + kNavAreaLeft },
+	{ 302 + kNavAreaLeft, 331 + kNavAreaLeft, 360 + kNavAreaLeft },
+	{ 303 + kNavAreaLeft, 333 + kNavAreaLeft, 363 + kNavAreaLeft },
+	{ 304 + kNavAreaLeft, 335 + kNavAreaLeft, 366 + kNavAreaLeft },
+	{ 305 + kNavAreaLeft, 337 + kNavAreaLeft, 369 + kNavAreaLeft }
+};
+
+static const tCoordType kHistoryTops[5] = {
+	39 + kNavAreaTop,
+	61 + kNavAreaTop,
+	84 + kNavAreaTop,
+	110 + kNavAreaTop,
+	137 + kNavAreaTop
+};
+
+static const tCoordType kOneAnswerWidth = 35;
+static const tCoordType kOneAnswerHeight = 27;
+
+static const tCoordType kDigitWidth = 16;
+static const tCoordType kDigitHeight = 12;
+
+static const tCoordType kCorrectCountLefts[5] = {
+	388 + kNavAreaLeft,
+	392 + kNavAreaLeft,
+	398 + kNavAreaLeft,
+	402 + kNavAreaLeft,
+	406 + kNavAreaLeft
+};
+
+static const tCoordType kCorrectCountTops[5] = {
+	40 + kNavAreaTop,
+	62 + kNavAreaTop,
+	86 + kNavAreaTop,
+	112 + kNavAreaTop,
+	140 + kNavAreaTop
+};
+
+static const tResIDType kReactorDigitsPICTID = 902;
+static const tResIDType kReactorHistoryPICTID = 903;
+static const tResIDType kReactorAnswerPICTID = 904;
+
+static const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+static const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
+
+static const tCoordType kAnswerLeft = kNavAreaLeft + 304;
+static const tCoordType kAnswerTop = kNavAreaTop + 180;
+
+ReactorHistory::ReactorHistory(const tDisplayElementID id) : DisplayElement(id) {
+	setBounds(kReactorHistoryLeft, kReactorHistoryTop, kReactorHistoryLeft + kReactorHistoryWidth,
+			kReactorHistoryTop + kReactorHistoryHeight);
+	setDisplayOrder(kMonitorLayer);
+	_numGuesses = 0;
+	_answer[0] = -1;
+	_answer[1] = -1;
+	_answer[2] = -1;
+	_showAnswer = false;
+}
+
+void ReactorHistory::initReactorHistory() {
+	_colors.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kReactorHistoryPICTID);
+	_digits.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kReactorDigitsPICTID);
+	_answerColors.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kReactorAnswerPICTID);
+	startDisplaying();
+	show();
+}
+
+void ReactorHistory::disposeReactorHistory() {
+	stopDisplaying();
+	_colors.deallocateSurface();
+}
+
+void ReactorHistory::addGuess(int32 a, int32 b, int32 c) {
+	_history[_numGuesses][0] = a;
+	_history[_numGuesses][1] = b;
+	_history[_numGuesses][2] = c;
+	_numGuesses++;
+	triggerRedraw();
+}
+
+void ReactorHistory::clearHistory() {
+	_numGuesses = 0;
+	_showAnswer = false;
+	triggerRedraw();
+}
+
+void ReactorHistory::setAnswer(int32 a, int32 b, int32 c) {
+	_answer[0] = a;
+	_answer[1] = b;
+	_answer[2] = c;
+}
+
+void ReactorHistory::showAnswer() {
+	_showAnswer = true;
+	triggerRedraw();
+}
+
+bool ReactorHistory::isSolved() {	
+	for (int i = 0; i < _numGuesses; i++)
+		if (_history[i][0] == _answer[0] && _history[i][1] == _answer[1] && _history[i][2] == _answer[2])
+			return true;
+
+	return false;
+}
+
+void ReactorHistory::draw(const Common::Rect &) {	
+	if (_colors.isSurfaceValid() && _digits.isSurfaceValid()) {
+		for (int i = 0; i < _numGuesses; ++i) {
+			Common::Rect r1(0, 0, kColorWidths[i], kColorHeights[i]);
+			Common::Rect r2 = r1;
+			Common::Rect r3(0, 0, kDigitWidth, kDigitHeight);
+			Common::Rect r4 = r3;
+			int correct = 0;
+
+			for (int j = 0; j < 3; ++j) {
+				r1.moveTo(kColorWidths[i] * _history[i][j], kColorTops[i]);
+				r2.moveTo(kHistoryLefts[i][j], kHistoryTops[i]);
+				_colors.copyToCurrentPortTransparent(r1, r2);
+
+				if (_history[i][j] == _answer[j])
+					correct++;
+			}
+
+			r3.moveTo(kDigitWidth * correct, 0);
+			r4.moveTo(kCorrectCountLefts[i], kCorrectCountTops[i]);
+			_digits.copyToCurrentPort(r3, r4);
+		}
+
+		if (_showAnswer && _answerColors.isSurfaceValid()) {
+			Common::Rect r1(0, 0, kOneAnswerWidth, kOneAnswerHeight);
+			Common::Rect r2 = r1;
+
+			for (int i = 0; i < 3; i++) {
+				r1.moveTo(kOneAnswerWidth * _answer[i], 0);
+				r2.moveTo(kAnswerLeft + 34 * i, kAnswerTop);
+				_answerColors.copyToCurrentPortTransparent(r1, r2);
+			}
+		}
+	}
+}
+
+int32 ReactorHistory::getCurrentNumCorrect() {	
+	int correct = 0;
+
+	for (int i = 0; i < 3; i++)
+		if (_history[_numGuesses - 1][i] == _answer[i])
+			correct++;
+
+	return correct;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/reactor.h b/engines/pegasus/neighborhood/mars/reactor.h
new file mode 100755
index 0000000..6719701
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/reactor.h
@@ -0,0 +1,108 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_REACTOR_H
+#define PEGASUS_NEIGHBORHOOD_MARS_REACTOR_H
+
+#include "pegasus/elements.h"
+#include "pegasus/surface.h"
+#include "pegasus/util.h"
+
+namespace Pegasus {
+
+class ReactorGuess : public DisplayElement {
+public:
+	ReactorGuess(const tDisplayElementID);
+	virtual ~ReactorGuess() {}
+
+	void initReactorGuess();
+	void disposeReactorGuess();
+
+	void setGuess(int32, int32, int32);
+
+	void draw(const Common::Rect &);
+
+protected:
+	int32 _currentGuess[3];
+
+	Surface _colors;
+};
+
+class ReactorChoiceHighlight : public DisplayElement {
+public:
+	ReactorChoiceHighlight(const tDisplayElementID);
+	virtual ~ReactorChoiceHighlight() {}
+
+	void initReactorChoiceHighlight();
+	void disposeReactorChoiceHighlight();
+
+	void resetHighlight() {
+		_choices.clearAllFlags();
+		triggerRedraw();
+	}
+
+	bool choiceHighlighted(uint32 whichChoice) { return _choices.getFlag(whichChoice); }
+
+	void draw(const Common::Rect &);
+
+	void highlightChoice(uint32 whichChoice) {
+		_choices.setFlag(whichChoice);
+		triggerRedraw();
+	}
+
+protected:
+	Surface _colors;
+	FlagsArray<byte, 5> _choices;
+};
+
+class ReactorHistory : public DisplayElement {
+public:
+	ReactorHistory(const tDisplayElementID);
+	virtual ~ReactorHistory() {}
+
+	void initReactorHistory();
+	void disposeReactorHistory();
+
+	void draw(const Common::Rect &);
+
+	void addGuess(int32, int32, int32);
+	int32 getNumGuesses() { return _numGuesses; }
+	void clearHistory();
+	void setAnswer(int32, int32, int32);
+	void showAnswer();
+	bool isSolved();
+	int32 getCurrentNumCorrect();
+
+protected:
+	Surface _colors, _digits, _answerColors;
+	int32 _answer[3];
+	int32 _history[5][3];
+	int32 _numGuesses;
+	bool _showAnswer;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 1c949d375a4f0dabb179e0e035bb3dbf8c059abf
    https://github.com/scummvm/scummvm/commit/1c949d375a4f0dabb179e0e035bb3dbf8c059abf
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-15T16:48:36-07:00

Commit Message:
PEGASUS: Add the Mars neighborhood

Does not include the space chase just yet or canyon chase.

The robot timer seems a bit wonky right now and doesn't stop, but everything else seems to be working.

Changed paths:
  A engines/pegasus/neighborhood/mars/mars.cpp
  A engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/constants.h
    engines/pegasus/items/biochips/mapimage.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 6010ec6..8d2c093 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -739,12 +739,6 @@ static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 // TODO: Remove me
 static const tRoomID kNorad01 = 0;
 static const tRoomID kNorad41 = 0;
-static const tRoomID kMars0A = 0;
-const tRoomID kMars35 = 38;
-const tRoomID kMars39 = 42;
-const tRoomID kMars60 = 58;
-const tRoomID kMarsMaze004 = 60;
-const tRoomID kMarsMaze200 = 224;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
index 5532aed..43a13ac 100755
--- a/engines/pegasus/items/biochips/mapimage.h
+++ b/engines/pegasus/items/biochips/mapimage.h
@@ -28,6 +28,7 @@
 
 #include "pegasus/elements.h"
 #include "pegasus/util.h"
+#include "pegasus/neighborhood/mars/mars.h"
 
 namespace Common {
 	class ReadStream;
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 0166443..a371aef 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -58,6 +58,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/mars/reactor.o \
+	neighborhood/mars/mars.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
new file mode 100755
index 0000000..3f46edb
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -0,0 +1,3419 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/items/biochips/shieldchip.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/mars/mars.h"
+
+namespace Pegasus {
+
+const TimeValue kMarsOxyMaskOnIn = 0;
+const TimeValue kMarsOxyMaskOnOut = 1560;
+
+const TimeValue kMarsAirlockButtonBeepIn = 1560;
+const TimeValue kMarsAirlockButtonBeepOut = 1620;
+
+const TimeValue kMarsColorMatchingButtonBeepIn = 1620;
+const TimeValue kMarsColorMatchingButtonBeepOut = 1680;
+
+const TimeValue kMarsKioskBeepIn = 1680;
+const TimeValue kMarsKioskBeepOut = 1740;
+
+const TimeValue kMarsBumpIntoWallIn = 1740;
+const TimeValue kMarsBumpIntoWallOut = 1888;
+
+const TimeValue kMarsGantryDoorCloseIn = 1888;
+const TimeValue kMarsGantryDoorCloseOut = 2866;
+
+const TimeValue kMarsTransportDoorCloseIn = 2866;
+const TimeValue kMarsTransportDoorCloseOut = 3593;
+
+const TimeValue kMarsAirlockPressurizeIn = 3593;
+const TimeValue kMarsAirlockPressurizeOut = 4766;
+
+const TimeValue kMarsBigAirlockDoorCloseIn = 4766;
+const TimeValue kMarsBigAirlockDoorCloseOut = 7872;
+
+const TimeValue kMarsSmallAirlockDoorCloseIn = 7872;
+const TimeValue kMarsSmallAirlockDoorCloseOut = 10000;
+
+const TimeValue kMarsMazeDoorCloseIn = 10000;
+const TimeValue kMarsMazeDoorCloseOut = 10969;
+
+const TimeValue kMarsRobotTakesTransportIn = 10969;
+const TimeValue kMarsRobotTakesTransportOut = 12802;
+
+const TimeValue kMarsPodDepartedUpperPlatformIn = 12802;
+const TimeValue kMarsPodDepartedUpperPlatformOut = 15783;
+
+const TimeValue kMarsPodDepartedLowerPlatformIn = 15783;
+const TimeValue kMarsPodDepartedLowerPlatformOut = 18736;
+
+const TimeValue kMarsPodArrivedUpperPlatformIn = 18736;
+const TimeValue kMarsPodArrivedUpperPlatformOut = 21605;
+
+const TimeValue kMarsCheckInRequiredIn = 21605;
+const TimeValue kMarsCheckInRequiredOut = 27463;
+
+const TimeValue kMarsCantOpenShuttleIn = 27463;
+const TimeValue kMarsCantOpenShuttleOut = 29214;
+
+const TimeValue kMarsShuttleLockOverrideIn = 29214;
+const TimeValue kMarsShuttleLockOverrideOut = 30330;
+
+const TimeValue kMarsNoShuttleIn = 30330;
+const TimeValue kMarsNoShuttleOut = 31502;
+
+const TimeValue kMustBeUnlockedIn = 31502;
+const TimeValue kMustBeUnlockedOut = 33960;
+
+const TimeValue kColorMatchBlueIn = 33960;
+const TimeValue kColorMatchBlueOut = 34240;
+
+const TimeValue kColorMatchRedIn = 34240;
+const TimeValue kColorMatchRedOut = 34538;
+
+const TimeValue kColorMatchGreenIn = 34538;
+const TimeValue kColorMatchGreenOut = 34827;
+
+const TimeValue kColorMatchYellowIn = 34827;
+const TimeValue kColorMatchYellowOut = 35162;
+
+const TimeValue kColorMatchPurpleIn = 35162;
+const TimeValue kColorMatchPurpleOut = 35426;
+
+const TimeValue kColorMatchZeroNodesIn = 35426;
+const TimeValue kColorMatchZeroNodesOut = 36376;
+
+const TimeValue kColorMatchOneNodeIn = 36376;
+const TimeValue kColorMatchOneNodeOut = 37209;
+
+const TimeValue kColorMatchTwoNodesIn = 37209;
+const TimeValue kColorMatchTwoNodesOut = 37983;
+
+const TimeValue kColorMatchThreeNodesIn = 37983;
+const TimeValue kColorMatchThreeNodesOut = 38784;
+
+const TimeValue kMarsShuttle1DepartedIn = 38784;
+const TimeValue kMarsShuttle1DepartedOut = 40323;
+
+const TimeValue kMarsShuttle2DepartedIn = 40323;
+const TimeValue kMarsShuttle2DepartedOut = 41824;
+
+const TimeValue kShuttleCockpitIn = 41824;
+const TimeValue kShuttleCockpitOut = 43126;
+
+const TimeValue kShuttleOnboardIn = 43126;
+const TimeValue kShuttleOnboardOut = 44284;
+
+const TimeValue kShuttleNavigationIn = 44284;
+const TimeValue kShuttleNavigationOut = 46049;
+
+const TimeValue kShuttleCommunicationIn = 46049;
+const TimeValue kShuttleCommunicationOut = 47288;
+
+const TimeValue kShuttleAutoTestingIn = 47288;
+const TimeValue kShuttleAutoTestingOut = 48179;
+
+const TimeValue kMarsThrusterAutoTestIn = 48179;
+const TimeValue kMarsThrusterAutoTestOut = 49979;
+
+const TimeValue kShuttleAllSystemsIn = 49979;
+const TimeValue kShuttleAllSystemsOut = 51065;
+
+const TimeValue kShuttleSecureLooseIn = 51065;
+const TimeValue kShuttleSecureLooseOut = 52346;
+
+const TimeValue kShuttlePrepareForDropIn = 52346;
+const TimeValue kShuttlePrepareForDropOut = 53216;
+
+const TimeValue kShuttleAllClearIn = 53216;
+const TimeValue kShuttleAllClearOut = 54031;
+
+const TimeValue kShuttleConfiguringIn = 54031;
+const TimeValue kShuttleConfiguringOut = 54994;
+
+const TimeValue kShuttleGeneratingIn = 54994;
+const TimeValue kShuttleGeneratingOut = 56033;
+
+const TimeValue kShuttleBreakawayIn = 56033;
+const TimeValue kShuttleBreakawayOut = 57346;
+
+const TimeValue kMarsAtmosphericBreakawayIn = 57346;
+const TimeValue kMarsAtmosphericBreakawayOut = 59237;
+
+const TimeValue kMarsCockpitChatterIn = 59237;
+const TimeValue kMarsCockpitChatterOut = 70344;
+
+const TimeValue kShuttleDamperDescIn = 70344;
+const TimeValue kShuttleDamperDescOut = 73262;
+
+const TimeValue kShuttleGravitonDescIn = 73262;
+const TimeValue kShuttleGravitonDescOut = 75296;
+
+const TimeValue kShuttleTractorDescIn = 75296;
+const TimeValue kShuttleTractorDescOut = 78381;
+
+const TimeValue kShuttleTargetSightedIn = 78381;
+const TimeValue kShuttleTargetSightedOut = 79074;
+
+const TimeValue kShuttleAutopilotEngagedIn = 79074;
+const TimeValue kShuttleAutopilotEngagedOut = 80414;
+
+const TimeValue kMarsEDBBlastIn = 80414;
+const TimeValue kMarsEDBBlastOut = 80705;
+
+const TimeValue kMarsGravitonBlastIn = 80705;
+const TimeValue kMarsGravitonBlastOut = 81199;
+
+const TimeValue kMarsJunkCollisionIn = 81199;
+const TimeValue kMarsJunkCollisionOut = 81961;
+
+const TimeValue kShuttleGravitonIn = 81961;
+const TimeValue kShuttleGravitonOut = 82587;
+
+const TimeValue kShuttleDampingBeamIn = 82587;
+const TimeValue kShuttleDampingBeamOut = 83331;
+
+const TimeValue kShuttleTractorBeamIn = 83331;
+const TimeValue kShuttleTractorBeamOut = 83802;
+
+const TimeValue kShuttleHullBreachIn = 83802;
+const TimeValue kShuttleHullBreachOut = 84721;
+
+const TimeValue kShuttleWingDamageIn = 84721;
+const TimeValue kShuttleWingDamageOut = 85640;
+
+const TimeValue kShuttleHullDamageIn = 85640;
+const TimeValue kShuttleHullDamageOut = 86513;
+
+const TimeValue kShuttleEnergyTooLowIn = 86513;
+const TimeValue kShuttleEnergyTooLowOut = 87578;
+
+const TimeValue kShuttleTractorLimitedIn = 87578;
+const TimeValue kShuttleTractorLimitedOut = 89164;
+
+const TimeValue kShuttleCantHoldIn = 89164;
+const TimeValue kShuttleCantHoldOut = 90945;
+
+const TimeValue kShuttleBrokeFreeIn = 90945;
+const TimeValue kShuttleBrokeFreeOut = 92322;
+
+const TimeValue kShuttleDestroyedIn = 92322;
+const TimeValue kShuttleDestroyedOut = 93189;
+
+const TimeValue kShuttleCoordinatesIn = 93189;
+const TimeValue kShuttleCoordinatesOut = 94018;
+
+const TimeValue kShuttleScanningIn = 94018;
+const TimeValue kShuttleScanningOut = 94975;
+
+const TimeValue kShuttleSafeIn = 94975;
+const TimeValue kShuttleSafeOut = 96176;
+
+const TimeValue kShuttleOverloadedIn = 96176;
+const TimeValue kShuttleOverloadedOut = 101308;
+
+const TimeScale kMarsMovieScale = 600;
+const TimeScale kMarsFramesPerSecond = 15;
+const TimeScale kMarsFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltMarsNormal = 0;
+const tAlternateID kAltMarsPodAtMars34 = 1;
+const tAlternateID kAltMarsTookCard = 2;
+const tAlternateID kAltMars35AirlockEast = 3;
+const tAlternateID kAltMars35AirlockWest = 4;
+const tAlternateID kAltMarsPodAtMars45 = 5;
+const tAlternateID kAltMarsTookMask = 6;
+const tAlternateID kAltMarsMaskOnFiller = 7;
+const tAlternateID kAltMars60AirlockEast = 8;
+const tAlternateID kAltMars60AirlockWest = 9;
+
+//	Room IDs.
+
+const tRoomID kMars00 = 1;
+const tRoomID kMars01 = 2;
+const tRoomID kMars02 = 3;
+const tRoomID kMars03 = 4;
+const tRoomID kMars04 = 5;
+const tRoomID kMars05 = 6;
+const tRoomID kMars06 = 7;
+const tRoomID kMars07 = 8;
+const tRoomID kMars08 = 9;
+const tRoomID kMars09 = 10;
+const tRoomID kMars10 = 11;
+const tRoomID kMars11 = 12;
+const tRoomID kMars12 = 13;
+const tRoomID kMars13 = 14;
+const tRoomID kMars14 = 15;
+const tRoomID kMars15 = 16;
+const tRoomID kMars16 = 17;
+const tRoomID kMars17 = 18;
+const tRoomID kMars18 = 19;
+const tRoomID kMars19 = 20;
+const tRoomID kMars20 = 21;
+const tRoomID kMars21 = 22;
+const tRoomID kMars22 = 23;
+const tRoomID kMars23 = 24;
+const tRoomID kMars24 = 25;
+const tRoomID kMars25 = 26;
+const tRoomID kMars26 = 27;
+const tRoomID kMars27 = 28;
+const tRoomID kMars28 = 29;
+const tRoomID kMars29 = 30;
+const tRoomID kMars30 = 31;
+const tRoomID kMars31 = 32;
+const tRoomID kMars31South = 33;
+const tRoomID kMars32 = 34;
+const tRoomID kMars33 = 35;
+const tRoomID kMars33North = 36;
+const tRoomID kMars34 = 37;
+const tRoomID kMars36 = 39;
+const tRoomID kMars37 = 40;
+const tRoomID kMars38 = 41;
+const tRoomID kMars41 = 43;
+const tRoomID kMars42 = 44;
+const tRoomID kMars43 = 45;
+const tRoomID kMars44 = 46;
+const tRoomID kMars45 = 47;
+const tRoomID kMars46 = 48;
+const tRoomID kMars47 = 49;
+const tRoomID kMars48 = 50;
+const tRoomID kMars49 = 51;
+const tRoomID kMars50 = 52;
+const tRoomID kMars51 = 53;
+const tRoomID kMars52 = 54;
+const tRoomID kMars54 = 55;
+const tRoomID kMars56 = 56;
+const tRoomID kMars58 = 57;
+const tRoomID kMarsRobotShuttle = 59;
+const tRoomID kMarsMaze005 = 61;
+const tRoomID kMarsMaze006 = 62;
+const tRoomID kMarsMaze007 = 63;
+const tRoomID kMarsMaze008 = 64;
+const tRoomID kMarsMaze009 = 65;
+const tRoomID kMarsMaze010 = 66;
+const tRoomID kMarsMaze011 = 67;
+const tRoomID kMarsMaze012 = 68;
+const tRoomID kMarsMaze015 = 69;
+const tRoomID kMarsMaze016 = 70;
+const tRoomID kMarsMaze017 = 71;
+const tRoomID kMarsMaze018 = 72;
+const tRoomID kMarsMaze019 = 73;
+const tRoomID kMarsMaze020 = 74;
+const tRoomID kMarsMaze021 = 75;
+const tRoomID kMarsMaze022 = 76;
+const tRoomID kMarsMaze023 = 77;
+const tRoomID kMarsMaze024 = 78;
+const tRoomID kMarsMaze025 = 79;
+const tRoomID kMarsMaze026 = 80;
+const tRoomID kMarsMaze027 = 81;
+const tRoomID kMarsMaze028 = 82;
+const tRoomID kMarsMaze031 = 83;
+const tRoomID kMarsMaze032 = 84;
+const tRoomID kMarsMaze033 = 85;
+const tRoomID kMarsMaze034 = 86;
+const tRoomID kMarsMaze035 = 87;
+const tRoomID kMarsMaze036 = 88;
+const tRoomID kMarsMaze037 = 89;
+const tRoomID kMarsMaze038 = 90;
+const tRoomID kMarsMaze039 = 91;
+const tRoomID kMarsMaze042 = 92;
+const tRoomID kMarsMaze043 = 93;
+const tRoomID kMarsMaze044 = 94;
+const tRoomID kMarsMaze045 = 95;
+const tRoomID kMarsMaze046 = 96;
+const tRoomID kMarsMaze047 = 97;
+const tRoomID kMarsMaze049 = 98;
+const tRoomID kMarsMaze050 = 99;
+const tRoomID kMarsMaze051 = 100;
+const tRoomID kMarsMaze052 = 101;
+const tRoomID kMarsMaze053 = 102;
+const tRoomID kMarsMaze054 = 103;
+const tRoomID kMarsMaze055 = 104;
+const tRoomID kMarsMaze056 = 105;
+const tRoomID kMarsMaze057 = 106;
+const tRoomID kMarsMaze058 = 107;
+const tRoomID kMarsMaze059 = 108;
+const tRoomID kMarsMaze060 = 109;
+const tRoomID kMarsMaze061 = 110;
+const tRoomID kMarsMaze063 = 111;
+const tRoomID kMarsMaze064 = 112;
+const tRoomID kMarsMaze065 = 113;
+const tRoomID kMarsMaze066 = 114;
+const tRoomID kMarsMaze067 = 115;
+const tRoomID kMarsMaze068 = 116;
+const tRoomID kMarsMaze069 = 117;
+const tRoomID kMarsMaze070 = 118;
+const tRoomID kMarsMaze071 = 119;
+const tRoomID kMarsMaze072 = 120;
+const tRoomID kMarsMaze074 = 121;
+const tRoomID kMarsMaze076 = 122;
+const tRoomID kMarsMaze078 = 123;
+const tRoomID kMarsMaze079 = 124;
+const tRoomID kMarsMaze081 = 125;
+const tRoomID kMarsMaze083 = 126;
+const tRoomID kMarsMaze084 = 127;
+const tRoomID kMarsMaze085 = 128;
+const tRoomID kMarsMaze086 = 129;
+const tRoomID kMarsMaze087 = 130;
+const tRoomID kMarsMaze088 = 131;
+const tRoomID kMarsMaze089 = 132;
+const tRoomID kMarsMaze090 = 133;
+const tRoomID kMarsMaze091 = 134;
+const tRoomID kMarsMaze092 = 135;
+const tRoomID kMarsMaze093 = 136;
+const tRoomID kMarsMaze098 = 137;
+const tRoomID kMarsMaze099 = 138;
+const tRoomID kMarsMaze100 = 139;
+const tRoomID kMarsMaze101 = 140;
+const tRoomID kMarsMaze104 = 141;
+const tRoomID kMarsMaze105 = 142;
+const tRoomID kMarsMaze106 = 143;
+const tRoomID kMarsMaze107 = 144;
+const tRoomID kMarsMaze108 = 145;
+const tRoomID kMarsMaze111 = 146;
+const tRoomID kMarsMaze113 = 147;
+const tRoomID kMarsMaze114 = 148;
+const tRoomID kMarsMaze115 = 149;
+const tRoomID kMarsMaze116 = 150;
+const tRoomID kMarsMaze117 = 151;
+const tRoomID kMarsMaze118 = 152;
+const tRoomID kMarsMaze119 = 153;
+const tRoomID kMarsMaze120 = 154;
+const tRoomID kMarsMaze121 = 155;
+const tRoomID kMarsMaze122 = 156;
+const tRoomID kMarsMaze123 = 157;
+const tRoomID kMarsMaze124 = 158;
+const tRoomID kMarsMaze125 = 159;
+const tRoomID kMarsMaze126 = 160;
+const tRoomID kMarsMaze127 = 161;
+const tRoomID kMarsMaze128 = 162;
+const tRoomID kMarsMaze129 = 163;
+const tRoomID kMarsMaze130 = 164;
+const tRoomID kMarsMaze131 = 165;
+const tRoomID kMarsMaze132 = 166;
+const tRoomID kMarsMaze133 = 167;
+const tRoomID kMarsMaze136 = 168;
+const tRoomID kMarsMaze137 = 169;
+const tRoomID kMarsMaze138 = 170;
+const tRoomID kMarsMaze139 = 171;
+const tRoomID kMarsMaze140 = 172;
+const tRoomID kMarsMaze141 = 173;
+const tRoomID kMarsMaze142 = 174;
+const tRoomID kMarsMaze143 = 175;
+const tRoomID kMarsMaze144 = 176;
+const tRoomID kMarsMaze145 = 177;
+const tRoomID kMarsMaze146 = 178;
+const tRoomID kMarsMaze147 = 179;
+const tRoomID kMarsMaze148 = 180;
+const tRoomID kMarsMaze149 = 181;
+const tRoomID kMarsMaze152 = 182;
+const tRoomID kMarsMaze153 = 183;
+const tRoomID kMarsMaze154 = 184;
+const tRoomID kMarsMaze155 = 185;
+const tRoomID kMarsMaze156 = 186;
+const tRoomID kMarsMaze157 = 187;
+const tRoomID kMarsMaze159 = 188;
+const tRoomID kMarsMaze160 = 189;
+const tRoomID kMarsMaze161 = 190;
+const tRoomID kMarsMaze162 = 191;
+const tRoomID kMarsMaze163 = 192;
+const tRoomID kMarsMaze164 = 193;
+const tRoomID kMarsMaze165 = 194;
+const tRoomID kMarsMaze166 = 195;
+const tRoomID kMarsMaze167 = 196;
+const tRoomID kMarsMaze168 = 197;
+const tRoomID kMarsMaze169 = 198;
+const tRoomID kMarsMaze170 = 199;
+const tRoomID kMarsMaze171 = 200;
+const tRoomID kMarsMaze172 = 201;
+const tRoomID kMarsMaze173 = 202;
+const tRoomID kMarsMaze174 = 203;
+const tRoomID kMarsMaze175 = 204;
+const tRoomID kMarsMaze177 = 205;
+const tRoomID kMarsMaze178 = 206;
+const tRoomID kMarsMaze179 = 207;
+const tRoomID kMarsMaze180 = 208;
+const tRoomID kMarsMaze181 = 209;
+const tRoomID kMarsMaze182 = 210;
+const tRoomID kMarsMaze183 = 211;
+const tRoomID kMarsMaze184 = 212;
+const tRoomID kMarsMaze187 = 213;
+const tRoomID kMarsMaze188 = 214;
+const tRoomID kMarsMaze189 = 215;
+const tRoomID kMarsMaze190 = 216;
+const tRoomID kMarsMaze191 = 217;
+const tRoomID kMarsMaze192 = 218;
+const tRoomID kMarsMaze193 = 219;
+const tRoomID kMarsMaze194 = 220;
+const tRoomID kMarsMaze195 = 221;
+const tRoomID kMarsMaze198 = 222;
+const tRoomID kMarsMaze199 = 223;
+const tRoomID kMarsDeathRoom = 225;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationReadyForKiosk = 1;
+const tHotSpotActivationID kActivationKioskChoice = 2;
+const tHotSpotActivationID kActivationTunnelMapReady = 3;
+const tHotSpotActivationID kActivateMarsPodClosed = 4;
+const tHotSpotActivationID kActivateMarsPodOpen = 5;
+const tHotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
+const tHotSpotActivationID kActivateAirlockPressurized = 7;
+const tHotSpotActivationID kActivateMaskOnHolder = 8;
+const tHotSpotActivationID kActivateMaskOnFiller = 9;
+const tHotSpotActivationID kActivateReactorPlatformOut = 10;
+const tHotSpotActivationID kActivateReactorPlatformIn = 11;
+const tHotSpotActivationID kActivateReactorAskLowerScreen = 12;
+const tHotSpotActivationID kActivateReactorReadyForNitrogen = 13;
+const tHotSpotActivationID kActivateReactorReadyForCrowBar = 14;
+const tHotSpotActivationID kActivateReactorAskOperation = 15;
+const tHotSpotActivationID kActivateReactorRanEvaluation = 16;
+const tHotSpotActivationID kActivateReactorRanDiagnostics = 17;
+const tHotSpotActivationID kActivateReactorAnalyzed = 18;
+const tHotSpotActivationID kActivateReactorInstructions = 19;
+const tHotSpotActivationID kActivateReactorInGame = 20;
+const tHotSpotActivationID kActivateReactorBombSafe = 21;
+const tHotSpotActivationID kActivateReactorBombExposed = 22;
+const tHotSpotActivationID kActivationRobotHeadClosed = 23;
+const tHotSpotActivationID kActivationRobotHeadOpen = 24;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kMars11NorthKioskSpotID = 5000;
+const tHotSpotID kMars11NorthKioskSightsSpotID = 5001;
+const tHotSpotID kMars11NorthKioskColonySpotID = 5002;
+const tHotSpotID kMars12NorthKioskSpotID = 5003;
+const tHotSpotID kMars12NorthKioskSightsSpotID = 5004;
+const tHotSpotID kMars12NorthKioskColonySpotID = 5005;
+const tHotSpotID kMars31SouthSpotID = 5006;
+const tHotSpotID kMars31SouthOutSpotID = 5007;
+const tHotSpotID kMars31SouthCardSpotID = 5008;
+const tHotSpotID kMars33NorthSpotID = 5009;
+const tHotSpotID kMars33NorthOutSpotID = 5010;
+const tHotSpotID kMars33NorthMonitorSpotID = 5011;
+const tHotSpotID kMars34NorthCardDropSpotID = 5012;
+const tHotSpotID kMars34SouthOpenStorageSpotID = 5013;
+const tHotSpotID kMars34SouthCloseStorageSpotID = 5014;
+const tHotSpotID kMars34SouthCrowbarSpotID = 5015;
+const tHotSpotID kMars35EastPressurizeSpotID = 5016;
+const tHotSpotID kMars35EastSpinSpotID = 5017;
+const tHotSpotID kMars35WestPressurizeSpotID = 5018;
+const tHotSpotID kMars35WestSpinSpotID = 5019;
+const tHotSpotID kMars45NorthOpenStorageSpotID = 5020;
+const tHotSpotID kMars45NorthCloseStorageSpotID = 5021;
+const tHotSpotID kMars45NorthCrowbarSpotID = 5022;
+const tHotSpotID kAttackRobotHotSpotID = 5023;
+const tHotSpotID kMars49AirMaskSpotID = 5024;
+const tHotSpotID kMars49AirMaskFilledSpotID = 5025;
+const tHotSpotID kMars49AirFillingDropSpotID = 5026;
+const tHotSpotID kMars52MoveLeftSpotID = 5027;
+const tHotSpotID kMars52MoveRightSpotID = 5028;
+const tHotSpotID kMars52ExtractSpotID = 5029;
+const tHotSpotID kMars53RetractSpotID = 5030;
+const tHotSpotID kMars54MoveLeftSpotID = 5031;
+const tHotSpotID kMars54MoveRightSpotID = 5032;
+const tHotSpotID kMars54ExtractSpotID = 5033;
+const tHotSpotID kMars55RetractSpotID = 5034;
+const tHotSpotID kMars56MoveLeftSpotID = 5035;
+const tHotSpotID kMars56MoveRightSpotID = 5036;
+const tHotSpotID kMars56ExtractSpotID = 5037;
+const tHotSpotID kMars57RetractSpotID = 5038;
+const tHotSpotID kMars57LowerScreenSpotID = 5039;
+const tHotSpotID kMars57Retract2SpotID = 5040;
+const tHotSpotID kMars57DropNitrogenSpotID = 5041;
+const tHotSpotID kMars57DropCrowBarSpotID = 5042;
+const tHotSpotID kMars57CantOpenPanelSpotID = 5043;
+const tHotSpotID kMars57ShieldEvaluationSpotID = 5044;
+const tHotSpotID kMars57MeasureOutputSpotID = 5045;
+const tHotSpotID kMars57RunDiagnosticsSpotID = 5046;
+const tHotSpotID kMars57BackToOperationMenuSpotID = 5047;
+const tHotSpotID kMars57AnalyzeObjectSpotID = 5048;
+const tHotSpotID kMars57RemoveObjectMenuSpotID = 5049;
+const tHotSpotID kMars57CircuitLinkSpotID = 5050;
+const tHotSpotID kMars57CancelCircuitLinkSpotID = 5051;
+const tHotSpotID kMars57GameInstructionsSpotID = 5052;
+const tHotSpotID kMars57UndoMoveSpotID = 5053;
+const tHotSpotID kMars57RedMoveSpotID = 5054;
+const tHotSpotID kMars57YellowMoveSpotID = 5055;
+const tHotSpotID kMars57GreenMoveSpotID = 5056;
+const tHotSpotID kMars57BlueMoveSpotID = 5057;
+const tHotSpotID kMars57PurpleMoveSpotID = 5058;
+const tHotSpotID kMars57LowerScreenSafelySpotID = 5059;
+const tHotSpotID kMars57GrabBombSpotID = 5060;
+const tHotSpotID kMars58MoveLeftSpotID = 5061;
+const tHotSpotID kMars58MoveRightSpotID = 5062;
+const tHotSpotID kMars58ExtractSpotID = 5063;
+const tHotSpotID kMars59RetractSpotID = 5064;
+const tHotSpotID kMars60EastPressurizeSpotID = 5065;
+const tHotSpotID kMars60EastSpinSpotID = 5066;
+const tHotSpotID kMars60WestPressurizeSpotID = 5067;
+const tHotSpotID kMars60WestSpinSpotID = 5068;
+const tHotSpotID kRobotShuttleOpenHeadSpotID = 5069;
+const tHotSpotID kRobotShuttleMapChipSpotID = 5070;
+const tHotSpotID kRobotShuttleOpticalChipSpotID = 5071;
+const tHotSpotID kRobotShuttleShieldChipSpotID = 5072;
+
+//	Extra sequence IDs.
+
+const tExtraID kMarsArrivalFromTSA = 0;
+const tExtraID kMars0AWatchShuttleDepart = 1;
+const tExtraID kRobotThrowsPlayer = 2;
+const tExtraID kMarsInfoKioskIntro = 3;
+const tExtraID kMarsColonyInfo = 4;
+const tExtraID kMarsSightsInfo = 5;
+const tExtraID kRobotOnWayToShuttle = 6;
+const tExtraID kMars31SouthZoomInNoCard = 7;
+const tExtraID kMars31SouthViewNoCard = 8;
+const tExtraID kMars31SouthZoomOutNoCard = 9;
+const tExtraID kMars31SouthZoomViewNoCard = 10;
+const tExtraID kMars33SlideShow1 = 11;
+const tExtraID kMars33SlideShow2 = 12;
+const tExtraID kMars33SlideShow3 = 13;
+const tExtraID kMars33SlideShow4 = 14;
+const tExtraID kMars34SpotOpenWithBar = 15;
+const tExtraID kMars34SpotCloseWithBar = 16;
+const tExtraID kMars34SpotOpenNoBar = 17;
+const tExtraID kMars34SpotCloseNoBar = 18;
+const tExtraID kMars34ViewOpenWithBar = 19;
+const tExtraID kMars34ViewOpenNoBar = 20;
+const tExtraID kMars34NorthPodGreeting = 21;
+const tExtraID kMarsTurnOnPod = 22;
+const tExtraID kMarsTakePodToMars45 = 23;
+const tExtraID kMars35WestSpinAirlockToEast = 24;
+const tExtraID kMars35EastSpinAirlockToWest = 25;
+const tExtraID kMars45SpotOpenWithBar = 26;
+const tExtraID kMars45SpotCloseWithBar = 27;
+const tExtraID kMars45SpotOpenNoBar = 28;
+const tExtraID kMars45SpotCloseNoBar = 29;
+const tExtraID kMars45ViewOpenWithBar = 30;
+const tExtraID kMars45ViewOpenNoBar = 31;
+const tExtraID kMars48RobotApproaches = 32;
+const tExtraID kMars48RobotKillsPlayer = 33;
+const tExtraID kMars48RobotLoops = 34;
+const tExtraID kMars48RobotView = 35;
+const tExtraID kMars48RobotDefends = 36;
+const tExtraID kMars49SouthViewMaskFilling = 37;
+const tExtraID kMars52SpinLeft = 38;
+const tExtraID kMars52SpinRight = 39;
+const tExtraID kMars52Extend = 40;
+const tExtraID kMars53Retract = 41;
+const tExtraID kMars54SpinLeft = 42;
+const tExtraID kMars54SpinRight = 43;
+const tExtraID kMars54Extend = 44;
+const tExtraID kMars55Retract = 45;
+const tExtraID kMars56SpinLeft = 46;
+const tExtraID kMars56SpinRight = 47;
+const tExtraID kMars56ExtendWithBomb = 48;
+const tExtraID kMars56ExtendNoBomb = 49;
+const tExtraID kMars57RetractWithBomb = 50;
+const tExtraID kMars57RetractNoBomb = 51;
+const tExtraID kMars57LowerScreenClosed = 52;
+const tExtraID kMars57CantOpenPanel = 53;
+const tExtraID kMars57FreezeLock = 54;
+const tExtraID kMars57BreakLock = 55;
+const tExtraID kMars57LockFrozenView = 56;
+const tExtraID kMars57ThawLock = 57;
+const tExtraID kMars57OpenPanel = 58;
+const tExtraID kMars57OpenPanelChoices = 59;
+const tExtraID kMars57ShieldEvaluation = 60;
+const tExtraID kMars57MeasureOutput = 61;
+const tExtraID kMars57ShieldOkayLoop = 62;
+const tExtraID kMars57RunDiagnostics = 63;
+const tExtraID kMars57BombExplodes = 64;
+const tExtraID kMars57BombAnalysis = 65;
+const tExtraID kMars57DontLink = 66;
+const tExtraID kMars57CircuitLink = 67;
+const tExtraID kMars57GameLevel1 = 68;
+const tExtraID kMars57GameLevel2 = 69;
+const tExtraID kMars57GameLevel3 = 70;
+const tExtraID kMars57BombExplodesInGame = 71;
+const tExtraID kMars57GameSolved = 72;
+const tExtraID kMars57ExposeBomb = 73;
+const tExtraID kMars57BackToNormal = 74;
+const tExtraID kMars57ViewOpenNoBomb = 75;
+const tExtraID kMars58SpinLeft = 76;
+const tExtraID kMars58SpinRight = 77;
+const tExtraID kMars58Extend = 78;
+const tExtraID kMars59Retract = 79;
+const tExtraID kMars60WestSpinAirlockToEast = 80;
+const tExtraID kMars60EastSpinAirlockToWest = 81;
+const tExtraID kMarsRobotHeadOpen = 82;
+const tExtraID kMarsRobotHeadClose = 83;
+const tExtraID kMarsRobotHead000 = 84;
+const tExtraID kMarsRobotHead001 = 85;
+const tExtraID kMarsRobotHead010 = 86;
+const tExtraID kMarsRobotHead011 = 87;
+const tExtraID kMarsRobotHead100 = 88;
+const tExtraID kMarsRobotHead101 = 89;
+const tExtraID kMarsRobotHead110 = 90;
+const tExtraID kMarsRobotHead111 = 91;
+const tExtraID kMarsMaze007RobotApproach = 92;
+const tExtraID kMarsMaze007RobotLoop = 93;
+const tExtraID kMarsMaze007RobotDeath = 94;
+const tExtraID kMarsMaze015SouthRobotApproach = 95;
+const tExtraID kMarsMaze015SouthRobotLoop = 96;
+const tExtraID kMarsMaze015SouthRobotDeath = 97;
+const tExtraID kMarsMaze101EastRobotApproach = 98;
+const tExtraID kMarsMaze101EastRobotLoop = 99;
+const tExtraID kMarsMaze101EastRobotDeath = 100;
+const tExtraID kMarsMaze104WestLoop = 101;
+const tExtraID kMarsMaze104WestDeath = 102;
+const tExtraID kMarsMaze133SouthApproach = 103;
+const tExtraID kMarsMaze133SouthLoop = 104;
+const tExtraID kMarsMaze133SouthDeath = 105;
+const tExtraID kMarsMaze136NorthApproach = 106;
+const tExtraID kMarsMaze136NorthLoop = 107;
+const tExtraID kMarsMaze136NorthDeath = 108;
+const tExtraID kMarsMaze184WestLoop = 109;
+const tExtraID kMarsMaze184WestDeath = 110;
+const tExtraID kMars200DeathInBucket = 111;
+
+const tResIDType kReactorUndoHilitePICTID = 900;
+
+const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
+const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
+
+const int16 kMars52Compass = 90;
+const int16 kMars54Compass = 180;
+const int16 kMars56Compass = 270;
+const int16 kMars58Compass = 0;
+
+// This should really be 22.5.
+// Probably no one will know the difference.
+const int16 kMarsShieldPanelOffsetAngle = 22;
+
+const tCanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
+
+const tNotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
+const tNotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
+const tNotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
+
+const tNotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
+													kExplosionFinishedFlag |
+													kTimeToTransportFlag;
+
+const TimeValue kLittleExplosionStart = 0 * 40;
+const TimeValue kLittleExplosionStop = 24 * 40;
+
+const TimeValue kBigExplosionStart = 24 * 40;
+const TimeValue kBigExplosionStop = 62 * 40;
+
+enum {
+	kMaze007RobotLoopingEvent,
+	kMaze015RobotLoopingEvent,
+	kMaze101RobotLoopingEvent,
+	kMaze104RobotLoopingEvent,
+	kMaze133RobotLoopingEvent,
+	kMaze136RobotLoopingEvent,
+	kMaze184RobotLoopingEvent
+};
+
+enum {
+	kMaze007RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
+	kMaze015RobotLoopingTime = (64 + 93) * kMarsFrameDuration,
+	kMaze101RobotLoopingTime = (64 + 45) * kMarsFrameDuration,
+	kMaze104RobotLoopingTime = 96 * kMarsFrameDuration,
+	kMaze133RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
+	kMaze136RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
+	kMaze184RobotLoopingTime = 96 * kMarsFrameDuration
+};
+
+void robotTimerExpiredFunction(FunctionPtr *, void *mars) {
+	((Mars *)mars)->robotTiredOfWaiting();
+}
+
+void lockThawTimerExpiredFunction(FunctionPtr *, void *mars) {
+	((Mars *)mars)->lockThawed();
+}
+
+void bombTimerExpiredFunction(FunctionPtr *, void *mars) {
+	((Mars *)mars)->didntFindBomb();
+}
+
+void bombTimerExpiredInGameFunction(FunctionPtr *, void *mars) {
+	((Mars *)mars)->bombExplodesInGame();
+}
+
+void airStageExpiredFunction(FunctionPtr *, void *mars) {
+	((Mars *)mars)->airStageExpired();
+}
+
+Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Mars", kMarsID),
+		_guessObject(kNoDisplayElement), _undoPict(kNoDisplayElement), _guessHistory(kNoDisplayElement),
+		_choiceHighlight(kNoDisplayElement), _shuttleInterface1(kNoDisplayElement), _shuttleInterface2(kNoDisplayElement),
+		_shuttleInterface3(kNoDisplayElement), _shuttleInterface4(kNoDisplayElement), _canyonChaseMovie(kNoDisplayElement) {
+	_noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
+	setIsItemTaken(kMarsCard);
+	setIsItemTaken(kAirMask);
+	setIsItemTaken(kCrowbar);
+	setIsItemTaken(kCardBomb);
+}
+
+Mars::~Mars() {
+}
+
+void Mars::init() {	
+	Neighborhood::init();
+	
+	Hotspot *attackSpot = g_allHotspots.findHotspotByID(kAttackRobotHotSpotID);
+	attackSpot->setMaskedHotspotFlags(kDropItemSpotFlag, kDropItemSpotFlag);
+	_attackingItem = NULL;
+	
+	forceStridingStop(kMars08, kNorth, kAltMarsNormal);
+
+	_neighborhoodNotification.notifyMe(this, kMarsNotificationFlags, kMarsNotificationFlags);
+}
+
+void Mars::flushGameState() {
+	g_energyMonitor->saveCurrentEnergyValue();
+}
+
+void Mars::start() {
+	g_energyMonitor->stopEnergyDraining();
+	g_energyMonitor->restoreLastEnergyValue();
+	_vm->resetEnergyDeathReason();
+	g_energyMonitor->startEnergyDraining();
+	Neighborhood::start();
+}
+
+class AirMaskCondition : public AICondition {
+public:
+	AirMaskCondition(const uint32);
+	
+	virtual bool fireCondition();
+
+protected:
+	uint32 _airThreshold;
+	uint32 _lastAirLevel;
+};
+
+AirMaskCondition::AirMaskCondition(const uint32 airThreshold) {
+	_airThreshold = airThreshold;
+	_lastAirLevel = g_airMask->getAirLeft();
+}
+
+bool AirMaskCondition::fireCondition() {
+	bool result = g_airMask && g_airMask->isAirMaskOn() &&
+			g_airMask->getAirLeft() <= _airThreshold && _lastAirLevel > _airThreshold;
+
+	_lastAirLevel = g_airMask->getAirLeft();
+	return result;
+}
+
+void Mars::setUpAIRules() {	
+	Neighborhood::setUpAIRules();
+
+	// Don't add these rules if we're going to the robot's shuttle...
+	if (g_AIArea && !GameState.getMarsReadyForShuttleTransport()) {
+		AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB1E", false);
+		AILocationCondition *locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars47, kSouth));
+		AIRule *rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM27NB", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars27, kNorth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM27NB", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars28, kNorth));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM41ED", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars19, kEast));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		AIDeactivateRuleAction *deactivate = new AIDeactivateRuleAction(rule);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars35, kWest));
+		rule = new AIRule(locCondition, deactivate);
+		g_AIArea->addAIRule(rule);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM41ED", false);
+		locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kMars48, kWest));
+		rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+
+		AirMaskCondition *airMask50Condition = new AirMaskCondition(50);
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB1", false);
+		AIRule *rule50 = new AIRule(airMask50Condition, messageAction);
+
+		AirMaskCondition *airMask25Condition = new AirMaskCondition(25);
+		AICompoundAction *compound = new AICompoundAction();
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB2", false);
+		compound->addAction(messageAction);
+		deactivate = new AIDeactivateRuleAction(rule50);
+		compound->addAction(deactivate);
+		AIRule *rule25 = new AIRule(airMask25Condition, compound);
+
+		AirMaskCondition *airMask5Condition = new AirMaskCondition(5);
+		compound = new AICompoundAction;
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB3", false);
+		compound->addAction(messageAction);
+		deactivate = new AIDeactivateRuleAction(rule50);
+		compound->addAction(deactivate);
+		deactivate = new AIDeactivateRuleAction(rule25);
+		compound->addAction(deactivate);
+		AIRule *rule5 = new AIRule(airMask5Condition, compound);
+
+		g_AIArea->addAIRule(rule5);
+		g_AIArea->addAIRule(rule25);
+		g_AIArea->addAIRule(rule50);
+
+		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM51ND", false);
+		AIDoorOpenedCondition *doorOpen = new AIDoorOpenedCondition(MakeRoomView(kMars51, kEast));
+		rule = new AIRule(doorOpen, messageAction);
+		g_AIArea->addAIRule(rule);
+	}
+}
+
+uint16 Mars::getDateResID() const {
+	return kDate2185ID;
+}
+
+TimeValue Mars::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry extra;
+	SpotTable::Entry spotEntry;
+	uint32 extraID = 0xffffffff;
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kMars0A, kNorth):
+		if (!GameState.getMarsSeenTimeStream()) {
+			getExtraEntry(kMarsArrivalFromTSA, extra);
+			return extra.movieStart;
+		}
+		break;
+	case MakeRoomView(kMars31South, kSouth):
+		if (GameState.isTakenItemID(kMarsCard))
+			extraID = kMars31SouthZoomViewNoCard;
+		break;
+	case MakeRoomView(kMars31, kSouth):
+		if (GameState.isTakenItemID(kMarsCard))
+			extraID = kMars31SouthViewNoCard;
+		break;
+	case MakeRoomView(kMars34, kSouth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			if (GameState.isTakenItemID(kCrowbar))
+				extraID = kMars34ViewOpenNoBar;
+			else
+				extraID = kMars34ViewOpenWithBar;
+		}
+		break;
+	case MakeRoomView(kMars36, kSouth):
+	case MakeRoomView(kMars37, kSouth):
+	case MakeRoomView(kMars38, kSouth):
+		findSpotEntry(room, direction, kSpotOnTurnMask | kSpotLoopsMask, spotEntry);
+		return spotEntry.movieStart;
+	case MakeRoomView(kMars45, kNorth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			if (GameState.isTakenItemID(kCrowbar))
+				extraID = kMars45ViewOpenNoBar;
+			else
+				extraID = kMars45ViewOpenWithBar;
+		}
+		break;
+	case MakeRoomView(kMars48, kEast):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
+			extraID = kMars48RobotView;
+		break;
+	case MakeRoomView(kMars56, kEast):
+		if (_privateFlags.getFlag(kMarsPrivateBombExposedFlag)) {
+			if (_privateFlags.getFlag(kMarsPrivateDraggingBombFlag))
+				extraID = kMars57ViewOpenNoBomb;
+			else
+				extraID = kMars57ExposeBomb;
+		} else if (GameState.getMarsLockBroken()) {
+			extraID = kMars57OpenPanelChoices;
+		} else if (GameState.getMarsLockFrozen()) {
+			extraID = kMars57LockFrozenView;
+		}
+		break;
+	case MakeRoomView(kMarsRobotShuttle, kEast):
+		if (getCurrentActivation() == kActivationRobotHeadOpen) {
+			extraID = kMarsRobotHead111;
+
+			if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag))
+				extraID -= 1;
+			if (_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag))
+				extraID -= 2;
+			if (_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag))
+				extraID -= 4;
+		}
+		break;
+	}
+
+	if (extraID == 0xffffffff)
+		return Neighborhood::getViewTime(room, direction);
+
+	getExtraEntry(extraID, extra);
+	return extra.movieEnd - 1;
+}
+
+void Mars::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry) {
+	Neighborhood::getZoomEntry(spotID, entry);
+
+	uint32 extraID = 0xffffffff;
+
+	switch (spotID) {
+	case kMars31SouthSpotID:
+		if (GameState.getCurrentDirection() == kSouth && GameState.isTakenItemID(kMarsCard))
+			extraID = kMars31SouthZoomInNoCard;
+		break;
+	case kMars31SouthOutSpotID:
+		if (GameState.getCurrentDirection() == kSouth && GameState.isTakenItemID(kMarsCard))
+			extraID = kMars31SouthZoomOutNoCard;
+		break;
+	}
+
+	if (extraID != 0xffffffff) {
+		ExtraTable::Entry extra;
+		getExtraEntry(extraID, extra);
+		entry.movieStart = extra.movieStart;
+		entry.movieEnd = extra.movieEnd;
+	}
+}
+
+void Mars::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
+	Neighborhood::findSpotEntry(room, direction, flags, entry);
+
+	if ((flags & (kSpotOnArrivalMask | kSpotOnTurnMask)) != 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kMars27, kNorth):
+			if (GameState.getMarsSeenThermalScan())
+				entry.clear();
+			else
+				GameState.setMarsSeenThermalScan(true);
+			break;
+		case MakeRoomView(kMars28, kNorth):
+			if (GameState.getMarsSeenThermalScan())
+				entry.clear();
+			else
+				GameState.setMarsSeenThermalScan(true);
+			break;
+		}
+	}
+}
+
+tCanMoveForwardReason Mars::canMoveForward(ExitTable::Entry &entry) {
+	tCanMoveForwardReason reason = Neighborhood::canMoveForward(entry);
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars48, kEast):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
+			reason = kCantMoveRobotBlocking;
+		break;
+	case MakeRoomView(kMars48, kSouth):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
+			_utilityFuse.stopFuse();
+		break;
+	}
+
+	return reason;
+}
+
+void Mars::cantMoveThatWay(tCanMoveForwardReason reason) {
+	if (reason == kCantMoveRobotBlocking) {
+		startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
+		loadLoopSound2("");
+	} else {
+		Neighborhood::cantMoveThatWay(reason);
+	}
+}
+
+void Mars::moveForward() {
+	if (GameState.getCurrentRoom() == kMars02 || (GameState.getCurrentRoom() >= kMars05 && GameState.getCurrentRoom() <= kMars08))
+		loadLoopSound2("");
+
+	Neighborhood::moveForward();
+}
+
+void Mars::bumpIntoWall() {
+	requestSpotSound(kMarsBumpIntoWallIn, kMarsBumpIntoWallOut, kFilterNoInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+tCanOpenDoorReason Mars::canOpenDoor(DoorTable::Entry &entry) {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars05, kEast):
+	case MakeRoomView(kMars06, kEast):
+	case MakeRoomView(kMars07, kEast):
+		if (!GameState.getMarsSecurityDown())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze037, kWest):
+	case MakeRoomView(kMarsMaze038, kEast):
+		if (GameState.getMarsMazeDoorPair1())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze050, kNorth):
+	case MakeRoomView(kMarsMaze058, kSouth):
+		if (!GameState.getMarsMazeDoorPair1())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze047, kNorth):
+	case MakeRoomView(kMarsMaze142, kSouth):
+		if (GameState.getMarsMazeDoorPair2())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze057, kNorth):
+	case MakeRoomView(kMarsMaze136, kSouth):
+		if (!GameState.getMarsMazeDoorPair2())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze120, kWest):
+	case MakeRoomView(kMarsMaze121, kEast):
+		if (GameState.getMarsMazeDoorPair3())
+			return kCantOpenLocked;
+		break;
+	case MakeRoomView(kMarsMaze081, kNorth):
+	case MakeRoomView(kMarsMaze083, kSouth):
+		if (!GameState.getMarsMazeDoorPair3())
+			return kCantOpenLocked;
+		break;
+	}
+
+	return Neighborhood::canOpenDoor(entry);
+}
+
+void Mars::cantOpenDoor(tCanOpenDoorReason reason) {
+	switch (GameState.getCurrentRoom()) {
+	case kMars05:
+	case kMars06:
+	case kMars07:
+		playSpotSoundSync(kMarsCantOpenShuttleIn, kMarsCantOpenShuttleOut);
+		break;
+	default:
+		Neighborhood::cantOpenDoor(reason);
+		break;
+	}
+}
+
+void Mars::openDoor() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars06, kEast):
+	case MakeRoomView(kMars07, kEast):
+		if (GameState.getMarsSecurityDown())
+			playSpotSoundSync(kMarsNoShuttleIn, kMarsNoShuttleOut);
+		break;
+	case MakeRoomView(kMars47, kSouth):
+		if (GameState.isTakenItemID(kAirMask))
+			setCurrentAlternate(kAltMarsTookMask);
+		else
+			setCurrentAlternate(kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars48, kNorth):
+		if (GameState.getMarsPodAtUpperPlatform())
+			setCurrentAlternate(kAltMarsNormal);
+		else
+			setCurrentAlternate(kAltMarsPodAtMars45);
+		break;
+	case MakeRoomView(kMars48, kEast):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
+			die(kDeathDidntGetOutOfWay);
+			return;
+		}
+		break;
+	}
+
+	Neighborhood::openDoor();
+}
+
+void Mars::doorOpened() {
+	switch (GameState.getCurrentRoom()) {
+	case kMars27:
+	case kMars28:
+		if (GameState.getCurrentDirection() == kNorth)
+			_vm->die(kDeathArrestedInMars);
+		else
+			Neighborhood::doorOpened();
+		break;
+	case kMars41:
+	case kMars42:
+		if (GameState.getCurrentDirection() == kEast)
+			_vm->die(kDeathWrongShuttleLock);
+		else
+			Neighborhood::doorOpened();
+		break;
+	case kMars51:
+		Neighborhood::doorOpened();
+		setUpReactorEnergyDrain();
+
+		if (g_AIArea)
+			g_AIArea->checkRules();
+		break;
+	case kMars19:
+		if (GameState.getCurrentDirection() == kEast)
+			GameState.setMarsAirlockOpen(true);
+
+		Neighborhood::doorOpened();
+		break;
+	case kMars48:
+		if (GameState.getCurrentDirection() == kWest)
+			GameState.setMarsAirlockOpen(true);
+
+		Neighborhood::doorOpened();
+		break;
+	default:
+		Neighborhood::doorOpened();
+		break;
+	}
+}
+
+void Mars::setUpReactorEnergyDrain() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars51, kEast):
+		if (GameState.isCurrentDoorOpen()) {
+			if (g_energyMonitor->getEnergyDrainRate() == kEnergyDrainNormal) {
+				if (GameState.getShieldOn()) {
+					g_shield->setItemState(kShieldRadiation);
+					g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainWithShield);
+				} else {
+					g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainNoShield);
+				}
+				_vm->setEnergyDeathReason(kDeathReactorBurn);
+			}
+		} else {
+			if (g_energyMonitor->getEnergyDrainRate() != kEnergyDrainNormal) {
+				if (GameState.getShieldOn())
+					g_shield->setItemState(kShieldNormal);
+				g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
+				_vm->resetEnergyDeathReason();
+			}
+		}
+		break;
+	case MakeRoomView(kMars52, kNorth):
+	case MakeRoomView(kMars52, kSouth):
+	case MakeRoomView(kMars52, kEast):
+	case MakeRoomView(kMars52, kWest):
+	case MakeRoomView(kMars54, kNorth):
+	case MakeRoomView(kMars54, kSouth):
+	case MakeRoomView(kMars54, kEast):
+	case MakeRoomView(kMars54, kWest):
+	case MakeRoomView(kMars56, kNorth):
+	case MakeRoomView(kMars56, kSouth):
+	case MakeRoomView(kMars56, kEast):
+	case MakeRoomView(kMars56, kWest):
+	case MakeRoomView(kMars58, kNorth):
+	case MakeRoomView(kMars58, kSouth):
+	case MakeRoomView(kMars58, kEast):
+	case MakeRoomView(kMars58, kWest):
+		if (g_energyMonitor->getEnergyDrainRate() == kEnergyDrainNormal) {
+			if (GameState.getShieldOn()) {
+				g_shield->setItemState(kShieldRadiation);
+				g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainWithShield);
+			} else {
+				g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainNoShield);
+			}
+			_vm->setEnergyDeathReason(kDeathReactorBurn);
+		}
+		break;
+	default:
+		if (g_energyMonitor->getEnergyDrainRate() != kEnergyDrainNormal) {
+			if (GameState.getShieldOn())
+				g_shield->setItemState(kShieldNormal);
+			g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
+			_vm->resetEnergyDeathReason();
+		}
+		break;
+	}
+}
+
+void Mars::closeDoorOffScreen(const tRoomID room, const tDirectionConstant direction) {
+	switch (room) {
+	case kMars51:
+		playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
+		if (GameState.getShieldOn())
+			g_shield->setItemState(kShieldNormal);
+		g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
+		_vm->resetEnergyDeathReason();
+		break;
+	case kMars05:
+	case kMars06:
+	case kMars07:
+	case kMars13:
+	case kMars22:
+	case kMars47:
+	case kMars52:
+		playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
+		break;
+	case kMars18:
+	case kMars32:
+		playSpotSoundSync(kMarsTransportDoorCloseIn, kMarsTransportDoorCloseOut);
+		break;
+	case kMars19:
+		if (GameState.getCurrentRoom() != kMars35) {
+			playSpotSoundSync(kMarsBigAirlockDoorCloseIn, kMarsBigAirlockDoorCloseOut);
+			GameState.setMarsAirlockOpen(false);
+		}
+		break;
+	case kMars36:
+		if (GameState.getCurrentRoom() != kMars35)
+			playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
+		break;
+	case kMars48:
+		if (direction == kWest) {
+			if (GameState.getCurrentRoom() != kMars60) {
+				playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
+				GameState.setMarsAirlockOpen(false);
+			}
+		} else {
+			playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
+		}
+		break;
+	case kMars41:
+	case kMars42:
+	case kMars43:
+		if (direction == kWest)
+			playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
+		break;
+	case kMarsMaze037:
+	case kMarsMaze038:
+	case kMarsMaze012:
+	case kMarsMaze066:
+	case kMarsMaze050:
+	case kMarsMaze058:
+	case kMarsMaze057:
+	case kMarsMaze136:
+	case kMarsMaze047:
+	case kMarsMaze142:
+	case kMarsMaze133:
+	case kMarsMaze132:
+	case kMarsMaze113:
+	case kMarsMaze114:
+	case kMarsMaze120:
+	case kMarsMaze121:
+	case kMarsMaze081:
+	case kMarsMaze083:
+	case kMarsMaze088:
+	case kMarsMaze089:
+	case kMarsMaze179:
+	case kMarsMaze180:
+		playSpotSoundSync(kMarsMazeDoorCloseIn, kMarsMazeDoorCloseOut);
+		break;
+	}
+}
+
+void Mars::checkAirlockDoors() {
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars19, kWest):
+	case MakeRoomView(kMars18, kWest):
+	case MakeRoomView(kMars17, kWest):
+	case MakeRoomView(kMars16, kWest):
+	case MakeRoomView(kMars15, kWest):
+	case MakeRoomView(kMars14, kWest):
+	case MakeRoomView(kMars12, kWest):
+	case MakeRoomView(kMars11, kWest):
+	case MakeRoomView(kMars10, kWest):
+		if (GameState.getMarsInAirlock()) {
+			playSpotSoundSync(kMarsBigAirlockDoorCloseIn, kMarsBigAirlockDoorCloseOut);
+			GameState.setMarsInAirlock(false);
+		}
+		break;
+	case MakeRoomView(kMars36, kEast):
+	case MakeRoomView(kMars37, kEast):
+	case MakeRoomView(kMars38, kEast):
+	case MakeRoomView(kMars39, kEast):
+	case MakeRoomView(kMars48, kEast):
+	case MakeRoomView(kMars50, kEast):
+	case MakeRoomView(kMars51, kEast):
+	case MakeRoomView(kMars52, kEast):
+		if (GameState.getMarsInAirlock()) {
+			playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
+			GameState.setMarsInAirlock(false);
+		}
+		break;
+	case MakeRoomView(kMars35, kWest):
+	case MakeRoomView(kMars35, kEast):
+	case MakeRoomView(kMars60, kWest):
+	case MakeRoomView(kMars60, kEast):
+		GameState.setMarsInAirlock(true);
+		break;
+	default:
+		GameState.setMarsInAirlock(false);
+		break;
+	}
+}
+
+int16 Mars::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	int16 angle = Neighborhood::getStaticCompassAngle(room, dir);
+
+	switch (MakeRoomView(room, dir)) {
+	case MakeRoomView(kMars0A, kNorth):
+		angle -= 20;
+		break;
+	case MakeRoomView(kMars23, kNorth):
+	case MakeRoomView(kMars23, kSouth):
+	case MakeRoomView(kMars23, kEast):
+	case MakeRoomView(kMars23, kWest):
+	case MakeRoomView(kMars26, kNorth):
+	case MakeRoomView(kMars26, kSouth):
+	case MakeRoomView(kMars26, kEast):
+	case MakeRoomView(kMars26, kWest):
+		angle += 30;
+		break;
+	case MakeRoomView(kMars24, kNorth):
+	case MakeRoomView(kMars24, kSouth):
+	case MakeRoomView(kMars24, kEast):
+	case MakeRoomView(kMars24, kWest):
+	case MakeRoomView(kMars25, kNorth):
+	case MakeRoomView(kMars25, kSouth):
+	case MakeRoomView(kMars25, kEast):
+	case MakeRoomView(kMars25, kWest):
+		angle -= 30;
+		break;
+	case MakeRoomView(kMars54, kNorth):
+	case MakeRoomView(kMars54, kSouth):
+	case MakeRoomView(kMars54, kEast):
+	case MakeRoomView(kMars54, kWest):
+		angle += 90;
+		break;
+	case MakeRoomView(kMars56, kNorth):
+	case MakeRoomView(kMars56, kSouth):
+	case MakeRoomView(kMars56, kEast):
+	case MakeRoomView(kMars56, kWest):
+		angle += 180;
+		break;
+	case MakeRoomView(kMars58, kNorth):
+	case MakeRoomView(kMars58, kSouth):
+	case MakeRoomView(kMars58, kEast):
+	case MakeRoomView(kMars58, kWest):
+		angle -= 90;
+		break;
+	}
+
+	return angle;
+}
+
+void Mars::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
+	Neighborhood::getExitCompassMove(exitEntry, compassMove);
+
+	if (exitEntry.room == kMars43 && exitEntry.direction == kEast) {
+		compassMove.insertFaderKnot(exitEntry.movieStart + 16 * kMarsFrameDuration, 90);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 32 * kMarsFrameDuration, 270);
+	} else if (exitEntry.room == kMars46 && exitEntry.direction == kWest && exitEntry.altCode != kAltMarsPodAtMars45) {
+		compassMove.makeTwoKnotFaderSpec(kMarsMovieScale, exitEntry.movieStart, 270, exitEntry.movieEnd, 360);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 43 * kMarsFrameDuration, 270);
+		compassMove.insertFaderKnot(exitEntry.movieStart + 58 * kMarsFrameDuration, 360);
+	}
+}
+
+void Mars::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
+	switch (entry.extra) {
+	case kMarsTakePodToMars45:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 0, entry.movieEnd, 180);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 3), 30);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 11), 10);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 14), 40);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 16), 30);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 23), 100);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 31), 70);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 34), 100);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 37), 85);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 42), 135);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 44), 125);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 46), 145);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 49), 160);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 51), 180);
+		break;
+	case kMars35WestSpinAirlockToEast:
+	case kMars60WestSpinAirlockToEast:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 270);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale, 90);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale * 3, 270);
+		break;
+	case kMars35EastSpinAirlockToWest:
+	case kMars60EastSpinAirlockToWest:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 270, entry.movieEnd, 90);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale, 270);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale * 3, 90);
+		break;
+	case kMars52SpinLeft:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass, entry.movieEnd, kMars54Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars54Compass);
+		break;
+	case kMars52SpinRight:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass, entry.movieEnd, kMars58Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars58Compass);
+		break;
+	case kMars52Extend:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass,
+				entry.movieEnd, kMars52Compass + kMarsShieldPanelOffsetAngle);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars52Compass + kMarsShieldPanelOffsetAngle);
+		break;
+	case kMars53Retract:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
+				kMars52Compass + kMarsShieldPanelOffsetAngle, entry.movieEnd, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass + kMarsShieldPanelOffsetAngle);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars52Compass);
+		break;
+	case kMars56ExtendWithBomb:
+	case kMars56ExtendNoBomb:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass,
+				entry.movieEnd, kMars56Compass - kMarsShieldPanelOffsetAngle);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars56Compass - kMarsShieldPanelOffsetAngle);
+		break;
+	case kMars57RetractWithBomb:
+	case kMars57RetractNoBomb:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
+				kMars56Compass - kMarsShieldPanelOffsetAngle, entry.movieEnd, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass - kMarsShieldPanelOffsetAngle);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars56Compass);
+		break;
+	case kMars54SpinLeft:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars54Compass, entry.movieEnd, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars54Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars56Compass);
+		break;
+	case kMars54SpinRight:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars54Compass, entry.movieEnd, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars54Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars52Compass);
+		break;
+	case kMars56SpinLeft:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass,
+				entry.movieEnd, kMars58Compass + 360);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars58Compass + 360);
+		break;
+	case kMars56SpinRight:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass, entry.movieEnd, kMars54Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars54Compass);
+		break;
+	case kMars58SpinLeft:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars58Compass,
+				entry.movieEnd, kMars52Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars58Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars52Compass);
+		break;
+	case kMars58SpinRight:
+		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
+				kMars58Compass + 360, entry.movieEnd, kMars56Compass);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars58Compass + 360);
+		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars56Compass);
+		break;
+	default:
+		Neighborhood::getExtraCompassMove(entry, compassMove);
+	}
+}
+
+void Mars::loadAmbientLoops() {
+	tRoomID room = GameState.getCurrentRoom();
+
+	if ((room >= kMars0A && room <= kMars21) || (room >= kMars41 && room <= kMars43)) {
+		if (GameState.getMarsSeenTimeStream())
+			loadLoopSound1("Sounds/Mars/Gantry Ambient.22K.8.AIFF");
+	} else if (room >= kMars22 && room <= kMars31South) {
+		loadLoopSound1("Sounds/Mars/Reception.02.22K.8.AIFF", 0x100 / 4);
+	} else if (room >= kMars32 && room <= kMars34) {
+		loadLoopSound1("Sounds/Mars/Pod Room Ambient.22K.8.AIFF");
+	} else if (room == kMars35) {
+		if (getAirQuality(room) == kAirQualityVacuum)
+			loadLoopSound1("Sounds/Mars/Gear Room Ambient.22K.8.AIFF");
+		else
+			loadLoopSound1("Sounds/Mars/Gantry Ambient.22K.8.AIFF", 0x100 / 2);
+	} else if (room >= kMars36 && room <= kMars39) {
+		loadLoopSound1("Sounds/Mars/Gear Room Ambient.22K.8.AIFF");
+	} else if (room >= kMars45 && room <= kMars51) {
+		loadLoopSound1("Sounds/Mars/Lower Mars Ambient.22K.8.AIFF");
+	} else if (room >= kMars52 && room <= kMars58) {
+		loadLoopSound1("Sounds/Mars/ReactorLoop.22K.8.AIFF");
+	} else if (room == kMars60) {
+		if (getAirQuality(room) == kAirQualityVacuum)
+			loadLoopSound1("Sounds/Mars/Mars Maze Ambient.22K.8.AIFF");
+		else
+			loadLoopSound1("Sounds/Mars/Lower Mars Ambient.22K.8.AIFF", 0x100 / 2);
+	} else if (room >= kMarsMaze004 && room <= kMarsMaze200) {
+		loadLoopSound1("Sounds/Mars/Mars Maze Ambient.22K.8.AIFF");
+	} else if (room == kMarsRobotShuttle) {
+		loadLoopSound1("Sounds/Mars/Robot Shuttle.22K.8.AIFF");
+	}
+	
+	if (!_noAirFuse.isFuseLit()) {
+		switch (room) {
+		case kMars02:
+		case kMars05:
+		case kMars06:
+		case kMars07:
+		case kMars08:
+			loadLoopSound2("Sounds/Mars/Gantry Loop.aiff", 0x100, 0, 0);
+			break;
+		// Robot at maze 48
+		case kMarsMaze037:
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			else
+				loadLoopSound2("");
+			break;
+		case kMarsMaze038:
+		case kMarsMaze039:
+		case kMarsMaze049:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
+			break;
+		case kMarsMaze050:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			break;
+		case kMarsMaze051:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		case kMarsMaze052:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
+			break;
+		case kMarsMaze042:
+		case kMarsMaze053:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 8);
+			break;
+		case kMarsMaze058:
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
+			else
+				loadLoopSound2("");
+			break;
+		// Robot at 151
+		case kMarsMaze148:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
+			break;
+		case kMarsMaze147:
+		case kMarsMaze149:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			break;
+		case kMarsMaze146:
+		case kMarsMaze152:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		case kMarsMaze145:
+		case kMarsMaze153:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
+			break;
+		// Robots at 80 and 82.
+		case kMarsMaze079:
+		case kMarsMaze081:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
+			break;
+		case kMarsMaze078:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			break;
+		case kMarsMaze083:
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			else
+				loadLoopSound2("");
+			break;
+		case kMarsMaze118:
+		case kMarsMaze076:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		case kMarsMaze074:
+		case kMarsMaze117:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
+			break;
+		// Robot at 94
+		case kMarsMaze093:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
+			break;
+		case kMarsMaze091:
+		case kMarsMaze092:
+		case kMarsMaze098:
+		case kMarsMaze101:
+		case kMarsMaze100:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			break;
+		case kMarsMaze090:
+		case kMarsMaze099:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		case kMarsMaze089:
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		case kMarsMaze178:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
+			break;
+		// Robot at 197
+		case kMarsMaze191:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
+			break;
+		case kMarsMaze190:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
+			break;
+		case kMarsMaze198:
+		case kMarsMaze189:
+			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
+			break;
+		default:
+			loadLoopSound2("");
+			break;
+		}
+	}
+}
+
+void Mars::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kMars02, kSouth):
+	case MakeRoomView(kMars19, kEast):
+	case MakeRoomView(kMars22, kNorth):
+	case MakeRoomView(kMars43, kEast):
+	case MakeRoomView(kMars51, kEast):
+	case MakeRoomView(kMars56, kEast):
+	case MakeRoomView(kMars60, kWest):
+	case MakeRoomView(kMarsMaze004, kWest):
+	case MakeRoomView(kMarsMaze009, kWest):
+	case MakeRoomView(kMarsMaze012, kWest):
+	case MakeRoomView(kMarsMaze037, kWest):
+	case MakeRoomView(kMarsMaze047, kNorth):
+	case MakeRoomView(kMarsMaze052, kWest):
+	case MakeRoomView(kMarsMaze057, kNorth):
+	case MakeRoomView(kMarsMaze071, kWest):
+	case MakeRoomView(kMarsMaze081, kNorth):
+	case MakeRoomView(kMarsMaze088, kWest):
+	case MakeRoomView(kMarsMaze093, kWest):
+	case MakeRoomView(kMarsMaze115, kNorth):
+	case MakeRoomView(kMarsMaze120, kWest):
+	case MakeRoomView(kMarsMaze126, kEast):
+	case MakeRoomView(kMarsMaze133, kNorth):
+	case MakeRoomView(kMarsMaze144, kNorth):
+	case MakeRoomView(kMarsMaze156, kEast):
+	case MakeRoomView(kMarsMaze162, kNorth):
+	case MakeRoomView(kMarsMaze177, kWest):
+	case MakeRoomView(kMarsMaze180, kNorth):
+	case MakeRoomView(kMarsMaze187, kWest):
+	case MakeRoomView(kMarsMaze199, kWest):
+		makeContinuePoint();
+		break;
+	case MakeRoomView(kMars05, kEast):
+	case MakeRoomView(kMars06, kEast):
+	case MakeRoomView(kMars07, kEast):
+		if (GameState.getMarsSecurityDown())
+			makeContinuePoint();
+		break;
+	case MakeRoomView(kMars46, kSouth):
+		if (!GameState.getMarsSeenRobotAtReactor())
+			makeContinuePoint();
+		break;
+	case MakeRoomView(kMars46, kWest):
+		if (GameState.getMarsAvoidedReactorRobot())
+			makeContinuePoint();
+		break;
+	}
+}
+
+void Mars::launchMaze007Robot() {
+	startExtraLongSequence(kMarsMaze007RobotApproach, kMarsMaze007RobotDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze007RobotLoopingTime, kMarsMovieScale, kMaze007RobotLoopingEvent);
+}
+
+void Mars::launchMaze015Robot() {
+	startExtraLongSequence(kMarsMaze015SouthRobotApproach, kMarsMaze015SouthRobotDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze015RobotLoopingTime, kMarsMovieScale, kMaze015RobotLoopingEvent);
+}
+
+void Mars::launchMaze101Robot() {
+	startExtraLongSequence(kMarsMaze101EastRobotApproach, kMarsMaze101EastRobotDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze101RobotLoopingTime, kMarsMovieScale, kMaze101RobotLoopingEvent);
+}
+
+void Mars::launchMaze104Robot() {
+	startExtraLongSequence(kMarsMaze104WestLoop, kMarsMaze104WestDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze104RobotLoopingTime, kMarsMovieScale, kMaze104RobotLoopingEvent);
+}
+
+void Mars::launchMaze133Robot() {
+	startExtraLongSequence(kMarsMaze133SouthApproach, kMarsMaze133SouthDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze133RobotLoopingTime, kMarsMovieScale, kMaze133RobotLoopingEvent);
+}
+
+void Mars::launchMaze136Robot() {
+	startExtraLongSequence(kMarsMaze136NorthApproach, kMarsMaze136NorthDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze136RobotLoopingTime, kMarsMovieScale, kMaze136RobotLoopingEvent);
+}
+
+void Mars::launchMaze184Robot() {
+	startExtraLongSequence(kMarsMaze184WestLoop, kMarsMaze184WestDeath, kExtraCompletedFlag, kFilterAllInput);
+	scheduleEvent(kMaze184RobotLoopingTime, kMarsMovieScale, kMaze184RobotLoopingEvent);
+}
+
+void Mars::timerExpired(const uint32 eventType) {
+	switch (eventType) {
+	case kMaze007RobotLoopingEvent:
+	case kMaze015RobotLoopingEvent:
+	case kMaze101RobotLoopingEvent:
+	case kMaze104RobotLoopingEvent:
+	case kMaze133RobotLoopingEvent:
+	case kMaze136RobotLoopingEvent:
+	case kMaze184RobotLoopingEvent:
+		_interruptionFilter = kFilterNoInput;
+		break;
+	}
+}
+
+void Mars::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kMars18, kNorth):
+		if (GameState.getMarsPodAtUpperPlatform())
+			setCurrentAlternate(kAltMarsPodAtMars34);
+		break;
+	case MakeRoomView(kMars27, kEast):
+	case MakeRoomView(kMars29, kEast):
+		if (GameState.isTakenItemID(kMarsCard))
+			setCurrentAlternate(kAltMarsTookCard);
+		else
+			setCurrentAlternate(kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars35, kEast):
+	case MakeRoomView(kMars35, kWest):
+		if (GameState.getMarsAirlockOpen())
+			setCurrentAlternate(kAltMars35AirlockWest);
+		else
+			setCurrentAlternate(kAltMars35AirlockEast);
+		break;
+	case MakeRoomView(kMars60, kEast):
+	case MakeRoomView(kMars60, kWest):
+		if (GameState.getMarsAirlockOpen())
+			setCurrentAlternate(kAltMars60AirlockEast);
+		else
+			setCurrentAlternate(kAltMars60AirlockWest);
+		break;
+	case MakeRoomView(kMars45, kNorth):
+	case MakeRoomView(kMars45, kSouth):
+	case MakeRoomView(kMars45, kEast):
+	case MakeRoomView(kMars45, kWest):
+		GameState.setMarsPodAtUpperPlatform(false);
+		setCurrentAlternate(kAltMarsPodAtMars45);
+		break;
+	case MakeRoomView(kMars46, kNorth):
+	case MakeRoomView(kMars46, kSouth):
+	case MakeRoomView(kMars46, kEast):
+	case MakeRoomView(kMars46, kWest):
+	case MakeRoomView(kMars47, kNorth):
+	case MakeRoomView(kMars47, kSouth):
+	case MakeRoomView(kMars47, kEast):
+	case MakeRoomView(kMars47, kWest):
+		if (GameState.getMarsPodAtUpperPlatform())
+			setCurrentAlternate(kAltMarsNormal);
+		else
+			setCurrentAlternate(kAltMarsPodAtMars45);
+		break;
+	case MakeRoomView(kMars48, kNorth):
+	case MakeRoomView(kMars48, kSouth):
+	case MakeRoomView(kMars48, kEast):
+	case MakeRoomView(kMars48, kWest):
+	case MakeRoomView(kMars49, kNorth):
+	case MakeRoomView(kMars49, kEast):
+	case MakeRoomView(kMars49, kWest):
+		if (GameState.isTakenItemID(kAirMask))
+			setCurrentAlternate(kAltMarsTookMask);
+		else
+			setCurrentAlternate(kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars49, kSouth):
+		if (GameState.getMarsMaskOnFiller())
+			setCurrentAlternate(kAltMarsMaskOnFiller);
+		else if (GameState.isTakenItemID(kAirMask))
+			setCurrentAlternate(kAltMarsTookMask);
+		else
+			setCurrentAlternate(kAltMarsNormal);
+		break;
+	}
+
+	Neighborhood::arriveAt(room, direction);
+	checkAirlockDoors();
+	setUpReactorEnergyDrain();
+
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kMars0A, kNorth):
+		if (!GameState.getMarsSeenTimeStream())
+			startExtraLongSequence(kMarsArrivalFromTSA, kMars0AWatchShuttleDepart, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kMars07, kSouth):
+	case MakeRoomView(kMars13, kNorth):
+		if (!GameState.getMarsHeardCheckInMessage()) {
+			playSpotSoundSync(kMarsCheckInRequiredIn, kMarsCheckInRequiredOut);
+			GameState.setMarsHeardCheckInMessage(true);
+		}
+		break;
+	case MakeRoomView(kMars44, kWest):
+		// TODO: Space Chase
+		_neighborhoodNotification.setNotificationFlags(kTimeForCanyonChaseFlag, kTimeForCanyonChaseFlag);
+		break;
+	case MakeRoomView(kMars10, kNorth):
+		if (!GameState.getMarsRobotThrownPlayer())
+			startExtraSequence(kRobotThrowsPlayer, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kMars11, kSouth):
+	case MakeRoomView(kMars12, kSouth):
+		setCurrentActivation(kActivationReadyForKiosk);
+		break;
+	case MakeRoomView(kMars15, kWest):
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown()) {
+			playSpotSoundSync(kMarsShuttle2DepartedIn, kMarsShuttle2DepartedOut);
+			restoreStriding(kMars17, kWest, kAltMarsNormal);
+			GameState.setMarsSecurityDown(true);
+		}
+		break;
+	case MakeRoomView(kMars17, kNorth):
+	case MakeRoomView(kMars17, kSouth):
+	case MakeRoomView(kMars17, kEast):
+	case MakeRoomView(kMars17, kWest):
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
+			forceStridingStop(kMars17, kWest, kAltMarsNormal);
+
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave()) {
+			startExtraSequence(kRobotOnWayToShuttle, kExtraCompletedFlag, kFilterNoInput);
+			restoreStriding(kMars19, kWest, kAltMarsNormal);
+			GameState.setMarsSawRobotLeave(true);
+		}
+		break;
+	case MakeRoomView(kMars19, kNorth):
+	case MakeRoomView(kMars19, kSouth):
+	case MakeRoomView(kMars19, kWest):
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave())
+			forceStridingStop(kMars19, kWest, kAltMarsNormal);
+
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
+			forceStridingStop(kMars17, kWest, kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars19, kEast):
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave())
+			forceStridingStop(kMars19, kWest, kAltMarsNormal);
+
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
+			forceStridingStop(kMars17, kWest, kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars32, kNorth):
+		if (!GameState.getMarsPodAtUpperPlatform()) {
+			playSpotSoundSync(kMarsPodArrivedUpperPlatformIn, kMarsPodArrivedUpperPlatformOut);
+			GameState.setMarsPodAtUpperPlatform(true);
+		}
+		break;
+	case MakeRoomView(kMars33North, kNorth):
+		setCurrentActivation(kActivationTunnelMapReady);
+		// Fall through...
+	case MakeRoomView(kMars33, kSouth):
+	case MakeRoomView(kMars33, kEast):
+	case MakeRoomView(kMars33, kWest):
+	case MakeRoomView(kMars32, kSouth):
+	case MakeRoomView(kMars32, kEast):
+	case MakeRoomView(kMars32, kWest):
+		if (!GameState.getMarsPodAtUpperPlatform())
+			GameState.setMarsPodAtUpperPlatform(true);
+		break;
+	case MakeRoomView(kMars34, kNorth):
+		startExtraSequence(kMars34NorthPodGreeting, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kMars34, kSouth):
+	case MakeRoomView(kMars45, kNorth):
+		setCurrentActivation(kActivateMarsPodClosed);
+		break;
+	case MakeRoomView(kMars35, kWest):
+		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
+			forceStridingStop(kMars19, kWest, kAltMarsNormal);
+		// Fall through...
+	case MakeRoomView(kMars60, kEast):
+		if (!GameState.getMarsAirlockOpen())
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+		break;
+	case MakeRoomView(kMars35, kEast):
+	case MakeRoomView(kMars60, kWest):
+		if (GameState.getMarsAirlockOpen())
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+		break;
+	case MakeRoomView(kMars39, kWest):
+		if (GameState.getLastRoom() == kMarsMaze200)
+			GameState.setMarsPodAtUpperPlatform(false);
+		break;
+	case MakeRoomView(kMars45, kSouth):
+		// Set up maze doors here.
+		// Doing it here makes sure that it will be the same if the player comes
+		// back out of the maze and goes back in, but will vary if
+		// the player comes back down to the maze a second time.
+		GameState.setMarsMazeDoorPair1(_vm->getRandomBit());
+		GameState.setMarsMazeDoorPair2(_vm->getRandomBit());
+		GameState.setMarsMazeDoorPair3(_vm->getRandomBit());
+		GameState.setMarsArrivedBelow(true);
+		break;
+	case MakeRoomView(kMars48, kEast):
+		if (!GameState.getMarsSeenRobotAtReactor()) {
+			// Preload the looping sound...
+			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0, 0, 0);
+			startExtraSequence(kMars48RobotApproaches, kExtraCompletedFlag, kFilterNoInput);
+		} else if (!GameState.getMarsAvoidedReactorRobot()) {
+			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
+			loopExtraSequence(kMars48RobotLoops);
+			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
+			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+			_utilityFuse.lightFuse();
+		}
+		break;
+	case MakeRoomView(kMars48, kSouth):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
+			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
+			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
+			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+			_utilityFuse.lightFuse();
+		}
+		break;
+	case MakeRoomView(kMars49, kSouth):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
+			playSpotSoundSync(kMarsRobotTakesTransportIn, kMarsRobotTakesTransportOut);
+			playSpotSoundSync(kMarsPodDepartedLowerPlatformIn, kMarsPodDepartedLowerPlatformOut);
+			GameState.setMarsAvoidedReactorRobot(true);
+			GameState.setMarsPodAtUpperPlatform(true);
+			GameState.getScoringAvoidedRobot();
+		}
+
+		if (GameState.isTakenItemID(kAirMask))
+			setCurrentActivation(kActivateHotSpotAlways);
+		else if (GameState.getMarsMaskOnFiller())
+			setCurrentActivation(kActivateMaskOnFiller);
+		else
+			setCurrentActivation(kActivateMaskOnHolder);
+		break;
+	case MakeRoomView(kMars51, kWest):
+	case MakeRoomView(kMars50, kWest):
+	case MakeRoomView(kMars48, kWest):
+		if (GameState.getShieldOn())
+			g_shield->setItemState(kShieldNormal);
+		g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
+		_vm->resetEnergyDeathReason();
+		break;
+	case MakeRoomView(kMars52, kNorth):
+	case MakeRoomView(kMars52, kSouth):
+	case MakeRoomView(kMars52, kEast):
+	case MakeRoomView(kMars52, kWest):
+	case MakeRoomView(kMars54, kNorth):
+	case MakeRoomView(kMars54, kSouth):
+	case MakeRoomView(kMars54, kEast):
+	case MakeRoomView(kMars54, kWest):
+	case MakeRoomView(kMars56, kNorth):
+	case MakeRoomView(kMars56, kSouth):
+	case MakeRoomView(kMars56, kWest):
+	case MakeRoomView(kMars58, kNorth):
+	case MakeRoomView(kMars58, kSouth):
+	case MakeRoomView(kMars58, kEast):
+	case MakeRoomView(kMars58, kWest):
+		setCurrentActivation(kActivateReactorPlatformOut);
+		break;
+	case MakeRoomView(kMars56, kEast):
+		if (GameState.getMarsLockBroken()) {
+			setCurrentActivation(kActivateReactorAskOperation);
+			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
+		} else if (GameState.getMarsLockFrozen()) {
+			setCurrentActivation(kActivateReactorReadyForCrowBar);
+			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
+			_utilityFuse.primeFuse(kLockFreezeTimeLmit);
+			_utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
+			_utilityFuse.lightFuse();
+		} else {
+			setCurrentActivation(kActivateReactorPlatformOut);
+		}
+		break;
+	case MakeRoomView(kMarsRobotShuttle, kEast):
+		setCurrentActivation(kActivationRobotHeadClosed);
+		break;
+	case MakeRoomView(kMarsMaze007, kNorth):
+		launchMaze007Robot();
+		break;
+	case MakeRoomView(kMarsMaze015, kSouth):
+		launchMaze015Robot();
+		break;
+	case MakeRoomView(kMarsMaze101, kEast):
+		launchMaze101Robot();
+		break;
+	case MakeRoomView(kMarsMaze104, kWest):
+		launchMaze104Robot();
+		break;
+	case MakeRoomView(kMarsMaze133, kSouth):
+		launchMaze133Robot();
+		break;
+	case MakeRoomView(kMarsMaze136, kNorth):
+		launchMaze136Robot();
+		break;
+	case MakeRoomView(kMarsMaze184, kWest):
+		launchMaze184Robot();
+		break;
+	case MakeRoomView(kMarsMaze199, kSouth):
+		GameState.setScoringThreadedMaze();
+		GameState.setMarsThreadedMaze(true);
+		break;
+	case MakeRoomView(kMarsDeathRoom, kNorth):
+	case MakeRoomView(kMarsDeathRoom, kSouth):
+	case MakeRoomView(kMarsDeathRoom, kEast):
+	case MakeRoomView(kMarsDeathRoom, kWest):
+		switch (GameState.getLastRoom()) {
+		case kMars39:
+			die(kDeathDidntLeaveBucket);
+			break;
+		case kMars46:
+			die(kDeathRunOverByPod);
+			break;
+		}
+		break;
+	}
+
+	checkAirMask();
+}
+
+void Mars::shieldOn() {
+	setUpReactorEnergyDrain();
+}
+
+void Mars::shieldOff() {
+	setUpReactorEnergyDrain();
+}
+
+void Mars::turnTo(const tDirectionConstant direction) {
+	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
+	case MakeRoomView(kMars27, kNorth):
+	case MakeRoomView(kMars27, kSouth):
+	case MakeRoomView(kMars27, kEast):
+	case MakeRoomView(kMars29, kNorth):
+	case MakeRoomView(kMars29, kSouth):
+	case MakeRoomView(kMars29, kEast):
+		if (GameState.isTakenItemID(kMarsCard))
+			setCurrentAlternate(kAltMarsTookCard);
+		break;
+	case MakeRoomView(kMars35, kNorth):
+	case MakeRoomView(kMars35, kSouth):
+	case MakeRoomView(kMars60, kNorth):
+	case MakeRoomView(kMars60, kSouth):
+		if (getCurrentActivation() == kActivateAirlockPressurized)
+			playSpotSoundSync(kMarsAirlockPressurizeIn, kMarsAirlockPressurizeOut);
+		break;
+	}
+
+	Neighborhood::turnTo(direction);
+
+	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
+	case MakeRoomView(kMars11, kSouth):
+	case MakeRoomView(kMars12, kSouth):
+		setCurrentActivation(kActivationReadyForKiosk);
+		break;
+	case MakeRoomView(kMars18, kNorth):
+		if (GameState.getMarsPodAtUpperPlatform())
+			setCurrentAlternate(kAltMarsPodAtMars34);
+		break;
+	case MakeRoomView(kMars22, kSouth):
+		if (!GameState.getMarsHeardCheckInMessage()) {
+			playSpotSoundSync(kMarsCheckInRequiredIn, kMarsCheckInRequiredOut);
+			GameState.setMarsHeardCheckInMessage(true);
+		}
+		break;
+	case MakeRoomView(kMars34, kSouth):
+	case MakeRoomView(kMars45, kNorth):
+		setCurrentActivation(kActivateMarsPodClosed);
+		break;
+	case MakeRoomView(kMars34, kNorth):
+		startExtraSequence(kMars34NorthPodGreeting, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case MakeRoomView(kMars35, kEast):
+	case MakeRoomView(kMars60, kWest):
+		if (GameState.getMarsAirlockOpen())
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+		break;
+	case MakeRoomView(kMars60, kEast):
+		if (!GameState.getMarsAirlockOpen())
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+		break;
+	case MakeRoomView(kMars35, kWest):
+		if (!GameState.getMarsAirlockOpen())
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+		
+		// Do this here because this will be called after spinning the airlock after
+		// going through the gear room.
+		if (GameState.getMarsThreadedMaze())
+			GameState.setScoringThreadedGearRoom();
+		break;
+	case MakeRoomView(kMars48, kNorth):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
+			die(kDeathDidntGetOutOfWay);
+		break;
+	case MakeRoomView(kMars48, kEast):
+		if (!GameState.getMarsSeenRobotAtReactor()) {
+			// Preload the looping sound...
+			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0, 0, 0);
+			startExtraSequence(kMars48RobotApproaches, kExtraCompletedFlag, kFilterNoInput);
+		} else if (!GameState.getMarsAvoidedReactorRobot()) {
+			loopExtraSequence(kMars48RobotLoops);
+		} else if (GameState.isTakenItemID(kAirMask)) {
+			setCurrentAlternate(kAltMarsTookMask);
+		} else {
+			setCurrentAlternate(kAltMarsNormal);
+		}
+		break;
+	case MakeRoomView(kMars48, kWest):
+		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
+			die(kDeathDidntGetOutOfWay);
+		else if (GameState.isTakenItemID(kAirMask))
+			setCurrentAlternate(kAltMarsTookMask);
+		else
+			setCurrentAlternate(kAltMarsNormal);
+		break;
+	case MakeRoomView(kMars49, kSouth):
+		if (GameState.isTakenItemID(kAirMask))
+			setCurrentActivation(kActivateHotSpotAlways);
+		else
+			setCurrentActivation(kActivateMaskOnHolder);
+		break;
+	case MakeRoomView(kMars52, kNorth):
+	case MakeRoomView(kMars52, kSouth):
+	case MakeRoomView(kMars52, kEast):
+	case MakeRoomView(kMars52, kWest):
+	case MakeRoomView(kMars54, kNorth):
+	case MakeRoomView(kMars54, kSouth):
+	case MakeRoomView(kMars54, kEast):
+	case MakeRoomView(kMars54, kWest):
+	case MakeRoomView(kMars56, kNorth):
+	case MakeRoomView(kMars56, kSouth):
+	case MakeRoomView(kMars56, kEast):
+	case MakeRoomView(kMars56, kWest):
+	case MakeRoomView(kMars58, kNorth):
+	case MakeRoomView(kMars58, kSouth):
+	case MakeRoomView(kMars58, kEast):
+	case MakeRoomView(kMars58, kWest):
+		setCurrentActivation(kActivateReactorPlatformOut);
+		break;
+	case MakeRoomView(kMarsMaze007, kNorth):
+		launchMaze007Robot();
+		break;
+	case MakeRoomView(kMarsMaze015, kSouth):
+		launchMaze015Robot();
+		break;
+	case MakeRoomView(kMarsMaze101, kEast):
+		launchMaze101Robot();
+		break;
+	case MakeRoomView(kMarsMaze104, kWest):
+		launchMaze104Robot();
+		break;
+	case MakeRoomView(kMarsMaze133, kSouth):
+		launchMaze133Robot();
+		break;
+	case MakeRoomView(kMarsMaze136, kNorth):
+		launchMaze136Robot();
+		break;
+	case MakeRoomView(kMarsMaze184, kWest):
+		launchMaze184Robot();
+		break;
+	}
+}
+
+void Mars::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
+	switch (hotspot->getObjectID()) {
+	case kMars57RedMoveSpotID:
+	case kMars57YellowMoveSpotID:
+	case kMars57GreenMoveSpotID:
+		if (!_choiceHighlight.choiceHighlighted(hotspot->getObjectID() - kMars57RedMoveSpotID))
+			hotspot->setActive();
+		break;
+	case kMars57BlueMoveSpotID:
+		if (_reactorStage >= 2 && !_choiceHighlight.choiceHighlighted(3))
+			hotspot->setActive();
+		break;
+	case kMars57PurpleMoveSpotID:
+		if (_reactorStage == 3 && !_choiceHighlight.choiceHighlighted(4))
+			hotspot->setActive();
+		break;
+	default:
+		Neighborhood::activateOneHotspot(entry, hotspot);
+		break;
+	}
+}
+
+void Mars::activateHotspots() {
+	InventoryItem *item;
+
+	Neighborhood::activateHotspots();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars48, kEast):
+		if ((_navMovie.getFlags() & kLoopTimeBase) != 0 && _vm->getDragType() == kDragInventoryUse)
+			g_allHotspots.activateOneHotspot(kAttackRobotHotSpotID);
+		break;
+	case MakeRoomView(kMars56, kEast):
+		switch (getCurrentActivation()) {
+		case kActivateReactorReadyForNitrogen:
+			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
+			if (item->getItemState() != kNitrogenFull)
+				g_allHotspots.deactivateOneHotspot(kMars57DropNitrogenSpotID);
+			// Fall through...
+		case kActivateReactorReadyForCrowBar:
+			g_allHotspots.activateOneHotspot(kMars57CantOpenPanelSpotID);
+			break;
+		}
+		break;
+	case MakeRoomView(kMarsRobotShuttle, kEast):
+		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag))
+			g_allHotspots.deactivateOneHotspot(kRobotShuttleMapChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kRobotShuttleMapChipSpotID);
+
+		if (_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag))
+			g_allHotspots.deactivateOneHotspot(kRobotShuttleOpticalChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kRobotShuttleOpticalChipSpotID);
+
+		if (_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag))
+			g_allHotspots.deactivateOneHotspot(kRobotShuttleShieldChipSpotID);
+		else
+			g_allHotspots.activateOneHotspot(kRobotShuttleShieldChipSpotID);
+		break;
+	default:
+		if (_privateFlags.getFlag(kMarsPrivateInSpaceChaseFlag)) {
+			// TODO
+		}
+		break;
+	}
+}
+
+void Mars::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
+	switch (clickedSpot->getObjectID()) {
+	case kMars11NorthKioskSpotID:
+	case kMars12NorthKioskSpotID:
+		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
+		Neighborhood::clickInHotspot(input, clickedSpot);
+		break;
+	case kMars11NorthKioskSightsSpotID:
+	case kMars12NorthKioskSightsSpotID:
+		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
+		if (!startExtraSequenceSync(kMarsSightsInfo, kFilterAllInput))
+			showExtraView(kMarsInfoKioskIntro);
+		break;
+	case kMars11NorthKioskColonySpotID:
+	case kMars12NorthKioskColonySpotID:
+		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
+		if (!startExtraSequenceSync(kMarsColonyInfo, kFilterAllInput))
+			showExtraView(kMarsInfoKioskIntro);
+		break;
+	case kMars33NorthMonitorSpotID:
+		switch (_lastExtra) {
+		case kMars33SlideShow1:
+			startExtraSequence(kMars33SlideShow2, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMars33SlideShow2:
+			startExtraSequence(kMars33SlideShow3, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMars33SlideShow3:
+			startExtraSequence(kMars33SlideShow4, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMars33SlideShow4:
+			// Should never happen...
+		default:
+			startExtraSequence(kMars33SlideShow1, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+		break;
+	case kMars34SouthOpenStorageSpotID:
+		if (GameState.isTakenItemID(kCrowbar))
+			startExtraSequence(kMars34SpotOpenNoBar, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kMars34SpotOpenWithBar, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kMars34SouthCloseStorageSpotID:
+		if (GameState.isTakenItemID(kCrowbar))
+			startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kMars35WestPressurizeSpotID:
+	case kMars35EastPressurizeSpotID:
+	case kMars60WestPressurizeSpotID:
+	case kMars60EastPressurizeSpotID:
+		playSpotSoundSync(kMarsAirlockButtonBeepIn, kMarsAirlockButtonBeepOut);
+		playSpotSoundSync(kMarsAirlockPressurizeIn, kMarsAirlockPressurizeOut);
+		setCurrentActivation(kActivateAirlockPressurized);
+		break;
+	case kMars45NorthOpenStorageSpotID:
+		if (GameState.isTakenItemID(kCrowbar))
+			startExtraSequence(kMars45SpotOpenNoBar, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kMars45SpotOpenWithBar, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kMars45NorthCloseStorageSpotID:
+		if (GameState.isTakenItemID(kCrowbar))
+			startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+		else
+			startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kMars56ExtractSpotID:
+		if (GameState.isTakenItemID(kCardBomb)) {
+			startExtraSequence(kMars56ExtendNoBomb, kExtraCompletedFlag, kFilterNoInput);
+			setCurrentActivation(kActivateReactorPlatformIn);
+		} else {
+			startExtraSequence(kMars56ExtendWithBomb, kExtraCompletedFlag, kFilterNoInput);
+			setCurrentActivation(kActivateReactorAskLowerScreen);
+		}
+		break;
+	case kMars57UndoMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doUndoOneGuess();
+		break;
+	case kMars57RedMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doReactorGuess(0);
+		break;
+	case kMars57YellowMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doReactorGuess(1);
+		break;
+	case kMars57GreenMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doReactorGuess(2);
+		break;
+	case kMars57BlueMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doReactorGuess(3);
+		break;
+	case kMars57PurpleMoveSpotID:
+		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
+		doReactorGuess(4);
+		break;
+	default:
+		Neighborhood::clickInHotspot(input, clickedSpot);
+		break;
+	}
+}
+
+tInputBits Mars::getInputFilter() {
+	tInputBits result = Neighborhood::getInputFilter();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars49, kSouth):
+		if (GameState.getMarsMaskOnFiller())
+			// Can't move when mask is on filler.
+			result &= ~kFilterAllDirections;
+		break;
+	case MakeRoomView(kMars52, kNorth):
+	case MakeRoomView(kMars52, kSouth):
+	case MakeRoomView(kMars52, kEast):
+	case MakeRoomView(kMars52, kWest):
+	case MakeRoomView(kMars54, kNorth):
+	case MakeRoomView(kMars54, kSouth):
+	case MakeRoomView(kMars54, kEast):
+	case MakeRoomView(kMars54, kWest):
+	case MakeRoomView(kMars56, kNorth):
+	case MakeRoomView(kMars56, kSouth):
+	case MakeRoomView(kMars56, kEast):
+	case MakeRoomView(kMars56, kWest):
+	case MakeRoomView(kMars58, kNorth):
+	case MakeRoomView(kMars58, kSouth):
+	case MakeRoomView(kMars58, kEast):
+	case MakeRoomView(kMars58, kWest):
+		if (_privateFlags.getFlag(kMarsPrivatePlatformZoomedInFlag))
+			// Can't move when platform is extended.
+			result &= ~kFilterAllDirections;
+		break;
+	case MakeRoomView(kMars44, kWest):
+		// TODO
+		break;
+	}
+
+	return result;
+}
+
+// Only called when trying to pick up an item and the player can't (because
+// the inventory is too full or because the player lets go of the item before
+// dropping it into the inventory).
+Hotspot *Mars::getItemScreenSpot(Item *item, DisplayElement *element) {
+	tHotSpotID destSpotID;
+
+	switch (item->getObjectID()) {
+	case kCardBomb:
+		destSpotID = kMars57GrabBombSpotID;
+		break;
+	case kMarsCard:
+		destSpotID = kMars31SouthCardSpotID;
+		break;
+	case kAirMask:
+		if (GameState.getMarsMaskOnFiller())
+			destSpotID = kMars49AirFillingDropSpotID;
+		else
+			destSpotID = kMars49AirMaskSpotID;
+		break;
+	case kCrowbar:
+		if (GameState.getCurrentRoom() == kMars34)
+			destSpotID = kMars34SouthCrowbarSpotID;
+		else
+			destSpotID = kMars45NorthCrowbarSpotID;
+		break;
+	case kMapBiochip:
+		destSpotID = kRobotShuttleMapChipSpotID;
+		break;
+	case kOpticalBiochip:
+		destSpotID = kRobotShuttleOpticalChipSpotID;
+		break;
+	case kShieldBiochip:
+		destSpotID = kRobotShuttleShieldChipSpotID;
+		break;
+	default:
+		destSpotID = kNoHotSpotID;
+		break;
+	}
+
+	if (destSpotID == kNoHotSpotID)
+		return Neighborhood::getItemScreenSpot(item, element);
+
+	return g_allHotspots.findHotspotByID(destSpotID);
+}
+
+void Mars::takeItemFromRoom(Item *item) {
+	switch (item->getObjectID()) {
+	case kAirMask:
+		setCurrentAlternate(kAltMarsTookMask);
+		break;
+	case kCardBomb:
+		_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, true);
+		break;
+	case kMapBiochip:
+		_privateFlags.setFlag(kMarsPrivateGotMapChipFlag, true);
+		break;
+	case kShieldBiochip:
+		_privateFlags.setFlag(kMarsPrivateGotShieldChipFlag, true);
+		break;
+	case kOpticalBiochip:
+		_privateFlags.setFlag(kMarsPrivateGotOpticalChipFlag, true);
+		break;
+	}
+
+	Neighborhood::takeItemFromRoom(item);
+}
+
+void Mars::pickedUpItem(Item *item) {
+	switch (item->getObjectID()) {
+	case kAirMask:
+		setCurrentActivation(kActivateHotSpotAlways);
+		if (!GameState.getScoringGotOxygenMask()) {
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XM48SB", false, kWarningInterruption);
+			GameState.setScoringGotOxygenMask();
+		}
+		break;
+	case kCrowbar:
+		GameState.setScoringGotCrowBar();
+		g_AIArea->checkMiddleArea();
+		break;
+	case kMarsCard:
+		GameState.setScoringGotMarsCard();
+		g_AIArea->checkMiddleArea();
+		break;
+	case kCardBomb:
+		GameState.setScoringGotCardBomb();
+		if (GameState.getMarsLockBroken()) {
+			startExtraSequence(kMars57BackToNormal, kExtraCompletedFlag, kFilterNoInput);
+			GameState.setMarsLockBroken(false);
+		}
+
+		_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, false);
+		break;
+	case kMapBiochip:
+		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
+			GameState.setMarsFinished(true);
+			GameState.setScoringMarsGandhi();
+			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kShieldBiochip:
+		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
+			GameState.setMarsFinished(true);
+			GameState.setScoringMarsGandhi();
+			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kOpticalBiochip:
+		g_opticalChip->addAries();
+		GameState.setScoringGotMarsOpMemChip();
+			
+		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
+				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
+			GameState.setMarsFinished(true);
+			GameState.setScoringMarsGandhi();
+			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	}
+}
+
+void Mars::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
+	if (dropSpot->getObjectID() == kAttackRobotHotSpotID) {
+		_attackingItem = (InventoryItem *)item;
+		startExtraSequence(kMars48RobotDefends, kExtraCompletedFlag, kFilterNoInput);
+		loadLoopSound2("");
+	} else {
+		switch (item->getObjectID()) {
+		case kMarsCard:
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			if (dropSpot && dropSpot->getObjectID() == kMars34NorthCardDropSpotID)
+				startExtraSequence(kMarsTurnOnPod, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kNitrogenCanister:
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			if (dropSpot && dropSpot->getObjectID() == kMars57DropNitrogenSpotID)
+				startExtraSequence(kMars57FreezeLock, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kCrowbar:
+			_utilityFuse.stopFuse();
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			if (dropSpot && dropSpot->getObjectID() == kMars57DropCrowBarSpotID)
+				startExtraSequence(kMars57BreakLock, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kAirMask:
+			if (dropSpot) {
+				if (dropSpot->getObjectID() == kMars49AirFillingDropSpotID) {
+					if (!GameState.getMarsMaskOnFiller()) {
+						Neighborhood::dropItemIntoRoom(item, dropSpot);
+						startExtraSequence(kMars49SouthViewMaskFilling, kExtraCompletedFlag, kFilterNoInput);
+					} else {
+						setCurrentActivation(kActivateMaskOnFiller);
+						setCurrentAlternate(kAltMarsMaskOnFiller);
+						Neighborhood::dropItemIntoRoom(item, dropSpot);
+					}
+				} else if (dropSpot->getObjectID() == kMars49AirMaskSpotID) {
+					setCurrentAlternate(kAltMarsNormal);
+					setCurrentActivation(kActivateMaskOnHolder);
+					Neighborhood::dropItemIntoRoom(item, dropSpot);
+				}
+			}
+			break;
+		case kCardBomb:
+			_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, false);
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			break;
+		case kMapBiochip:
+			_privateFlags.setFlag(kMarsPrivateGotMapChipFlag, false);
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			break;
+		case kShieldBiochip:
+			_privateFlags.setFlag(kMarsPrivateGotShieldChipFlag, false);
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			break;
+		case kOpticalBiochip:
+			_privateFlags.setFlag(kMarsPrivateGotOpticalChipFlag, false);
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			break;
+		default:
+			Neighborhood::dropItemIntoRoom(item, dropSpot);
+			break;
+		}
+	}
+}
+
+void Mars::robotTiredOfWaiting() {
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kMars48, kEast)) {
+		if (_attackingItem) {
+			startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
+			loadLoopSound2("");
+		} else {
+			_privateFlags.setFlag(kMarsPrivateRobotTiredOfWaitingFlag, true);
+		}
+	} else {
+		die(kDeathDidntGetOutOfWay);
+	}
+}
+
+void Mars::turnLeft() {
+	if (isEventTimerRunning())
+		cancelEvent();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars34, kSouth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, true);
+			if (GameState.isTakenItemID(kCrowbar))
+				startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			Neighborhood::turnLeft();
+		}
+		break;
+	case MakeRoomView(kMars45, kNorth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, true);
+			if (GameState.isTakenItemID(kCrowbar))
+				startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			Neighborhood::turnLeft();
+		}
+		break;
+	default:
+		Neighborhood::turnLeft();
+		break;
+	}
+}
+
+void Mars::turnRight() {
+	if (isEventTimerRunning())
+		cancelEvent();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kMars34, kSouth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, true);
+			if (GameState.isTakenItemID(kCrowbar))
+				startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			Neighborhood::turnRight();
+		}
+		break;
+	case MakeRoomView(kMars45, kNorth):
+		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
+			_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, true);
+			if (GameState.isTakenItemID(kCrowbar))
+				startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
+		} else {
+			Neighborhood::turnRight();
+		}
+		break;
+	default:
+		Neighborhood::turnRight();
+		break;
+	}
+}
+
+void Mars::receiveNotification(Notification *notification, const tNotificationFlags flag) {
+	InventoryItem *item;
+	
+	Neighborhood::receiveNotification(notification, flag);
+
+	if ((flag & kExtraCompletedFlag) != 0) {
+		_interruptionFilter = kFilterAllInput;
+
+		switch (_lastExtra) {
+		case kMarsArrivalFromTSA:
+			GameState.setMarsSeenTimeStream(true);
+			loadAmbientLoops();
+			playSpotSoundSync(kMarsShuttle1DepartedIn, kMarsShuttle1DepartedOut);
+			makeContinuePoint();
+			break;
+		case kRobotThrowsPlayer:
+			GameState.setMarsRobotThrownPlayer(true);
+			GameState.setScoringThrownByRobot();
+			restoreStriding(kMars08, kNorth, kAltMarsNormal);
+			arriveAt(kMars08, kNorth);
+			if (!GameState.getMarsHeardUpperPodMessage()) {
+				playSpotSoundSync(kMarsPodDepartedUpperPlatformIn,
+											kMarsPodDepartedUpperPlatformOut);
+				GameState.setMarsHeardUpperPodMessage(true);
+			}
+			break;
+		case kMarsInfoKioskIntro:
+			GameState.setScoringSawMarsKiosk();
+			setCurrentActivation(kActivationKioskChoice);
+			break;
+		case kMars33SlideShow4:
+			GameState.setScoringSawTransportMap();
+			setCurrentActivation(kActivateHotSpotAlways);
+			break;
+		case kMars34SpotOpenNoBar:
+		case kMars34SpotOpenWithBar:
+		case kMars45SpotOpenNoBar:
+		case kMars45SpotOpenWithBar:
+			_privateFlags.setFlag(kMarsPrivatePodStorageOpenFlag, true);
+			setCurrentActivation(kActivateMarsPodOpen);
+			break;
+		case kMars34SpotCloseNoBar:
+		case kMars34SpotCloseWithBar:
+		case kMars45SpotCloseNoBar:
+		case kMars45SpotCloseWithBar:
+			_privateFlags.setFlag(kMarsPrivatePodStorageOpenFlag, false);
+			setCurrentActivation(kActivateMarsPodClosed);
+			if (_privateFlags.getFlag(kMarsPrivatePodTurnLeftFlag)) {
+				_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, false);
+				turnLeft();
+			} else if (_privateFlags.getFlag(kMarsPrivatePodTurnRightFlag)) {
+				_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, false);
+				turnRight();
+			}
+			break;
+		case kMarsTurnOnPod:
+			item = (InventoryItem *)g_allItems.findItemByID(kMarsCard);
+			_vm->addItemToInventory(item);
+			GameState.setScoringTurnedOnTransport();
+			loadLoopSound1("");
+			loadLoopSound2("");
+			startExtraSequence(kMarsTakePodToMars45, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMarsTakePodToMars45:
+			arriveAt(kMars45, kSouth);
+			break;
+		case kMars35WestSpinAirlockToEast:
+			GameState.setMarsAirlockOpen(false);
+			setCurrentAlternate(kAltMars35AirlockEast);
+			turnTo(kWest);
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+			g_airMask->airQualityChanged();
+			checkAirMask();
+			loadAmbientLoops();
+			break;
+		case kMars35EastSpinAirlockToWest:
+			GameState.setMarsAirlockOpen(true);
+			setCurrentAlternate(kAltMars35AirlockWest);
+			turnTo(kEast);
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+			g_airMask->airQualityChanged();
+			checkAirMask();
+			loadAmbientLoops();
+			break;
+		case kMars48RobotApproaches:
+			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
+			GameState.setMarsSeenRobotAtReactor(true);
+			loopExtraSequence(kMars48RobotLoops);
+			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
+			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
+			_utilityFuse.lightFuse();
+			break;
+		case kMars48RobotDefends:
+			_vm->addItemToInventory(_attackingItem);
+			_attackingItem = 0;
+			if (_privateFlags.getFlag(kMarsPrivateRobotTiredOfWaitingFlag)) {
+				startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
+				loadLoopSound2("", 0x100, 0, 0);
+			} else {
+				loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
+				loopExtraSequence(kMars48RobotLoops, kExtraCompletedFlag);
+			}
+			break;
+		case kMars48RobotKillsPlayer:
+			loadLoopSound2("");
+			die(kDeathDidntGetOutOfWay);
+			break;
+		case kMars49SouthViewMaskFilling:
+			setCurrentActivation(kActivateMaskOnFiller);
+			setCurrentAlternate(kAltMarsMaskOnFiller);
+			GameState.setMarsMaskOnFiller(true);
+			break;
+		case kMars58SpinLeft:
+		case kMars54SpinRight:
+			GameState.setScoringActivatedPlatform();
+			arriveAt(kMars52, kEast);
+			break;
+		case kMars52SpinLeft:
+		case kMars56SpinRight:
+			GameState.setScoringActivatedPlatform();
+			arriveAt(kMars54, kEast);
+			break;
+		case kMars54SpinLeft:
+		case kMars58SpinRight:
+			GameState.setScoringActivatedPlatform();
+			arriveAt(kMars56, kEast);
+			break;
+		case kMars56SpinLeft:
+		case kMars52SpinRight:
+			GameState.setScoringActivatedPlatform();
+			arriveAt(kMars58, kEast);
+			break;
+		case kMars52Extend:
+		case kMars54Extend:
+		case kMars56ExtendNoBomb:
+		case kMars58Extend:
+			GameState.setScoringActivatedPlatform();
+			setCurrentActivation(kActivateReactorPlatformIn);
+			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
+			break;
+		case kMars53Retract:
+		case kMars55Retract:
+		case kMars57RetractWithBomb:
+		case kMars57RetractNoBomb:
+		case kMars59Retract:
+			GameState.setScoringActivatedPlatform();
+			setCurrentActivation(kActivateReactorPlatformOut);
+			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, false);
+			break;
+		case kMars56ExtendWithBomb:
+			playSpotSoundSync(kMustBeUnlockedIn, kMustBeUnlockedOut);
+			GameState.setScoringActivatedPlatform();
+			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
+			break;
+		case kMars57CantOpenPanel:
+			GameState.setScoringActivatedPlatform();
+			setCurrentActivation(kActivateReactorAskLowerScreen);
+			break;
+		case kMars57LowerScreenClosed:
+		case kMars57ThawLock:
+			setCurrentActivation(kActivateReactorReadyForNitrogen);
+			GameState.setMarsLockFrozen(false);
+			break;
+		case kMars57FreezeLock:
+			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
+			item->setItemState(kNitrogenEmpty);
+			_vm->addItemToInventory(item);
+			setCurrentActivation(kActivateReactorReadyForCrowBar);
+			GameState.setScoringUsedLiquidNitrogen();
+			GameState.setMarsLockFrozen(true);
+			showExtraView(kMars57LockFrozenView);
+			_utilityFuse.primeFuse(kLockFreezeTimeLmit);
+			_utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
+			_utilityFuse.lightFuse();
+			break;
+		case kMars57BreakLock:
+			item = (InventoryItem *)g_allItems.findItemByID(kCrowbar);
+			_vm->addItemToInventory(item);
+			GameState.setScoringUsedCrowBar();
+			GameState.setMarsLockBroken(true);
+			GameState.setMarsLockFrozen(false);
+			startExtraLongSequence(kMars57OpenPanel, kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMars57OpenPanel:
+		case kMars57OpenPanelChoices:
+			setCurrentActivation(kActivateReactorAskOperation);
+			break;
+		case kMars57ShieldEvaluation:
+		case kMars57MeasureOutput:
+			setCurrentActivation(kActivateReactorRanEvaluation);
+			loopExtraSequence(kMars57ShieldOkayLoop);
+			break;
+		case kMars57RunDiagnostics:
+			setCurrentActivation(kActivateReactorRanDiagnostics);
+			GameState.setScoringFoundCardBomb();
+			break;
+		case kMars57BombExplodes:
+		case kMars57BombExplodesInGame:
+			die(kDeathDidntDisarmMarsBomb);
+			break;
+		case kMars57BombAnalysis:
+			setCurrentActivation(kActivateReactorAnalyzed);
+			break;
+		case kMars57DontLink:
+			startExtraSequence(kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kMars57CircuitLink:
+			setCurrentActivation(kActivateReactorInstructions);
+			break;
+		case kMars57GameLevel1:
+			setUpReactorLevel1();
+			break;
+		case kMars57GameLevel2:
+		case kMars57GameLevel3:
+			setUpNextReactorLevel();
+			break;
+		case kMars57GameSolved:
+			setCurrentActivation(kActivateReactorBombSafe);
+			break;
+		case kMars57ExposeBomb:
+			setCurrentActivation(kActivateReactorBombExposed);
+			_privateFlags.setFlag(kMarsPrivateBombExposedFlag, true);
+			break;
+		case kMars57BackToNormal:
+			setCurrentActivation(kActivateReactorPlatformIn);
+			_privateFlags.setFlag(kMarsPrivateBombExposedFlag, false);
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XM51SW", false, kWarningInterruption);
+			break;
+		case kMars60WestSpinAirlockToEast:
+			GameState.setMarsAirlockOpen(true);
+			setCurrentAlternate(kAltMars60AirlockEast);
+			turnTo(kWest);
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+			g_airMask->airQualityChanged();
+			checkAirMask();
+			loadAmbientLoops();
+			break;
+		case kMars60EastSpinAirlockToWest:
+			GameState.setMarsAirlockOpen(false);
+			setCurrentAlternate(kAltMars60AirlockWest);
+			turnTo(kEast);
+			setCurrentActivation(kActivateReadyToPressurizeAirlock);
+			g_airMask->airQualityChanged();
+			checkAirMask();
+			loadAmbientLoops();
+			break;
+		case kMarsRobotHeadOpen:
+			setCurrentActivation(kActivationRobotHeadOpen);
+			break;
+		case kMarsRobotHeadClose:
+			recallToTSASuccess();
+			break;
+		case kMarsMaze007RobotApproach:
+		case kMarsMaze015SouthRobotApproach:
+		case kMarsMaze101EastRobotApproach:
+		case kMarsMaze104WestLoop:
+		case kMarsMaze133SouthApproach:
+		case kMarsMaze136NorthApproach:
+		case kMarsMaze184WestLoop:
+			die(kDeathGroundByMazebot);
+			break;
+		}
+	} else if ((flag & kTimeForCanyonChaseFlag) != 0) {
+		// TODO
+	} else if ((flag & kExplosionFinishedFlag) != 0) {
+		// TODO
+	} else if ((flag & kTimeToTransportFlag) != 0) {
+		// TODO
+	}
+
+	if (g_AIArea)
+		g_AIArea->checkMiddleArea();
+}
+
+void Mars::spotCompleted() {
+	Neighborhood::spotCompleted();
+
+	if (GameState.getCurrentRoom() == kMarsRobotShuttle)
+		g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XN59WD", false, kWarningInterruption);
+}
+
+tAirQuality Mars::getAirQuality(const tRoomID room) {
+	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
+		return kAirQualityVacuum;
+	if (room == kMars35 && !GameState.getMarsAirlockOpen())
+		return kAirQualityVacuum;
+	if (room == kMars60 && !GameState.getMarsAirlockOpen())
+		return kAirQualityVacuum;
+
+	return Neighborhood::getAirQuality(room);
+}
+
+// Start up panting sound if necessary.
+
+void Mars::checkAirMask() {
+	Neighborhood::checkAirMask();
+
+	if (getAirQuality(GameState.getCurrentRoom()) == kAirQualityVacuum) {
+		if (g_airMask->isAirMaskOn()) {
+			if (_noAirFuse.isFuseLit()) {
+				_noAirFuse.stopFuse();
+				loadLoopSound2("");
+				loadAmbientLoops();
+				playSpotSoundSync(kMarsOxyMaskOnIn, kMarsOxyMaskOnOut);
+			}
+		} else {
+			if (!_noAirFuse.isFuseLit()) {
+				loadLoopSound2("Sounds/Mars/SukWind1.22K.AIFF");
+				_noAirFuse.primeFuse(kVacuumSurvivalTimeLimit);
+				_noAirFuse.lightFuse();
+			}
+		}
+	} else {
+		if (_noAirFuse.isFuseLit()) {
+			_noAirFuse.stopFuse();
+			loadLoopSound2("");
+			loadAmbientLoops();
+		}
+	}
+}
+
+void Mars::airStageExpired() {
+	if (((PegasusEngine *)g_engine)->playerHasItemID(kAirMask))
+		die(kDeathNoAirInMaze);
+	else
+		die(kDeathNoMaskInMaze);
+}
+
+void Mars::lockThawed() {
+	startExtraSequence(kMars57ThawLock, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void Mars::setUpReactorLevel1() {
+	_reactorStage = 1;
+	makeColorSequence();
+	_guessObject.initReactorGuess();
+	_undoPict.initFromPICTResource(_vm->_resFork, kReactorUndoHilitePICTID);
+	_undoPict.setDisplayOrder(kMonitorLayer);
+	_undoPict.moveElementTo(kUndoHiliteLeft, kUndoHiliteTop);
+	_undoPict.startDisplaying();
+	_guessHistory.initReactorHistory();
+	_choiceHighlight.initReactorChoiceHighlight();
+	setCurrentActivation(kActivateReactorInGame);
+	_bombFuse.primeFuse(kColorMatchingTimeLimit);
+	_bombFuse.setFunctionPtr(&bombTimerExpiredInGameFunction, (void *)this);
+	_bombFuse.lightFuse();
+}
+
+void Mars::setUpNextReactorLevel() {
+	_guessObject.show();
+	_guessHistory.show();
+	_guessHistory.clearHistory();
+	_choiceHighlight.show();
+	_reactorStage++;
+	makeColorSequence();
+}
+
+void Mars::makeColorSequence() {
+	int32 code[5];
+	int32 highest = _reactorStage + 2;
+
+	for (int32 i = 0; i < highest; i++)
+		code[i] = i;
+
+	_vm->shuffleArray(code, highest);
+	_currentGuess[0] = -1;
+	_currentGuess[1] = -1;
+	_currentGuess[2] = -1;
+	_nextGuess = 0;
+	_guessObject.setGuess(-1, -1, -1);
+	_guessHistory.setAnswer(code[0], code[1], code[2]);
+}
+
+void Mars::doUndoOneGuess() {
+	if (_nextGuess > 0) {
+		_undoPict.show();
+		_vm->delayShell(1, 2);
+		_undoPict.hide();
+		_nextGuess--;
+		_currentGuess[_nextGuess] = -1;
+		_guessObject.setGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
+		_choiceHighlight.resetHighlight();
+
+		if (_currentGuess[0] != -1) {
+			_choiceHighlight.highlightChoice(_currentGuess[0]);
+
+			if (_currentGuess[1] != -1) {
+				_choiceHighlight.highlightChoice(_currentGuess[1]);
+
+				if (_currentGuess[2] != -1)
+					_choiceHighlight.highlightChoice(_currentGuess[2]);
+			}
+		}
+	}
+}
+
+void Mars::doReactorGuess(int32 guess) {
+	_choiceHighlight.highlightChoice(guess);
+	_currentGuess[_nextGuess] = guess;
+	_guessObject.setGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
+
+	switch (guess) {
+	case 0:
+		playSpotSoundSync(kColorMatchRedIn, kColorMatchRedOut);
+		break;
+	case 1:
+		playSpotSoundSync(kColorMatchYellowIn, kColorMatchYellowOut);
+		break;
+	case 2:
+		playSpotSoundSync(kColorMatchGreenIn, kColorMatchGreenOut);
+		break;
+	case 3:
+		playSpotSoundSync(kColorMatchBlueIn, kColorMatchBlueOut);
+		break;
+	case 4:
+		playSpotSoundSync(kColorMatchPurpleIn, kColorMatchPurpleOut);
+		break;
+	}
+
+	_nextGuess++;
+
+	if (_nextGuess == 3) {
+		_vm->delayShell(1, 2);
+		_nextGuess = 0;
+		_guessHistory.addGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
+
+		switch (_guessHistory.getCurrentNumCorrect()) {
+		case 0:
+			playSpotSoundSync(kColorMatchZeroNodesIn, kColorMatchZeroNodesOut);
+			break;
+		case 1:
+			playSpotSoundSync(kColorMatchOneNodeIn, kColorMatchOneNodeOut);
+			break;
+		case 2:
+			playSpotSoundSync(kColorMatchTwoNodesIn, kColorMatchTwoNodesOut);
+			break;
+		case 3:
+			playSpotSoundSync(kColorMatchThreeNodesIn, kColorMatchThreeNodesOut);
+			break;
+		}
+
+		_currentGuess[0] = -1;
+		_currentGuess[1] = -1;
+		_currentGuess[2] = -1;
+		_guessObject.setGuess(-1, -1, -1);
+		_choiceHighlight.resetHighlight();
+
+		if (_guessHistory.isSolved()) {
+			_guessHistory.showAnswer();
+			_vm->delayShell(1, 2);
+			_guessObject.hide();
+			_guessHistory.hide();
+			_choiceHighlight.hide();
+
+			switch (_reactorStage) {
+			case 1:
+				startExtraSequence(kMars57GameLevel2, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 2:
+				startExtraSequence(kMars57GameLevel3, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 3:
+				_bombFuse.stopFuse();
+				_guessObject.disposeReactorGuess();
+				_undoPict.deallocateSurface();
+				_guessHistory.disposeReactorHistory();
+				_choiceHighlight.disposeReactorChoiceHighlight();
+				GameState.setScoringDisarmedCardBomb();
+				startExtraSequence(kMars57GameSolved, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			}
+		} else if (_guessHistory.getNumGuesses() >= 5) {
+			_vm->delayShell(2, 1);
+			bombExplodesInGame();
+		}
+	}
+}
+
+void Mars::bombExplodesInGame() {
+	_guessObject.disposeReactorGuess();
+	_undoPict.deallocateSurface();
+	_guessHistory.disposeReactorHistory();
+	_choiceHighlight.disposeReactorChoiceHighlight();
+	startExtraSequence(kMars57BombExplodesInGame, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void Mars::didntFindBomb() {
+	die(kDeathDidntFindMarsBomb);
+}
+
+Common::String Mars::getBriefingMovie() {
+	Common::String movieName = Neighborhood::getBriefingMovie();
+
+	if (!movieName.empty())
+		return movieName;
+
+	return "Images/AI/Mars/XM01";
+}
+
+Common::String Mars::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		tRoomID room = GameState.getCurrentRoom();
+
+		if (room >= kMars0A && room <= kMars21)
+			return "Images/AI/Mars/XME1";
+		else if (room >= kMars22 && room <= kMars31South)
+			return "Images/AI/Mars/XME2";
+		else if (room >= kMars52 && room <= kMars58)
+			return "Images/AI/Mars/XMREACE";
+
+		return "Images/AI/Mars/XME3";
+	}
+
+	return movieName;
+}
+
+uint Mars::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kMars27, kNorth):
+		case MakeRoomView(kMars28, kNorth):
+		case MakeRoomView(kMars49, kSouth):
+			numHints = 1;
+			break;
+		case MakeRoomView(kMars31, kSouth):
+		case MakeRoomView(kMars31South, kSouth):
+			if (!GameState.isTakenItemID(kMarsCard))
+				numHints = 1;
+			break;
+		case MakeRoomView(kMars34, kNorth):
+			if (!GameState.isTakenItemID(kMarsCard))
+				numHints = 2;
+			break;
+		case MakeRoomView(kMars34, kSouth):
+		case MakeRoomView(kMars45, kNorth):
+			if (!GameState.isTakenItemID(kCrowbar))
+				numHints = 1;
+			break;
+		case MakeRoomView(kMars51, kEast):
+			if (GameState.isCurrentDoorOpen() && !GameState.getShieldOn()) {
+				if (GameState.isTakenItemID(kShieldBiochip))
+					numHints = 1;
+				else
+					numHints = 2;
+			}
+			break;
+		case MakeRoomView(kMars52, kNorth):
+		case MakeRoomView(kMars52, kSouth):
+		case MakeRoomView(kMars52, kEast):
+		case MakeRoomView(kMars52, kWest):
+		case MakeRoomView(kMars54, kNorth):
+		case MakeRoomView(kMars54, kSouth):
+		case MakeRoomView(kMars54, kEast):
+		case MakeRoomView(kMars54, kWest):
+		case MakeRoomView(kMars56, kNorth):
+		case MakeRoomView(kMars56, kSouth):
+		case MakeRoomView(kMars56, kWest):
+		case MakeRoomView(kMars58, kNorth):
+		case MakeRoomView(kMars58, kSouth):
+		case MakeRoomView(kMars58, kEast):
+		case MakeRoomView(kMars58, kWest):
+			if (!GameState.getShieldOn()) {
+				if (GameState.isTakenItemID(kShieldBiochip))
+					numHints = 1;
+				else
+					numHints = 2;
+			}
+			break;
+		case MakeRoomView(kMars56, kEast):
+			if (getCurrentActivation() == kActivateReactorReadyForNitrogen) {
+				if ((tExtraID)_lastExtra == kMars57LowerScreenClosed)
+					numHints = 3;
+			} else if (getCurrentActivation() == kActivateReactorPlatformOut) {
+				if (!GameState.getShieldOn()) {
+					if (GameState.isTakenItemID(kShieldBiochip))
+						numHints = 1;
+					else
+						numHints = 2;
+				}
+			}
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String Mars::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kMars27, kNorth):
+		case MakeRoomView(kMars28, kNorth):
+			return "Images/AI/Globals/XGLOB5C";
+		case MakeRoomView(kMars31, kSouth):
+		case MakeRoomView(kMars31South, kSouth):
+		case MakeRoomView(kMars34, kSouth):
+		case MakeRoomView(kMars45, kNorth):
+			return "Images/AI/Globals/XGLOB1C";
+		case MakeRoomView(kMars34, kNorth):
+			if (hintNum == 1)
+				return "Images/AI/Globals/XGLOB2C";
+
+			return "Images/AI/Globals/XGLOB3G";
+		case MakeRoomView(kMars49, kSouth):
+			if (GameState.isTakenItemID(kAirMask))
+				return "Images/AI/Globals/XGLOB3E";
+
+			return "Images/AI/Globals/XGLOB1C";
+		case MakeRoomView(kMars51, kEast):
+			if (GameState.isTakenItemID(kShieldBiochip))
+				return "Images/AI/Mars/XM52NW";
+
+			if (hintNum == 1)
+				return "Images/AI/Globals/XGLOB2D";
+
+			return "Images/AI/Globals/XGLOB3F";
+		case MakeRoomView(kMars52, kNorth):
+		case MakeRoomView(kMars52, kSouth):
+		case MakeRoomView(kMars52, kEast):
+		case MakeRoomView(kMars52, kWest):
+		case MakeRoomView(kMars54, kNorth):
+		case MakeRoomView(kMars54, kSouth):
+		case MakeRoomView(kMars54, kEast):
+		case MakeRoomView(kMars54, kWest):
+		case MakeRoomView(kMars56, kNorth):
+		case MakeRoomView(kMars56, kSouth):
+		case MakeRoomView(kMars56, kWest):
+		case MakeRoomView(kMars58, kNorth):
+		case MakeRoomView(kMars58, kSouth):
+		case MakeRoomView(kMars58, kEast):
+		case MakeRoomView(kMars58, kWest):
+			if (hintNum == 1) {
+				if (GameState.isTakenItemID(kShieldBiochip))
+					return "Images/AI/Mars/XM52NW";
+
+				return "Images/AI/Globals/XGLOB2D";
+			}
+
+			return "Images/AI/Globals/XGLOB3F";
+		case MakeRoomView(kMars56, kEast):
+			if (getCurrentActivation() == kActivateReactorReadyForNitrogen)
+				return Common::String::format("Images/AI/Mars/XM57SD%d", hintNum);
+
+			if (hintNum == 1) {
+				if (GameState.isTakenItemID(kShieldBiochip))
+					return "Images/AI/Mars/XM52NW";
+
+				return "Images/AI/Globals/XGLOB2D";
+			}
+
+			return "Images/AI/Globals/XGLOB3F";
+		}
+	}
+
+	return movieName;
+}
+
+bool Mars::inColorMatchingGame() {
+	return _guessObject.isDisplaying();
+}
+
+bool Mars::canSolve() {
+	return GameState.getCurrentRoomAndView() == MakeRoomView(kMars56, kEast) && (getCurrentActivation() == kActivateReactorReadyForNitrogen ||
+			getCurrentActivation() == kActivateReactorReadyForCrowBar || inColorMatchingGame());
+}
+
+void Mars::doSolve() {
+	if (getCurrentActivation() == kActivateReactorReadyForNitrogen || getCurrentActivation() == kActivateReactorReadyForCrowBar) {
+		_utilityFuse.stopFuse();
+		GameState.setMarsLockBroken(true);
+		GameState.setMarsLockFrozen(false);
+		startExtraLongSequence(kMars57OpenPanel, kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
+	} else if (inColorMatchingGame()) {
+		_bombFuse.stopFuse();
+		_guessObject.disposeReactorGuess();
+		_undoPict.deallocateSurface();
+		_guessHistory.disposeReactorHistory();
+		_choiceHighlight.disposeReactorChoiceHighlight();
+		startExtraSequence(kMars57GameSolved, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+Common::String Mars::getSoundSpotsName() {
+	return "Sounds/Mars/Mars Spots";
+}
+
+Common::String Mars::getNavMovieName() {
+	return "Images/Mars/Mars.movie";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
new file mode 100755
index 0000000..3eb0fc8
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -0,0 +1,198 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_MARS_H
+#define PEGASUS_NEIGHBORHOOD_MARS_MARS_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/mars/reactor.h"
+
+namespace Pegasus {
+
+class InventoryItem;
+class Mars;
+
+enum tMarsTimerCode {
+	kMarsLaunchTubeReached,
+	kMarsCanyonChaseFinished,
+	kMarsSpaceChaseFinished // Player ran out of time...
+};
+
+struct tMarsTimerEvent {
+	Mars *mars;
+	tMarsTimerCode event;
+};
+
+enum tShuttleWeaponSelection {
+	kNoWeapon,
+	kEnergyBeam,
+	kGravitonCannon,
+	kTractorBeam
+};
+
+const tRoomID kMars0A = 0;
+const tRoomID kMars35 = 38;
+const tRoomID kMars39 = 42;
+const tRoomID kMars60 = 58;
+const tRoomID kMarsMaze004 = 60;
+const tRoomID kMarsMaze200 = 224;
+
+class Mars : public Neighborhood {
+friend void robotTimerExpiredFunction(FunctionPtr *, void *);
+friend void lockThawTimerExpiredFunction(FunctionPtr *, void *);
+friend void bombTimerExpiredFunction(FunctionPtr *, void *);
+friend void bombTimerExpiredInGameFunction(FunctionPtr *, void *);
+friend void airStageExpiredFunction(FunctionPtr *, void *);
+
+public:
+	Mars(InputHandler *, PegasusEngine *);
+	virtual ~Mars();
+
+	void flushGameState();
+
+	virtual uint16 getDateResID() const;
+
+	virtual tAirQuality getAirQuality(const tRoomID);
+
+	void checkAirMask();
+
+	Common::String getBriefingMovie();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+
+	virtual void shieldOn();
+	virtual void shieldOff();
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+	bool inColorMatchingGame();
+
+	// TODO: Space chase functions
+
+protected:
+	enum {
+		kMarsPrivatePodStorageOpenFlag,
+		kMarsPrivatePodTurnLeftFlag,
+		kMarsPrivatePodTurnRightFlag,
+		kMarsPrivateRobotTiredOfWaitingFlag,
+		kMarsPrivatePlatformZoomedInFlag,
+		kMarsPrivateBombExposedFlag,
+		kMarsPrivateDraggingBombFlag,
+		kMarsPrivateInSpaceChaseFlag,
+		kMarsPrivateGotMapChipFlag,
+		kMarsPrivateGotOpticalChipFlag,
+		kMarsPrivateGotShieldChipFlag,
+		kNumMarsPrivateFlags
+	};
+	
+	void init();
+	void start();
+	void setUpAIRules();
+	void arriveAt(const tRoomID, const tDirectionConstant);
+	void takeItemFromRoom(Item *);
+	void dropItemIntoRoom(Item *, Hotspot *);
+	void activateHotspots();
+	void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
+	void clickInHotspot(const Input &, const Hotspot *);
+	tInputBits getInputFilter();
+	
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	void openDoor();
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
+	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
+	void turnTo(const tDirectionConstant);
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void doorOpened();
+	void setUpReactorEnergyDrain();
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+	void lockThawed();
+	void robotTiredOfWaiting();
+	
+	void setUpReactorLevel1();
+	void setUpNextReactorLevel();
+	void makeColorSequence();
+	void doUndoOneGuess();
+	void doReactorGuess(int32 guess);
+	void bombExplodesInGame();
+	void didntFindBomb();
+	tCanMoveForwardReason canMoveForward(ExitTable::Entry &);
+	void cantMoveThatWay(tCanMoveForwardReason);
+	void moveForward();
+	void bumpIntoWall();
+	void turnLeft();
+	void turnRight();
+	void airStageExpired();
+	void loadAmbientLoops();
+	void checkAirlockDoors();
+	void pickedUpItem(Item *item);
+	void cantOpenDoor(tCanOpenDoorReason);
+	void launchMaze007Robot();
+	void launchMaze015Robot();
+	void launchMaze101Robot();
+	void launchMaze104Robot();
+	void launchMaze133Robot();
+	void launchMaze136Robot();
+	void launchMaze184Robot();
+	void timerExpired(const uint32);
+	void spotCompleted();
+
+	// TODO: Space chase functions
+
+	Common::String getSoundSpotsName();
+	Common::String getNavMovieName();
+	
+	InventoryItem *_attackingItem;
+	FuseFunction _bombFuse;
+	FuseFunction _noAirFuse;
+	FuseFunction _utilityFuse;
+	FlagsArray<byte, kNumMarsPrivateFlags> _privateFlags;
+	uint _reactorStage, _nextGuess;
+	int32 _currentGuess[3];
+	ReactorGuess _guessObject;
+	Picture _undoPict;
+	ReactorHistory _guessHistory;
+	ReactorChoiceHighlight _choiceHighlight;
+
+	Picture _shuttleInterface1;
+	Picture _shuttleInterface2;
+	Picture _shuttleInterface3;
+	Picture _shuttleInterface4;
+	Movie _canyonChaseMovie;
+
+	// TODO: Space chase variables
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index e5508ba..8f5bf47 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -32,6 +32,7 @@
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
+#include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"
 
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index 419ecba..3075895 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -29,6 +29,7 @@
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ec7ed6c..ab5ab55 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -62,6 +62,7 @@
 #include "pegasus/items/inventory/keycard.h"
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
@@ -1348,6 +1349,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kCaldoriaID:
 		neighborhood = new Caldoria(g_AIArea, this);
 		break;
+	case kMarsID:
+		neighborhood = new Mars(g_AIArea, this);
+		break;
 	case kPrehistoricID:
 		neighborhood = new Prehistoric(g_AIArea, this);
 		break;


Commit: 4b9914104eece973f153f608b259e47f67d6156c
    https://github.com/scummvm/scummvm/commit/4b9914104eece973f153f608b259e47f67d6156c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-15T19:15:10-07:00

Commit Message:
PEGASUS: Remove the unused biochip AI warnings from WSC

WSC is now completable using the violent method

Changed paths:
    engines/pegasus/neighborhood/wsc/wsc.cpp



diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index 82fbdb8..cc12a2f 100755
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -1918,14 +1918,18 @@ void WSC::receiveNotification(Notification *notification, const tNotificationFla
 					372 + kNavAreaLeft, 149 + kNavAreaTop));
 			setCurrentActivation(kActivationRobotDead);
 			GameState.setWSCRobotDead(true);
-			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
+
+			// Unused?
+			//g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
 			break;
 		case kW98RobotGassed:
 			item = (Item *)g_allItems.findItemByID(kArgonCanister);
 			_vm->addItemToInventory((InventoryItem *)item);
 			setCurrentActivation(kActivationRobotDead);
 			GameState.setWSCRobotDead(true);
-			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
+
+			// Unused?
+			//g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
 			break;
 		case kW98RobotHeadOpensLight:
 		case kW98RobotHeadOpensDark:


Commit: 77033ecc6cb37549ed0fedc8461c2cd0d0affb95
    https://github.com/scummvm/scummvm/commit/77033ecc6cb37549ed0fedc8461c2cd0d0affb95
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-15T20:17:27-07:00

Commit Message:
PEGASUS: Fix the Mars robot timer not stopping

Changed paths:
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index e1aa814..e95f76c 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -125,9 +125,9 @@ public:
 	virtual void activateHotspots();
 	virtual void clickInHotspot(const Input &, const Hotspot *);
 
-	tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
-	tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
-	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
+	virtual tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
+	virtual tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
+	virtual tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
 
 	virtual void cantMoveThatWay(tCanMoveForwardReason);
 	virtual void cantTurnThatWay(tCanTurnReason) {}


Commit: 802873d3231a665d13d1f690bd9c780f7f7b7fb4
    https://github.com/scummvm/scummvm/commit/802873d3231a665d13d1f690bd9c780f7f7b7fb4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-16T19:27:51-07:00

Commit Message:
VIDEO: Fix QuickTime audio track ends

Fixes videos where the audio track length is smaller than the video track length.

Changed paths:
    video/qt_decoder.cpp



diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp
index 74bf533..058dd6b 100644
--- a/video/qt_decoder.cpp
+++ b/video/qt_decoder.cpp
@@ -298,9 +298,17 @@ bool QuickTimeDecoder::endOfVideo() const {
 }
 
 uint32 QuickTimeDecoder::getElapsedTime() const {
-	if (_audStream)
-		return g_system->getMixer()->getSoundElapsedTime(_audHandle) + _audioStartOffset.msecs();
+	if (_audStream) {
+		// Use the audio time if present and the audio track's time is less than the
+		// total length of the audio track. The audio track can end before the video
+		// track, so we need to fall back on the getMillis() time tracking in that
+		// case.
+		uint32 time = g_system->getMixer()->getSoundElapsedTime(_audHandle) + _audioStartOffset.msecs();
+		if (time < _tracks[_audioTrackIndex]->duration * 1000 / _tracks[_audioTrackIndex]->timeScale)
+			return time;
+	}
 
+	// Just use time elapsed since the beginning
 	return SeekableVideoDecoder::getElapsedTime();
 }
 


Commit: 0dada6e231460c9acd61fff03b97858d26424e75
    https://github.com/scummvm/scummvm/commit/0dada6e231460c9acd61fff03b97858d26424e75
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-16T20:44:48-07:00

Commit Message:
PEGASUS: Implement screen shaking

Would be great to be able to use OSystem's stuff, but that only handles vertical shaking.

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 1e529d0..8b83ed7 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -212,5 +212,104 @@ void GraphicsManager::doFadeInSync(const TimeValue, const TimeValue, uint32) {
 void GraphicsManager::markCursorAsDirty() {
 	_modifiedScreen = true;
 }
+
+void GraphicsManager::newShakePoint(int32 index1, int32 index2, int32 maxRadius) {
+	int32 index3 = (index1 + index2) >> 1;
+
+	if (maxRadius == 0) {
+		_shakeOffsets[index3].x = ((_shakeOffsets[index1].x + _shakeOffsets[index2].x) >> 1);
+		_shakeOffsets[index3].y = ((_shakeOffsets[index1].y + _shakeOffsets[index2].y) >> 1);
+	} else {
+		double angle = (int32)(_vm->getRandomNumber(360 - 1) * 3.1415926535 / 180);
+		int32 radius = maxRadius;
+		_shakeOffsets[index3].x = (int32)(((_shakeOffsets[index1].x + _shakeOffsets[index2].x) >> 1) +
+				cos(angle) / 2 * radius);
+		_shakeOffsets[index3].y = (int32)(((_shakeOffsets[index1].y + _shakeOffsets[index2].y) >> 1) +
+				sin(angle) * radius);
+	}
+
+	if (index1 < index3 - 1)
+		newShakePoint(index1, index3, maxRadius * 2 / 3);
+
+	if (index3 < index2 - 1)
+		newShakePoint(index3, index2, maxRadius * 2 / 3);
+}
+
+void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
+	if (duration == 0 || scale == 0)
+		return;
+
+	_shakeOffsets[0].x = 0;
+	_shakeOffsets[0].y = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) / 4].x = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) / 4].y = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) / 2].x = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) / 2].y = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) * 3 / 4].x = 0;
+	_shakeOffsets[(kMaxShakeOffsets - 1) * 3 / 4].y = 0;
+	_shakeOffsets[kMaxShakeOffsets - 1].x = 0;
+	_shakeOffsets[kMaxShakeOffsets - 1].y = 0;
+
+	newShakePoint(0, (kMaxShakeOffsets - 1) / 4, 8);
+	newShakePoint((kMaxShakeOffsets - 1) / 4, (kMaxShakeOffsets - 1) / 2, 6);
+	newShakePoint((kMaxShakeOffsets - 1) / 2, (kMaxShakeOffsets - 1) * 3 / 4, 4);
+	newShakePoint((kMaxShakeOffsets - 1) * 3 / 4, kMaxShakeOffsets - 1, 3);
+
+	Common::Point lastOffset(0, 0);
+
+	// Convert to millis
+	duration = duration * 1000 / scale;
+	
+	uint32 startTime = g_system->getMillis();
+
+	while (g_system->getMillis() < startTime + duration) {
+		Common::Point thisOffset = _shakeOffsets[(g_system->getMillis() - startTime) * (kMaxShakeOffsets - 1) / duration];
+		if (thisOffset != lastOffset) {
+			// Fill the screen with black
+			Graphics::Surface *screen = g_system->lockScreen();
+			screen->fillRect(Common::Rect(0, 0, 640, 480), g_system->getScreenFormat().RGBToColor(0, 0, 0));
+			g_system->unlockScreen();
+
+			// Calculate the src/dst offsets and the width/height
+			int32 srcOffsetX, dstOffsetX, width;
+
+			if (thisOffset.x > 0) {
+				srcOffsetX = 0;
+				dstOffsetX = thisOffset.x;
+				width = 640 - dstOffsetX;
+			} else {
+				srcOffsetX = -thisOffset.x;
+				dstOffsetX = 0;
+				width = 640 - srcOffsetX;
+			}
+
+			int32 srcOffsetY, dstOffsetY, height;
+
+			if (thisOffset.y > 0) {
+				srcOffsetY = 0;
+				dstOffsetY = thisOffset.y;
+				height = 480 - dstOffsetY;
+			} else {
+				srcOffsetY = -thisOffset.y;
+				dstOffsetY = 0;
+				height = 480 - srcOffsetY;
+			}
+
+			// Now copy to the screen
+			g_system->copyRectToScreen((byte *)_workArea.getBasePtr(srcOffsetX, srcOffsetY), _workArea.pitch,
+					dstOffsetX, dstOffsetY, width, height);
+			g_system->updateScreen();
+
+			lastOffset = thisOffset;
+		}
+
+		g_system->delayMillis(10);
+	}
+
+	if (lastOffset.x != 0 || lastOffset.y != 0) {
+		g_system->copyRectToScreen((byte *)_workArea.pixels, _workArea.pitch, 0, 0, 640, 480);
+		g_system->updateScreen();
+	}
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index e1b3398..c68c2de 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -57,6 +57,7 @@ public:
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
 	DisplayElement *findDisplayElement(const tDisplayElementID id);
+	void shakeTheWorld(TimeValue time, TimeScale scale);
 
 	// These default to black
 	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
@@ -73,6 +74,11 @@ private:
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 	Graphics::Surface _workArea;
+
+	// Shake Shake Shake!
+	static const int kMaxShakeOffsets = 17;
+	Common::Point _shakeOffsets[kMaxShakeOffsets];
+	void newShakePoint(int32 index1, int32 index2, int32 maxRadius);
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index f6da386..5d8f386 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -30,6 +30,7 @@
 #include "pegasus/cursor.h"
 #include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
+#include "pegasus/graphics.h"
 #include "pegasus/input.h"
 #include "pegasus/interaction.h"
 #include "pegasus/interface.h"
@@ -726,7 +727,8 @@ void Neighborhood::turnTo(const tDirectionConstant direction) {
 	if (g_map)
 		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), direction);
 
-	_pushIn.copyToCurrentPort();
+	// FIXME: This isn't right. Crazy TGWorldSaver stuff
+	//_pushIn.copyToCurrentPort();
 	
 	// Added 2/10/97. Shouldn't this be here? Shouldn't we set the current activation to
 	// always when turning to a new view?
@@ -1419,8 +1421,7 @@ void Neighborhood::newInteraction(const tInteractionID interactionID) {
 }
 
 void Neighborhood::bumpIntoWall() {
-	// TODO
-	warning("bump");
+	_vm->_gfx->shakeTheWorld(15, 30);
 }
 
 void Neighborhood::zoomUpOrBump() {


Commit: 5c2a89dc4aa005e9b8f74dfe290fdaf4f8f32ad3
    https://github.com/scummvm/scummvm/commit/5c2a89dc4aa005e9b8f74dfe290fdaf4f8f32ad3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-16T21:56:27-07:00

Commit Message:
PEGASUS: Fix drop box highlight color

Changed paths:
    engines/pegasus/elements.cpp
    engines/pegasus/items/itemdragger.cpp



diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 79faa1a..6fce18f 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -166,7 +166,7 @@ bool DisplayElement::validToDraw(tDisplayOrder backLayer, tDisplayOrder frontLay
 }
 
 DropHighlight::DropHighlight(const tDisplayElementID id) : DisplayElement(id) {
-	_highlightColor = g_system->getScreenFormat().RGBToColor(0x48, 0x80, 0xD8);
+	_highlightColor = 0;
 	_thickness = 2;
 	_cornerDiameter = 0;
 }
diff --git a/engines/pegasus/items/itemdragger.cpp b/engines/pegasus/items/itemdragger.cpp
index 4e3a9f1..9e77ad5 100755
--- a/engines/pegasus/items/itemdragger.cpp
+++ b/engines/pegasus/items/itemdragger.cpp
@@ -183,8 +183,11 @@ void ItemDragger::exitHotspot(Hotspot *spot) {
 }
 
 void ItemDragger::setHighlightBounds() {
+	uint32 color = g_system->getScreenFormat().RGBToColor(0x48, 0x80, 0xD8);
 	_inventoryHighlight.setBounds(Common::Rect(76, 334, 172, 430));
+	_inventoryHighlight.setHighlightColor(color);
 	_biochipHighlight.setBounds(Common::Rect(364, 334, 460, 430));
+	_biochipHighlight.setHighlightColor(color);
 }
 
 } // End of namespace Pegasus


Commit: 1529ed0891b9721c349e84468dcb28d4f655dc1b
    https://github.com/scummvm/scummvm/commit/1529ed0891b9721c349e84468dcb28d4f655dc1b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-17T06:21:49-07:00

Commit Message:
PEGASUS: Implement deleting items when inventory is full

Changed paths:
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.h
    engines/pegasus/neighborhood/wsc/wsc.cpp
    engines/pegasus/neighborhood/wsc/wsc.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 9f297e3..923df41 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -222,6 +222,7 @@ void AIArea::playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSig
 		vm->_cursor->hide();
 
 		while (_middleAreaMovie.isRunning()) {
+			vm->checkCallBacks();
 			vm->refreshDisplay();
 			g_system->delayMillis(10);
 		}
@@ -245,6 +246,7 @@ void AIArea::playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSig
 		vm->_cursor->hide();
 
 		while (_rightAreaMovie.isRunning()) {
+			vm->checkCallBacks();
 			vm->refreshDisplay();
 			g_system->delayMillis(10);
 		}
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 3f46edb..f13890c 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -292,11 +292,9 @@ const tRoomID kMars28 = 29;
 const tRoomID kMars29 = 30;
 const tRoomID kMars30 = 31;
 const tRoomID kMars31 = 32;
-const tRoomID kMars31South = 33;
 const tRoomID kMars32 = 34;
 const tRoomID kMars33 = 35;
 const tRoomID kMars33North = 36;
-const tRoomID kMars34 = 37;
 const tRoomID kMars36 = 39;
 const tRoomID kMars37 = 40;
 const tRoomID kMars38 = 41;
@@ -308,7 +306,6 @@ const tRoomID kMars45 = 47;
 const tRoomID kMars46 = 48;
 const tRoomID kMars47 = 49;
 const tRoomID kMars48 = 50;
-const tRoomID kMars49 = 51;
 const tRoomID kMars50 = 52;
 const tRoomID kMars51 = 53;
 const tRoomID kMars52 = 54;
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index 3eb0fc8..b663a62 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -53,8 +53,11 @@ enum tShuttleWeaponSelection {
 };
 
 const tRoomID kMars0A = 0;
+const tRoomID kMars31South = 33;
+const tRoomID kMars34 = 37;
 const tRoomID kMars35 = 38;
 const tRoomID kMars39 = 42;
+const tRoomID kMars49 = 51;
 const tRoomID kMars60 = 58;
 const tRoomID kMarsMaze004 = 60;
 const tRoomID kMarsMaze200 = 224;
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 8f5bf47..1aac583 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -112,7 +112,6 @@ const tRoomID kTSA23Cyan = 24;
 const tRoomID kTSA24Cyan = 25;
 const tRoomID kTSA25Cyan = 26;
 const tRoomID kTSA21Red = 27;
-const tRoomID kTSA22Red = 28;
 const tRoomID kTSA23Red = 29;
 const tRoomID kTSA24Red = 30;
 const tRoomID kTSA25Red = 31;
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
index 447482f..aa21192 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.h
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.h
@@ -50,6 +50,7 @@ protected:
 //	Room IDs.
 
 const tRoomID kTSA00 = 0;
+const tRoomID kTSA22Red = 28;
 const tRoomID kTSA37 = 42;
 
 class FullTSA : public Neighborhood {
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index cc12a2f..e42b90e 100755
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -173,8 +173,6 @@ const tAlternateID kAltWSCPeopleAtW19North = 3;
 //	Room IDs.
 
 const tRoomID kWSC02 = 1;
-const tRoomID kWSC02Morph = 2;
-const tRoomID kWSC02Messages = 3;
 const tRoomID kWSC03 = 4;
 const tRoomID kWSC04 = 5;
 const tRoomID kWSC06 = 6;
@@ -233,7 +231,6 @@ const tRoomID kWSC60North = 58;
 const tRoomID kWSC61 = 59;
 const tRoomID kWSC61South = 60;
 const tRoomID kWSC61West = 61;
-const tRoomID kWSC62 = 62;
 const tRoomID kWSC63 = 63;
 const tRoomID kWSC64 = 64;
 const tRoomID kWSC65 = 65;
diff --git a/engines/pegasus/neighborhood/wsc/wsc.h b/engines/pegasus/neighborhood/wsc/wsc.h
index 554c2f7..8646da3 100755
--- a/engines/pegasus/neighborhood/wsc/wsc.h
+++ b/engines/pegasus/neighborhood/wsc/wsc.h
@@ -35,6 +35,9 @@ const tDisplayOrder kWSCMoleculeBinOrder = kMonitorLayer;
 const tDisplayOrder kWSCMoleculesMovieOrder = kWSCMoleculeBinOrder + 1;
 
 const tRoomID kWSC01 = 0;
+const tRoomID kWSC02Morph = 2;
+const tRoomID kWSC02Messages = 3;
+const tRoomID kWSC62 = 62;
 
 class WSC : public Neighborhood {
 public:
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ab5ab55..2871ed1 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1227,9 +1227,8 @@ tInventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
 		else
 			result = _items.addItem(item);
 
-		// TODO
 		if (result == kTooMuchWeight)
-			error("Out of inventory space");
+			destroyInventoryItem(pickItemToDestroy());
 	} while (result != kInventoryOK);
 
 	GameState.setTakenItem(item, true);
@@ -1945,4 +1944,129 @@ void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, ui
 	scaledFrame.free();
 }
 
+void PegasusEngine::destroyInventoryItem(const tItemID itemID) {
+	InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
+
+	ItemExtraEntry entry;
+
+	switch (itemID) {
+	case kAirMask:
+		item->findItemExtra(kRemoveAirMask, entry);
+		item->setItemRoom(kMarsID, kMars49, kSouth);
+		break;
+	case kArgonCanister:
+		item->findItemExtra(kRemoveArgon, entry);
+		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
+		break;
+	case kCrowbar:
+		item->findItemExtra(kRemoveCrowbar, entry);
+		item->setItemRoom(kMarsID, kMars34, kSouth);
+		break;
+	case kJourneymanKey:
+		item->findItemExtra(kRemoveJourneymanKey, entry);
+		item->setItemRoom(kFullTSAID, kTSA22Red, kEast);
+		break;
+	case kMarsCard:
+		item->findItemExtra(kRemoveMarsCard, entry);
+		item->setItemRoom(kMarsID, kMars31South, kSouth);
+		break;
+	case kNitrogenCanister:
+		item->findItemExtra(kRemoveNitrogen, entry);
+		item->setItemRoom(kWSCID, kWSC02Messages, kSouth);
+		break;
+	case kOrangeJuiceGlassEmpty:
+		item->findItemExtra(kRemoveGlass, entry);
+		item->setItemRoom(kCaldoriaID, kCaldoriaReplicator, kNorth);
+		break;
+	case kPoisonDart:
+		item->findItemExtra(kRemoveDart, entry);
+		item->setItemRoom(kWSCID, kWSC01, kWest);
+		break;
+	case kSinclairKey:
+		item->findItemExtra(kRemoveSinclairKey, entry);
+		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
+		break;
+	default:
+		return;
+	}
+
+	g_interface->setCurrentInventoryItemID(itemID);
+	g_AIArea->playAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
+	removeItemFromInventory(item);
+}
+
+tItemID PegasusEngine::pickItemToDestroy() {
+/*
+	Must pick an item to destroy
+	
+	Part I: Polite -- try to find an item that's been used
+	Part II: Desperate -- return the first available item.
+*/
+
+	// Polite:
+	if (playerHasItemID(kOrangeJuiceGlassEmpty))
+		return kOrangeJuiceGlassEmpty;
+	if (playerHasItemID(kPoisonDart)) {
+		if (GameState.getCurrentNeighborhood() != kWSCID ||
+				GameState.getWSCAnalyzedDart())
+			return kPoisonDart;
+	}
+	if (playerHasItemID(kJourneymanKey)) {
+		if (GameState.getTSAState() >= kTSAPlayerGotHistoricalLog &&
+				GameState.getTSAState() != kPlayerOnWayToPrehistoric &&
+				GameState.getTSAState() != kPlayerWentToPrehistoric)
+			return kJourneymanKey;
+	}
+	if (playerHasItemID(kMarsCard)) {
+		if (GameState.getCurrentNeighborhood() != kMarsID || GameState.getMarsArrivedBelow())
+			return kMarsCard;
+	}
+
+	// Don't want to deal with deleting the sinclair key and argon canister, since it's
+	// impossible to pick them up one at a time.
+
+	if (playerHasItemID(kNitrogenCanister)) {
+		if (GameState.getScoringGotCardBomb() && GameState.getCurrentNeighborhood() != kMarsID)
+			return kNitrogenCanister;
+	}
+	if (playerHasItemID(kCrowbar)) {
+		if (GameState.getCurrentNeighborhood() == kWSCID) {
+			if (GameState.getCurrentRoom() >= kWSC62)
+				return kCrowbar;
+		} else if (GameState.getCurrentNeighborhood() == kMarsID) {
+			if (GameState.getScoringGotCardBomb())
+				return kCrowbar;
+		} else
+			return kCrowbar;
+	}
+	if (playerHasItemID(kAirMask)) {
+		if (GameState.getCurrentNeighborhood() == kMarsID) {
+			if (g_neighborhood->getAirQuality(GameState.getCurrentRoom()) == kAirQualityGood)
+				return kAirMask;
+		} else if (GameState.getCurrentNeighborhood() != kNoradAlphaID &&
+				GameState.getCurrentNeighborhood() != kNoradDeltaID) {
+			return kAirMask;
+		}
+	}
+
+	// Desperate:
+	if (playerHasItemID(kPoisonDart))
+		return kPoisonDart;
+	if (playerHasItemID(kJourneymanKey))
+		return kJourneymanKey;
+	if (playerHasItemID(kMarsCard))
+		return kMarsCard;
+	if (playerHasItemID(kNitrogenCanister))
+		return kNitrogenCanister;
+	if (playerHasItemID(kCrowbar))
+		return kCrowbar;
+	if (playerHasItemID(kAirMask))
+		return kAirMask;
+
+	// Should never get this far...
+	error("Could not find item to delete");
+
+	return kNoItemID;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index e3a933a..13145f3 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -223,6 +223,8 @@ private:
 	Inventory _biochips;
 	tItemID _currentItemID;
 	tItemID _currentBiochipID;
+	void destroyInventoryItem(const tItemID itemID);
+	tItemID pickItemToDestroy();
 
 	// TimeBases
 	Common::List<TimeBase *> _timeBases;


Commit: 81ace6e105406873905d36e1df82e33493edfbc9
    https://github.com/scummvm/scummvm/commit/81ace6e105406873905d36e1df82e33493edfbc9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-17T07:07:49-07:00

Commit Message:
PEGASUS: Fix TSA door locks

Changed paths:
    engines/pegasus/neighborhood/tsa/fulltsa.cpp



diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 1aac583..fcfae06 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -1267,12 +1267,15 @@ tCanOpenDoorReason FullTSA::canOpenDoor(DoorTable::Entry &entry) {
 	case MakeRoomView(kTSA02, kNorth):
 		if (!GameState.getTSAFrontDoorUnlockedOutside())
 			return kCantOpenLocked;
+		break;
 	case MakeRoomView(kTSA03, kSouth):
 		if (!GameState.getTSAFrontDoorUnlockedInside())
 			return kCantOpenLocked;
+		break;
 	case MakeRoomView(kTSA16, kNorth):
 		if (GameState.getTSACommandCenterLocked())
 			return kCantOpenLocked;
+		break;
 	}
 
 	return Neighborhood::canOpenDoor(entry);


Commit: 4af1fe25af35ccd484e3ff4650cad74cf903e30b
    https://github.com/scummvm/scummvm/commit/4af1fe25af35ccd484e3ff4650cad74cf903e30b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-18T06:37:56-07:00

Commit Message:
PEGASUS: Add our TGWorldSaver replacement

The scoring on the death/pause screens are now shown

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/menu.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/surface.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 8b83ed7..74e2aed 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -44,6 +44,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_firstDisplayElement = _lastDisplayElement = 0;
 	_workArea.create(640, 480, _vm->_system->getScreenFormat());
 	_modifiedScreen = false;
+	_curSurface = &_workArea;
 }
 	
 GraphicsManager::~GraphicsManager() {
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index c68c2de..18dfd3f 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -54,6 +54,8 @@ public:
 	tDisplayOrder getBackOfActiveLayer() const { return _backLayer; }
 	tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
 	void updateDisplay();
+	Graphics::Surface *getCurSurface() { return _curSurface; }
+	void setCurSurface(Graphics::Surface *surface) { _curSurface = surface; }
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
 	DisplayElement *findDisplayElement(const tDisplayElementID id);
@@ -73,7 +75,7 @@ private:
 	Common::Rect _dirtyRect;
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
-	Graphics::Surface _workArea;
+	Graphics::Surface _workArea, *_curSurface;
 
 	// Shake Shake Shake!
 	static const int kMaxShakeOffsets = 17;
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index dfef67c..ce95e6b 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -676,8 +676,11 @@ DeathMenu::DeathMenu(const tDeathReason deathReason) : GameMenu(kDeathMenuID), _
 	_deathBackground.initFromPICTFile(imageName);
 	_deathReason = deathReason;
 
-	if (!isDemo)
+	if (!isDemo) {
+		vm->_gfx->setCurSurface(_deathBackground.getSurface());
 		drawAllScores();
+		vm->_gfx->setCurSurface(vm->_gfx->getWorkArea());
+	}
 
 	_deathBackground.setDisplayOrder(0);
 	_deathBackground.startDisplaying();
@@ -993,8 +996,10 @@ PauseMenu::PauseMenu() : GameMenu(kPauseMenuID), _pauseBackground(0), _saveButto
 	if (!vm->isDemo()) {
 		Surface numbers;
 		numbers.getImageFromPICTFile("Images/Pause Screen/Numbers.pict");
+		vm->_gfx->setCurSurface(_pauseBackground.getSurface());
 		drawScore(GameState.getTotalScore(), kMaxTotalScore,
 				Common::Rect(kPauseScoreLeft, kPauseScoreTop, kPauseScoreRight, kPauseScoreBottom), &numbers);
+		vm->_gfx->setCurSurface(vm->_gfx->getWorkArea());
 	}
 
 	_pauseBackground.setDisplayOrder(kPauseMenuOrder);
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 5d8f386..fb95b07 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -727,8 +727,10 @@ void Neighborhood::turnTo(const tDirectionConstant direction) {
 	if (g_map)
 		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), direction);
 
-	// FIXME: This isn't right. Crazy TGWorldSaver stuff
-	//_pushIn.copyToCurrentPort();
+	// clone2727 says: Is this necessary?
+	_vm->_gfx->setCurSurface(_navMovie.getSurface());
+	_pushIn.copyToCurrentPort();
+	_vm->_gfx->setCurSurface(_vm->_gfx->getWorkArea());
 	
 	// Added 2/10/97. Shouldn't this be here? Shouldn't we set the current activation to
 	// always when turning to a new view?
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 43cf90a..69eeb31 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -164,7 +164,7 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &rect) const {
 }
 
 void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
-	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 
@@ -182,7 +182,7 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Co
 	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
 	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
 
-	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 


Commit: 422ff6c4c11bf09cfaa557c146b2f2d869c2cc3e
    https://github.com/scummvm/scummvm/commit/422ff6c4c11bf09cfaa557c146b2f2d869c2cc3e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-19T11:55:48-07:00

Commit Message:
PEGASUS: Don't use the work area for screen shaking

It may have stuff purposely not drawn on it

Changed paths:
    engines/pegasus/graphics.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 74e2aed..cc6dcf0 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -258,6 +258,12 @@ void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
 
 	Common::Point lastOffset(0, 0);
 
+	// Store the current screen for later use
+	Graphics::Surface oldScreen;
+	Graphics::Surface *curScreen = g_system->lockScreen();
+	oldScreen.copyFrom(*curScreen);
+	g_system->unlockScreen();
+
 	// Convert to millis
 	duration = duration * 1000 / scale;
 	
@@ -297,7 +303,7 @@ void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
 			}
 
 			// Now copy to the screen
-			g_system->copyRectToScreen((byte *)_workArea.getBasePtr(srcOffsetX, srcOffsetY), _workArea.pitch,
+			g_system->copyRectToScreen((byte *)oldScreen.getBasePtr(srcOffsetX, srcOffsetY), oldScreen.pitch,
 					dstOffsetX, dstOffsetY, width, height);
 			g_system->updateScreen();
 
@@ -308,9 +314,11 @@ void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
 	}
 
 	if (lastOffset.x != 0 || lastOffset.y != 0) {
-		g_system->copyRectToScreen((byte *)_workArea.pixels, _workArea.pitch, 0, 0, 640, 480);
+		g_system->copyRectToScreen((byte *)oldScreen.pixels, oldScreen.pitch, 0, 0, 640, 480);
 		g_system->updateScreen();
 	}
+
+	oldScreen.free();
 }
 	
 } // End of namespace Pegasus


Commit: d6dee9ff1880cd8c0badbf55d6e50ec67d43031a
    https://github.com/scummvm/scummvm/commit/d6dee9ff1880cd8c0badbf55d6e50ec67d43031a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-20T14:35:25-07:00

Commit Message:
PEGASUS: Add the base Norad code

(Common stuff between both Norad Alpha and Norad Delta)

Changed paths:
  A engines/pegasus/neighborhood/norad/norad.cpp
  A engines/pegasus/neighborhood/norad/norad.h
  A engines/pegasus/neighborhood/norad/noradelevator.cpp
  A engines/pegasus/neighborhood/norad/noradelevator.h
  A engines/pegasus/neighborhood/norad/pressuredoor.cpp
  A engines/pegasus/neighborhood/norad/pressuredoor.h
  A engines/pegasus/neighborhood/norad/pressuretracker.cpp
  A engines/pegasus/neighborhood/norad/pressuretracker.h
  A engines/pegasus/neighborhood/norad/subcontrolroom.cpp
  A engines/pegasus/neighborhood/norad/subcontrolroom.h
  A engines/pegasus/neighborhood/norad/subplatform.cpp
  A engines/pegasus/neighborhood/norad/subplatform.h
    engines/pegasus/module.mk
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index a371aef..58c9dc9 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -59,6 +59,12 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/mars.o \
+	neighborhood/norad/norad.o \
+	neighborhood/norad/noradelevator.o \
+	neighborhood/norad/pressuredoor.o \
+	neighborhood/norad/pressuretracker.o \
+	neighborhood/norad/subcontrolroom.o \
+	neighborhood/norad/subplatform.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 75790ed..9551248 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -57,8 +57,19 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 
 	releaseMovie();
 	_video = new Video::QuickTimeDecoder();
-	if (!_video->loadFile(fileName))	
-		error("Could not load video '%s'", fileName.c_str());
+	if (!_video->loadFile(fileName)) {
+		// Replace any colon with an underscore, since only Mac OS X
+		// supports that. See PegasusEngine::detectOpeningClosingDirectory()
+		// for more info.
+		Common::String newName(fileName);
+		if (newName.contains(':'))
+			for (uint i = 0; i < newName.size(); i++)
+				if (newName[i] == ':')
+					newName.setChar(i, '_');
+
+		if (!_video->loadFile(newName))
+			error("Could not load video '%s'", fileName.c_str());
+	}
 
 	_video->pauseVideo(true);
 
diff --git a/engines/pegasus/neighborhood/norad/norad.cpp b/engines/pegasus/neighborhood/norad/norad.cpp
new file mode 100755
index 0000000..931d854
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/norad.cpp
@@ -0,0 +1,284 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/noradelevator.h"
+#include "pegasus/neighborhood/norad/pressuredoor.h"
+#include "pegasus/neighborhood/norad/subcontrolroom.h"
+#include "pegasus/neighborhood/norad/subplatform.h"
+
+namespace Pegasus {
+
+const tNotificationFlags kDoneWithPressureDoorNotification = 1;
+
+const tNotificationFlags kNoradNotificationFlags = kDoneWithPressureDoorNotification;
+
+// This class handles everything that Norad Alpha and Delta have in common, such as
+// oxygen mask usage, the elevator and the pressure doors.
+
+Norad::Norad(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id) :
+		Neighborhood(nextHandler, vm, resName, id), _noradNotification(kNoradNotificationID, vm) {
+	_elevatorUpSpotID = kNoHotSpotID;
+	_elevatorDownSpotID = kNoHotSpotID;
+	_elevatorUpRoomID = kNoHotSpotID;
+	_elevatorDownRoomID = kNoHotSpotID;
+
+	_subRoomEntryRoom1 = kNoRoomID;
+	_subRoomEntryDir1 = kNoDirection;
+	_subRoomEntryRoom2 = kNoRoomID;
+	_subRoomEntryDir2 = kNoDirection;
+	_upperPressureDoorRoom = kNoRoomID;
+	_lowerPressureDoorRoom = kNoRoomID;
+
+	_upperPressureDoorUpSpotID = kNoHotSpotID;
+	_upperPressureDoorDownSpotID = kNoHotSpotID;
+	_upperPressureDoorAbortSpotID = kNoHotSpotID;
+
+	_lowerPressureDoorUpSpotID = kNoHotSpotID;
+	_lowerPressureDoorDownSpotID = kNoHotSpotID;
+	_lowerPressureDoorAbortSpotID = kNoHotSpotID;
+
+	_pressureSoundIn = 0xffffffff;
+	_pressureSoundOut = 0xffffffff;
+	_equalizeSoundIn = 0xffffffff;
+	_equalizeSoundOut = 0xffffffff;
+	_accessDeniedIn = 0xffffffff;
+	_accessDeniedOut = 0xffffffff;
+
+	_platformRoom = kNoRoomID;
+	_subControlRoom = kNoRoomID;
+
+	_doneWithPressureDoor = false;
+
+	_noradNotification.notifyMe(this, kNoradNotificationFlags, kNoradNotificationFlags);
+}
+
+GameInteraction *Norad::makeInteraction(const tInteractionID interactionID) {
+	PressureDoor *pressureDoor;
+	SubControlRoom *subControl;
+
+	switch (interactionID) {
+		case kNoradElevatorInteractionID:
+			return new NoradElevator(this, _elevatorUpRoomID, _elevatorDownRoomID, _elevatorUpSpotID, _elevatorDownSpotID);
+		case kNoradPressureDoorInteractionID:
+			if (GameState.getCurrentRoom() == _upperPressureDoorRoom)
+				pressureDoor = new PressureDoor(this, true, _upperPressureDoorUpSpotID, _upperPressureDoorDownSpotID,
+						_upperPressureDoorAbortSpotID, _pressureSoundIn, _pressureSoundOut, _equalizeSoundIn, _equalizeSoundOut);
+			else
+				pressureDoor = new PressureDoor(this, false, _lowerPressureDoorUpSpotID, _lowerPressureDoorDownSpotID,
+						_lowerPressureDoorAbortSpotID, _pressureSoundIn, _pressureSoundOut, _equalizeSoundIn, _equalizeSoundOut);
+
+			if (GameState.getCurrentRoom() == kNorad59West && playingAgainstRobot())
+				pressureDoor->playAgainstRobot();
+
+			return pressureDoor;
+		case kNoradSubControlRoomInteractionID:
+			subControl = new SubControlRoom(this);
+
+			if (GameState.getCurrentRoom() == kNorad60West && playingAgainstRobot())
+				subControl->playAgainstRobot();
+
+			return subControl;
+		case kNoradSubPlatformInteractionID:
+			return new SubPlatform(this);
+		default:
+			return 0;
+	}
+}
+
+void Norad::flushGameState() {
+	g_energyMonitor->saveCurrentEnergyValue();
+}
+
+void Norad::start() {
+	setUpAirMask();
+	Neighborhood::start();
+}
+
+void Norad::activateHotspots() {	
+	Neighborhood::activateHotspots();
+
+	tRoomID room = GameState.getCurrentRoom();
+	if (room == _elevatorUpRoomID)
+		_neighborhoodHotspots.activateOneHotspot(_elevatorDownSpotID);
+	else if (room == _elevatorDownRoomID)
+		_neighborhoodHotspots.activateOneHotspot(_elevatorUpSpotID);
+}
+
+void Norad::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	Neighborhood::arriveAt(room, direction);
+
+	if (GameState.getCurrentRoom() == _elevatorUpRoomID || GameState.getCurrentRoom() == _elevatorDownRoomID)
+		arriveAtNoradElevator();
+	else if (GameState.getCurrentRoom() == _upperPressureDoorRoom)
+		arriveAtUpperPressureDoorRoom();
+	else if (GameState.getCurrentRoom() == _lowerPressureDoorRoom)
+		arriveAtLowerPressureDoorRoom();
+	else if (GameState.getCurrentRoom() == _platformRoom)
+		arriveAtSubPlatformRoom();
+	else if (GameState.getCurrentRoom() == _subControlRoom)
+		arriveAtSubControlRoom();
+
+	if (_doneWithPressureDoor) {
+		_doneWithPressureDoor = false;
+		openDoor();
+	}
+}
+
+void Norad::arriveAtNoradElevator() {
+	if (_currentInteraction)
+		_currentInteraction->startOverInteraction();
+	else
+		newInteraction(kNoradElevatorInteractionID);
+}
+
+void Norad::arriveAtUpperPressureDoorRoom() {
+	newInteraction(kNoradPressureDoorInteractionID);
+}
+
+void Norad::arriveAtLowerPressureDoorRoom() {
+	newInteraction(kNoradPressureDoorInteractionID);
+}
+
+void Norad::arriveAtSubPlatformRoom() {
+	newInteraction(kNoradSubPlatformInteractionID);
+}
+
+void Norad::arriveAtSubControlRoom() { 
+	newInteraction(kNoradSubControlRoomInteractionID);
+}
+
+int16 Norad::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+	int16 result = Neighborhood::getStaticCompassAngle(room, dir);
+
+	if (room == _elevatorUpRoomID || room == _elevatorDownRoomID)
+		result += kElevatorCompassAngle;
+	else if (room == _platformRoom)
+		result += kSubPlatformCompassAngle;
+	else if (room == _subControlRoom)
+		result += kSubControlCompassAngle;
+
+	return result;
+}
+
+tCanOpenDoorReason Norad::canOpenDoor(DoorTable::Entry &entry) {
+	if (((GameState.getCurrentRoom() == _subRoomEntryRoom1 && GameState.getCurrentDirection() == _subRoomEntryDir1) ||
+			(GameState.getCurrentRoom() == _subRoomEntryRoom2 && GameState.getCurrentDirection() == _subRoomEntryDir2)) &&
+			GameState.getNoradSubRoomPressure() != kNormalSubRoomPressure)
+		return kCantOpenBadPressure;
+
+	return Neighborhood::canOpenDoor(entry);
+}
+
+void Norad::cantOpenDoor(tCanOpenDoorReason reason) {
+	if (reason == kCantOpenBadPressure)
+		playSpotSoundSync(_pressureSoundIn, _pressureSoundOut);
+	else
+		playSpotSoundSync(_accessDeniedIn, _accessDeniedOut);
+}
+
+void Norad::startExitMovie(const ExitTable::Entry &exitEntry) {
+	if (GameState.getCurrentRoom() == _elevatorUpRoomID) {
+		if (exitEntry.exitRoom != _elevatorDownRoomID)
+			newInteraction(kNoInteractionID);
+	} else if (GameState.getCurrentRoom() == _elevatorDownRoomID) {
+		if (exitEntry.exitRoom != _elevatorUpRoomID)
+			newInteraction(kNoInteractionID);
+	} else {
+		newInteraction(kNoInteractionID);
+	}
+
+	Neighborhood::startExitMovie(exitEntry);
+}
+
+void Norad::startZoomMovie(const ZoomTable::Entry &zoomEntry) {
+	newInteraction(kNoInteractionID);
+	Neighborhood::startZoomMovie(zoomEntry);
+}
+
+void Norad::upButton(const Input &input) {
+	if (GameState.getCurrentRoom() != _elevatorUpRoomID && GameState.getCurrentRoom() != _elevatorDownRoomID)
+		Neighborhood::upButton(input);
+}
+
+void Norad::setUpAirMask() {	
+	_airMaskCallBack.setNotification(&_neighborhoodNotification);
+	_airMaskCallBack.initCallBack(&_airMaskTimer, kCallBackAtExtremes);
+	_airMaskCallBack.setCallBackFlag(kAirTimerExpiredFlag);
+	_neighborhoodNotification.notifyMe(this, kAirTimerExpiredFlag, kAirTimerExpiredFlag);
+	_airMaskCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_airMaskTimer.setScale(1);
+	_airMaskTimer.setSegment(0, kNoradAirMaskTimeLimit);
+	checkAirMask();
+}
+
+void Norad::checkAirMask() {
+	if (g_airMask && g_airMask->isAirFilterOn()) {
+		_airMaskTimer.stop();
+	} else if (GameState.getNoradGassed() && !_airMaskTimer.isRunning()) {
+		_airMaskTimer.setTime(0);
+		_airMaskTimer.start();
+	}
+
+	loadAmbientLoops();
+}
+
+void Norad::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+	if (notification == &_neighborhoodNotification && (flags & kAirTimerExpiredFlag) != 0)
+		((PegasusEngine *)g_engine)->die(kDeathGassedInNorad);
+
+	Neighborhood::receiveNotification(notification, flags);
+
+	if (notification == &_noradNotification) {
+		// Must be kDoneWithPressureDoorNotification...
+		Input scratch;
+		_doneWithPressureDoor = true;
+		downButton(scratch);
+	}
+}
+
+uint16 Norad::getDateResID() const {
+	return kDate2112ID;
+}
+
+Common::String Norad::getBriefingMovie() {
+	return "Images/AI/Norad/XNO";
+}
+
+void Norad::pickedUpItem(Item *item) {
+	Neighborhood::pickedUpItem(item);
+	g_AIArea->checkMiddleArea();
+}
+
+void Norad::doneWithPressureDoor() {
+	_noradNotification.setNotificationFlags(kDoneWithPressureDoorNotification, kDoneWithPressureDoorNotification);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/norad.h b/engines/pegasus/neighborhood/norad/norad.h
new file mode 100755
index 0000000..4b4473c
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/norad.h
@@ -0,0 +1,485 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_NORAD_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_NORAD_H
+
+#include "pegasus/neighborhood/neighborhood.h"
+
+namespace Pegasus {
+
+const tCanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
+
+const tNotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
+
+const uint16 kNoradWarningVolume = 0x100 / 3;
+const uint16 kNoradSuckWindVolume = 0x100 / 2;
+
+const int16 kElevatorCompassAngle = -40;
+const int16 kSubPlatformCompassAngle = 45;
+const int16 kSubControlCompassAngle = -10;
+
+//	Norad interactions.
+
+const tInteractionID kNoradGlobeGameInteractionID = 0;
+const tInteractionID kNoradECRMonitorInteractionID = 1;
+const tInteractionID kNoradFillingStationInteractionID = 2;
+const tInteractionID kNoradElevatorInteractionID = 3;
+const tInteractionID kNoradPressureDoorInteractionID = 4;
+const tInteractionID kNoradSubControlRoomInteractionID = 5;
+const tInteractionID kNoradSubPlatformInteractionID = 6;
+
+/////////////////////////////////////////////
+//
+//	Norad Alpha
+
+const tCoordType kECRSlideShowLeft = kNavAreaLeft + 78;
+const tCoordType kECRSlideShowTop = kNavAreaTop + 1;
+
+const tCoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
+const tCoordType kECRPanTop = kNavAreaTop + 1 + 4;
+const tCoordType kECRPanRight = kECRPanLeft + 213;
+const tCoordType kECRPanBottom = kECRPanTop + 241;
+
+const tCoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
+const tCoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
+
+const tCoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
+const tCoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
+
+const tCoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
+const tCoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
+
+const tCoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
+const tCoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
+
+const tCoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
+const tCoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
+
+const tCoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
+const tCoordType kNoradUpperUpTop = kNavAreaTop + 32;
+
+const tCoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
+const tCoordType kNoradUpperDownTop = kNavAreaTop + 66;
+
+const tCoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
+const tCoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
+
+const tCoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
+const tCoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
+
+const tCoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
+const tCoordType kNoradLowerUpTop = kNavAreaTop + 164;
+
+const tCoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
+const tCoordType kNoradLowerDownTop = kNavAreaTop + 212;
+
+const tCoordType kNoradPlatformLeft = kNavAreaLeft + 36;
+const tCoordType kNoradPlatformTop = kNavAreaTop + 87;
+
+const tCoordType kNoradSubControlLeft = kNavAreaLeft + 0;
+const tCoordType kNoradSubControlTop = kNavAreaTop + 84;
+
+const tCoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
+const tCoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
+
+const tCoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
+const tCoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
+
+const tCoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
+const tCoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
+
+const tCoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
+const tCoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
+
+const tCoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
+const tCoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
+
+const tCoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
+const tCoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
+
+const tCoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
+const tCoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
+
+const tCoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
+const tCoordType kNoradClawMonitorTop = kNavAreaTop + 97;
+
+const tCoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
+const tCoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
+
+const tCoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
+const tCoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
+
+const tCoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
+const tCoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
+
+const tCoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
+const tCoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
+
+/////////////////////////////////////////////
+//
+//	Norad Delta
+
+const tCoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
+const tCoordType kGlobeMonitorTop = kNavAreaTop + 144;
+
+const tCoordType kGlobeLeft = kNavAreaLeft + 172;
+const tCoordType kGlobeTop = kNavAreaTop;
+
+const tCoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
+const tCoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
+
+const tCoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
+const tCoordType kGlobeCircleRightTop = kNavAreaTop + 41;
+
+const tCoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
+const tCoordType kGlobeCircleUpTop = kNavAreaTop + 7;
+
+const tCoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
+const tCoordType kGlobeCircleDownTop = kNavAreaTop + 142;
+
+const tCoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
+const tCoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
+
+const tCoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
+const tCoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
+
+const tCoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
+const tCoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
+
+const tCoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
+const tCoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
+
+const tCoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
+const tCoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
+
+const tCoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
+const tCoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
+
+const tCoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
+const tCoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
+
+const tCoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
+const tCoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
+
+const tCoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
+const tCoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
+
+const tCoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
+const tCoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
+
+const tCoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
+const tCoordType kGlobeCountdownTop = kNavAreaTop + 164;
+
+//	Norad Alpha display IDs.
+
+const tDisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
+const tDisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
+const tDisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
+const tDisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
+const tDisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
+const tDisplayElementID kN01RightSideID = kN01LeftSideID + 1;
+const tDisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
+const tDisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
+const tDisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
+const tDisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
+const tDisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
+const tDisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
+const tDisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
+const tDisplayElementID kSubControlPinchID = kClawMonitorID + 1;
+const tDisplayElementID kSubControlDownID = kSubControlPinchID + 1;
+const tDisplayElementID kSubControlRightID = kSubControlDownID + 1;
+const tDisplayElementID kSubControlLeftID = kSubControlRightID + 1;
+const tDisplayElementID kSubControlUpID = kSubControlLeftID + 1;
+const tDisplayElementID kSubControlCCWID = kSubControlUpID + 1;
+const tDisplayElementID kSubControlCWID = kSubControlCCWID + 1;
+const tDisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
+
+//	Norad Delta display IDs.
+
+const tDisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
+const tDisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
+const tDisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
+const tDisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
+const tDisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
+const tDisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
+const tDisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
+const tDisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
+const tDisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
+const tDisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
+const tDisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
+const tDisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
+const tDisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
+const tDisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
+const tDisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
+const tDisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
+const tDisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
+
+//	Norad Alpha:
+
+const tDisplayOrder kECRMonitorOrder = kMonitorLayer;
+const tDisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
+
+const tDisplayOrder kN01LeftSideOrder = kMonitorLayer;
+const tDisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
+
+const tDisplayOrder kElevatorControlsOrder = kMonitorLayer;
+
+const tDisplayOrder kPressureLevelsOrder = kMonitorLayer;
+const tDisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
+const tDisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
+const tDisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
+
+const tDisplayOrder kPlatformOrder = kMonitorLayer;
+
+const tDisplayOrder kSubControlOrder = kMonitorLayer;
+const tDisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
+const tDisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
+const tDisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
+const tDisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
+const tDisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
+const tDisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
+const tDisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
+const tDisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
+const tDisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
+
+//	Norad Delta:
+
+const tDisplayOrder kGlobeMonitorLayer = kMonitorLayer;
+const tDisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
+const tDisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
+const tDisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
+const tDisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
+const tDisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
+const tDisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
+
+
+//	Norad Alpha Extra sequence IDs.
+
+const tExtraID kNoradArriveFromTSA = 0;
+const tExtraID kNorad01RobotTaunt = 1;
+const tExtraID kNorad01ZoomInWithGasCanister = 2;
+const tExtraID kN01WGasCanister = 3;
+const tExtraID kNorad01ZoomOutWithGasCanister = 4;
+const tExtraID kN01WZEmptyLit = 5;
+const tExtraID kN01WZGasCanisterDim = 6;
+const tExtraID kN01WZGasCanisterLit = 7;
+const tExtraID kN01WZArgonCanisterDim = 8;
+const tExtraID kN01WZArgonCanisterLit = 9;
+const tExtraID kN01WZAirMaskDim = 10;
+const tExtraID kN01WZAirMaskLit = 11;
+const tExtraID kN01WZNitrogenCanisterDim = 12;
+const tExtraID kN01WZNitrogenCanisterLit = 13;
+const tExtraID kNorad04EastDeath = 14;
+const tExtraID kNorad19PrepSub = 15;
+const tExtraID kNorad19ExitToSub = 16;
+const tExtraID kNorad22SouthIntro = 17;
+const tExtraID kNorad22SouthReply = 18;
+const tExtraID kNorad22SouthFinish = 19;
+const tExtraID kN22ClawFromAToB = 20;
+const tExtraID kN22ClawALoop = 21;
+const tExtraID kN22ClawAPinch = 22;
+const tExtraID kN22ClawACounterclockwise = 23;
+const tExtraID kN22ClawAClockwise = 24;
+const tExtraID kN22ClawFromBToA = 25;
+const tExtraID kN22ClawFromBToC = 26;
+const tExtraID kN22ClawFromBToD = 27;
+const tExtraID kN22ClawBLoop = 28;
+const tExtraID kN22ClawBPinch = 29;
+const tExtraID kN22ClawBCounterclockwise = 30;
+const tExtraID kN22ClawBClockwise = 31;
+const tExtraID kN22ClawFromCToB = 32;
+const tExtraID kN22ClawCLoop = 33;
+const tExtraID kN22ClawCPinch = 34;
+const tExtraID kN22ClawCCounterclockwise = 35;
+const tExtraID kN22ClawCClockwise = 36;
+const tExtraID kN22ClawFromDToB = 37;
+const tExtraID kN22ClawDLoop = 38;
+const tExtraID kN22ClawDPinch = 39;
+const tExtraID kN22ClawDCounterclockwise = 40;
+const tExtraID kN22ClawDClockwise = 41;
+
+//	Norad Delta Extra sequence IDs.
+
+const tExtraID kArriveFromSubChase = 0;
+const tExtraID kN59ZoomWithRobot = 1;
+const tExtraID kN59RobotApproaches = 2;
+const tExtraID kN59RobotPunchLoop = 3;
+const tExtraID kN59PlayerWins1 = 4;
+const tExtraID kN59PlayerWins2 = 5;
+const tExtraID kN59RobotWins = 6;
+const tExtraID kN59RobotHeadOpens = 7;
+const tExtraID kN59Biochips111 = 8;
+const tExtraID kN59Biochips011 = 9;
+const tExtraID kN59Biochips101 = 10;
+const tExtraID kN59Biochips001 = 11;
+const tExtraID kN59Biochips110 = 12;
+const tExtraID kN59Biochips010 = 13;
+const tExtraID kN59Biochips100 = 14;
+const tExtraID kN59Biochips000 = 15;
+const tExtraID kN59RobotDisappears = 16;
+const tExtraID kN60ClawFromAToB = 17;
+const tExtraID kN60ClawALoop = 18;
+const tExtraID kN60ClawAPinch = 19;
+const tExtraID kN60ClawACounterclockwise = 20;
+const tExtraID kN60ClawAClockwise = 21;
+const tExtraID kN60ClawFromBToA = 22;
+const tExtraID kN60ClawFromBToC = 23;
+const tExtraID kN60ClawFromBToD = 24;
+const tExtraID kN60ClawBLoop = 25;
+const tExtraID kN60ClawBPinch = 26;
+const tExtraID kN60ClawBCounterclockwise = 27;
+const tExtraID kN60ClawBClockwise = 28;
+const tExtraID kN60ClawFromCToB = 29;
+const tExtraID kN60ClawCLoop = 30;
+const tExtraID kN60ClawCPinch = 31;
+const tExtraID kN60ClawCCounterclockwise = 32;
+const tExtraID kN60ClawCClockwise = 33;
+const tExtraID kN60ClawFromDToB = 34;
+const tExtraID kN60ClawDLoop = 35;
+const tExtraID kN60ClawDPinch = 36;
+const tExtraID kN60ClawDCounterclockwise = 37;
+const tExtraID kN60ClawDClockwise = 38;
+const tExtraID kN60RobotApproaches = 39;
+const tExtraID kN60FirstMistake = 40;
+const tExtraID kN60ArmActivated = 41;
+const tExtraID kN60SecondMistake = 42;
+const tExtraID kN60ArmToPositionB = 43;
+const tExtraID kN60ThirdMistake = 44;
+const tExtraID kN60ArmGrabsRobot = 45;
+const tExtraID kN60FourthMistake = 46;
+const tExtraID kN60ArmCarriesRobotToPositionA = 47;
+const tExtraID kN60PlayerFollowsRobotToDoor = 48;
+const tExtraID kN60RobotHeadOpens = 49;
+const tExtraID kN60Biochips111 = 50;
+const tExtraID kN60Biochips011 = 51;
+const tExtraID kN60Biochips101 = 52;
+const tExtraID kN60Biochips001 = 53;
+const tExtraID kN60Biochips110 = 54;
+const tExtraID kN60Biochips010 = 55;
+const tExtraID kN60Biochips100 = 56;
+const tExtraID kN60Biochips000 = 57;
+const tExtraID kN60RobotDisappears = 58;
+const tExtraID kNoradDeltaRetinalScanBad = 59;
+const tExtraID kNoradDeltaRetinalScanGood = 60;
+const tExtraID kN79BrightView = 61;
+
+const TimeScale kNoradAlphaMovieScale = 600;
+const TimeScale kNoradAlphaFramesPerSecond = 15;
+const TimeScale kNoradAlphaFrameDuration = 40;
+
+const tRoomID kNorad59West = 23;
+const tRoomID kNorad60West = 25;
+const tHotSpotID kNorad19ActivateMonitorSpotID = 5031;
+
+// This is the code common to both Norad Alpha and Norad Delta
+
+class Norad : public Neighborhood {
+public:
+	Norad(InputHandler *, PegasusEngine *owner, const Common::String &resName, const tNeighborhoodID);
+	virtual ~Norad() {}
+
+	void flushGameState();
+
+	virtual void start();
+
+	virtual void getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID,
+			tHotSpotID &clawControlSpotID, tHotSpotID &pinchClawSpotID,
+			tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID,
+			tHotSpotID &moveClawLeftSpotID,tHotSpotID &moveClawUpSpotID,
+			tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &, uint32 *&) = 0;
+	void checkAirMask();
+
+	virtual uint16 getDateResID() const;
+
+	virtual GameInteraction *makeInteraction(const tInteractionID);
+
+	Common::String getBriefingMovie();
+
+	void pickedUpItem(Item *);
+
+	virtual void playClawMonitorIntro() {}
+
+	void doneWithPressureDoor();
+
+protected:
+	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	void cantOpenDoor(tCanOpenDoorReason);
+	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	virtual void startExitMovie(const ExitTable::Entry &);
+	void startZoomMovie(const ZoomTable::Entry &);
+	virtual void upButton(const Input &);
+	virtual void activateHotspots();
+
+	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	virtual void arriveAtNoradElevator();
+	virtual void arriveAtUpperPressureDoorRoom();
+	virtual void arriveAtLowerPressureDoorRoom();
+	virtual void arriveAtSubPlatformRoom();
+	virtual void arriveAtSubControlRoom();
+	void setUpAirMask();
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual bool playingAgainstRobot() { return false; }
+
+	Notification _noradNotification;
+	bool _doneWithPressureDoor;
+
+	tRoomID _elevatorUpRoomID;
+	tRoomID _elevatorDownRoomID;
+	tHotSpotID _elevatorUpSpotID;
+	tHotSpotID _elevatorDownSpotID;
+
+	TimeBase _airMaskTimer;
+	NotificationCallBack _airMaskCallBack;
+
+	tRoomID _subRoomEntryRoom1;
+	tDirectionConstant _subRoomEntryDir1;
+	tRoomID _subRoomEntryRoom2;
+	tDirectionConstant _subRoomEntryDir2;
+	tRoomID _upperPressureDoorRoom;
+	tRoomID _lowerPressureDoorRoom;
+
+	tHotSpotID _upperPressureDoorUpSpotID;
+	tHotSpotID _upperPressureDoorDownSpotID;
+	tHotSpotID _upperPressureDoorAbortSpotID;
+	
+	tHotSpotID _lowerPressureDoorUpSpotID;
+	tHotSpotID _lowerPressureDoorDownSpotID;
+	tHotSpotID _lowerPressureDoorAbortSpotID;
+	
+	TimeValue _pressureSoundIn;
+	TimeValue _pressureSoundOut;
+	TimeValue _equalizeSoundIn;
+	TimeValue _equalizeSoundOut;
+	TimeValue _accessDeniedIn;
+	TimeValue _accessDeniedOut;
+	
+	tRoomID	 _platformRoom;
+	tRoomID _subControlRoom;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.cpp b/engines/pegasus/neighborhood/norad/noradelevator.cpp
new file mode 100755
index 0000000..98b3d29
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/noradelevator.cpp
@@ -0,0 +1,130 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/noradelevator.h"
+
+namespace Pegasus {
+
+//	Norad elevator PICTs:
+
+const tResIDType kElevatorLabelID = 200;
+const tResIDType kElevatorButtonsID = 201;
+const tResIDType kElevatorDownOnID = 202;
+const tResIDType kElevatorUpOnID = 203;
+
+NoradElevator::NoradElevator(Neighborhood *handler, const tRoomID upRoom, const tRoomID downRoom,
+		const tHotSpotID upHotspot, const tHotSpotID downHotspot) : GameInteraction(kNoradElevatorInteractionID, handler),
+		_elevatorControls(kNoradElevatorControlsID), _elevatorNotification(kNoradElevatorNotificationID, ((PegasusEngine *)g_engine)) {
+	_timerExpired = false;
+	_upRoom = upRoom;
+	_downRoom = downRoom;
+	_upHotspot = upHotspot;
+	_downHotspot = downHotspot;
+}
+
+void NoradElevator::openInteraction() {	
+	SpriteFrame *frame = new SpriteFrame();
+	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorLabelID, true);
+	_elevatorControls.addFrame(frame, 0, 0);
+	
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorButtonsID, true);
+	_elevatorControls.addFrame(frame, 0, 0);
+	
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorDownOnID, true);
+	_elevatorControls.addFrame(frame, 0, 0);
+	
+	frame = new SpriteFrame();
+	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorUpOnID, true);
+	_elevatorControls.addFrame(frame, 0, 0);
+	
+	_elevatorControls.setCurrentFrameIndex(0);
+	_elevatorControls.setDisplayOrder(kElevatorControlsOrder);
+
+	Common::Rect r;
+	frame->getSurfaceBounds(r);
+	r.moveTo(kNoradAlphaElevatorControlsLeft, kNoradAlphaElevatorControlsTop);
+
+	_elevatorControls.setBounds(r);
+	_elevatorControls.startDisplaying();
+	_elevatorControls.show();
+}
+
+void NoradElevator::initInteraction() {	
+	_elevatorTimer.setScale(2);
+	_elevatorTimer.setSegment(0, 1);
+	_elevatorCallBack.initCallBack(&_elevatorTimer, kCallBackAtExtremes);
+	_elevatorCallBack.setCallBackFlag(1);
+	_elevatorCallBack.setNotification(&_elevatorNotification);
+	_elevatorNotification.notifyMe(this, 1, 1);
+	_elevatorCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_elevatorTimer.start();
+}
+
+void NoradElevator::closeInteraction() {
+	_elevatorControls.stopDisplaying();
+	_elevatorControls.discardFrames();
+	_elevatorCallBack.releaseCallBack();
+}
+
+void NoradElevator::resetInteraction() {
+	_elevatorControls.setCurrentFrameIndex(1);
+}
+
+void NoradElevator::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	if (_timerExpired) {
+		if (GameState.getCurrentRoom() == _upRoom)
+			g_allHotspots.activateOneHotspot(_downHotspot);
+		else if (GameState.getCurrentRoom() == _downRoom)
+			g_allHotspots.activateOneHotspot(_upHotspot);
+	}
+}
+
+void NoradElevator::clickInHotspot(const Input &input, const Hotspot *spot) {
+	tHotSpotID id = spot->getObjectID();
+
+	if (id == _upHotspot || id == _downHotspot) {
+		g_neighborhood->moveForward();
+		if (id == _downHotspot)
+			_elevatorControls.setCurrentFrameIndex(2);
+		else
+			_elevatorControls.setCurrentFrameIndex(3);
+	} else {
+		GameInteraction::clickInHotspot(input, spot);
+	}
+}
+
+void NoradElevator::receiveNotification(Notification *, const tNotificationFlags) {
+	_elevatorControls.setCurrentFrameIndex(1);
+	_timerExpired = true;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.h b/engines/pegasus/neighborhood/norad/noradelevator.h
new file mode 100755
index 0000000..58dc8ab
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/noradelevator.h
@@ -0,0 +1,67 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_NORADELEVATOR_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_NORADELEVATOR_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/notification.h"
+#include "pegasus/surface.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class Neighborhood;
+
+class NoradElevator : public GameInteraction, private NotificationReceiver {
+public:
+	NoradElevator(Neighborhood *, const tRoomID, const tRoomID, const tHotSpotID, const tHotSpotID);
+	virtual ~NoradElevator() {}
+
+protected:
+	virtual void openInteraction();
+	virtual void initInteraction();
+	virtual void closeInteraction();
+	virtual void resetInteraction();
+	
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	
+	virtual void receiveNotification(Notification*, const tNotificationFlags);
+	
+	tRoomID _upRoom;
+	tRoomID _downRoom;
+	tHotSpotID _upHotspot;
+	tHotSpotID _downHotspot;
+	Sprite _elevatorControls;
+	TimeBase _elevatorTimer;
+	NotificationCallBack _elevatorCallBack;
+	Notification _elevatorNotification;
+	bool _timerExpired;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
new file mode 100755
index 0000000..066914c
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
@@ -0,0 +1,543 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/pressuredoor.h"
+
+namespace Pegasus {
+
+const TimeValue kLevelsSplashStart = 0;
+const TimeValue kLevelsSplashStop = 1;
+const TimeValue kPressureBase = 1;
+
+const TimeValue kDoorSealedTime = 0;
+const TimeValue kEqualizeTime = 1;
+const TimeValue kMaxPressureLoopStart = 2;
+const TimeValue kMaxPressureLoopStop = 3;
+const TimeValue kOpeningDoorLoopStart = 3;
+const TimeValue kOpeningDoorLoopStop = 4;
+const TimeValue kIncreasingPressureTime = 4;
+const TimeValue kDecreasingPressureTime = 5;
+const TimeValue kCautionLoopStart = 6;
+const TimeValue kCautionLoopStop = 7;
+
+const tNotificationFlags kSplashFinished = 1;
+const tNotificationFlags kPressureDroppingFlag = kSplashFinished << 1;
+
+const tNotificationFlags kPressureNotificationFlags = kSplashFinished |
+														kPressureDroppingFlag;
+
+const tNotificationFlags kDoorJumpsUpFlag = 1;
+const tNotificationFlags kDoorJumpsBackFlag = kDoorJumpsUpFlag << 1;
+const tNotificationFlags kDoorCrushedFlag = kDoorJumpsBackFlag << 1;
+
+const tNotificationFlags kUtilityNotificationFlags = kDoorJumpsUpFlag |
+														kDoorJumpsBackFlag |
+														kDoorCrushedFlag;
+
+enum {
+	kPlayingRobotApproaching,
+	kRobotPunching,
+	kRobotComingThrough,
+	kRobotDying,
+	kRobotDead
+};
+
+const short kMaxPunches = 5;
+
+enum {
+	kPlayingSplash,
+	kPlayingPressureMessage,
+	kPlayingEqualizeMessage,
+	kWaitingForPlayer,
+	kPlayingDoneMessage,
+	kGameOver
+};
+
+//	Pressure values range from 0 to 11.
+const short kMinPressure = 0;
+const short kMaxPressure = 11;
+
+const TimeScale kNavTimeScale = 600;
+const TimeValue kNavFrameRate = 15;
+const TimeValue kNavTimePerFrame = kNavTimeScale / kNavFrameRate;
+
+const TimeValue kApproachPunchInTime = 122 * kNavTimePerFrame;
+const TimeValue kLoopPunchInTime = 38 * kNavTimePerFrame;
+const TimeValue kPunchThroughTime = 38 * kNavTimePerFrame;
+
+//	Pressure door PICTs:
+
+const tResIDType kUpperPressureUpOffPICTID = 400;
+const tResIDType kUpperPressureUpOnPICTID = 401;
+const tResIDType kUpperPressureDownOffPICTID = 402;
+const tResIDType kUpperPressureDownOnPICTID = 403;
+
+const tResIDType kLowerPressureUpOffPICTID = 404;
+const tResIDType kLowerPressureUpOnPICTID = 405;
+const tResIDType kLowerPressureDownOffPICTID = 406;
+const tResIDType kLowerPressureDownOnPICTID = 407;
+
+PressureDoor::PressureDoor(Neighborhood *handler, bool isUpperDoor, const tHotSpotID upSpotID, const tHotSpotID downSpotID,
+		const tHotSpotID outSpotID, TimeValue pressureSoundIn, TimeValue pressureSoundOut, TimeValue equalizeSoundIn,
+		TimeValue equalizeSoundOut) : GameInteraction(kNoradPressureDoorInteractionID, handler),
+		_levelsMovie(kPressureDoorLevelsID), _typeMovie(kPressureDoorTypeID), _upButton(kPressureDoorUpButtonID),
+		_downButton(kPressureDoorDownButtonID), _pressureNotification(kNoradPressureNotificationID, ((PegasusEngine *)g_engine)),
+		_doorTracker(this), _utilityNotification(kNoradUtilityNotificationID, ((PegasusEngine *)g_engine)) {
+	_neighborhoodNotification = handler->getNeighborhoodNotification();
+	_upHotspotID = upSpotID;
+	_downHotspotID = downSpotID;
+	_outHotspotID = outSpotID;
+	_pressureSoundIn = pressureSoundIn;
+	_pressureSoundOut = pressureSoundOut;
+	_equalizeSoundIn = equalizeSoundIn;
+	_equalizeSoundOut = equalizeSoundOut;
+	_playingAgainstRobot = false;
+	_isUpperDoor = isUpperDoor;
+}
+
+void PressureDoor::openInteraction() {
+	if (_isUpperDoor) {
+		_levelsMovie.initFromMovieFile("Images/Norad Alpha/Upper Levels Movie");
+		_levelsMovie.moveElementTo(kNoradUpperLevelsLeft, kNoradUpperLevelsTop);
+	} else {
+		_levelsMovie.initFromMovieFile("Images/Norad Alpha/Lower Levels Movie");
+		_levelsMovie.moveElementTo(kNoradLowerLevelsLeft, kNoradLowerLevelsTop);
+	}
+
+	_levelsScale = _levelsMovie.getScale();
+	_levelsMovie.setDisplayOrder(kPressureLevelsOrder);
+	_levelsMovie.startDisplaying();
+	_levelsMovie.setSegment(kLevelsSplashStart * _levelsScale, kLevelsSplashStop * _levelsScale);
+	_levelsMovie.setTime(kLevelsSplashStart * _levelsScale);
+	_levelsMovie.show();
+	
+	_pressureCallBack.setNotification(&_pressureNotification);
+	_pressureCallBack.initCallBack(&_levelsMovie, kCallBackAtExtremes);
+	_pressureCallBack.setCallBackFlag(kSplashFinished);
+	_pressureCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+	_pressureNotification.notifyMe(this, kPressureNotificationFlags, kPressureNotificationFlags);
+
+	if (_isUpperDoor) {
+		_typeMovie.initFromMovieFile("Images/Norad Alpha/Upper Type Movie");
+		_typeMovie.moveElementTo(kNoradUpperTypeLeft, kNoradUpperTypeTop);
+	} else {
+		_typeMovie.initFromMovieFile("Images/Norad Alpha/Lower Type Movie");
+		_typeMovie.moveElementTo(kNoradLowerTypeLeft, kNoradLowerTypeTop);
+	}
+
+	_typeScale = _typeMovie.getScale();
+	_typeMovie.setDisplayOrder(kPressureTypeOrder);
+	_typeMovie.startDisplaying();
+	_typeMovie.setTime(kDoorSealedTime * _typeScale);
+
+	SpriteFrame *frame = new SpriteFrame();
+	if (_isUpperDoor)
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureUpOffPICTID);
+	else
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureUpOffPICTID);
+	_upButton.addFrame(frame, 0, 0);
+
+	frame = new SpriteFrame();
+	if (_isUpperDoor)
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureUpOnPICTID);
+	else
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureUpOnPICTID);
+	_upButton.addFrame(frame, 0, 0);
+
+	_upButton.setCurrentFrameIndex(0);
+	_upButton.setDisplayOrder(kPressureUpOrder);
+
+	Common::Rect r;
+	frame->getSurfaceBounds(r);
+	if (_isUpperDoor)
+		r.moveTo(kNoradUpperUpLeft, kNoradUpperUpTop);
+	else
+		r.moveTo(kNoradLowerUpLeft, kNoradLowerUpTop);
+
+	_upButton.setBounds(r);
+	_upButton.startDisplaying();
+	_upButton.show();
+
+	frame = new SpriteFrame();
+	if (_isUpperDoor)
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureDownOffPICTID);
+	else
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureDownOffPICTID);
+	_downButton.addFrame(frame, 0, 0);
+
+	frame = new SpriteFrame();
+	if (_isUpperDoor)
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureDownOnPICTID);
+	else
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureDownOnPICTID);
+	_downButton.addFrame(frame, 0, 0);
+
+	_downButton.setCurrentFrameIndex(0);
+	_downButton.setDisplayOrder(kPressureDownOrder);
+
+	frame->getSurfaceBounds(r);
+	if (_isUpperDoor)
+		r.moveTo(kNoradUpperDownLeft, kNoradUpperDownTop);
+	else
+		r.moveTo(kNoradLowerDownLeft, kNoradLowerDownTop);
+
+	_downButton.setBounds(r);
+	_downButton.startDisplaying();
+	_downButton.show();
+
+	_utilityCallBack.setNotification(&_utilityNotification);
+	_utilityCallBack.initCallBack(&_utilityTimer, kCallBackAtTime);
+	_utilityNotification.notifyMe(this, kUtilityNotificationFlags, kUtilityNotificationFlags);
+	_utilityTimer.setMasterTimeBase(getOwner()->getNavMovie());
+
+	if (_playingAgainstRobot)
+		_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag | kDelayCompletedFlag |
+				kSpotSoundCompletedFlag, kExtraCompletedFlag | kDelayCompletedFlag | kSpotSoundCompletedFlag);
+	else
+		_neighborhoodNotification->notifyMe(this, kDelayCompletedFlag | kSpotSoundCompletedFlag,
+				kDelayCompletedFlag | kSpotSoundCompletedFlag);
+	
+	_gameState = kPlayingSplash;
+}
+
+void PressureDoor::initInteraction() {	
+	_levelsMovie.start();
+
+	if (_playingAgainstRobot) {
+		ExtraTable::Entry entry;
+		_owner->getExtraEntry(kN59RobotApproaches, entry);
+		_utilityTimer.setSegment(entry.movieStart, entry.movieEnd);
+		_utilityCallBack.setCallBackFlag(kDoorJumpsUpFlag);
+		_punchInTime = kApproachPunchInTime + entry.movieStart;
+		_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, _punchInTime, kNavTimeScale);
+		_utilityTimer.setTime(entry.movieStart);
+		_owner->startExtraSequence(kN59RobotApproaches, kExtraCompletedFlag, kFilterAllInput);
+		_utilityTimer.start();
+		_robotState = kPlayingRobotApproaching;
+	}
+
+	// TODO: MoviesTask call -- needed?
+}
+
+void PressureDoor::closeInteraction() {	
+	_pressureNotification.cancelNotification(this);
+	_pressureCallBack.releaseCallBack();
+	_utilityNotification.cancelNotification(this);
+	_utilityCallBack.releaseCallBack();
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void PressureDoor::playAgainstRobot() {
+	_playingAgainstRobot = true;
+}
+
+void PressureDoor::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	Neighborhood *owner = getOwner();
+
+	if (notification == _neighborhoodNotification) {
+		if (_playingAgainstRobot && (flags & kExtraCompletedFlag) != 0) {
+			ExtraTable::Entry entry;
+
+			switch (_robotState) {
+			case kPlayingRobotApproaching:
+				_utilityTimer.stop();
+				if (GameState.getNoradSubRoomPressure() == kMaxPressure) {
+					owner->getExtraEntry(kN59PlayerWins1, entry);
+					_utilityTimer.setSegment(entry.movieStart, entry.movieEnd);
+					_utilityTimer.setTime(entry.movieStart);
+					_utilityCallBack.setCallBackFlag(kDoorJumpsUpFlag);
+					_punchInTime = kLoopPunchInTime + entry.movieStart;
+					_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, _punchInTime, kNavTimeScale);
+					owner->startExtraSequence(kN59PlayerWins1, kExtraCompletedFlag, kFilterNoInput);
+					_utilityTimer.start();
+					_robotState = kRobotDying;
+				} else {
+					owner->getExtraEntry(kN59RobotPunchLoop, entry);
+					_utilityTimer.setSegment(entry.movieStart, entry.movieEnd);
+					_utilityTimer.setTime(entry.movieStart);
+					_utilityCallBack.setCallBackFlag(kDoorJumpsUpFlag);
+					_punchInTime = kLoopPunchInTime + entry.movieStart;
+					_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, _punchInTime, kNavTimeScale);
+					owner->startSpotLoop(entry.movieStart, entry.movieEnd, kExtraCompletedFlag);
+					_utilityTimer.start();
+					_robotState = kRobotPunching;
+					_punchCount = 1;
+				}
+				break;
+			case kRobotPunching:
+				if (GameState.getNoradSubRoomPressure() == kMaxPressure) {
+					owner->startExtraSequence(kN59PlayerWins1, kExtraCompletedFlag, kFilterNoInput);
+					_robotState = kRobotDying;
+				} else if (++_punchCount >= kMaxPunches) {
+					_robotState = kRobotComingThrough;
+					owner->getExtraEntry(kN59RobotWins, entry);
+					_utilityTimer.stop();
+					_utilityTimer.setSegment(entry.movieStart, entry.movieEnd);
+					_utilityTimer.setTime(entry.movieStart);
+					_utilityCallBack.cancelCallBack();
+					_utilityCallBack.setCallBackFlag(kDoorCrushedFlag);
+					_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, kPunchThroughTime + entry.movieStart, kNavTimeScale);
+					owner->startExtraSequence(kN59RobotWins, kExtraCompletedFlag, kFilterNoInput);
+					_utilityTimer.start();
+				} else {
+					_utilityCallBack.setCallBackFlag(kDoorJumpsUpFlag);
+					_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, _punchInTime, kNavTimeScale);
+					owner->scheduleNavCallBack(kExtraCompletedFlag);
+				}
+				break;
+			case kRobotComingThrough:
+				g_system->delayMillis(2 * 1000);
+				((PegasusEngine *)g_engine)->die(kDeathRobotThroughNoradDoor);
+				break;
+			case kRobotDying:
+				_robotState = kRobotDead;
+				_levelsMovie.stop();
+				_levelsMovie.setSegment((kNormalSubRoomPressure + kPressureBase) * _levelsScale,
+						(GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+				_pressureCallBack.setCallBackFlag(kPressureDroppingFlag);
+				_pressureCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
+				_typeMovie.stop();
+				_typeMovie.setSegment(0, _typeMovie.getDuration());
+				_typeMovie.setTime(kDecreasingPressureTime * _typeScale);
+				_typeMovie.show();
+				_downButton.show();
+				_downButton.setCurrentFrameIndex(1);
+				_gameState = kGameOver;
+				allowInput(false);
+				_levelsMovie.setRate(Common::Rational(0x5555, 0x10000) - 1); // Should match door tracker.
+				break;
+			case kRobotDead:
+				allowInput(true);
+				// TODO
+				//((NoradDelta *)owner)->playerBeatRobotWithDoor();
+				owner->requestDeleteCurrentInteraction();
+				break;
+			}
+		}
+
+		if ((flags & (kDelayCompletedFlag | kSpotSoundCompletedFlag)) != 0) {
+			switch (_gameState) {
+			case kPlayingPressureMessage:
+				_typeMovie.setTime(kEqualizeTime * _typeScale);
+				owner->requestDelay(1, 5, kFilterNoInput, 0);
+				owner->requestSpotSound(_equalizeSoundIn, _equalizeSoundOut, kFilterNoInput, 0);
+				owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
+				_gameState = kPlayingEqualizeMessage;
+				break;
+			case kPlayingEqualizeMessage:
+				_gameState = kWaitingForPlayer;
+				stopChangingPressure();
+				break;
+			case kPlayingDoneMessage:
+				_gameState = kWaitingForPlayer;
+				_typeMovie.stop();
+				_typeMovie.setFlags(0);
+				_typeMovie.hide();
+				if (!_playingAgainstRobot)
+					((Norad *)_owner)->doneWithPressureDoor();
+				break;
+			}
+		}
+	} else if (notification == &_pressureNotification) {
+		switch (flags) {
+		case kSplashFinished:
+			_levelsMovie.stop();
+			_levelsMovie.setSegment(0, _levelsMovie.getDuration());
+			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+
+			if (GameState.getNoradSubRoomPressure() != kNormalSubRoomPressure) {
+				_typeMovie.show();
+				owner->requestDelay(1, 5, kFilterNoInput, 0);
+				owner->requestSpotSound(_pressureSoundIn, _pressureSoundOut, kFilterNoInput, 0);
+				owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
+				_gameState = kPlayingPressureMessage;
+			} else {
+				_gameState = kWaitingForPlayer;
+			}
+			break;
+		case kPressureDroppingFlag:
+			_levelsMovie.stop();
+			_levelsMovie.hide();
+			_typeMovie.stop();
+			_typeMovie.hide();
+			_upButton.hide();
+			_downButton.hide();
+			owner->startExtraSequence(kN59PlayerWins2, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		}
+	} else if (notification == &_utilityNotification) {
+		switch (flags) {
+		case kDoorJumpsUpFlag:
+			_utilityCallBack.setCallBackFlag(kDoorJumpsBackFlag);
+			_utilityCallBack.scheduleCallBack(kTriggerTimeFwd, _punchInTime + kNavTimePerFrame, kNavTimeScale);
+			_levelsMovie.hide();
+			_typePunched = _typeMovie.isVisible();
+			if (_typePunched == true)
+				_typeMovie.hide();
+			_upButton.hide();
+			_downButton.hide();
+			break;
+		case kDoorJumpsBackFlag:
+			_levelsMovie.show();
+			_upButton.show();
+			_downButton.show();
+			if (_typePunched)
+				_typeMovie.show();
+			break;
+		case kDoorCrushedFlag:
+			_levelsMovie.hide();
+			_typeMovie.hide();
+			_upButton.hide();
+			_downButton.hide();
+			break;
+		}
+	}
+}
+
+void PressureDoor::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	switch (_gameState) {
+	case kWaitingForPlayer:
+		g_allHotspots.activateOneHotspot(_upHotspotID);
+		g_allHotspots.activateOneHotspot(_downHotspotID);
+		if (!_playingAgainstRobot)
+			g_allHotspots.activateOneHotspot(_outHotspotID);
+		break;
+	default:
+		break;
+	}
+}
+
+void PressureDoor::clickInHotspot(const Input &input, const Hotspot *spot) {
+	tHotSpotID id = spot->getObjectID();
+
+	if (id == _upHotspotID || id == _downHotspotID) {
+		if (id == _upHotspotID)
+			_doorTracker.setTrackParameters(spot, &_upButton);
+		else
+			_doorTracker.setTrackParameters(spot, &_downButton);
+
+		_doorTracker.startTracking(input);
+	} else {
+		GameInteraction::clickInHotspot(input, spot);
+	}
+}
+
+void PressureDoor::incrementPressure(const tHotSpotID id) {
+	_typeMovie.stop();
+	_typeMovie.setSegment(0, _typeMovie.getDuration());
+	_typeMovie.setFlags(0);
+
+	if (id == _upHotspotID) {
+		if (GameState.getNoradSubRoomPressure() < kMaxPressure) {
+			GameState.setNoradSubRoomPressure(GameState.getNoradSubRoomPressure() + 1);
+			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+			_typeMovie.setTime(kIncreasingPressureTime * _typeScale);
+			_typeMovie.show();
+			g_AIArea->checkMiddleArea();
+		} else {
+			_typeMovie.hide();
+		}
+	} else if (id == _downHotspotID) {
+		if (GameState.getNoradSubRoomPressure() > kMinPressure) {
+			GameState.setNoradSubRoomPressure(GameState.getNoradSubRoomPressure() - 1);
+			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+			_typeMovie.setTime(kDecreasingPressureTime * _typeScale);
+			_typeMovie.show();
+			g_AIArea->checkMiddleArea();
+		} else {
+			_typeMovie.hide();
+		}
+	}
+}
+
+void PressureDoor::stopChangingPressure() {
+	Neighborhood *owner;
+
+	switch (GameState.getNoradSubRoomPressure()) {
+	case 11:
+		_typeMovie.setSegment(kMaxPressureLoopStart * _typeScale, kMaxPressureLoopStop * _typeScale);
+		_typeMovie.setFlags(kLoopTimeBase);
+		_typeMovie.show();
+		_typeMovie.start();
+		break;
+	case 10:
+		_typeMovie.setSegment(kCautionLoopStart * _typeScale, kCautionLoopStop * _typeScale);
+		_typeMovie.setFlags(kLoopTimeBase);
+		_typeMovie.show();
+		_typeMovie.start();
+		break;
+	case kNormalSubRoomPressure:
+		owner = getOwner();
+		_typeMovie.setSegment(kOpeningDoorLoopStart * _typeScale, kOpeningDoorLoopStop * _typeScale);
+		_typeMovie.setFlags(kLoopTimeBase);
+		_typeMovie.show();
+		_gameState = kPlayingDoneMessage;
+		owner->requestDelay(2, 1, kFilterNoInput, kDelayCompletedFlag);
+		_typeMovie.start();
+		break;
+	default:
+		_typeMovie.hide();
+		break;
+	}
+}
+
+bool PressureDoor::canSolve() {
+	if (_playingAgainstRobot)
+		return GameState.getNoradSubRoomPressure() < 11;
+
+	return GameState.getNoradSubRoomPressure() != kNormalSubRoomPressure;
+}
+
+void PressureDoor::doSolve() {	
+	if (_playingAgainstRobot) {
+		GameState.setNoradSubRoomPressure(11);
+		_levelsMovie.setTime((11 + kPressureBase) * _levelsScale);
+		_typeMovie.setSegment(kMaxPressureLoopStart * _typeScale, kMaxPressureLoopStop * _typeScale);
+		_typeMovie.setFlags(kLoopTimeBase);
+		_typeMovie.show();
+		_typeMovie.start();
+		g_AIArea->checkMiddleArea();
+	} else {
+		GameState.setNoradSubRoomPressure(kNormalSubRoomPressure);
+		_levelsMovie.setTime((kNormalSubRoomPressure + kPressureBase) * _levelsScale);
+		_typeMovie.setSegment(kOpeningDoorLoopStart * _typeScale, kOpeningDoorLoopStop * _typeScale);
+		_typeMovie.setFlags(kLoopTimeBase);
+		_typeMovie.show();
+		Neighborhood *owner = getOwner();
+		owner->requestDelay(2, 1, kFilterNoInput, kDelayCompletedFlag);
+		_gameState = kPlayingDoneMessage;
+		_typeMovie.start();
+		g_AIArea->checkMiddleArea();
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.h b/engines/pegasus/neighborhood/norad/pressuredoor.h
new file mode 100755
index 0000000..94868bd
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.h
@@ -0,0 +1,93 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_PRESSUREDOOR_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_PRESSUREDOOR_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+#include "pegasus/neighborhood/norad/pressuretracker.h"
+
+namespace Pegasus {
+
+const short kNormalSubRoomPressure = 2;
+
+class PressureDoor : public GameInteraction, public NotificationReceiver {
+public:
+	PressureDoor(Neighborhood *, bool isUpperDoor, const tHotSpotID, const tHotSpotID,
+			const tHotSpotID, TimeValue pressureSoundIn, TimeValue pressureSoundOut,
+			TimeValue equalizeSoundIn, TimeValue equalizeSoundOut);
+	virtual ~PressureDoor() {}
+
+	void incrementPressure(const tHotSpotID);
+	void stopChangingPressure();
+
+	void playAgainstRobot();
+
+	bool canSolve();
+	void doSolve();
+
+protected:
+	virtual void openInteraction();
+	virtual void initInteraction();
+	virtual void closeInteraction();
+
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+
+	Movie _levelsMovie;
+	TimeScale _levelsScale;
+	Movie _typeMovie;
+	TimeScale _typeScale;
+	Sprite _upButton;
+	Sprite _downButton;
+	Notification _pressureNotification;
+	NotificationCallBack _pressureCallBack;
+	Notification *_neighborhoodNotification;
+	int _gameState;
+	tHotSpotID _upHotspotID;
+	tHotSpotID _downHotspotID;
+	tHotSpotID _outHotspotID;
+	PressureTracker _doorTracker;
+	TimeValue _pressureSoundIn;
+	TimeValue _pressureSoundOut;
+	TimeValue _equalizeSoundIn;
+	TimeValue _equalizeSoundOut;
+	bool _isUpperDoor;
+	
+	bool _playingAgainstRobot, _typePunched;
+	int _robotState, _punchCount;
+	TimeBase _utilityTimer;
+	Notification _utilityNotification;
+	NotificationCallBack _utilityCallBack;
+	TimeValue _punchInTime;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.cpp b/engines/pegasus/neighborhood/norad/pressuretracker.cpp
new file mode 100755
index 0000000..60521a4
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/pressuretracker.cpp
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/hotspot.h"
+#include "pegasus/neighborhood/norad/pressuredoor.h"
+#include "pegasus/neighborhood/norad/pressuretracker.h"
+
+namespace Pegasus {
+
+PressureTracker::PressureTracker(PressureDoor *pressureDoor) {
+	_pressureDoor = pressureDoor;
+	_trackSpot = 0;
+	_trackTime = 0;
+}
+
+void PressureTracker::setTrackParameters(const Hotspot *trackSpot, Sprite *trackButton) {
+	_trackSpot = trackSpot;
+	_trackButton = trackButton;
+	_trackTime = 0;
+}
+
+void PressureTracker::activateHotspots() {
+	Tracker::activateHotspots();
+
+	if (_trackSpot)
+		g_allHotspots.activateOneHotspot(_trackSpot->getObjectID());
+}
+
+// For click-hold dragging.
+bool PressureTracker::stopTrackingInput(const Input &input) {
+	return !JMPPPInput::isPressingInput(input);
+}
+
+void PressureTracker::continueTracking(const Input &input) {
+	Common::Point where;
+	input.getInputLocation(where);
+
+	if (g_allHotspots.findHotspot(where) == _trackSpot) {
+		trackPressure();
+		_trackButton->setCurrentFrameIndex(1);
+	} else {
+		_trackButton->setCurrentFrameIndex(0);
+	}
+}
+
+void PressureTracker::startTracking(const Input &input) {
+	Tracker::startTracking(input);
+	trackPressure();
+}
+
+void PressureTracker::stopTracking(const Input &input) {
+	_trackButton->setCurrentFrameIndex(0);
+	_pressureDoor->stopChangingPressure();
+	Tracker::stopTracking(input);
+}
+
+void PressureTracker::trackPressure() {
+	if (g_system->getMillis() - _trackTime > kPressureDoorTrackInterval * 1000 / 60) {
+		_pressureDoor->incrementPressure(_trackSpot->getObjectID());
+		_trackTime = g_system->getMillis();
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.h b/engines/pegasus/neighborhood/norad/pressuretracker.h
new file mode 100755
index 0000000..39ce1c1
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/pressuretracker.h
@@ -0,0 +1,69 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_PRESSURETRACKER_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_PRESSURETRACKER_H
+
+#include "pegasus/input.h"
+
+namespace Pegasus {
+
+// This class assumes that the globe movie is built at 15 frames per second with a
+// time scale of 600, yielding 40 time unit per frame.
+
+typedef enum {
+	kTrackPressureUp,
+	kTrackPressureDown
+} tPressureTrackDirection;
+
+const int kPressureDoorTrackInterval = 45;
+
+class PressureDoor;
+class Sprite;
+
+class PressureTracker : public Tracker {
+public:
+	PressureTracker(PressureDoor *);
+	virtual ~PressureTracker() {}
+	
+	void setTrackParameters(const Hotspot *, Sprite *);
+	void continueTracking(const Input &);
+	void startTracking(const Input &);
+	void stopTracking(const Input &);
+	void activateHotspots();
+	bool stopTrackingInput(const Input &);
+
+protected:
+	void trackPressure();
+
+	PressureDoor *_pressureDoor;
+	const Hotspot *_trackSpot;
+	Sprite *_trackButton;
+	long _trackTime;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
new file mode 100755
index 0000000..7a01d32
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -0,0 +1,1174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/subcontrolroom.h"
+
+namespace Pegasus {
+
+// Right Monitor times
+
+const TimeValue kAlphaClawSplashStart = 0;
+const TimeValue kAlphaClawSplashStop = 4000;
+
+const TimeValue kDeltaClawSplashStart = 4000;
+const TimeValue kDeltaClawSplashStop = 8000;
+
+const TimeValue kClawAtATime = 8000;
+const TimeValue kClawAtAPinchedTime = 8600;
+const TimeValue kClawAtATurnedTime = 9200;
+const TimeValue kClawAtAWithRobotPinchedTime = 9800;
+
+const TimeValue kClawAtBTime = 10400;
+const TimeValue kClawAtBPinchedTime = 11000;
+const TimeValue kClawAtBTurnedTime = 11600;
+const TimeValue kClawAtBWithRobotTime = 12200;
+const TimeValue kClawAtBWithRobotPinchedTime = 12800;
+
+const TimeValue kClawAtCTime = 13400;
+const TimeValue kClawAtCPinchedTime = 14000;
+const TimeValue kClawAtCTurnedTime = 14600;
+
+const TimeValue kClawAtDTime = 15200;
+const TimeValue kClawAtDPinchedTime = 15800;
+const TimeValue kClawAtDTurnedTime = 16400;
+
+const TimeValue kAToBStart = 17000;
+const TimeValue kAToBStop = 18680;
+const TimeValue kAPinchStart = 18680;
+const TimeValue kAPinchStop = 20200;
+const TimeValue kACCWStart = 20200;
+const TimeValue kACCWStop = 21600;
+const TimeValue kACWStart = 21600;
+const TimeValue kACWStop = 23000;
+
+const TimeValue kBToAStart = 23000;
+const TimeValue kBToAStop = 24680;
+const TimeValue kBToCStart = 24680;
+const TimeValue kBToCStop = 26520;
+const TimeValue kBToDStart = 26520;
+const TimeValue kBToDStop = 28320;
+const TimeValue kBPinchStart = 28320;
+const TimeValue kBPinchStop = 29680;
+const TimeValue kBCCWStart = 29680;
+const TimeValue kBCCWStop = 31200;
+const TimeValue kBCWStart = 31200;
+const TimeValue kBCWStop = 32720;
+
+const TimeValue kCToBStart = 32720;
+const TimeValue kCToBStop = 34560;
+const TimeValue kCPinchStart = 34560;
+const TimeValue kCPinchStop = 36400;
+const TimeValue kCCCWStart = 36400;
+const TimeValue kCCCWStop = 37840;
+const TimeValue kCCWStart = 37840;
+const TimeValue kCCWStop = 39280;
+
+const TimeValue kDToBStart = 39280;
+const TimeValue kDToBStop = 41080;
+const TimeValue kDPinchStart = 41080;
+const TimeValue kDPinchStop = 42600;
+const TimeValue kDCCWStart = 42600;
+const TimeValue kDCCWStop = 44000;
+const TimeValue kDCWStart = 44000;
+const TimeValue kDCWStop = 45400;
+
+const TimeValue kRobotApproachStart = 45400;
+const TimeValue kRobotApproachStop = 56800;
+
+const TimeValue kCToBWithRobotStart = 56800;
+const TimeValue kCToBWithRobotStop = 58600;
+
+const TimeValue kBPinchWithRobotStart = 58600;
+const TimeValue kBPinchWithRobotStop = 60400;
+const TimeValue kBToAWithRobotStart = 60400;
+const TimeValue kBToAWithRobotStop = 62240;
+
+// As usual, times here are in seconds.
+
+// Left monitor times.
+
+const TimeValue kAlphaSplashStart = 0;
+const TimeValue kAlphaSplashStop = 2;
+
+const TimeValue kMainMenuTime = 2;
+const TimeValue kLaunchPrepRolloverTime = 3;
+const TimeValue kLaunchPrepHighlightStart = 4;
+const TimeValue kLaunchPrepHighlightStop = 5;
+const TimeValue kClawControlRolloverTime = 5;
+const TimeValue kClawControlHighlightStart = 6;
+const TimeValue kClawControlHighlightStop = 7;
+
+const TimeValue kAlphaLaunchPrepStart = 7;
+const TimeValue kAlphaLaunchPrepStop = 17;
+
+const TimeValue kClawMenuStart = 17;
+const TimeValue kClawMenuStop = 18;
+
+const TimeValue kClawMenuTime = 18;
+
+const TimeValue kDeltaSplashStart = 19;
+const TimeValue kDeltaSplashStop = 21;
+
+const TimeValue kDeltaLaunchPrepStart = 21;
+const TimeValue kDeltaLaunchPrepStop = 30;
+
+// Right monitor times.
+
+const tNotificationFlags kAlphaSplashFinished = 1;
+const tNotificationFlags kAlphaPrepFinished = kAlphaSplashFinished << 1;
+const tNotificationFlags kPrepHighlightFinished = kAlphaPrepFinished << 1;
+const tNotificationFlags kClawHighlightFinished = kPrepHighlightFinished << 1;
+const tNotificationFlags kClawMenuFinished = kClawHighlightFinished << 1;
+const tNotificationFlags kDeltaSplashFinished = kClawMenuFinished << 1;
+const tNotificationFlags kDeltaPrepFinished = kDeltaSplashFinished << 1;
+
+const tNotificationFlags kSubControlNotificationFlags = kAlphaSplashFinished |
+														kAlphaPrepFinished |
+														kPrepHighlightFinished |
+														kClawHighlightFinished |
+														kClawMenuFinished |
+														kDeltaSplashFinished |
+														kDeltaPrepFinished;
+
+const tNotificationFlags kOneSecondOfMoveFinished = 1;
+
+const tNotificationFlags kGreenBallNotificationFlags = kOneSecondOfMoveFinished;
+
+enum {
+	kButtonDimFrame,
+	kButtonActiveFrame,
+	kButtonHighlightedFrame
+};
+
+enum {
+	kAlphaSplash,
+	kAlphaMainMenu,
+	kDeltaSplash,
+	kDeltaMainMenu,
+	kClawMenu,
+	kPlayingHighlight,
+	kPuttingClawAway
+};
+
+// The owning neighborhood must provide an array of longs which hold the various
+// extra IDs for moving the claw around. In addition, the owner must tell the sub
+// control room interaction what position the claw starts out in (which is also the
+// position the claw must be in before leaving).
+
+// Standard array indices:
+enum {
+	kClawFromAToBIndex,
+	kClawALoopIndex,
+	kClawAPinchIndex,
+	kClawACounterclockwiseIndex,
+	kClawAClockwiseIndex,
+	kClawFromBToAIndex,
+	kClawFromBToCIndex,
+	kClawFromBToDIndex,
+	kClawBLoopIndex,
+	kClawBPinchIndex,
+	kClawBCounterclockwiseIndex,
+	kClawBClockwiseIndex,
+	kClawFromCToBIndex,
+	kClawCLoopIndex,
+	kClawCPinchIndex,
+	kClawCCounterclockwiseIndex,
+	kClawCClockwiseIndex,
+	kClawFromDToBIndex,
+	kClawDLoopIndex,
+	kClawDPinchIndex,
+	kClawDCounterclockwiseIndex,
+	kClawDClockwiseIndex
+};
+
+// Action indices for s_clawStateTable:
+// Can also be used as indices into _buttons (except for kNoActionIndex and kLoopActionIndex).
+enum {
+	kNoActionIndex = -1,
+	kPinchActionIndex = 0,
+	kMoveDownActionIndex,
+	kMoveRightActionIndex,
+	kMoveLeftActionIndex,
+	kMoveUpActionIndex,
+	kCCWActionIndex,
+	kCWActionIndex,
+	kLoopActionIndex
+};
+
+/*
+	_currentAction and _nextAction:
+	
+	At any time, _currentAction contains an action index (defined above). The current
+	action index is what the claw is doing right now. If the player presses a button
+	before the current action completes, _nextAction saves the new action and input
+	is disabled. This has the effect of implementing a queue of commands for the claw
+	that can save at most one extra command.
+	
+	The general strategy for using _currentAction and _nextAction are:
+	--	If the player presses a claw button and _currentAction is kNoActionIndex,
+		do the command immediately and set _currentAction accordingly.
+	--	If the player presses a claw button and _currentAction is not kNoActionIndex,
+		save the appropriate action index in _nextAction.
+	--	When a command animation completes, set _nextAction to kNoActionIndex, then
+		check if _nextAction has a command waiting in it. If so, play the appriate
+		animation, copy _nextAction into _currentAction and set _nextAction to
+		kNoActionIndex.
+	--	If the player tries to get up, disable input (including all claw buttons) until
+		the player rises. Then, if the claw is in its original position, play the
+		animation of the player rising.
+	--	If the claw needs to be put back, play the first move required to put the
+		claw back by setting _currentAction and playing the appropriate animation.
+		Leave _nextAction alone. When the animation, completes, check to see if the
+		claw is in its original position or not. If so, complete the player rising
+		sequence by playing the rising animation. If not, repeat this whole step.
+	
+	Using this general strategy allows the use of a single function,
+	DispatchClawAction, which can both cause the claw to perform a command and saving
+	the next command in _nextAction.
+*/
+
+// Array indexed by [claw position] [action]
+// array yields an index into the neighborhood's extra id table for claw animation or -1.
+static const int s_clawStateTable[4][8] = {
+	{
+		kClawAPinchIndex,
+		kNoActionIndex,
+		kNoActionIndex,
+		kClawFromAToBIndex,
+		kNoActionIndex,
+		kClawACounterclockwiseIndex,
+		kClawAClockwiseIndex,
+		kClawALoopIndex
+	},
+	{
+		kClawBPinchIndex,
+		kNoActionIndex,
+		kClawFromBToAIndex,
+		kClawFromBToDIndex,
+		kClawFromBToCIndex,
+		kClawBCounterclockwiseIndex,
+		kClawBClockwiseIndex,
+		kClawBLoopIndex
+	},
+	{
+		kClawCPinchIndex,
+		kClawFromCToBIndex,
+		kNoActionIndex,
+		kNoActionIndex,
+		kNoActionIndex,
+		kClawCCounterclockwiseIndex,
+		kClawCClockwiseIndex,
+		kClawCLoopIndex
+	},
+	{
+		kClawDPinchIndex,
+		kNoActionIndex,
+		kClawFromDToBIndex,
+		kNoActionIndex,
+		kNoActionIndex,
+		kClawDCounterclockwiseIndex,
+		kClawDClockwiseIndex,
+		kClawDLoopIndex
+	}
+};
+
+// Move directions for s_clawMovieTable:
+enum {
+	kMoveClawDown,
+	kMoveClawRight,
+	kMoveClawLeft,
+	kMoveClawUp
+};
+
+const int kClawNowhere = -1;
+
+// Array indexed by [claw position] [move direction]
+// array yields new claw position or -1.
+static const int s_clawMovieTable[4][4] = {
+	{
+		kClawNowhere,
+		kClawNowhere,
+		kClawAtB,
+		kClawNowhere
+	},
+	{
+		kClawNowhere,
+		kClawAtA,
+		kClawAtD,
+		kClawAtC
+	},
+	{
+		kClawAtB,
+		kClawNowhere,
+		kClawNowhere,
+		kClawNowhere
+	},
+	{
+		kClawNowhere,
+		kClawAtB,
+		kClawNowhere,
+		kClawNowhere
+	}
+};
+
+// Indexed by claw action index, claw position, plus 0 for start, 1 for stop.
+// (Never indexed with kLoopActionIndex.)
+static const TimeValue s_clawMonitorTable[7][4][2] = {
+	{
+		{ kAPinchStart, kAPinchStop },
+		{ kBPinchStart, kBPinchStop },
+		{ kCPinchStart, kCPinchStop },
+		{ kDPinchStart, kDPinchStop }
+	},
+	{
+		{ 0xffffffff, 0xffffffff },
+		{ 0xffffffff, 0xffffffff },
+		{ kCToBStart, kCToBStop },
+		{ 0xffffffff, 0xffffffff }
+	},
+	{
+		{ 0xffffffff, 0xffffffff },
+		{ kBToAStart, kBToAStop },
+		{ 0xffffffff, 0xffffffff },
+		{ kDToBStart, kDToBStop }
+	},
+	{
+		{ kAToBStart, kAToBStop },
+		{ kBToDStart, kBToDStop },
+		{ 0xffffffff, 0xffffffff },
+		{ 0xffffffff, 0xffffffff }
+	},
+	{
+		{ 0xffffffff, 0xffffffff },
+		{ kBToCStart, kBToCStop },
+		{ 0xffffffff, 0xffffffff },
+		{ 0xffffffff, 0xffffffff }
+	},
+	{
+		{ kACCWStart, kACCWStop },
+		{ kBCCWStart, kBCCWStop },
+		{ kCCCWStart, kCCCWStop },
+		{ kDCCWStart, kDCCWStop }
+	},
+	{
+		{ kACWStart, kACWStop },
+		{ kBCWStart, kBCWStop },
+		{ kCCWStart, kCCWStop },
+		{ kDCWStart, kDCWStop }
+	}
+};
+
+// Frame indices for the green ball sprite.
+enum {
+	kGreenBallAtA,
+	kGreenBallAtAWithClaw,
+	kGreenBallAtAWithClawAndRobot,
+	kGreenBallAtB,
+	kGreenBallAtBWithClaw,
+	kGreenBallAtBWithClawAndRobot,
+	kGreenBallAtCArmAtA,
+	kGreenBallAtCArmAtB,
+	kGreenBallAtCArmAtD,
+	kGreenBallAtCWithClaw,
+	kGreenBallAtD,
+	kGreenBallAtDWithClaw,
+	kNumClawGreenBalls
+};
+
+// State constants for _robotState.
+enum {
+	kNoRobot,
+	kRobotApproaching,
+	kPunchingOnce,
+	kPunchingTwice,
+	kPunchingThrice,
+	kCarriedToDoor,
+	kPlayerWon,
+	kRobotWon
+};
+
+//	Sub Control Room button PICTs:
+
+const tResIDType kSubControlButtonBaseID = 500;
+const tResIDType kClawMonitorGreenBallBaseID = 600;
+
+// Constructor
+SubControlRoom::SubControlRoom(Neighborhood *handler) : GameInteraction(kNoradSubControlRoomInteractionID, handler),
+		_subControlMovie(kSubControlMonitorID), _subControlNotification(kSubControlNotificationID, (PegasusEngine *)g_engine),
+		_clawMonitorMovie(kClawMonitorID), _pinchButton(kSubControlPinchID), _downButton(kSubControlDownID),
+		_rightButton(kSubControlRightID), _leftButton(kSubControlLeftID), _upButton(kSubControlUpID),
+		_ccwButton(kSubControlCCWID), _cwButton(kSubControlCWID), _greenBall(kClawMonitorGreenBallID),
+		_greenBallNotification(kNoradGreenBallNotificationID, (PegasusEngine *)g_engine) {
+	_neighborhoodNotification = handler->getNeighborhoodNotification();
+	_playingAgainstRobot = false;
+	_robotState = kNoRobot;
+}
+
+void SubControlRoom::playAgainstRobot() {
+	_playingAgainstRobot = true;
+}
+
+void SubControlRoom::openInteraction() {	
+	_currentAction = kNoActionIndex;
+	_nextAction = kNoActionIndex;
+
+	Norad *owner = (Norad *)getOwner();
+	owner->getClawInfo(_outSpotID, _prepSpotID, _clawControlSpotID, _clawButtonSpotIDs[0],
+			_clawButtonSpotIDs[1], _clawButtonSpotIDs[2], _clawButtonSpotIDs[3],
+			_clawButtonSpotIDs[4], _clawButtonSpotIDs[5], _clawButtonSpotIDs[6],
+			_clawStartPosition, _clawExtraIDs);
+
+	_clawPosition = _clawStartPosition;
+	_clawNextPosition = _clawPosition;
+	_subControlMovie.initFromMovieFile("Images/Norad Alpha/N22 Left Monitor Movie");
+	_subControlMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
+	_subControlMovie.moveElementTo(kNoradSubControlLeft, kNoradSubControlTop);
+	_subControlScale = _subControlMovie.getScale();
+	_subControlMovie.setDisplayOrder(kSubControlOrder);
+	_subControlMovie.startDisplaying();
+	_subControlCallBack.setNotification(&_subControlNotification);
+	_subControlCallBack.initCallBack(&_subControlMovie, kCallBackAtExtremes);
+
+	_clawMonitorMovie.initFromMovieFile("Images/Norad Alpha/N22:N60 Right Monitor");
+	_clawMonitorMovie.moveElementTo(kNoradClawMonitorLeft, kNoradClawMonitorTop);
+	_clawMonitorMovie.setDisplayOrder(kClawMonitorOrder);
+	_clawMonitorMovie.startDisplaying();
+	_clawMonitorCallBack.setNotification(&_subControlNotification);
+	_clawMonitorCallBack.initCallBack(&_clawMonitorMovie, kCallBackAtExtremes);
+
+	_subControlNotification.notifyMe(this, kSubControlNotificationFlags, kSubControlNotificationFlags);
+
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+
+	_buttons[0] = &_pinchButton;
+	_buttons[1] = &_downButton;
+	_buttons[2] = &_rightButton;
+	_buttons[3] = &_leftButton;
+	_buttons[4] = &_upButton;
+	_buttons[5] = &_ccwButton;
+	_buttons[6] = &_cwButton;
+
+	_pinchButton.setDisplayOrder(kSubControlPinchOrder);
+	_downButton.setDisplayOrder(kSubControlDownOrder);
+	_rightButton.setDisplayOrder(kSubControlRightOrder);
+	_leftButton.setDisplayOrder(kSubControlLeftOrder);
+	_upButton.setDisplayOrder(kSubControlUpOrder);
+	_ccwButton.setDisplayOrder(kSubControlCCWOrder);
+	_cwButton.setDisplayOrder(kSubControlCWOrder);
+
+	for (int i = 0; i < kNumClawButtons; i++) {
+		SpriteFrame *frame = new SpriteFrame();
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kSubControlButtonBaseID + i * 3, true);
+		_buttons[i]->addFrame(frame, 0, 0);
+
+		frame = new SpriteFrame();
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kSubControlButtonBaseID + i * 3 + 1, true);
+		_buttons[i]->addFrame(frame, 0, 0);
+
+		frame = new SpriteFrame();
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kSubControlButtonBaseID + i * 3 + 2, true);
+		_buttons[i]->addFrame(frame, 0, 0);
+
+		_buttons[i]->setCurrentFrameIndex(0);
+		_buttons[i]->startDisplaying();
+	}
+
+	_pinchButton.moveElementTo(kNoradSubControlPinchLeft, kNoradSubControlPinchTop);
+	_downButton.moveElementTo(kNoradSubControlDownLeft, kNoradSubControlDownTop);
+	_rightButton.moveElementTo(kNoradSubControlRightLeft, kNoradSubControlRightTop);
+	_leftButton.moveElementTo(kNoradSubControlLeftLeft, kNoradSubControlLeftTop);
+	_upButton.moveElementTo(kNoradSubControlUpLeft, kNoradSubControlUpTop);
+	_ccwButton.moveElementTo(kNoradSubControlCCWLeft, kNoradSubControlCCWTop);
+	_cwButton.moveElementTo(kNoradSubControlCWLeft, kNoradSubControlCWTop);
+
+	_greenBall.setDisplayOrder(kClawMonitorGreenBallOrder);
+
+	for (int i = 0; i < kNumClawGreenBalls; i++) {
+		SpriteFrame *frame = new SpriteFrame();
+		frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kClawMonitorGreenBallBaseID + i);
+		_greenBall.addFrame(frame, 0, 0);
+	}
+
+	_greenBall.setCurrentFrameIndex(0);
+	_greenBall.startDisplaying();
+
+	_greenBallTimer.setScale(owner->getNavMovie()->getScale());
+	_greenBallCallBack.setNotification(&_greenBallNotification);
+	_greenBallCallBack.initCallBack(&_greenBallTimer, kCallBackAtExtremes);
+	_greenBallCallBack.setCallBackFlag(kOneSecondOfMoveFinished);
+	_greenBallNotification.notifyMe(this, kGreenBallNotificationFlags, kGreenBallNotificationFlags);
+
+	_subControlMovie.show();
+	_clawMonitorMovie.show();
+}									
+
+void SubControlRoom::initInteraction() {
+	if (GameState.getNoradSubPrepState() == kSubDamaged) {
+		playControlMonitorSection(kDeltaSplashStart * _subControlScale, kDeltaSplashStop * _subControlScale,
+				0, kDeltaSplash, false);
+		playClawMonitorSection(kDeltaClawSplashStart, kDeltaClawSplashStop, kDeltaSplashFinished, _gameState, false);
+	} else {
+		playControlMonitorSection(kAlphaSplashStart * _subControlScale, kAlphaSplashStop * _subControlScale,
+				0, kAlphaSplash, false);
+		playClawMonitorSection(kAlphaClawSplashStart, kAlphaClawSplashStop, kAlphaSplashFinished, _gameState, false);
+	}
+
+	// TODO: MoviesTask call. Needed?
+
+	GameState.setScoringPlayedWithClaw(true);
+}									
+
+void SubControlRoom::closeInteraction() {
+	_subControlNotification.cancelNotification(this);
+	_subControlCallBack.releaseCallBack();
+	_greenBallNotification.cancelNotification(this);
+	_greenBallCallBack.releaseCallBack();
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void SubControlRoom::setSoundFXLevel(const uint16 fxLevel) {
+	_subControlMovie.setVolume(fxLevel);
+}
+
+void SubControlRoom::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+	Norad *owner = (Norad *)getOwner();
+
+	if (notification == &_subControlNotification) {
+		switch (flags) {
+		case kAlphaSplashFinished:
+			setControlMonitorToTime(kMainMenuTime * _subControlScale, kAlphaMainMenu, true);
+			break;
+		case kPrepHighlightFinished:
+			if (GameState.getNoradSubPrepState() == kSubDamaged)
+				playControlMonitorSection(kDeltaLaunchPrepStart * _subControlScale,
+						kDeltaLaunchPrepStop * _subControlScale, kDeltaPrepFinished, _gameState, false);
+			else
+				playControlMonitorSection(kAlphaLaunchPrepStart * _subControlScale,
+						kAlphaLaunchPrepStop * _subControlScale, kAlphaPrepFinished, _gameState, false);
+			break;
+		case kAlphaPrepFinished:
+			GameState.setNoradSubPrepState(kSubPrepped);
+			GameState.setScoringPreppedSub(true);
+			setControlMonitorToTime(kMainMenuTime * _subControlScale, kAlphaMainMenu, true);
+			break;
+		case kClawHighlightFinished:
+			playControlMonitorSection(kClawMenuStart * _subControlScale, kClawMenuStop * _subControlScale,
+					kClawMenuFinished, _gameState, false);
+			break;
+		case kClawMenuFinished:
+			owner->playClawMonitorIntro();
+			showButtons();
+			setControlMonitorToTime(kClawMenuTime * _subControlScale, kClawMenu, true);
+
+			if (!_playingAgainstRobot) {
+				updateClawMonitor();
+				owner->loopExtraSequence(_clawExtraIDs[s_clawStateTable[_clawPosition][kLoopActionIndex]]);
+			}
+			break;
+		case kDeltaSplashFinished:
+			setControlMonitorToTime(kMainMenuTime * _subControlScale, kDeltaMainMenu, true);
+
+			if (_playingAgainstRobot) {
+				_robotState = kRobotApproaching;
+				playClawMonitorSection(kRobotApproachStart, kRobotApproachStop, 0, _gameState, true);
+				owner->startExtraSequence(kN60RobotApproaches, kExtraCompletedFlag, kFilterAllInput);
+			}
+			break;
+		case kDeltaPrepFinished:
+			setControlMonitorToTime(kMainMenuTime * _subControlScale, kDeltaMainMenu, true);
+			break;
+		}
+	} else if (notification == &_greenBallNotification) {
+		if (_robotState == kRobotWon) {
+			// We are using the green ball notification to hide stuff when the robot comes through
+			// the glass.
+			hideEverything();
+		} else {
+			// We are now midway through a move, time to update the claw's position and the green
+			// ball.
+			_clawPosition = _clawNextPosition;
+			updateClawMonitor();
+			updateGreenBall();
+		}
+	} else if (notification == _neighborhoodNotification) {
+		_currentAction = kNoActionIndex;
+		if (_playingAgainstRobot) {
+			switch (_robotState) {
+			case kRobotApproaching:
+				if (_gameState == kClawMenu) {
+					_robotState = kPunchingOnce;
+					dispatchClawAction(kNoActionIndex);
+				} else {
+					robotKillsPlayer(kN60FirstMistake, owner);
+				}
+				break;
+			case kPunchingOnce:
+				if (_nextAction == kMoveDownActionIndex) {
+					_robotState = kPunchingTwice;
+					performActionImmediately(_nextAction, _clawExtraIDs[s_clawStateTable[_clawPosition][_nextAction]], owner);
+				} else {
+					robotKillsPlayer(kN60SecondMistake, owner);
+				}
+				break;
+			case kPunchingTwice:
+				if (_nextAction == kPinchActionIndex) {
+					_robotState = kPunchingThrice;
+					performActionImmediately(_nextAction, _clawExtraIDs[s_clawStateTable[_clawPosition][_nextAction]], owner);
+				} else {
+					robotKillsPlayer(kN60ThirdMistake, owner);
+				}
+				break;
+			case kPunchingThrice:
+				if (_nextAction == kMoveRightActionIndex) {
+					_robotState = kCarriedToDoor;
+					performActionImmediately(_nextAction, _clawExtraIDs[s_clawStateTable[_clawPosition][_nextAction]], owner);
+				} else {
+					robotKillsPlayer(kN60FourthMistake, owner);
+				}
+				break;
+			case kCarriedToDoor:
+				hideEverything();
+				_robotState = kPlayerWon;
+				owner->startExtraSequence(kN60PlayerFollowsRobotToDoor, kExtraCompletedFlag, kFilterAllInput);
+				break;
+			case kPlayerWon:
+				// TODO
+				//((NoradDelta *)owner)->playerBeatRobotWithClaw();
+				owner->requestDeleteCurrentInteraction();
+				break;
+			case kRobotWon:
+				g_system->delayMillis(2 * 1000); // 120 ticks
+				((PegasusEngine *)g_engine)->die(kDeathRobotSubControlRoom);
+				break;
+			}
+		} else {
+			if (_gameState == kPuttingClawAway && _nextAction == kNoActionIndex) {
+				if (_clawPosition == _clawStartPosition) {
+					Input scratch;
+					GameInteraction::clickInHotspot(scratch, g_allHotspots.findHotspotByID(_outSpotID));
+				} else {
+					switch (_clawPosition) {
+					case kClawAtA:
+						dispatchClawAction(kMoveLeftActionIndex);
+						break;
+					case kClawAtB:
+						if (_clawStartPosition == kClawAtD)				//	Norad Alpha
+							dispatchClawAction(kMoveLeftActionIndex);
+						else if (_clawStartPosition == kClawAtC)		//	Norad Delta
+							dispatchClawAction(kMoveUpActionIndex);
+						break;
+					case kClawAtC:
+						dispatchClawAction(kMoveDownActionIndex);
+						break;
+					case kClawAtD:
+						dispatchClawAction(kMoveRightActionIndex);
+						break;
+					}
+				}
+			} else {
+				dispatchClawAction(_nextAction);
+			}
+		}
+	}
+}
+
+void SubControlRoom::hideEverything() {
+	hideButtons();
+	_subControlMovie.hide();
+	_clawMonitorMovie.hide();
+	_greenBall.hide();
+}
+
+void SubControlRoom::robotKillsPlayer(const uint32 extraID, Neighborhood *owner) {	
+	_robotState = kRobotWon;
+	owner->startExtraSequence(extraID, kExtraCompletedFlag, kFilterAllInput);
+	_greenBallTimer.stop();
+	_greenBallTimer.setSegment(0, 32 * _greenBallTimer.getScale() / 15);
+	_greenBallTimer.setTime(0);
+	_greenBallCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_greenBallTimer.start();
+}
+
+void SubControlRoom::activateHotspots() {	
+	if (_robotState == kRobotWon || _robotState == kPlayerWon)
+		return;
+
+	GameInteraction::activateHotspots();
+
+	switch (_gameState) {
+	case kAlphaMainMenu:
+	case kDeltaMainMenu:
+		g_allHotspots.activateOneHotspot(_prepSpotID);
+		g_allHotspots.activateOneHotspot(_clawControlSpotID);
+		break;
+	case kClawMenu:
+		//	This could be called during a move, so use _clawNextPosition.
+		if (_playingAgainstRobot) {
+			g_allHotspots.deactivateOneHotspot(_outSpotID);
+			if (_robotState != kRobotApproaching && _nextAction == kNoActionIndex)
+				for (int i = 0; i < kNumClawButtons; i++)
+					if (s_clawStateTable[_clawNextPosition][i] != kNoActionIndex)
+						g_allHotspots.activateOneHotspot(_clawButtonSpotIDs[i]);
+		} else if (_nextAction == kNoActionIndex) {
+			for (int i = 0; i < kNumClawButtons; i++)
+				if (s_clawStateTable[_clawNextPosition][i] != kNoActionIndex)
+					g_allHotspots.activateOneHotspot(_clawButtonSpotIDs[i]);
+		}
+		break;
+	default:
+		break;
+	}
+}
+
+void SubControlRoom::showButtons() {	
+	if (_playingAgainstRobot && _robotState == kRobotApproaching) {
+		for (int i = 0; i < kNumClawButtons; i++) {
+			_buttons[i]->show();
+			_buttons[i]->setCurrentFrameIndex(kButtonDimFrame);
+		}
+	} else if (_nextAction != kNoActionIndex) {
+		for (int i = 0; i < kNumClawButtons; i++) {
+			_buttons[i]->show();
+			if (i == _currentAction || i == _nextAction)
+				_buttons[i]->setCurrentFrameIndex(kButtonHighlightedFrame);
+			else
+				_buttons[i]->setCurrentFrameIndex(kButtonDimFrame);
+		}
+	} else {
+		for (int i = 0; i < kNumClawButtons; i++) {
+			_buttons[i]->show();
+			if (i == _currentAction)
+				_buttons[i]->setCurrentFrameIndex(kButtonHighlightedFrame);
+			else if (s_clawStateTable[_clawNextPosition][i] != kNoActionIndex &&
+					_gameState != kPuttingClawAway) // this could be called during a move, so check _clawNextPosition
+				_buttons[i]->setCurrentFrameIndex(kButtonActiveFrame);
+			else
+				_buttons[i]->setCurrentFrameIndex(kButtonDimFrame);
+		}
+	}
+}
+
+void SubControlRoom::hideButtons() {	
+	for (int i = 0; i < kNumClawButtons; i++)
+		_buttons[i]->hide();
+}
+
+int SubControlRoom::findActionIndex(tHotSpotID id) {	
+	for (int i = 0; i < kNumClawButtons; i++)
+		if (id == _clawButtonSpotIDs[i])
+			return i;
+
+	return kNoActionIndex;
+}
+
+void SubControlRoom::clickInHotspot(const Input &input, const Hotspot *spot) {
+	tHotSpotID clickedID = spot->getObjectID();
+	int actionIndex = findActionIndex(clickedID);
+
+	if (actionIndex != kNoActionIndex) {
+		dispatchClawAction(actionIndex);
+	} else if (clickedID == _prepSpotID) {
+		playControlMonitorSection(kLaunchPrepHighlightStart * _subControlScale,
+				kLaunchPrepHighlightStop * _subControlScale,
+				kPrepHighlightFinished, kPlayingHighlight, false);
+	} else if (clickedID == _clawControlSpotID) {
+		playControlMonitorSection(kClawControlHighlightStart * _subControlScale,
+				kClawControlHighlightStop * _subControlScale,
+				kClawHighlightFinished, kPlayingHighlight, false);
+	} else if (clickedID == _outSpotID) {
+		_gameState = kPuttingClawAway;
+
+		if (_currentAction == kNoActionIndex)
+			if (_clawPosition == _clawStartPosition) {
+				GameInteraction::clickInHotspot(input, spot);
+			} else {
+				switch (_clawPosition) {
+				case kClawAtA:
+					dispatchClawAction(kMoveLeftActionIndex);
+					break;
+				case kClawAtB:
+					if (_clawStartPosition == kClawAtD)				//	Norad Alpha
+						dispatchClawAction(kMoveLeftActionIndex);
+					else if (_clawStartPosition == kClawAtC)		//	Norad Delta
+						dispatchClawAction(kMoveUpActionIndex);
+					break;
+				case kClawAtC:
+					dispatchClawAction(kMoveDownActionIndex);
+					break;
+				case kClawAtD:
+					dispatchClawAction(kMoveRightActionIndex);
+					break;
+				}
+			}
+	} else {
+		GameInteraction::clickInHotspot(input, spot);
+	}
+}
+
+void SubControlRoom::dispatchClawAction(const int newAction) {
+	Neighborhood *owner = getOwner();
+
+	if (newAction == kNoActionIndex) {
+		_currentAction = kNoActionIndex;
+		_nextAction = kNoActionIndex;
+		showButtons();
+		updateGreenBall();
+
+		if (_playingAgainstRobot)
+			owner->startExtraSequence(kN60ArmActivated, kExtraCompletedFlag, kFilterAllInput);
+		else
+			owner->loopExtraSequence(_clawExtraIDs[s_clawStateTable[_clawPosition][kLoopActionIndex]]);
+	} else {
+		if (_currentAction == kNoActionIndex) {
+			if (_playingAgainstRobot) {
+				_nextAction = newAction;
+				showButtons();
+				updateGreenBall();
+			} else {
+				performActionImmediately(newAction, _clawExtraIDs[s_clawStateTable[_clawPosition][newAction]], owner);
+			}
+		} else if (_nextAction == kNoActionIndex) {
+			_nextAction = newAction;
+			showButtons();
+			updateGreenBall();
+		}
+	}
+}
+
+void SubControlRoom::performActionImmediately(const int action, const uint32 extraID, Neighborhood *owner) {
+	_currentAction = action;
+	_nextAction = kNoActionIndex;
+	ExtraTable::Entry entry;
+
+	switch (action) {
+	case kMoveDownActionIndex:
+	case kMoveRightActionIndex:
+	case kMoveLeftActionIndex:
+	case kMoveUpActionIndex:
+		// Set up green ball callback.
+		owner->getExtraEntry(extraID, entry);
+		_greenBallTimer.stop();
+		_greenBallTimer.setSegment(entry.movieStart, entry.movieStart + owner->getNavMovie()->getScale());
+		_greenBallTimer.setTime(entry.movieStart);
+		_greenBallCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		// Start move.
+		_greenBallTimer.start();
+		break;
+	}
+
+	if (_playingAgainstRobot) {
+		switch (_robotState) {
+		case kPunchingTwice:
+			owner->startExtraSequence(kN60ArmToPositionB, kExtraCompletedFlag, kFilterAllInput);
+			break;
+		case kPunchingThrice:
+			owner->startExtraSequence(kN60ArmGrabsRobot, kExtraCompletedFlag, kFilterAllInput);
+			break;
+		case kCarriedToDoor:
+			owner->startExtraSequence(kN60ArmCarriesRobotToPositionA, kExtraCompletedFlag, kFilterAllInput);
+			break;
+		}
+	} else {
+		owner->startExtraSequence(extraID, kExtraCompletedFlag, kFilterAllInput);
+	}
+
+	switch (action) {
+	case kMoveDownActionIndex:
+		_clawNextPosition = s_clawMovieTable[_clawPosition][kMoveClawDown];
+		break;
+	case kMoveRightActionIndex:
+		_clawNextPosition = s_clawMovieTable[_clawPosition][kMoveClawRight];
+		break;
+	case kMoveLeftActionIndex:
+		_clawNextPosition = s_clawMovieTable[_clawPosition][kMoveClawLeft];
+		break;
+	case kMoveUpActionIndex:
+		_clawNextPosition = s_clawMovieTable[_clawPosition][kMoveClawUp];
+		break;
+	case kLoopActionIndex:
+		// Do nothing.
+		break;
+	default:
+		playClawMonitorSection(s_clawMonitorTable[action][_clawPosition][0],
+				s_clawMonitorTable[action][_clawPosition][1], 0, _gameState, true);
+		break;
+	}
+
+	showButtons();
+	updateGreenBall();
+}
+
+void SubControlRoom::setControlMonitorToTime(const TimeValue newTime, const int newState, const bool shouldAllowInput) {
+	_subControlMovie.stop();
+	_subControlMovie.setSegment(0, _subControlMovie.getDuration());
+	_subControlMovie.setTime(newTime);
+	_gameState = newState;
+	allowInput(shouldAllowInput);
+}
+
+void SubControlRoom::playControlMonitorSection(const TimeValue in, const TimeValue out, const tNotificationFlags flags,
+		const int newState, const bool shouldAllowInput) {	
+	_subControlMovie.stop();
+	_subControlMovie.setSegment(in, out);
+	_subControlMovie.setTime(in);
+
+	if (flags != 0) {
+		_subControlCallBack.setCallBackFlag(flags);
+		_subControlCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	_gameState = newState;
+	allowInput(shouldAllowInput);
+	_subControlMovie.start();
+}
+
+void SubControlRoom::updateClawMonitor() {
+	switch (_clawPosition) {
+	case kClawAtA:
+		setClawMonitorToTime(kClawAtATime);
+		break;
+	case kClawAtB:
+		setClawMonitorToTime(kClawAtBTime);
+		break;
+	case kClawAtC:
+		setClawMonitorToTime(kClawAtCTime);
+		break;
+	case kClawAtD:
+		setClawMonitorToTime(kClawAtDTime);
+		break;
+	}
+}
+
+void SubControlRoom::setClawMonitorToTime(const TimeValue newTime) {
+	_clawMonitorMovie.stop();
+	_clawMonitorMovie.setSegment(0, _clawMonitorMovie.getDuration());
+	_clawMonitorMovie.setTime(newTime);
+}
+
+void SubControlRoom::playClawMonitorSection(const TimeValue in, const TimeValue out, const tNotificationFlags flags,
+		const int newState, const bool shouldAllowInput) {	
+	_clawMonitorMovie.stop();
+	_clawMonitorMovie.setSegment(in, out);
+	_clawMonitorMovie.setTime(in);
+
+	if (flags != 0) {
+		_clawMonitorCallBack.setCallBackFlag(flags);
+		_clawMonitorCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	}
+
+	_gameState = newState;
+	allowInput(shouldAllowInput);
+	_clawMonitorMovie.start();
+}
+
+void SubControlRoom::updateGreenBall() {
+	switch (_currentAction) {
+	case kMoveDownActionIndex:
+		switch (_nextAction) {
+		case kMoveRightActionIndex:
+			moveGreenBallToA();
+			break;
+		case kMoveLeftActionIndex:
+			moveGreenBallToD();
+			break;
+		case kMoveUpActionIndex:
+			moveGreenBallToC();
+			break;
+		default:
+			moveGreenBallToB();
+			break;
+		}
+		break;
+	case kMoveRightActionIndex:
+		if (_clawNextPosition == kClawAtA) {
+			switch (_nextAction) {
+			case kMoveLeftActionIndex:
+				moveGreenBallToB();
+				break;
+			default:
+				moveGreenBallToA();
+				break;
+			}
+		} else {
+			switch (_nextAction) {
+			case kMoveRightActionIndex:
+				moveGreenBallToA();
+				break;
+			case kMoveLeftActionIndex:
+				moveGreenBallToD();
+				break;
+			case kMoveUpActionIndex:
+				moveGreenBallToC();
+				break;
+			default:
+				moveGreenBallToB();
+				break;
+			}
+		}
+		break;
+	case kMoveLeftActionIndex:
+		if (_clawNextPosition == kClawAtB) {
+			switch (_nextAction) {
+			case kMoveRightActionIndex:
+				moveGreenBallToA();
+				break;
+			case kMoveLeftActionIndex:
+				moveGreenBallToD();
+				break;
+			case kMoveUpActionIndex:
+				moveGreenBallToC();
+				break;
+			default:
+				moveGreenBallToB();
+				break;
+			}
+		} else {
+			switch (_nextAction) {
+			case kMoveRightActionIndex:
+				moveGreenBallToB();
+				break;
+			default:
+				moveGreenBallToD();
+				break;
+			}
+		}
+		break;
+	case kMoveUpActionIndex:
+		switch (_nextAction) {
+		case kMoveDownActionIndex:
+			moveGreenBallToB();
+			break;
+		default:
+			moveGreenBallToC();
+			break;
+		}
+		break;
+	default:
+		switch (_nextAction) {
+		case kMoveDownActionIndex:
+			moveGreenBallToB();
+			break;
+		case kMoveRightActionIndex:
+			if (_clawPosition == kClawAtB)
+				moveGreenBallToA();
+			else
+				moveGreenBallToB();
+			break;
+		case kMoveLeftActionIndex:
+			if (_clawPosition == kClawAtB)
+				moveGreenBallToD();
+			else
+				moveGreenBallToB();
+			break;
+		case kMoveUpActionIndex:
+			moveGreenBallToC();
+			break;
+		default:
+			_greenBall.hide();
+			break;
+		}
+		break;
+	}
+}
+
+void SubControlRoom::moveGreenBallToA() {
+	if (_clawPosition == kClawAtA) {
+		if (_playingAgainstRobot)
+			_greenBall.setCurrentFrameIndex(kGreenBallAtAWithClawAndRobot);
+		else
+			_greenBall.setCurrentFrameIndex(kGreenBallAtAWithClaw);
+	} else {
+		_greenBall.setCurrentFrameIndex(kGreenBallAtA);
+	}
+
+	_greenBall.moveElementTo(kNoradGreenBallAtALeft, kNoradGreenBallAtATop);
+	_greenBall.show();
+}
+
+void SubControlRoom::moveGreenBallToB() {
+	if (_clawPosition == kClawAtB) {
+		if (_playingAgainstRobot)
+			_greenBall.setCurrentFrameIndex(kGreenBallAtBWithClawAndRobot);
+		else
+			_greenBall.setCurrentFrameIndex(kGreenBallAtBWithClaw);
+	} else {
+		_greenBall.setCurrentFrameIndex(kGreenBallAtB);
+	}
+
+	_greenBall.moveElementTo(kNoradGreenBallAtBLeft, kNoradGreenBallAtBTop);
+	_greenBall.show();
+}
+
+void SubControlRoom::moveGreenBallToC() {
+	switch (_clawPosition) {
+	case kClawAtA:
+		_greenBall.setCurrentFrameIndex(kGreenBallAtCArmAtA);
+		break;
+	case kClawAtB:
+		_greenBall.setCurrentFrameIndex(kGreenBallAtCArmAtB);
+		break;
+	case kClawAtC:
+		_greenBall.setCurrentFrameIndex(kGreenBallAtCWithClaw);
+		break;
+	case kClawAtD:
+		_greenBall.setCurrentFrameIndex(kGreenBallAtCArmAtD);
+		break;
+	}
+
+	_greenBall.moveElementTo(kNoradGreenBallAtCLeft, kNoradGreenBallAtCTop);
+	_greenBall.show();
+}
+
+void SubControlRoom::moveGreenBallToD() {
+	if (_clawPosition == kClawAtD)
+		_greenBall.setCurrentFrameIndex(kGreenBallAtDWithClaw);
+	else
+		_greenBall.setCurrentFrameIndex(kGreenBallAtD);
+
+	_greenBall.moveElementTo(kNoradGreenBallAtDLeft, kNoradGreenBallAtDTop);
+	_greenBall.show();
+}
+
+bool SubControlRoom::canSolve() {
+	return _playingAgainstRobot && _robotState < kCarriedToDoor;
+}
+
+void SubControlRoom::doSolve() {
+	_robotState = kCarriedToDoor;
+	hideEverything();
+	getOwner()->startExtraSequence(kN60ArmGrabsRobot, kExtraCompletedFlag, kFilterAllInput);
+}
+
+tInputBits SubControlRoom::getInputFilter() {
+	if (_playingAgainstRobot)
+		return GameInteraction::getInputFilter() & ~kFilterDownButtonAny;
+
+	return GameInteraction::getInputFilter();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.h b/engines/pegasus/neighborhood/norad/subcontrolroom.h
new file mode 100755
index 0000000..4a6889f
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.h
@@ -0,0 +1,133 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_SUBCONTROLROOM_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_SUBCONTROLROOM_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+const uint32 kClawAtA = 0;
+const uint32 kClawAtB = 1;
+const uint32 kClawAtC = 2;
+const uint32 kClawAtD = 3;
+
+const int kNumClawButtons = 7;
+
+class Norad;
+
+class SubControlRoom : public GameInteraction, public NotificationReceiver {
+public:
+	SubControlRoom(Neighborhood *);
+	virtual ~SubControlRoom() {}
+
+	void playAgainstRobot();
+
+	virtual void setSoundFXLevel(const uint16);
+
+	bool canSolve();
+	void doSolve();
+
+protected:	
+	virtual void openInteraction();
+	virtual void initInteraction();
+	virtual void closeInteraction();
+
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+
+	void robotKillsPlayer(const uint32, Neighborhood *);
+	tInputBits getInputFilter();
+
+	int findActionIndex(tHotSpotID);
+	void dispatchClawAction(const int);
+	void performActionImmediately(const int, const uint32, Neighborhood *);
+
+	void hideEverything();
+	void showButtons();
+	void hideButtons();
+
+	void updateGreenBall();
+	void moveGreenBallToA();
+	void moveGreenBallToB();
+	void moveGreenBallToC();
+	void moveGreenBallToD();
+
+	void setControlMonitorToTime(const TimeValue, const int, const bool);
+	void playControlMonitorSection(const TimeValue, const TimeValue, const tNotificationFlags,
+			const int, const bool);
+	
+	void updateClawMonitor();
+	void setClawMonitorToTime(const TimeValue);
+	void playClawMonitorSection(const TimeValue, const TimeValue, const tNotificationFlags,
+			const int, const bool);
+	
+	Movie _subControlMovie;
+	TimeScale _subControlScale;
+	Notification _subControlNotification;
+	NotificationCallBack _subControlCallBack;
+	Movie _clawMonitorMovie;
+	NotificationCallBack _clawMonitorCallBack;
+	int _gameState;
+	uint32 _clawStartPosition;
+	uint32 _clawPosition;
+	uint32 _clawNextPosition;
+	uint32 *_clawExtraIDs;
+
+	int _currentAction;
+	int _nextAction;
+
+	Sprite *_buttons[kNumClawButtons];
+	Sprite _pinchButton;
+	Sprite _downButton;
+	Sprite _rightButton;
+	Sprite _leftButton;
+	Sprite _upButton;
+	Sprite _ccwButton;
+	Sprite _cwButton;
+
+	Sprite _greenBall;
+	TimeBase _greenBallTimer;
+	Notification _greenBallNotification;
+	NotificationCallBack _greenBallCallBack;
+
+	tHotSpotID _outSpotID;
+	tHotSpotID _prepSpotID;
+	tHotSpotID _clawControlSpotID;
+	tHotSpotID _clawButtonSpotIDs[kNumClawButtons];
+
+	Notification *_neighborhoodNotification;
+
+	bool _playingAgainstRobot;
+	int _robotState;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/subplatform.cpp b/engines/pegasus/neighborhood/norad/subplatform.cpp
new file mode 100755
index 0000000..0d4827b
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/subplatform.cpp
@@ -0,0 +1,205 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/subplatform.h"
+
+namespace Pegasus {
+
+// As usual, times here are in seconds.
+
+const TimeValue kNormalSplashStart = 0;
+const TimeValue kNormalSplashStop = 5;
+
+const TimeValue kPrepSubStart = 5;
+const TimeValue kPrepSubStop = 15;
+
+const TimeValue kPrepIncompleteStart = 15;
+const TimeValue kPrepIncompleteStop = 19;
+
+const TimeValue kDamagedStart = 19;
+const TimeValue kDamagedStop = 28;
+
+const tNotificationFlags kNormalSplashFinished = 1;
+const tNotificationFlags kPrepSubFinished = kNormalSplashFinished << 1;
+const tNotificationFlags kPrepIncompleteFinished = kPrepSubFinished << 1;
+const tNotificationFlags kDamagedFinished = kPrepIncompleteFinished << 1;
+
+const tNotificationFlags kPlatformNotificationFlags = kNormalSplashFinished |
+														kPrepSubFinished |
+														kPrepIncompleteFinished |
+														kDamagedFinished;
+
+const uint16 kSubPreppedBit = (1 << 0);
+const uint16 kWaitingForPlayerBit = (1 << 1);
+
+SubPlatform::SubPlatform(Neighborhood *handler) : GameInteraction(kNoradSubPlatformInteractionID, handler),
+		_platformMovie(kPlatformMonitorID), _platformNotification(kNoradSubPlatformNotificationID, (PegasusEngine *)g_engine) {
+	_neighborhoodNotification = handler->getNeighborhoodNotification();
+}
+
+void SubPlatform::openInteraction() {
+	_stateBits = 0;
+
+	// TODO: These next two lines seem unused?
+	if (GameState.getNoradSubPrepState() == kSubPrepped)
+		_stateBits |= kSubPreppedBit;
+
+	_stateBits |= kWaitingForPlayerBit;
+	_platformMovie.initFromMovieFile("Images/Norad Alpha/Platform Monitor Movie");
+	_platformMovie.setVolume(((PegasusEngine *)g_engine)->getSoundFXLevel());
+	_platformMovie.moveElementTo(kNoradPlatformLeft, kNoradPlatformTop);
+	_platformScale = _platformMovie.getScale();
+	_platformMovie.setDisplayOrder(kPlatformOrder);
+	_platformMovie.startDisplaying();
+	_platformCallBack.setNotification(&_platformNotification);
+	_platformCallBack.initCallBack(&_platformMovie, kCallBackAtExtremes);
+	
+	_platformNotification.notifyMe(this, kPlatformNotificationFlags, kPlatformNotificationFlags);
+}
+
+void SubPlatform::initInteraction() {
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+}
+
+void SubPlatform::closeInteraction() {
+	_platformNotification.cancelNotification(this);
+	_platformCallBack.releaseCallBack();
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void SubPlatform::setSoundFXLevel(const uint16 fxLevel) {
+	_platformMovie.setVolume(fxLevel);
+}
+
+void SubPlatform::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	FaderMoveSpec loop1Spec, loop2Spec;
+	ExtraTable::Entry entry;
+
+	Norad *owner = (Norad *)getOwner();
+
+	if (notification == &_platformNotification) {
+		switch (flags) {
+		case kNormalSplashFinished:
+			_platformMovie.stop();
+			switch (GameState.getNoradSubPrepState()) {
+			case kSubNotPrepped:
+				_platformMovie.setSegment(kPrepIncompleteStart * _platformScale, kPrepIncompleteStop * _platformScale);
+				_platformMovie.setTime(kPrepIncompleteStart * _platformScale);
+				_platformCallBack.setCallBackFlag(kPrepIncompleteFinished);
+				_platformCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+				_platformMovie.start();
+				break;
+			case kSubPrepped:
+				_platformMovie.setSegment(kPrepSubStart * _platformScale, kPrepSubStop * _platformScale);
+				_platformMovie.setTime(kPrepSubStart * _platformScale);
+				_platformCallBack.setCallBackFlag(kPrepSubFinished);
+				_platformCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+				owner->startExtraSequence(kNorad19PrepSub, 0, kFilterNoInput);
+				_platformMovie.start();
+				break;
+			case kSubDamaged:
+				// Shouldn't happen.
+				break;
+			}
+			break;
+		case kPrepSubFinished:
+			_platformMovie.stop();
+			_platformMovie.stopDisplaying();
+
+			owner->getExtraEntry(kNorad19ExitToSub, entry);
+				
+			loop1Spec.makeTwoKnotFaderSpec(kNoradAlphaMovieScale, 0, kNoradWarningVolume,
+					entry.movieEnd - entry.movieStart, 0);
+			loop1Spec.insertFaderKnot(4560, kNoradWarningVolume);
+			loop1Spec.insertFaderKnot(5080, 0);
+				
+			loop2Spec.makeTwoKnotFaderSpec(kNoradAlphaMovieScale, 0, kNoradSuckWindVolume,
+					entry.movieEnd - entry.movieStart, 0);
+			loop1Spec.insertFaderKnot(4560, kNoradSuckWindVolume);
+			loop1Spec.insertFaderKnot(5080, 0);
+
+			owner->startExtraSequence(kNorad19ExitToSub, kExtraCompletedFlag, kFilterNoInput);
+
+			owner->startLoop1Fader(loop1Spec);
+			owner->startLoop2Fader(loop2Spec);
+			break;
+		case kPrepIncompleteFinished:
+			// TODO
+			//((NoradAlpha *)owner)->setSubPrepFailed(true);
+			g_AIArea->checkMiddleArea();
+			// Fall through...
+		case kDamagedFinished:
+			_platformMovie.stop();
+			_platformMovie.hide();
+			_stateBits |= kWaitingForPlayerBit;
+			allowInput(true);
+			break;
+		}
+	} else if (notification == _neighborhoodNotification) {
+		allowInput(true);
+		((PegasusEngine *)g_engine)->jumpToNewEnvironment(kNoradSubChaseID, kNoRoomID, kNoDirection);
+		GameState.setScoringEnteredSub(true);
+	}
+}
+
+void SubPlatform::activateHotspots() {
+	if (_stateBits & kWaitingForPlayerBit)
+		g_allHotspots.activateOneHotspot(kNorad19ActivateMonitorSpotID);
+
+	GameInteraction::activateHotspots();
+}
+
+void SubPlatform::clickInHotspot(const Input &input, const Hotspot *spot) {	
+	if (spot->getObjectID() == kNorad19ActivateMonitorSpotID) {
+		if (GameState.getNoradSubPrepState() == kSubDamaged) {
+			_platformMovie.setSegment(kDamagedStart * _platformScale, kDamagedStop * _platformScale);
+			_platformMovie.setTime(kDamagedStart * _platformScale);
+			_platformCallBack.setCallBackFlag(kDamagedFinished);
+		} else {
+			_platformMovie.setSegment(kNormalSplashStart * _platformScale, kNormalSplashStop * _platformScale);
+			_platformMovie.setTime(kNormalSplashStart * _platformScale);
+			_platformCallBack.setCallBackFlag(kNormalSplashFinished);
+		}
+
+		_platformCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+		_platformMovie.show();
+		_platformMovie.start();
+
+		// TODO: MoviesTask call? I don't think it's needed
+
+		_stateBits &= ~kWaitingForPlayerBit;
+		
+		allowInput(false);
+	} else {
+		GameInteraction::clickInHotspot(input, spot);
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/subplatform.h b/engines/pegasus/neighborhood/norad/subplatform.h
new file mode 100755
index 0000000..ae35cce
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/subplatform.h
@@ -0,0 +1,63 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_SUBPLATFORM_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_SUBPLATFORM_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class SubPlatform : public GameInteraction, public NotificationReceiver {
+public:
+	SubPlatform(Neighborhood *);
+	virtual ~SubPlatform() {}
+
+	virtual void setSoundFXLevel(const uint16);
+
+protected:
+	virtual void openInteraction();
+	virtual void initInteraction();
+	virtual void closeInteraction();
+
+	virtual void activateHotspots();
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	
+	Movie _platformMovie;
+	TimeScale _platformScale;
+	Notification _platformNotification;
+	NotificationCallBack _platformCallBack;
+	Notification *_neighborhoodNotification;
+	uint16 _stateBits;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: f9ecab1953644c79913fb483b1d64c6d9e779481
    https://github.com/scummvm/scummvm/commit/f9ecab1953644c79913fb483b1d64c6d9e779481
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-22T19:29:09-07:00

Commit Message:
PEGASUS: Add Norad Alpha

Not yet completable, but you can at least fill the oxygen mask to go through the Mars Maze now.

Changed paths:
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.h
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.h
    engines/pegasus/constants.h
    engines/pegasus/module.mk
    engines/pegasus/movie.cpp
    engines/pegasus/neighborhood/norad/norad.h
    engines/pegasus/neighborhood/norad/pressuredoor.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.h
    engines/pegasus/neighborhood/norad/subplatform.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/neighborhood/zoom.cpp
    engines/pegasus/neighborhood/zoom.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 8d2c093..cc096dd 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -737,7 +737,6 @@ static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
 static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 // TODO: Remove me
-static const tRoomID kNorad01 = 0;
 static const tRoomID kNorad41 = 0;
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 58c9dc9..c8a67bf 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -65,6 +65,8 @@ MODULE_OBJS = \
 	neighborhood/norad/pressuretracker.o \
 	neighborhood/norad/subcontrolroom.o \
 	neighborhood/norad/subplatform.o \
+	neighborhood/norad/alpha/fillingstation.o \
+	neighborhood/norad/alpha/noradalpha.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 9551248..fe15261 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -140,8 +140,11 @@ void Movie::setTime(const TimeValue time, const TimeScale scale) {
 }
 
 void Movie::setRate(const Common::Rational rate) {
-	if (rate != 1 && rate != 0)
-		error("Cannot set movie rate");
+	if (rate != 1 && rate != 0) {
+		warning("Cannot set movie rate");
+		start();
+		return;
+	}
 
 	TimeBase::setRate(rate);
 }
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
new file mode 100755
index 0000000..a858e75
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
@@ -0,0 +1,445 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/alpha/fillingstation.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
+
+namespace Pegasus {
+
+const tNotificationFlags kFSPowerUpFinishedFlag = 1;
+const tNotificationFlags kFSSplashFinishedFlag = kFSPowerUpFinishedFlag << 1;
+const tNotificationFlags kFSIntakeWarningFinishedFlag = kFSSplashFinishedFlag << 1;
+const tNotificationFlags kFSIntakeHiliteFinishedFlag = kFSIntakeWarningFinishedFlag << 1;
+const tNotificationFlags kFSDispenseHiliteFinishedFlag = kFSIntakeHiliteFinishedFlag << 1;
+const tNotificationFlags kFSArHiliteFinishedFlag = kFSDispenseHiliteFinishedFlag << 1;
+const tNotificationFlags kFSCO2HiliteFinishedFlag = kFSArHiliteFinishedFlag << 1;
+const tNotificationFlags kFSHeHiliteFinishedFlag = kFSCO2HiliteFinishedFlag << 1;
+const tNotificationFlags kFSOHiliteFinishedFlag = kFSHeHiliteFinishedFlag << 1;
+const tNotificationFlags kFSNHiliteFinishedFlag = kFSOHiliteFinishedFlag << 1;
+
+const tNotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
+												kFSSplashFinishedFlag |
+												kFSIntakeWarningFinishedFlag |
+												kFSIntakeHiliteFinishedFlag |
+												kFSDispenseHiliteFinishedFlag |
+												kFSArHiliteFinishedFlag |
+												kFSCO2HiliteFinishedFlag |
+												kFSHeHiliteFinishedFlag |
+												kFSOHiliteFinishedFlag |
+												kFSNHiliteFinishedFlag;
+
+const int16 kNoState = 0;
+const int16 kMainMenu = 1;
+const int16 kWaitingForAttach = 2;
+const int16 kDispenseMenu = 3;
+const int16 kWaitingForDispense = 4;
+
+// Dummy itemIDs
+
+const tItemID kCO2Item = 10000;
+const tItemID kHeItem = 10001;
+
+//	Interactive points.
+
+const TimeValue kFSPowerUpStartStart = 0;
+const TimeValue kFSPowerUpStartStop = 600;
+const TimeValue kFSSplashStart = 600;
+const TimeValue kFSSplashStop = 7800;
+const TimeValue kFSSplashIntakeStart = 7800;
+const TimeValue kFSSplashIntakeStop = 18600;
+
+const TimeValue kFSMainMenu = 18600;
+const TimeValue kFSIntakeHiliteStart = 19200;
+const TimeValue kFSIntakeHiliteStop = 19800;
+const TimeValue kFSDispenseHiliteStart = 19800;
+const TimeValue kFSDispenseHiliteStop = 20400;
+
+const TimeValue kFSDispenseMenu = 20400;
+
+const TimeValue kFSArHiliteStart = 21000;
+const TimeValue kFSArHiliteStop = 21600;
+const TimeValue kFSArAttach = 21600;
+const TimeValue kFSArFilledStart = 22200;
+const TimeValue kFSArFilledStop = 25200;
+const TimeValue kFSArIncompatibleStart = 25200;
+const TimeValue kFSArIncompatibleStop = 30000;
+
+const TimeValue kFSCO2HiliteStart = 30000;
+const TimeValue kFSCO2HiliteStop = 30600;
+const TimeValue kFSCO2Attach = 30600;
+const TimeValue kFSCO2FilledStart = 31200;
+const TimeValue kFSCO2FilledStop = 34200;
+const TimeValue kFSCO2IncompatibleStart = 34200;
+const TimeValue kFSCO2IncompatibleStop = 39000;
+
+const TimeValue kFSHeHiliteStart = 39000;
+const TimeValue kFSHeHiliteStop = 39600;
+const TimeValue kFSHeAttach = 39600;
+const TimeValue kFSHeFilledStart = 40200;
+const TimeValue kFSHeFilledStop = 43200;
+const TimeValue kFSHeIncompatibleStart = 43200;
+const TimeValue kFSHeIncompatibleStop = 48000;
+
+const TimeValue kFSOHiliteStart = 48000;
+const TimeValue kFSOHiliteStop = 48600;
+const TimeValue kFSOAttach = 48600;
+const TimeValue kFSOFilledStart = 49200;
+const TimeValue kFSOFilledStop = 52200;
+const TimeValue kFSOIncompatibleStart = 52200;
+const TimeValue kFSOIncompatibleStop = 57000;
+
+const TimeValue kFSNHiliteStart = 57000;
+const TimeValue kFSNHiliteStop = 57600;
+const TimeValue kFSNAttach = 57600;
+const TimeValue kFSNFilledStart = 58200;
+const TimeValue kFSNFilledStop = 61200;
+const TimeValue kFSNIncompatibleStart = 61200;
+const TimeValue kFSNIncompatibleStop = 66000;
+
+const TimeValue kFSIntakeMenu = 66000;
+const TimeValue kFSIntakeInProgressStart = 66600;
+const TimeValue kFSIntakeInProgressStop = 69600;
+
+NoradAlphaFillingStation::NoradAlphaFillingStation(Neighborhood *owner) : GameInteraction(kNoradFillingStationInteractionID, owner),
+		_rightSideMovie(kN01RightSideID), _rightSideNotification(kNoradFillingStationNotificationID, ((PegasusEngine *)g_engine)) {
+	_state = kNoState;
+}
+
+void NoradAlphaFillingStation::openInteraction() {	
+	_rightSideMovie.initFromMovieFile("Images/Norad Alpha/N01W Right Side");
+	_rightSideMovie.moveElementTo(kNoradAlpha01RightSideLeft, kNoradAlpha01RightSideTop);
+	_rightSideMovie.setDisplayOrder(kN01RightSideOrder);
+	_rightSideMovie.startDisplaying();
+	_rightSideCallBack.setNotification(&_rightSideNotification);
+	_rightSideCallBack.initCallBack(&_rightSideMovie, kCallBackAtExtremes);
+	_rightSideCallBack.setCallBackFlag(kFSPowerUpFinishedFlag);
+	_rightSideNotification.notifyMe(this, kFSNotificationFlags, kFSNotificationFlags);
+	_rightSideCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_rightSideMovie.show();
+	_rightSideMovie.redrawMovieWorld();
+	_rightSideMovie.setSegment(kFSPowerUpStartStart, kFSPowerUpStartStop);
+}
+
+void NoradAlphaFillingStation::initInteraction() {
+	allowInput(false);
+
+	_rightSideMovie.setRate(2);
+}
+
+void NoradAlphaFillingStation::closeInteraction() {
+	_rightSideMovie.stop();
+	_rightSideMovie.stopDisplaying();
+	_rightSideMovie.releaseMovie();
+	_rightSideCallBack.releaseCallBack();
+	((NoradAlpha *)getOwner())->turnOffFillingStation();
+}
+
+void NoradAlphaFillingStation::setStaticState(TimeValue time, int16 state) {
+	_rightSideMovie.stop();
+	_rightSideMovie.setSegment(0, _rightSideMovie.getDuration());
+	_rightSideMovie.setTime(time);
+	_state = state;
+	allowInput(true);
+}
+
+void NoradAlphaFillingStation::setSegmentState(TimeValue start, TimeValue stop, tNotificationFlags flag, int16 state) {	
+	_rightSideMovie.stop();
+	_rightSideMovie.setSegment(start, stop);
+	_rightSideMovie.setTime(start);
+	_rightSideCallBack.setCallBackFlag(flag);
+	_rightSideCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_state = state;
+	allowInput(false);
+	_rightSideMovie.setRate(2);
+}
+
+void NoradAlphaFillingStation::powerUpFinished() {
+	((NoradAlpha *)getOwner())->turnOnFillingStation();
+	setSegmentState(kFSSplashStart, kFSSplashStop, kFSSplashFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::splashFinished() {
+	if (GameState.getNoradGassed())
+		setSegmentState(kFSSplashIntakeStart, kFSSplashIntakeStop, kFSIntakeWarningFinishedFlag, kNoState);
+	else
+		intakeWarningFinished();
+}
+
+void NoradAlphaFillingStation::intakeWarningFinished() {
+	setStaticState(kFSMainMenu, kMainMenu);
+}
+
+void NoradAlphaFillingStation::showIntakeInProgress(uint16 numSeconds) {	
+	if (numSeconds == 0) {
+		setSegmentState(kFSIntakeInProgressStart, kFSIntakeInProgressStop, kFSIntakeWarningFinishedFlag, kNoState);
+		Item *item = ((NoradAlpha *)getOwner())->getFillingItem();
+
+		if (item->getObjectID() == kGasCanister) {
+			GameState.setNoradGassed(true);
+			((NoradAlpha *)getOwner())->loadAmbientLoops();
+			getOwner()->restoreStriding(kNorad03, kEast, kAltNoradAlphaNormal);
+		}
+	} else {
+		setSegmentState(kFSIntakeInProgressStart, kFSIntakeInProgressStart + _rightSideMovie.getScale() * numSeconds,
+				kFSIntakeWarningFinishedFlag, kNoState);
+	}
+}
+
+void NoradAlphaFillingStation::intakeHighlightFinished() {	
+	_rightSideMovie.stop();
+
+	if (GameState.getNoradGassed()) {
+		showIntakeInProgress(2);
+	} else {
+		Item *item = ((NoradAlpha *)getOwner())->getFillingItem();
+		if (item)
+			showIntakeInProgress(0);
+		else
+			setStaticState(kFSIntakeMenu, kWaitingForAttach);
+	}
+}
+
+void NoradAlphaFillingStation::dispenseHighlightFinished() {
+	setStaticState(kFSDispenseMenu, kDispenseMenu);
+}
+
+void NoradAlphaFillingStation::dispenseGas() {	
+	Item *item = ((NoradAlpha *)getOwner())->getFillingItem();
+
+	if (item) {
+		if (item->getObjectID() != _dispenseItemID)
+			switch (_dispenseItemID) {
+			case kArgonCanister:
+				setSegmentState(kFSArIncompatibleStart, kFSArIncompatibleStop,
+						kFSIntakeWarningFinishedFlag, kNoState);
+				break;
+			case kCO2Item:
+				setSegmentState(kFSCO2IncompatibleStart, kFSCO2IncompatibleStop,
+						kFSIntakeWarningFinishedFlag, kNoState);
+				break;
+			case kHeItem:
+				setSegmentState(kFSHeIncompatibleStart, kFSHeIncompatibleStop,
+						kFSIntakeWarningFinishedFlag, kNoState);
+				break;
+			case kAirMask:
+				setSegmentState(kFSOIncompatibleStart, kFSOIncompatibleStop,
+						kFSIntakeWarningFinishedFlag, kNoState);
+				break;
+			case kNitrogenCanister:
+				setSegmentState(kFSNIncompatibleStart, kFSNIncompatibleStop,
+						kFSIntakeWarningFinishedFlag, kNoState);
+				break;
+			}
+		else {
+			if (_dispenseItemID == kArgonCanister) {
+				setSegmentState(kFSArFilledStart, kFSArFilledStop, kFSIntakeWarningFinishedFlag, kNoState);
+				item->setItemState(kArgonFull);
+				GameState.setScoringFilledArgonCanister(true);
+			} else if (_dispenseItemID == kAirMask) {
+				setSegmentState(kFSOFilledStart, kFSOFilledStop, kFSIntakeWarningFinishedFlag, kNoState);
+				((AirMask *)item)->refillAirMask();
+				GameState.setScoringFilledOxygenCanister(true);
+			} else if (_dispenseItemID == kNitrogenCanister) {
+				setSegmentState(kFSNFilledStart, kFSNFilledStop, kFSIntakeWarningFinishedFlag, kNoState);
+				item->setItemState(kNitrogenFull);
+			}
+		}
+	} else {
+		switch (_dispenseItemID) {
+		case kArgonCanister:
+			setStaticState(kFSArAttach, kWaitingForDispense);
+			break;
+		case kCO2Item:
+			setStaticState(kFSCO2Attach, kWaitingForDispense);
+			break;
+		case kHeItem:
+			setStaticState(kFSHeAttach, kWaitingForDispense);
+			break;
+		case kAirMask:
+			setStaticState(kFSOAttach, kWaitingForDispense);
+			break;
+		case kNitrogenCanister:
+			setStaticState(kFSNAttach, kWaitingForDispense);
+			break;
+		}
+	}
+}
+
+void NoradAlphaFillingStation::ArHighlightFinished() {
+	_dispenseItemID = kArgonCanister;
+	dispenseGas();
+}
+
+void NoradAlphaFillingStation::CO2HighlightFinished() {
+	_dispenseItemID = kCO2Item;
+	dispenseGas();
+}
+
+void NoradAlphaFillingStation::HeHighlightFinished() {
+	_dispenseItemID = kHeItem;
+	dispenseGas();
+}
+
+void NoradAlphaFillingStation::OHighlightFinished() {
+	_dispenseItemID = kAirMask;
+	dispenseGas();
+}
+
+void NoradAlphaFillingStation::NHighlightFinished() {
+	_dispenseItemID = kNitrogenCanister;
+	dispenseGas();
+}
+
+void NoradAlphaFillingStation::receiveNotification(Notification *, const tNotificationFlags flags) {
+	switch (flags) {
+	case kFSPowerUpFinishedFlag:
+		powerUpFinished();
+		break;
+	case kFSSplashFinishedFlag:
+		splashFinished();
+		break;
+	case kFSIntakeWarningFinishedFlag:
+		intakeWarningFinished();
+		break;
+	case kFSIntakeHiliteFinishedFlag:
+		intakeHighlightFinished();
+		break;
+	case kFSDispenseHiliteFinishedFlag:
+		dispenseHighlightFinished();
+		break;
+	case kFSArHiliteFinishedFlag:
+		ArHighlightFinished();
+		break;
+	case kFSCO2HiliteFinishedFlag:
+		CO2HighlightFinished();
+		break;
+	case kFSHeHiliteFinishedFlag:
+		HeHighlightFinished();
+		break;
+	case kFSOHiliteFinishedFlag:
+		OHighlightFinished();
+		break;
+	case kFSNHiliteFinishedFlag:
+		NHighlightFinished();
+		break;
+	}
+}
+
+void NoradAlphaFillingStation::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+void NoradAlphaFillingStation::clickInIntake() {
+	setSegmentState(kFSIntakeHiliteStart, kFSIntakeHiliteStop, kFSIntakeHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInDispense() {
+	setSegmentState(kFSDispenseHiliteStart, kFSDispenseHiliteStop, kFSDispenseHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInAr() {
+	setSegmentState(kFSArHiliteStart, kFSArHiliteStop, kFSArHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInCO2() {
+	setSegmentState(kFSCO2HiliteStart, kFSCO2HiliteStop, kFSCO2HiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInHe() {
+	setSegmentState(kFSHeHiliteStart, kFSHeHiliteStop, kFSHeHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInO() {
+	setSegmentState(kFSOHiliteStart, kFSOHiliteStop, kFSOHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInN() {
+	setSegmentState(kFSNHiliteStart, kFSNHiliteStop, kFSNHiliteFinishedFlag, kNoState);
+}
+
+void NoradAlphaFillingStation::clickInHotspot(const Input &input, const Hotspot *spot) {
+	GameInteraction::clickInHotspot(input, spot);
+
+	switch (spot->getObjectID()) {
+	case kNorad01IntakeSpotID:
+		clickInIntake();
+		break;
+	case kNorad01DispenseSpotID:
+		clickInDispense();
+		break;
+	case kNorad01ArSpotID:
+		clickInAr();
+		break;
+	case kNorad01CO2SpotID:
+		clickInCO2();
+		break;
+	case kNorad01HeSpotID:
+		clickInHe();
+		break;
+	case kNorad01OSpotID:
+		clickInO();
+		break;
+	case kNorad01NSpotID:
+		clickInN();
+		break;
+	}
+}
+
+void NoradAlphaFillingStation::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	switch (_state) {
+	case kMainMenu:
+		g_allHotspots.activateOneHotspot(kNorad01IntakeSpotID);
+		g_allHotspots.activateOneHotspot(kNorad01DispenseSpotID);
+		break;
+	case kDispenseMenu:
+		g_allHotspots.activateOneHotspot(kNorad01ArSpotID);
+		g_allHotspots.activateOneHotspot(kNorad01CO2SpotID);
+		g_allHotspots.activateOneHotspot(kNorad01HeSpotID);
+		g_allHotspots.activateOneHotspot(kNorad01OSpotID);
+		g_allHotspots.activateOneHotspot(kNorad01NSpotID);
+		break;
+	}
+}
+
+void NoradAlphaFillingStation::newFillingItem(Item *item) {
+	switch (_state) {
+	case kWaitingForAttach:
+		if (item)
+			showIntakeInProgress(0);
+		break;
+	case kWaitingForDispense:
+		dispenseGas();
+		break;
+	default:
+		break;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.h b/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
new file mode 100755
index 0000000..e3fb1f6
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_FILLINGSTATION_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_FILLINGSTATION_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+class Item;
+
+class NoradAlphaFillingStation : public GameInteraction, public NotificationReceiver {
+public:
+	NoradAlphaFillingStation(Neighborhood *);
+	virtual ~NoradAlphaFillingStation() {}
+
+	virtual void handleInput(const Input &, const Hotspot *);
+
+	virtual void clickInHotspot(const Input &, const Hotspot *);
+	virtual void activateHotspots();
+
+	void newFillingItem(Item *);
+
+protected:
+	void receiveNotification(Notification *, const tNotificationFlags);
+
+	virtual void openInteraction();
+	virtual void initInteraction();
+	virtual void closeInteraction();
+
+	void powerUpFinished();
+	void splashFinished();
+	void intakeWarningFinished();
+	void intakeHighlightFinished();
+	void dispenseHighlightFinished();
+	void ArHighlightFinished();
+	void CO2HighlightFinished();
+	void HeHighlightFinished();
+	void OHighlightFinished();
+	void NHighlightFinished();
+
+	void showIntakeInProgress(uint16);
+
+	void clickInIntake();
+	void clickInDispense();
+	void clickInAr();
+	void clickInCO2();
+	void clickInHe();
+	void clickInO();
+	void clickInN();
+
+	void dispenseGas();
+
+	void setStaticState(TimeValue, int16);
+	void setSegmentState(TimeValue, TimeValue, tNotificationFlags, int16);
+
+	Movie _rightSideMovie;
+	Notification _rightSideNotification;
+	NotificationCallBack _rightSideCallBack;
+	int16 _state;
+	tItemID _dispenseItemID;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
new file mode 100755
index 0000000..c12623f
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -0,0 +1,763 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/subcontrolroom.h"
+#include "pegasus/neighborhood/norad/alpha/fillingstation.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
+
+namespace Pegasus {
+
+const uint32 NoradAlpha::_noradAlphaClawExtras[22] = {
+	kN22ClawFromAToB,
+	kN22ClawALoop,
+	kN22ClawAPinch,
+	kN22ClawACounterclockwise,
+	kN22ClawAClockwise,
+	kN22ClawFromBToA,
+	kN22ClawFromBToC,
+	kN22ClawFromBToD,
+	kN22ClawBLoop,
+	kN22ClawBPinch,
+	kN22ClawBCounterclockwise,
+	kN22ClawBClockwise,
+	kN22ClawFromCToB,
+	kN22ClawCLoop,
+	kN22ClawCPinch,
+	kN22ClawCCounterclockwise,
+	kN22ClawCClockwise,
+	kN22ClawFromDToB,
+	kN22ClawDLoop,
+	kN22ClawDPinch,
+	kN22ClawDCounterclockwise,
+	kN22ClawDClockwise
+};
+
+NoradAlpha::NoradAlpha(InputHandler *nextHandler, PegasusEngine *owner) : Norad(nextHandler, owner, "Norad Alpha", kNoradAlphaID) {
+	_elevatorUpRoomID = kNorad11South;
+	_elevatorDownRoomID = kNorad12South;
+	_elevatorUpSpotID = kNorad12ElevatorUpSpotID;
+	_elevatorDownSpotID = kNorad11ElevatorDownSpotID;
+
+	_subRoomEntryRoom1 = kNorad10;
+	_subRoomEntryDir1 = kEast;
+	_subRoomEntryRoom2 = kNorad21;
+	_subRoomEntryDir2 = kWest;
+	_upperPressureDoorRoom = kNorad10East;
+	_lowerPressureDoorRoom = kNorad21West;
+
+	_upperPressureDoorUpSpotID = kAlphaUpperPressureDoorUpSpotID;
+	_upperPressureDoorDownSpotID = kAlphaUpperPressureDoorDownSpotID;
+	_upperPressureDoorAbortSpotID = kNorad10EastOutSpotID;
+
+	_lowerPressureDoorUpSpotID = kAlphaLowerPressureDoorUpSpotID;
+	_lowerPressureDoorDownSpotID = kAlphaLowerPressureDoorDownSpotID;
+	_lowerPressureDoorAbortSpotID = kNorad21WestOutSpotID;
+
+	_pressureSoundIn = kPressureDoorIntro1In;
+	_pressureSoundOut = kPressureDoorIntro1Out;
+	_equalizeSoundIn = kPressureDoorIntro2In;
+	_equalizeSoundOut = kPressureDoorIntro2Out;
+	_accessDeniedIn = kAlphaAccessDeniedIn;
+	_accessDeniedOut = kAlphaAccessDeniedOut;
+
+	_platformRoom = kNorad19West;
+	_subControlRoom = kNorad22West;
+
+	_subPrepFailed = false;
+
+	setIsItemTaken(kGasCanister);
+}
+
+void NoradAlpha::init() {
+	Norad::init();
+	
+	Hotspot *hotspot = g_allHotspots.findHotspotByID(kN01GasCanisterSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
+	HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kN01GasCanisterSpotID);
+	hotspotEntry->hotspotItem = kGasCanister;
+	
+	hotspot = g_allHotspots.findHotspotByID(kN01ArgonCanisterSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
+	hotspotEntry = findHotspotEntry(kN01ArgonCanisterSpotID);
+	hotspotEntry->hotspotItem = kArgonCanister;
+	
+	hotspot = g_allHotspots.findHotspotByID(kN01NitrogenCanisterSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
+	hotspotEntry = findHotspotEntry(kN01NitrogenCanisterSpotID);
+	hotspotEntry->hotspotItem = kNitrogenCanister;
+	
+	hotspot = g_allHotspots.findHotspotByID(kN01AirMaskSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
+	hotspotEntry = findHotspotEntry(kN01AirMaskSpotID);
+	hotspotEntry->hotspotItem = kAirMask;
+	
+	hotspot = g_allHotspots.findHotspotByID(kN01GasOutletSpotID);
+	hotspot->setMaskedHotspotFlags(kDropItemSpotFlag, kDropItemSpotFlag);
+}
+
+void NoradAlpha::start() {	
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->restoreLastEnergyValue();
+		_vm->resetEnergyDeathReason();
+		g_energyMonitor->startEnergyDraining();
+	}
+
+	tNeighborhoodID itemNeighborhood;
+	tRoomID itemRoom;
+	tDirectionConstant itemDirection;
+
+	Item *item = (Item *)g_allItems.findItemByID(kGasCanister);
+	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
+
+	if (itemNeighborhood == getObjectID()) {
+		_fillingStationItem = item;
+	} else {
+		item = (Item *)g_allItems.findItemByID(kAirMask);
+		item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
+
+		if (itemNeighborhood == getObjectID()) {
+			_fillingStationItem = item;
+		} else {
+			item = (Item *)g_allItems.findItemByID(kNitrogenCanister);
+			item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
+
+			if (itemNeighborhood == getObjectID()) {
+				_fillingStationItem = item;
+			} else {
+				item = (Item *)g_allItems.findItemByID(kArgonCanister);
+				item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
+				if (itemNeighborhood == getObjectID())
+					_fillingStationItem = item;
+				else
+					_fillingStationItem = 0;
+			}
+		}
+	}
+
+	if (!GameState.getNoradGassed())
+		forceStridingStop(kNorad03, kEast, kAltNoradAlphaNormal);
+
+	GameState.setNoradArrivedFromSub(false);
+	Norad::start();
+}
+
+void NoradAlpha::setUpAIRules() {	
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Norad/XN01WD1", false);
+		AIHasItemCondition *hasGasCanisterCondition = new AIHasItemCondition(kGasCanister);
+		AIRule *rule = new AIRule(hasGasCanisterCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+	}
+}
+
+bool NoradAlpha::okayToJump() {
+	bool result = Neighborhood::okayToJump();
+
+	if (!result)
+		playSpotSoundSync(kAlphaCantTransportIn, kAlphaCantTransportOut);
+
+	return result;
+}
+
+void NoradAlpha::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
+	if (entry.extra == kNorad19ExitToSub) {
+		compassMove.makeTwoKnotFaderSpec(kNoradAlphaMovieScale, entry.movieStart, 270 + kSubPlatformCompassAngle,
+				entry.movieEnd, 90 + 20 + 360);
+		compassMove.insertFaderKnot(entry.movieStart + 10 * kNoradAlphaFrameDuration, 270 + kSubPlatformCompassAngle);
+		compassMove.insertFaderKnot(entry.movieStart + 29 * kNoradAlphaFrameDuration, 270 + kSubPlatformCompassAngle + 20);
+		compassMove.insertFaderKnot(entry.movieStart + 52 * kNoradAlphaFrameDuration, 270 + kSubPlatformCompassAngle + 20);
+		compassMove.insertFaderKnot(entry.movieStart + 84 * kNoradAlphaFrameDuration, 360 + 90);
+		compassMove.insertFaderKnot(entry.movieStart + 198 * kNoradAlphaFrameDuration, 360 + 90);
+		compassMove.insertFaderKnot(entry.movieStart + 270 * kNoradAlphaFrameDuration, 360 + 90 + 15);
+		compassMove.insertFaderKnot(entry.movieStart + 280 * kNoradAlphaFrameDuration, 360 + 90 + 20);
+	} else {
+		Norad::getExtraCompassMove(entry, compassMove);
+	}
+}
+
+void NoradAlpha::playClawMonitorIntro() {
+	playSpotSoundSync(kLoadClawIntroIn, kLoadClawIntroOut);
+}
+
+GameInteraction *NoradAlpha::makeInteraction(const tInteractionID interactionID) {
+	switch (interactionID) {
+	case kNoradECRMonitorInteractionID:
+		// TODO
+		warning("Unhandled ECR monitor interaction");
+		break;
+	case kNoradFillingStationInteractionID:
+		return new NoradAlphaFillingStation(this);
+	}
+
+	return Norad::makeInteraction(interactionID);
+}
+
+void NoradAlpha::loadAmbientLoops() {
+	// clone2727 would like to point out that the following comment does not quite
+	// match the code logic below
+
+/*
+	Logic:
+	
+	loop sound 1:
+		if gassed,
+			play warning loop of some sort
+		else
+			play nothing
+	loop sound 2:
+		if gassed and not wearing air mask
+			if in ECR
+				play breathing water loop
+			else
+				play breathing
+		else
+			if in ECR
+				play water loop
+			if at N07 north
+				play unmanned loop
+*/
+
+	if (!GameState.getNoradSeenTimeStream())
+		return;
+
+	tRoomID room = GameState.getCurrentRoom();
+	if (GameState.getNoradGassed()) {
+		if (room >= kNorad11 && room <= kNorad19West)
+			loadLoopSound1("Sounds/Norad/NEW SUB AMB.22K.AIFF", kNoradWarningVolume * 3);
+		else if (room >= kNorad21 && room <= kNorad22West)
+			loadLoopSound1("Sounds/Norad/SUB CONTRL LOOP.22K.AIFF", kNoradWarningVolume * 3);
+		else
+			loadLoopSound1("Sounds/Norad/WARNING LOOP.22K.AIFF", kNoradWarningVolume);
+	} else {
+		loadLoopSound1("");
+	}
+
+	if (GameState.getNoradGassed() && !g_airMask->isAirFilterOn()) {
+		if (room >= kNorad01 && room <= kNorad01West) {
+			loadLoopSound2("Sounds/Norad/Breathing Water.22K.AIFF", kNoradSuckWindVolume);
+		} else if (room == kNorad02) {
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Norad/Breathing Water.22K.AIFF", kNoradSuckWindVolume);
+			else
+				loadLoopSound2("Sounds/Norad/SUCKING WIND.22K.AIFF", kNoradSuckWindVolume, 0, 0);
+		} else {
+			loadLoopSound2("Sounds/Norad/SUCKING WIND.22K.AIFF", kNoradSuckWindVolume, 0, 0);
+		}
+	} else {
+		if (room >= kNorad01 && room <= kNorad01West) {
+			loadLoopSound2("Sounds/Norad/WATER FLOWING.AIFF", 0x100 / 2);
+		} else if (room == kNorad02) {
+			if (GameState.isCurrentDoorOpen())
+				loadLoopSound2("Sounds/Norad/WATER FLOWING.AIFF", 0x100 / 2);
+			else
+				loadLoopSound2("");
+		} else {
+			loadLoopSound2("");
+		}
+	}
+	
+}
+
+void NoradAlpha::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kNorad02, kEast):
+	case MakeRoomView(kNorad06, kEast):
+	case MakeRoomView(kNorad11, kEast):
+	case MakeRoomView(kNorad15, kEast):
+	case MakeRoomView(kNorad19, kWest):
+	case MakeRoomView(kNorad21, kSouth):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void NoradAlpha::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	Norad::arriveAt(room, direction);
+
+	switch (GameState.getCurrentRoom()) {
+	case kNorad01:
+		arriveAtNorad01();
+		break;
+	case kNorad01East:
+		arriveAtNorad01East();
+		break;
+	case kNorad01West:
+		arriveAtNorad01West();
+		break;
+	case kNorad04:
+		arriveAtNorad04();
+		break;
+	case kNorad07North:
+		GameState.setScoringSawUnconsciousOperator(true);
+		break;
+	case kNorad11:
+		GameState.setScoringWentThroughPressureDoor(true);
+		break;
+	case kNorad22:
+		arriveAtNorad22();
+		break;
+	}
+}
+
+void NoradAlpha::arriveAtNorad01() {
+	if (!GameState.getNoradSeenTimeStream() && GameState.getCurrentDirection() == kSouth) {
+		GameState.setNoradN22MessagePlayed(false);
+		requestExtraSequence(kNoradArriveFromTSA, kExtraCompletedFlag, kFilterNoInput);
+		// You are no match for me, human.
+		requestExtraSequence(kNorad01RobotTaunt, kExtraCompletedFlag, kFilterNoInput);
+	}
+}
+
+void NoradAlpha::arriveAtNorad01East() {
+	GameState.setScoringSawSecurityMonitor(true);
+	newInteraction(kNoradECRMonitorInteractionID);
+}
+
+void NoradAlpha::arriveAtNorad01West() {
+	newInteraction(kNoradFillingStationInteractionID);
+}
+
+void NoradAlpha::arriveAtNorad04() {
+	if (GameState.getCurrentDirection() == kEast && !GameState.getNoradGassed())
+		playDeathExtra(kNorad04EastDeath, kDeathWokeUpNorad);
+}
+
+void NoradAlpha::arriveAtNorad22() {
+	if (!GameState.getNoradN22MessagePlayed() && GameState.getCurrentDirection() == kSouth) {
+		startExtraSequence(kNorad22SouthIntro, kExtraCompletedFlag, kFilterNoInput);
+		GameState.setNoradN22MessagePlayed(true);
+	}
+}
+
+void NoradAlpha::bumpIntoWall() {
+	requestSpotSound(kAlphaBumpIntoWallIn, kAlphaBumpIntoWallOut, kFilterNoInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+void NoradAlpha::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	if ((flags & kExtraCompletedFlag) != 0) {
+		switch (_lastExtra) {
+		case kNoradArriveFromTSA:
+			GameState.setNoradSeenTimeStream(true);
+			loadAmbientLoops();
+			break;
+		case kNorad01RobotTaunt:
+			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Norad/XN01SB", false, kWarningInterruption);
+			_interruptionFilter = kFilterAllInput;
+			makeContinuePoint();
+			break;
+		}
+	}
+
+	Norad::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		switch (_lastExtra) {
+		case kNorad22SouthIntro:
+			loopExtraSequence(kNorad22SouthReply);
+			playSpotSoundSync(kN22ReplyIn, kN22ReplyOut);
+			startExtraSequence(kNorad22SouthFinish, kExtraCompletedFlag, kFilterNoInput);
+			break;
+		case kNorad22SouthFinish:
+			_interruptionFilter = kFilterAllInput;
+			// Force ArriveAt to do its thing...
+			GameState.setCurrentRoom(kNorad21);
+			arriveAt(kNorad22, kSouth);
+			break;
+		}
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+void NoradAlpha::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry) {
+	Norad::getZoomEntry(spotID, entry);
+
+	ExtraTable::Entry extra;
+
+	if (spotID == kNorad01GasSpotID) {
+		if (_fillingStationItem) {
+			if (_fillingStationItem->getObjectID() == kGasCanister) {
+				getExtraEntry(kNorad01ZoomInWithGasCanister, extra);
+				entry.movieStart = extra.movieStart;
+				entry.movieEnd = extra.movieEnd;
+			} else {
+				entry.clear();
+			}
+		}
+	} else if (spotID == kNorad01GasOutSpotID) {
+		if (_fillingStationItem) {
+			if (_fillingStationItem->getObjectID() == kGasCanister) {
+				getExtraEntry(kNorad01ZoomOutWithGasCanister, extra);
+				entry.movieStart = extra.movieStart;
+				entry.movieEnd = extra.movieEnd;
+			} else {
+				entry.clear();
+			}
+		}
+	}
+}
+
+TimeValue NoradAlpha::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry entry;
+	
+	if (room == kNorad01 && direction == kSouth && !GameState.getNoradSeenTimeStream()) {
+		getExtraEntry(kNoradArriveFromTSA, entry);
+		return entry.movieStart;
+	}
+
+	if (room == kNorad01 && direction == kWest) {
+		if (!_fillingStationItem) {
+			return Norad::getViewTime(room, direction);
+		} else {
+			getExtraEntry(kN01WGasCanister, entry);
+			return entry.movieStart;
+		}
+	} else if (room == kNorad01West && direction == kWest) {
+		uint32 extraID = 0xffffffff;
+		if (_fillingStationItem) {
+			switch (_fillingStationItem->getObjectID()) {
+			case kArgonCanister:
+				if (GameState.getNoradFillingStationOn())
+					extraID = kN01WZArgonCanisterLit;
+				else
+					extraID = kN01WZArgonCanisterDim;
+				break;
+			case kGasCanister:
+				if (GameState.getNoradFillingStationOn())
+					extraID = kN01WZGasCanisterLit;
+				else
+					extraID = kN01WZGasCanisterDim;
+				break;
+			case kAirMask:
+				if (GameState.getNoradFillingStationOn())
+					extraID = kN01WZAirMaskLit;
+				else
+					extraID = kN01WZAirMaskDim;
+				break;
+			case kNitrogenCanister:
+				if (GameState.getNoradFillingStationOn())
+					extraID = kN01WZNitrogenCanisterLit;
+				else
+					extraID = kN01WZNitrogenCanisterDim;
+				break;
+			default:
+				// Should never happen.
+				break;
+			}
+		} else if (GameState.getNoradFillingStationOn()) {
+			extraID = kN01WZEmptyLit;
+		}
+
+		if (extraID == 0xffffffff) {
+			return Norad::getViewTime(room, direction);
+		} else {
+			getExtraEntry(extraID, entry);
+			return entry.movieStart;
+		}
+	}
+
+	return Norad::getViewTime(room, direction);
+}
+
+void NoradAlpha::turnOnFillingStation() {
+	if (GameState.getCurrentRoom() == kNorad01West && !GameState.getNoradFillingStationOn()) {
+		GameState.setNoradFillingStationOn(true);
+		updateViewFrame();
+	}
+}
+
+void NoradAlpha::turnOffFillingStation() {
+	if (GameState.getCurrentRoom() == kNorad01West && GameState.getNoradFillingStationOn()) {
+		GameState.setNoradFillingStationOn(false);
+		updateViewFrame();
+	}
+}
+
+void NoradAlpha::activateHotspots() {
+	Norad::activateHotspots();
+
+	switch (GameState.getCurrentRoomAndView()) {
+	case MakeRoomView(kNorad01West, kWest):
+		if (_vm->getDragType() == kDragInventoryUse) {
+			if (!_fillingStationItem) {
+				tItemID itemID = _vm->getDraggingItem()->getObjectID();
+				if (itemID == kArgonCanister || itemID == kGasCanister || itemID == kAirMask ||
+						itemID == kNitrogenCanister)
+					g_allHotspots.activateOneHotspot(kN01GasOutletSpotID);
+			}
+		} else {
+			tHotSpotID spotID;
+
+			if (_fillingStationItem) {
+				switch (_fillingStationItem->getObjectID()) {
+				case kArgonCanister:
+					spotID = kN01ArgonCanisterSpotID;
+					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					break;
+				case kGasCanister:
+					spotID = kN01GasCanisterSpotID;
+					break;
+				case kAirMask:
+					spotID = kN01AirMaskSpotID;
+					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					break;
+				case kNitrogenCanister:
+					spotID = kN01NitrogenCanisterSpotID;
+					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					break;
+				default:
+					// Should never happen.
+					spotID = kNoHotSpotID;
+					break;
+				}
+				g_allHotspots.activateOneHotspot(spotID);
+			}
+		}
+		break;
+	case MakeRoomView(kNorad10, kEast):
+		if (GameState.isCurrentDoorOpen())
+			g_allHotspots.deactivateOneHotspot(kNorad10DoorSpotID);
+		break;
+	case MakeRoomView(kNorad21, kWest):
+		if (GameState.isCurrentDoorOpen())
+			g_allHotspots.deactivateOneHotspot(kNorad21WestSpotID);
+		break;
+	}
+}
+
+void NoradAlpha::clickInHotspot(const Input &input, const Hotspot *cursorSpot) {	
+	Norad::clickInHotspot(input, cursorSpot);
+
+	if (_vm->getDragType() == kDragInventoryUse) {
+		if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad01West, kWest)) {
+			Item *item = _vm->getDraggingItem();
+			if (item->getObjectID() == kAirMask || item->getObjectID() == kArgonCanister ||
+					item->getObjectID() == kNitrogenCanister || item->getObjectID() == kGasCanister) {
+				HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kN01GasOutletSpotID);
+				hotspotEntry->hotspotItem = item->getObjectID();
+			}
+		}
+	}
+}
+
+void NoradAlpha::takeItemFromRoom(Item *item) {
+	if (GameState.getCurrentRoom() == kNorad01West) {
+		if (_fillingStationItem == item) {
+			_fillingStationItem = 0;
+			GameState.setNoradGassed(false);
+			loadAmbientLoops();
+			((NoradAlphaFillingStation *)_currentInteraction)->newFillingItem(0);
+			forceStridingStop(kNorad03, kEast, kAltNoradAlphaNormal);
+		}
+	}
+
+	Norad::takeItemFromRoom(item);
+}
+
+void NoradAlpha::dropItemIntoRoom(Item *item, Hotspot *droppedSpot) {
+	if (GameState.getCurrentRoom() == kNorad01West) {
+		if (!_fillingStationItem) {
+			_fillingStationItem = item;
+			((NoradAlphaFillingStation *)_currentInteraction)->newFillingItem(item);
+		}
+	}
+
+	Norad::dropItemIntoRoom(item, droppedSpot);
+}
+
+void NoradAlpha::getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID, tHotSpotID &pinchClawSpotID,
+		tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID, tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID,
+		tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &clawPosition, const uint32 *&clawExtraIDs) {
+	outSpotID = kNorad22MonitorOutSpotID;
+	prepSpotID = kNorad22LaunchPrepSpotID;
+	clawControlSpotID = kNorad22ClawControlSpotID;
+	pinchClawSpotID = kNorad22ClawPinchSpotID;
+	moveClawDownSpotID = kNorad22ClawDownSpotID;
+	moveClawRightSpotID = kNorad22ClawRightSpotID;
+	moveClawLeftSpotID = kNorad22ClawLeftSpotID;
+	moveClawUpSpotID = kNorad22ClawUpSpotID;
+	clawCCWSpotID = kNorad22ClawCCWSpotID;
+	clawCWSpotID = kNorad22ClawCWSpotID;
+	clawPosition = kClawAtD;
+	clawExtraIDs = _noradAlphaClawExtras;
+}
+
+Hotspot *NoradAlpha::getItemScreenSpot(Item *item, DisplayElement *element) {
+	switch (item->getObjectID()) {
+	case kGasCanister:
+		return g_allHotspots.findHotspotByID(kN01GasCanisterSpotID);
+	case kAirMask:
+		return g_allHotspots.findHotspotByID(kN01AirMaskSpotID);
+	case kArgonCanister:
+		return g_allHotspots.findHotspotByID(kN01ArgonCanisterSpotID);
+	case kNitrogenCanister:
+		return g_allHotspots.findHotspotByID(kN01NitrogenCanisterSpotID);
+	}
+
+	return Norad::getItemScreenSpot(item, element);
+}
+
+Common::String NoradAlpha::getEnvScanMovie() {
+	Common::String movieName = Neighborhood::getEnvScanMovie();
+
+	if (movieName.empty()) {
+		tRoomID room = GameState.getCurrentRoom();
+		if (room >= kNorad01 && room <= kNorad01West)
+			return "Images/AI/Norad/XNE1";
+		else if ((room >= kNorad02 && room <= kNorad19West))
+			return "Images/AI/Norad/XNE2";
+
+		return "Images/AI/Norad/XNE3";
+	}
+
+	return movieName;
+}
+
+uint NoradAlpha::getNumHints() {
+	uint numHints = Neighborhood::getNumHints();
+
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kNorad01, kNorth):
+		case MakeRoomView(kNorad01, kSouth):
+		case MakeRoomView(kNorad01, kEast):
+		case MakeRoomView(kNorad01, kWest):
+		case MakeRoomView(kNorad01East, kEast):
+		case MakeRoomView(kNorad01West, kWest):
+			if (GameState.getNoradGassed()) {
+				if (g_airMask->isAirFilterOn())
+					numHints = 0;
+				else
+					numHints = 3;
+			} else {
+				numHints = 2;
+			}
+			break;
+		case MakeRoomView(kNorad19West, kWest):
+			if (getSubPrepFailed() && GameState.getNoradSubPrepState() != kSubPrepped)
+				numHints = 1;
+			break;
+		case MakeRoomView(kNorad22, kWest):
+			numHints = 1;
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String NoradAlpha::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kNorad01, kNorth):
+		case MakeRoomView(kNorad01, kSouth):
+		case MakeRoomView(kNorad01, kEast):
+		case MakeRoomView(kNorad01, kWest):
+		case MakeRoomView(kNorad01East, kEast):
+		case MakeRoomView(kNorad01West, kWest):
+			switch (hintNum) {
+			case 1:
+				if (GameState.getNoradGassed())
+					return "Images/AI/Norad/XN01SW";
+
+				return "Images/AI/Norad/XN01WD2";
+			case 2:
+				if (GameState.getNoradGassed()) {
+					if (_vm->playerHasItemID(kAirMask))
+						// Mask must not be on if we get here...
+						return "Images/AI/Globals/XGLOB1A";
+
+					return "Images/AI/Globals/XGLOB3D";
+				}
+
+				return "Images/AI/Globals/XGLOB5C";
+			case 3:
+				return "Images/AI/Norad/XN01SH";
+			}
+			break;
+		case MakeRoomView(kNorad19West, kWest):
+			return "Images/AI/Norad/XN19NH";
+		case MakeRoomView(kNorad22, kWest):
+			return "Images/AI/Globals/XGLOB1C";
+		}
+	}
+
+	return movieName;
+}
+
+void NoradAlpha::closeDoorOffScreen(const tRoomID room, const tDirectionConstant) {
+	switch (room) {
+	case kNorad12:
+	case kNorad13:
+	case kNorad18:
+	case kNorad19:
+		playSpotSoundSync(kAlphaElevatorDoorCloseIn, kAlphaElevatorDoorCloseOut);
+		break;
+	default:
+		playSpotSoundSync(kAlphaRegDoorCloseIn, kAlphaRegDoorCloseOut);
+		break;
+	}
+}
+
+void NoradAlpha::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {
+	if (room == kNorad01 && direction == kSouth)
+		spotEntry.clear();
+	else
+		Norad::findSpotEntry(room, direction, flags, spotEntry);
+}
+
+bool NoradAlpha::canSolve() {
+	return Norad::canSolve() || getHintMovie(1) == "Images/AI/Norad/XN01SW";
+}
+
+void NoradAlpha::doSolve() {
+	Norad::doSolve();
+
+	if (getHintMovie(1) == "Images/AI/Norad/XN01SW") {
+		_vm->addItemToInventory(g_airMask);
+		g_airMask->putMaskOn();
+	}
+}
+
+Common::String NoradAlpha::getNavMovieName() {
+	return "Images/Norad Alpha/Norad Alpha.movie";
+}
+
+Common::String NoradAlpha::getSoundSpotsName() {
+	return "Sounds/Norad/Norad Alpha Spots";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
new file mode 100755
index 0000000..72a7ac6
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
@@ -0,0 +1,142 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_NORADALPHA_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_NORADALPHA_H
+
+#include "pegasus/neighborhood/norad/norad.h"
+
+namespace Pegasus {
+
+const TimeValue kAlphaBumpIntoWallIn = 0;
+const TimeValue kAlphaBumpIntoWallOut = 303;
+
+const TimeValue kAlphaAccessDeniedIn = 303;
+const TimeValue kAlphaAccessDeniedOut = 3045;
+
+const TimeValue kAlphaRegDoorCloseIn = 3045;
+const TimeValue kAlphaRegDoorCloseOut = 4476;
+
+const TimeValue kAlphaElevatorDoorCloseIn = 4476;
+const TimeValue kAlphaElevatorDoorCloseOut = 5071;
+
+const TimeValue kAlphaCantTransportIn = 5071;
+const TimeValue kAlphaCantTransportOut = 9348;
+
+const TimeValue kPressureDoorIntro1In = 9348;
+const TimeValue kPressureDoorIntro1Out = 11061;
+
+const TimeValue kPressureDoorIntro2In = 11061;
+const TimeValue kPressureDoorIntro2Out = 14098;
+
+const TimeValue kN22ReplyIn = 14098;
+const TimeValue kN22ReplyOut = 18442;
+
+const TimeValue kLoadClawIntroIn = 18442;
+const TimeValue kLoadClawIntroOut = 20698;
+
+class Item;
+
+class NoradAlpha : public Norad {
+public:
+	NoradAlpha(InputHandler *, PegasusEngine *);
+	virtual ~NoradAlpha() {}
+
+	virtual void init();
+	void start();
+
+	virtual bool okayToJump();
+
+	void playClawMonitorIntro();
+
+	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
+
+	void turnOnFillingStation();
+	void turnOffFillingStation();
+	Item *getFillingItem() { return _fillingStationItem; }
+	bool gasCanisterIntake();
+
+	virtual void takeItemFromRoom(Item *);
+	virtual void dropItemIntoRoom(Item *, Hotspot *);
+
+	virtual GameInteraction *makeInteraction(const tInteractionID);
+
+	virtual void getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID,
+			tHotSpotID &pinchClawSpotID, tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID,
+			tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID, tHotSpotID &clawCCWSpotID,
+			tHotSpotID &clawCWSpotID, uint32 &, const uint32 *&);
+
+	void loadAmbientLoops();
+
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+	void setUpAIRules();
+
+	void setSubPrepFailed(bool value) { _subPrepFailed = value; }
+	bool getSubPrepFailed() { return _subPrepFailed; }
+
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	void clickInHotspot(const Input &, const Hotspot *);
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+protected:
+	static const uint32 _noradAlphaClawExtras[22];
+
+	virtual void arriveAtNorad01();
+	virtual void arriveAtNorad01East();
+	virtual void arriveAtNorad01West();
+	virtual void arriveAtNorad04();
+	virtual void arriveAtNorad22();
+	
+	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	
+	virtual void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
+	virtual TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+
+	virtual void activateHotspots();
+
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+
+	void bumpIntoWall();
+
+	Item *_fillingStationItem;
+
+	bool _subPrepFailed;
+
+	Common::String getSoundSpotsName();
+	Common::String getNavMovieName();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/norad.h b/engines/pegasus/neighborhood/norad/norad.h
index 4b4473c..5e81890 100755
--- a/engines/pegasus/neighborhood/norad/norad.h
+++ b/engines/pegasus/neighborhood/norad/norad.h
@@ -276,7 +276,103 @@ const tDisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
 const tDisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
 
 
-//	Norad Alpha Extra sequence IDs.
+//	Norad Alpha constants
+
+const TimeScale kNoradAlphaMovieScale = 600;
+const TimeScale kNoradAlphaFramesPerSecond = 15;
+const TimeScale kNoradAlphaFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltNoradAlphaNormal = 0;
+
+//	Room IDs.
+
+const tRoomID kNorad01 = 0;
+const tRoomID kNorad01East = 1;
+const tRoomID kNorad01West = 2;
+const tRoomID kNorad02 = 3;
+const tRoomID kNorad03 = 4;
+const tRoomID kNorad04 = 5;
+const tRoomID kNorad05 = 6;
+const tRoomID kNorad06 = 7;
+const tRoomID kNorad07 = 8;
+const tRoomID kNorad07North = 9;
+const tRoomID kNorad08 = 10;
+const tRoomID kNorad09 = 11;
+const tRoomID kNorad10 = 12;
+const tRoomID kNorad10East = 13;
+const tRoomID kNorad11 = 14;
+const tRoomID kNorad11South = 15;
+const tRoomID kNorad12 = 16;
+const tRoomID kNorad12South = 17;
+const tRoomID kNorad13 = 18;
+const tRoomID kNorad14 = 19;
+const tRoomID kNorad15 = 20;
+const tRoomID kNorad16 = 21;
+const tRoomID kNorad17 = 22;
+const tRoomID kNorad18 = 23;
+const tRoomID kNorad19 = 24;
+const tRoomID kNorad19West = 25;
+const tRoomID kNorad21 = 26;
+const tRoomID kNorad21West = 27;
+const tRoomID kNorad22 = 28;
+const tRoomID kNorad22West = 29;
+
+//	Hot Spot Activation IDs.
+
+
+//	Hot Spot IDs.
+
+const tHotSpotID kNorad01ECRSpotID = 5000;
+const tHotSpotID kNorad01GasSpotID = 5001;
+const tHotSpotID kNorad01ECROutSpotID = 5002;
+const tHotSpotID kNorad01GasOutSpotID = 5003;
+const tHotSpotID kNorad01MonitorSpotID = 5004;
+const tHotSpotID kNorad01IntakeSpotID = 5005;
+const tHotSpotID kNorad01DispenseSpotID = 5006;
+const tHotSpotID kNorad01ArSpotID = 5007;
+const tHotSpotID kNorad01CO2SpotID = 5008;
+const tHotSpotID kNorad01HeSpotID = 5009;
+const tHotSpotID kNorad01OSpotID = 5010;
+const tHotSpotID kNorad01NSpotID = 5011;
+const tHotSpotID kN01GasCanisterSpotID = 5012;
+const tHotSpotID kN01ArgonCanisterSpotID = 5013;
+const tHotSpotID kN01AirMaskSpotID = 5014;
+const tHotSpotID kN01NitrogenCanisterSpotID = 5015;
+const tHotSpotID kN01GasOutletSpotID = 5016;
+const tHotSpotID kNorad07DoorSpotID = 5017;
+const tHotSpotID kNorad07DoorOutSpotID = 5018;
+const tHotSpotID kNorad10DoorSpotID = 5019;
+const tHotSpotID kNorad10EastOutSpotID = 5020;
+const tHotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
+const tHotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
+const tHotSpotID kNorad11ElevatorSpotID = 5023;
+const tHotSpotID kNorad11ElevatorOutSpotID = 5024;
+const tHotSpotID kNorad11ElevatorDownSpotID = 5025;
+const tHotSpotID kNorad12ElevatorSpotID = 5026;
+const tHotSpotID kNorad12ElevatorOutSpotID = 5027;
+const tHotSpotID kNorad12ElevatorUpSpotID = 5028;
+const tHotSpotID kNorad19MonitorSpotID = 5029;
+const tHotSpotID kNorad19MonitorOutSpotID = 5030;
+const tHotSpotID kNorad19ActivateMonitorSpotID = 5031;
+const tHotSpotID kNorad21WestSpotID = 5032;
+const tHotSpotID kNorad21WestOutSpotID = 5033;
+const tHotSpotID kAlphaLowerPressureDoorUpSpotID = 5034;
+const tHotSpotID kAlphaLowerPressureDoorDownSpotID = 5035;
+const tHotSpotID kNorad22MonitorSpotID = 5036;
+const tHotSpotID kNorad22MonitorOutSpotID = 5037;
+const tHotSpotID kNorad22LaunchPrepSpotID = 5038;
+const tHotSpotID kNorad22ClawControlSpotID = 5039;
+const tHotSpotID kNorad22ClawPinchSpotID = 5040;
+const tHotSpotID kNorad22ClawDownSpotID = 5041;
+const tHotSpotID kNorad22ClawRightSpotID = 5042;
+const tHotSpotID kNorad22ClawLeftSpotID = 5043;
+const tHotSpotID kNorad22ClawUpSpotID = 5044;
+const tHotSpotID kNorad22ClawCCWSpotID = 5045;
+const tHotSpotID kNorad22ClawCWSpotID = 5046;
+
+//	Extra sequence IDs.
 
 const tExtraID kNoradArriveFromTSA = 0;
 const tExtraID kNorad01RobotTaunt = 1;
@@ -321,6 +417,7 @@ const tExtraID kN22ClawDPinch = 39;
 const tExtraID kN22ClawDCounterclockwise = 40;
 const tExtraID kN22ClawDClockwise = 41;
 
+
 //	Norad Delta Extra sequence IDs.
 
 const tExtraID kArriveFromSubChase = 0;
@@ -386,13 +483,8 @@ const tExtraID kNoradDeltaRetinalScanBad = 59;
 const tExtraID kNoradDeltaRetinalScanGood = 60;
 const tExtraID kN79BrightView = 61;
 
-const TimeScale kNoradAlphaMovieScale = 600;
-const TimeScale kNoradAlphaFramesPerSecond = 15;
-const TimeScale kNoradAlphaFrameDuration = 40;
-
 const tRoomID kNorad59West = 23;
 const tRoomID kNorad60West = 25;
-const tHotSpotID kNorad19ActivateMonitorSpotID = 5031;
 
 // This is the code common to both Norad Alpha and Norad Delta
 
@@ -409,7 +501,7 @@ public:
 			tHotSpotID &clawControlSpotID, tHotSpotID &pinchClawSpotID,
 			tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID,
 			tHotSpotID &moveClawLeftSpotID,tHotSpotID &moveClawUpSpotID,
-			tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &, uint32 *&) = 0;
+			tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &, const uint32 *&) = 0;
 	void checkAirMask();
 
 	virtual uint16 getDateResID() const;
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
index 066914c..0fd5f45 100755
--- a/engines/pegasus/neighborhood/norad/pressuredoor.cpp
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
@@ -243,7 +243,7 @@ void PressureDoor::initInteraction() {
 		_robotState = kPlayingRobotApproaching;
 	}
 
-	// TODO: MoviesTask call -- needed?
+	_levelsMovie.redrawMovieWorld();
 }
 
 void PressureDoor::closeInteraction() {	
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index 7a01d32..69244bc 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -538,7 +538,8 @@ void SubControlRoom::initInteraction() {
 		playClawMonitorSection(kAlphaClawSplashStart, kAlphaClawSplashStop, kAlphaSplashFinished, _gameState, false);
 	}
 
-	// TODO: MoviesTask call. Needed?
+	_subControlMovie.redrawMovieWorld();
+	_clawMonitorMovie.redrawMovieWorld();
 
 	GameState.setScoringPlayedWithClaw(true);
 }									
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.h b/engines/pegasus/neighborhood/norad/subcontrolroom.h
index 4a6889f..deea504 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.h
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.h
@@ -98,7 +98,7 @@ protected:
 	uint32 _clawStartPosition;
 	uint32 _clawPosition;
 	uint32 _clawNextPosition;
-	uint32 *_clawExtraIDs;
+	const uint32 *_clawExtraIDs;
 
 	int _currentAction;
 	int _nextAction;
diff --git a/engines/pegasus/neighborhood/norad/subplatform.cpp b/engines/pegasus/neighborhood/norad/subplatform.cpp
index 0d4827b..2665ab4 100755
--- a/engines/pegasus/neighborhood/norad/subplatform.cpp
+++ b/engines/pegasus/neighborhood/norad/subplatform.cpp
@@ -28,6 +28,7 @@
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/subplatform.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 
 namespace Pegasus {
 
@@ -150,8 +151,7 @@ void SubPlatform::receiveNotification(Notification *notification, const tNotific
 			owner->startLoop2Fader(loop2Spec);
 			break;
 		case kPrepIncompleteFinished:
-			// TODO
-			//((NoradAlpha *)owner)->setSubPrepFailed(true);
+			((NoradAlpha *)owner)->setSubPrepFailed(true);
 			g_AIArea->checkMiddleArea();
 			// Fall through...
 		case kDamagedFinished:
@@ -191,8 +191,7 @@ void SubPlatform::clickInHotspot(const Input &input, const Hotspot *spot) {
 
 		_platformMovie.show();
 		_platformMovie.start();
-
-		// TODO: MoviesTask call? I don't think it's needed
+		_platformMovie.redrawMovieWorld();
 
 		_stateBits &= ~kWaitingForPlayerBit;
 		
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index fcfae06..0ce533c 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -31,6 +31,7 @@
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index 3075895..831ab08 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -30,6 +30,7 @@
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"
 
diff --git a/engines/pegasus/neighborhood/zoom.cpp b/engines/pegasus/neighborhood/zoom.cpp
index 9422890..ee2d8be 100755
--- a/engines/pegasus/neighborhood/zoom.cpp
+++ b/engines/pegasus/neighborhood/zoom.cpp
@@ -52,6 +52,10 @@ void ZoomTable::clear() {
 }
 
 ZoomTable::Entry::Entry() {
+	clear();
+}
+
+void ZoomTable::Entry::clear() {
 	hotspot = kNoHotSpotID;
 	movieStart = 0xffffffff;
 	movieEnd = 0xffffffff;
diff --git a/engines/pegasus/neighborhood/zoom.h b/engines/pegasus/neighborhood/zoom.h
index 4046a76..27290a8 100755
--- a/engines/pegasus/neighborhood/zoom.h
+++ b/engines/pegasus/neighborhood/zoom.h
@@ -49,6 +49,7 @@ public:
 
 	struct Entry {
 		Entry();
+		void clear();
 		bool isEmpty() { return movieStart == 0xffffffff; }
 
 		tHotSpotID hotspot;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 2871ed1..b823ff2 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -63,6 +63,7 @@
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
@@ -1363,6 +1364,9 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kWSCID:
 		neighborhood = new WSC(g_AIArea, this);
 		break;
+	case kNoradAlphaID:
+		neighborhood = new NoradAlpha(g_AIArea, this);
+		break;
 	default:
 		error("Unhandled neighborhood %d", neighborhoodID);
 	}


Commit: c8526bf6c3a193cd41a41789eceb9dc155b85f5b
    https://github.com/scummvm/scummvm/commit/c8526bf6c3a193cd41a41789eceb9dc155b85f5b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T09:51:33-07:00

Commit Message:
PEGASUS: Add support for scaled/glowing images/movies

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index fe15261..dbdb63f 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -202,4 +202,48 @@ void Movie::updateTime() {
 	}
 }
 
+GlowingMovie::GlowingMovie(const tDisplayElementID id) : Movie(id) {
+	_glowing = false;
+}
+
+void GlowingMovie::draw(const Common::Rect &r) {
+	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
+	// never fall off the screen.
+	if (_glowing) {
+		Common::Rect bounds;
+		getBounds(bounds);
+
+		copyToCurrentPortTransparentGlow(_movieBox, bounds);
+	} else {
+		Movie::draw(r);
+	}
+}
+
+void GlowingMovie::setBounds(const Common::Rect &r) {
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	if (r != bounds) {
+		// Avoid Movie::setBounds.
+		// clone2727 asks why, but goes along with it
+		Animation::setBounds(r);
+	}
+}
+
+ScalingMovie::ScalingMovie(const tDisplayElementID id) : GlowingMovie(id) {
+}
+
+void ScalingMovie::draw(const Common::Rect &) {
+	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
+	// never fall off the screen.
+
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	if (_glowing)
+		scaleTransparentCopyGlow(_movieBox, bounds);
+	else
+		scaleTransparentCopy(_movieBox, bounds);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 704da0e..b248cc1 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -75,6 +75,29 @@ protected:
 	Common::Rect _movieBox;
 };
 
+class GlowingMovie : public Movie {
+public:
+	GlowingMovie(tDisplayElementID);
+	virtual ~GlowingMovie() {}
+
+	virtual void draw(const Common::Rect &);
+
+	void setBounds(const Common::Rect &);
+
+	void setGlowing(const bool);
+
+protected:
+	bool _glowing;
+};
+
+class ScalingMovie : public GlowingMovie {
+public:
+	ScalingMovie(tDisplayElementID);
+	virtual ~ScalingMovie() {}
+
+	virtual void draw(const Common::Rect &);
+};
+
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 69eeb31..2bf9895 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -178,10 +178,6 @@ void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect
 }
 
 void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
-	// HACK: Seems we're truncating some color data somewhere...
-	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
-	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
-
 	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
@@ -192,11 +188,11 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Co
 		for (int x = 0; x < srcRect.width(); x++) {
 			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 				uint16 color = READ_UINT16(src);
-				if (color != transColor1 && color != transColor2)
+				if (!isTransparent(color))
 					memcpy(dst, src, 2);
 			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 				uint32 color = READ_UINT32(src);
-				if (color != transColor1 && color != transColor2)
+				if (!isTransparent(color))
 					memcpy(dst, src, 4);
 			}
 
@@ -209,6 +205,112 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Co
 	}
 }
 
+void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
+	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
+	// pixel all the way up.
+
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
+	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
+
+	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
+
+	for (int y = 0; y < srcRect.height(); y++) {
+		for (int x = 0; x < srcRect.width(); x++) {
+			if (g_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = READ_UINT16(src);
+				if (!isTransparent(color))
+					WRITE_UINT16(dst, getGlowColor(color));
+			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = READ_UINT32(src);
+				if (!isTransparent(color))
+					WRITE_UINT32(dst, getGlowColor(color));
+			}
+
+			src += g_system->getScreenFormat().bytesPerPixel;
+			dst += g_system->getScreenFormat().bytesPerPixel;
+		}
+
+		src += _surface->pitch - lineSize;
+		dst += screen->pitch - lineSize;
+	}
+}
+
+void Surface::scaleTransparentCopy(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
+	// I'm doing simple linear scaling here
+	// dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH);
+
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+
+	int srcW = srcRect.width();
+	int srcH = srcRect.height();
+	int dstW = dstRect.width();
+	int dstH = dstRect.height();
+
+	for (int y = 0; y < dstH; y++) {
+		for (int x = 0; x < dstW; x++) {
+			if (g_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
+						x * srcW / dstW + srcRect.left,
+						y * srcH / dstH + srcRect.top));
+				if (!isTransparent(color))
+					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
+			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
+						x * srcW / dstW + srcRect.left,
+						y * srcH / dstH + srcRect.top));
+				if (!isTransparent(color))
+					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
+			}
+		}
+	}
+}
+
+void Surface::scaleTransparentCopyGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
+	// This is the same as scaleTransparentCopy(), but turns the red value of each
+	// pixel all the way up.
+
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+
+	int srcW = srcRect.width();
+	int srcH = srcRect.height();
+	int dstW = dstRect.width();
+	int dstH = dstRect.height();
+
+	for (int y = 0; y < dstH; y++) {
+		for (int x = 0; x < dstW; x++) {
+			if (g_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
+						x * srcW / dstW + srcRect.left,
+						y * srcH / dstH + srcRect.top));
+				if (!isTransparent(color))
+					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
+			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
+						x * srcW / dstW + srcRect.left,
+						y * srcH / dstH + srcRect.top));
+				if (!isTransparent(color))
+					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
+			}
+		}
+	}
+}
+
+uint32 Surface::getGlowColor(uint32 color) const {
+	// Can't just 'or' it on like the original did :P
+	byte r, g, b;
+	g_system->getScreenFormat().colorToRGB(color, r, g, b);
+	return g_system->getScreenFormat().RGBToColor(0xff, g, b);
+}
+
+bool Surface::isTransparent(uint32 color) const {
+	// HACK: Seems we're truncating some color data somewhere...
+	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
+	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
+
+	return color == transColor1 || color == transColor2;
+}
+
 PixelImage::PixelImage() {
 	_transparent = false;
 }
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index c94ccdf..9270de0 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -70,6 +70,9 @@ public:
 	void copyToCurrentPortTransparent(const Common::Rect &) const;
 	void copyToCurrentPort(const Common::Rect &, const Common::Rect &) const;
 	void copyToCurrentPortTransparent(const Common::Rect &, const Common::Rect &) const;
+	void copyToCurrentPortTransparentGlow(const Common::Rect &, const Common::Rect &) const;
+	void scaleTransparentCopy(const Common::Rect &, const Common::Rect &) const;
+	void scaleTransparentCopyGlow(const Common::Rect &, const Common::Rect &) const;
 
 	virtual void getImageFromPICTFile(const Common::String &fileName);
 	virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
@@ -82,6 +85,9 @@ protected:
 
 private:
 	void getImageFromPICTStream(Common::SeekableReadStream *stream);
+
+	uint32 getGlowColor(uint32 color) const;
+	bool isTransparent(uint32 color) const;
 };
 
 class PixelImage : public Surface {


Commit: de3962fbc8707f90eeed4cabfbaf06c7e939b565
    https://github.com/scummvm/scummvm/commit/de3962fbc8707f90eeed4cabfbaf06c7e939b565
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T15:52:49-07:00

Commit Message:
PEGASUS: Add the Mars canyon chase sequence

Changed paths:
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index c8a67bf..c4f0f5e 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -57,8 +57,9 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
-	neighborhood/mars/reactor.o \
 	neighborhood/mars/mars.o \
+	neighborhood/mars/reactor.o \
+	neighborhood/mars/shuttleenergymeter.o \
 	neighborhood/norad/norad.o \
 	neighborhood/norad/noradelevator.o \
 	neighborhood/norad/pressuredoor.o \
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index f13890c..7404e1e 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -23,6 +23,10 @@
  *
  */
 
+#include "common/events.h"
+#include "video/qt_decoder.h"
+
+#include "pegasus/cursor.h"
 #include "pegasus/energymonitor.h"
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
@@ -698,9 +702,6 @@ const tExtraID kMars200DeathInBucket = 111;
 
 const tResIDType kReactorUndoHilitePICTID = 900;
 
-const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
-const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
-
 const int16 kMars52Compass = 90;
 const int16 kMars54Compass = 180;
 const int16 kMars56Compass = 270;
@@ -766,10 +767,18 @@ void airStageExpiredFunction(FunctionPtr *, void *mars) {
 	((Mars *)mars)->airStageExpired();
 }
 
+void marsTimerFunction(FunctionPtr *, void *event) {
+	((MarsTimerEvent *)event)->mars->marsTimerExpired(*(MarsTimerEvent *)event);
+}
+
 Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Mars", kMarsID),
 		_guessObject(kNoDisplayElement), _undoPict(kNoDisplayElement), _guessHistory(kNoDisplayElement),
 		_choiceHighlight(kNoDisplayElement), _shuttleInterface1(kNoDisplayElement), _shuttleInterface2(kNoDisplayElement),
-		_shuttleInterface3(kNoDisplayElement), _shuttleInterface4(kNoDisplayElement), _canyonChaseMovie(kNoDisplayElement) {
+		_shuttleInterface3(kNoDisplayElement), _shuttleInterface4(kNoDisplayElement), _canyonChaseMovie(kNoDisplayElement),
+		_leftShuttleMovie(kNoDisplayElement), _rightShuttleMovie(kNoDisplayElement), _lowerLeftShuttleMovie(kNoDisplayElement),
+		_lowerRightShuttleMovie(kNoDisplayElement), _centerShuttleMovie(kNoDisplayElement),
+		_upperLeftShuttleMovie(kNoDisplayElement), _upperRightShuttleMovie(kNoDisplayElement),
+		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement) {
 	_noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
 	setIsItemTaken(kMarsCard);
 	setIsItemTaken(kAirMask);
@@ -2980,7 +2989,7 @@ void Mars::receiveNotification(Notification *notification, const tNotificationFl
 			break;
 		}
 	} else if ((flag & kTimeForCanyonChaseFlag) != 0) {
-		// TODO
+		doCanyonChase();
 	} else if ((flag & kExplosionFinishedFlag) != 0) {
 		// TODO
 	} else if ((flag & kTimeToTransportFlag) != 0) {
@@ -2998,6 +3007,213 @@ void Mars::spotCompleted() {
 		g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XN59WD", false, kWarningInterruption);
 }
 
+void Mars::doCanyonChase() {	
+	GameState.setScoringEnteredShuttle();
+	setNextHandler(_vm);
+	throwAwayInterface();
+
+	_vm->_cursor->hide();
+	
+	// Open the spot sounds movie again...
+	_spotSounds.initFromQuickTime(getSoundSpotsName());
+	_spotSounds.setVolume(_vm->getSoundFXLevel());
+
+	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
+	if (!video->loadFile("Images/Mars/M44ESA.movie"))
+		error("Could not load interface->shuttle transition video");
+
+	while (!_vm->shouldQuit() && !video->endOfVideo()) {
+		if (video->needsUpdate()) {
+			const Graphics::Surface *frame = video->decodeNextFrame();
+
+			if (frame)
+				_vm->drawScaledFrame(frame, 0, 0);
+		}
+
+		Common::Event event;
+		while (g_system->getEventManager()->pollEvent(event))
+			;
+
+		g_system->delayMillis(10);
+	}
+
+	delete video;
+
+	if (_vm->shouldQuit())
+		return;
+
+	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
+							kShuttle1Top, true);
+	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
+							kShuttle2Top, true);
+	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
+							kShuttle3Top, true);
+	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
+							kShuttle4Top, true);
+
+	initOneMovie(&_canyonChaseMovie, "Images/Mars/Canyon.movie",
+						kShuttleMonitorOrder, kShuttleWindowLeft, kShuttleWindowTop, true);
+	_canyonChaseMovie.setVolume(_vm->getSoundFXLevel());
+
+	loadLoopSound1("Sounds/Mars/Inside Cockpit.22K.8.AIFF");
+
+	// Swing shuttle around...
+	playMovieSegment(&_canyonChaseMovie, kShuttleSwingStart, kShuttleSwingStop);
+
+	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
+	
+	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
+	
+	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
+	
+	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
+	
+	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
+	
+	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
+	
+	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
+	
+	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
+	
+	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
+	
+	_centerShuttleMovie.show();
+	_centerShuttleMovie.setTime(kShuttleCenterBoardingTime);
+	playSpotSoundSync(kShuttleCockpitIn, kShuttleCockpitOut);
+	
+	_centerShuttleMovie.setTime(kShuttleCenterCheckTime);
+	playSpotSoundSync(kShuttleOnboardIn, kShuttleOnboardOut);
+	
+	_shuttleEnergyMeter.initShuttleEnergyMeter();
+	_shuttleEnergyMeter.powerUpMeter();
+	while (_shuttleEnergyMeter.isFading()) {
+		_vm->checkCallBacks();
+		_vm->refreshDisplay();
+		g_system->updateScreen();
+	}
+
+	_leftShuttleMovie.show();
+	playMovieSegment(&_leftShuttleMovie, kShuttleLeftIntroStart, kShuttleLeftIntroStop);
+
+	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
+	_leftShuttleMovie.redrawMovieWorld();
+	
+	_leftDamageShuttleMovie.show();
+	playMovieSegment(&_leftDamageShuttleMovie);
+
+	// Take it down a tick initially. This sets the time to the time of the last tick,
+	// so that subsequence drops will drop it down a tick.
+	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
+	
+	_lowerRightShuttleMovie.show();
+	_lowerRightShuttleMovie.setTime(kShuttleLowerRightOffTime);
+	_lowerRightShuttleMovie.redrawMovieWorld();
+	_centerShuttleMovie.setTime(kShuttleCenterNavCompTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttleNavigationIn, kShuttleNavigationOut);
+
+	_centerShuttleMovie.setTime(kShuttleCenterCommTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttleCommunicationIn, kShuttleCommunicationOut);
+
+	_centerShuttleMovie.setTime(kShuttleCenterAllSystemsTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttleAllSystemsIn, kShuttleAllSystemsOut);
+
+	_centerShuttleMovie.setTime(kShuttleCenterSecureLooseTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttleSecureLooseIn, kShuttleSecureLooseOut);
+
+	_centerShuttleMovie.setTime(kShuttleCenterAutoTestTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttleAutoTestingIn, kShuttleAutoTestingOut);
+
+	_leftShuttleMovie.setTime(kShuttleLeftAutoTestTime);
+	_leftShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kMarsThrusterAutoTestIn, kMarsThrusterAutoTestOut);
+	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
+	_leftShuttleMovie.redrawMovieWorld();
+
+	_centerShuttleMovie.setTime(kShuttleCenterLaunchTime);
+	_centerShuttleMovie.redrawMovieWorld();
+	playSpotSoundSync(kShuttlePrepareForDropIn, kShuttlePrepareForDropOut);
+
+	playSpotSoundSync(kShuttleAllClearIn, kShuttleAllClearOut);
+
+	_centerShuttleMovie.setTime(kShuttleCenterEnterTubeTime);
+	_centerShuttleMovie.redrawMovieWorld();
+
+	_lowerLeftShuttleMovie.show();
+	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftCollisionTime);
+
+	loadLoopSound1("");
+
+	_canyonChaseMovie.setSegment(kCanyonChaseStart, kCanyonChaseStop);
+	_canyonChaseMovie.start();
+
+	startMarsTimer(kLaunchTubeReachedTime, kMovieTicksPerSecond, kMarsLaunchTubeReached);
+}
+
+void Mars::setSoundFXLevel(const uint16 level) {
+	Neighborhood::setSoundFXLevel(level);
+
+	if (_canyonChaseMovie.isMovieValid())
+		_canyonChaseMovie.setVolume(level);
+
+	// TODO: Explosions
+}
+
+void Mars::startMarsTimer(TimeValue time, TimeScale scale, MarsTimerCode code) {
+	_utilityFuse.primeFuse(time, scale);
+	_marsEvent.mars = this;
+	_marsEvent.event = code;
+	_utilityFuse.setFunctionPtr(&marsTimerFunction, (void *)&_marsEvent);
+	_utilityFuse.lightFuse();
+}
+
+void Mars::marsTimerExpired(MarsTimerEvent &event) {	
+	switch (event.event) {
+	case kMarsLaunchTubeReached:
+		_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftTubeTime);
+		_lowerLeftShuttleMovie.redrawMovieWorld();
+		startMarsTimer(kCanyonChaseFinishedTime, kMovieTicksPerSecond, kMarsCanyonChaseFinished);
+		break;
+	case kMarsCanyonChaseFinished:
+		GameState.setScoringEnteredLaunchTube();
+
+		while (_canyonChaseMovie.isRunning()) {
+			_vm->checkCallBacks();
+			_vm->refreshDisplay();
+			_vm->_system->delayMillis(10);
+		}
+
+		_canyonChaseMovie.stop();
+		_canyonChaseMovie.stopDisplaying();
+		_canyonChaseMovie.releaseMovie();
+
+		error("STUB: Space chase");
+		break;			
+	case kMarsSpaceChaseFinished:
+		// Player failed to stop the robot in time...
+		// TODO
+		break;
+	default:
+		break;
+	}
+
+	_interruptionFilter = kFilterAllInput;
+}
+
 tAirQuality Mars::getAirQuality(const tRoomID room) {
 	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
 		return kAirQualityVacuum;
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index b663a62..1b29cdf 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -28,24 +28,254 @@
 
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/mars/reactor.h"
+#include "pegasus/neighborhood/mars/shuttleenergymeter.h"
 
 namespace Pegasus {
 
+//	Element Coordinates
+
+const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
+const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
+
+const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
+
+const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+
+const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
+
+const tCoordType kAnswerLeft = kNavAreaLeft + 304;
+const tCoordType kAnswerTop = kNavAreaTop + 180;
+
+const tCoordType kShuttle1Left = 0;
+const tCoordType kShuttle1Top = 0;
+
+const tCoordType kShuttle2Left = 0;
+const tCoordType kShuttle2Top = 96;
+
+const tCoordType kShuttle3Left = 500;
+const tCoordType kShuttle3Top = 96;
+
+const tCoordType kShuttle4Left = 0;
+const tCoordType kShuttle4Top = 320;
+
+const tCoordType kShuttleWindowLeft = 140;
+const tCoordType kShuttleWindowTop = 96;
+const tCoordType kShuttleWindowWidth = 360;
+const tCoordType kShuttleWindowHeight = 224;
+
+const tCoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
+const tCoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
+
+const tCoordType kShuttleLeftLeft = 0;
+const tCoordType kShuttleLeftTop = 128;
+
+const tCoordType kShuttleRightLeft = 506;
+const tCoordType kShuttleRightTop = 128;
+
+const tCoordType kShuttleLowerLeftLeft = 74;
+const tCoordType kShuttleLowerLeftTop = 358;
+
+const tCoordType kShuttleLowerRightLeft = 486;
+const tCoordType kShuttleLowerRightTop = 354;
+
+const tCoordType kShuttleCenterLeft = 260;
+const tCoordType kShuttleCenterTop = 336;
+
+const tCoordType kShuttleUpperLeftLeft = 30;
+const tCoordType kShuttleUpperLeftTop = 32;
+
+const tCoordType kShuttleUpperRightLeft = 506;
+const tCoordType kShuttleUpperRightTop = 52;
+
+const tCoordType kShuttleLeftEnergyLeft = 110;
+const tCoordType kShuttleLeftEnergyTop = 186;
+
+const tCoordType kShuttleRightEnergyLeft = 510;
+const tCoordType kShuttleRightEnergyTop = 186;
+
+const tCoordType kShuttleEnergyLeft = 186;
+const tCoordType kShuttleEnergyTop = 60;
+const tCoordType kShuttleEnergyWidth = 252;
+const tCoordType kShuttleEnergyHeight = 22;
+
+const tCoordType kPlanetStartLeft = kShuttleWindowLeft;
+const tCoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
+
+const tCoordType kPlanetStopLeft = kShuttleWindowLeft;
+const tCoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
+
+const tCoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
+const tCoordType kShuttleTractorTop = kShuttleWindowTop + 56;
+const tCoordType kShuttleTractorWidth = 348;
+const tCoordType kShuttleTractorHeight = 112;
+
+const tCoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
+const tCoordType kShuttleJunkTop = kShuttleWindowTop + 6;
+
+const tDisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
+const tDisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
+const tDisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
+const tDisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
+const tDisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
+const tDisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
+const tDisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
+const tDisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
+const tDisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
+const tDisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
+const tDisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
+const tDisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
+
+const TimeValue kShuttleSwingStart = 0;
+const TimeValue kShuttleSwingStop = 5 * 600;
+
+const TimeValue kCanyonChaseStart = kShuttleSwingStop;
+const TimeValue kCanyonChaseStop = 60 * 600 + 43 * 600 + 14 * 40;
+
+const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonChaseStart;
+const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
+											kLaunchTubeReachedTime;
+
+//	Left shuttle.
+
+const TimeValue kShuttleLeftIntroStart = 0;
+const TimeValue kShuttleLeftIntroStop = 400;
+
+const TimeValue kShuttleLeftBlankTime = 400;
+
+const TimeValue kShuttleLeftNormalTime = 440;
+
+const TimeValue kShuttleLeftAutoTestTime = 480;
+
+const TimeValue kShuttleLeftDamagedTime = 520;
+
+const TimeValue kShuttleLeftDampingTime = 560;
+
+const TimeValue kShuttleLeftGravitonTime = 600;
+
+const TimeValue kShuttleLeftTractorTime = 640;
+
+//	Right shuttle.
+
+const TimeValue kShuttleRightIntroStart = 0;
+const TimeValue kShuttleRightIntroStop = 400;
+
+const TimeValue kShuttleRightDestroyedStart = 400;
+const TimeValue kShuttleRightDestroyedStop = 840;
+
+const TimeValue kShuttleRightBlankTime = 840;
+
+const TimeValue kShuttleRightNormalTime = 880;
+
+const TimeValue kShuttleRightDamagedTime = 920;
+
+const TimeValue kShuttleRightTargetLockTime = 960;
+
+const TimeValue kShuttleRightGravitonTime = 1000;
+
+const TimeValue kShuttleRightOverloadTime = 1040;
+
+//	Lower Left shuttle.
+
+const TimeValue kShuttleLowerLeftCollisionTime = 0;
+
+const TimeValue kShuttleLowerLeftTubeTime = 40;
+
+const TimeValue kShuttleLowerLeftAutopilotTime = 80;
+
+//	Lower Right shuttle.
+
+const TimeValue kShuttleLowerRightOffTime = 0;
+
+const TimeValue kShuttleLowerRightTrackingTime = 40;
+
+const TimeValue kShuttleLowerRightTransportTime = 80;
+
+const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
+
+//	Center shuttle.
+
+const TimeValue kShuttleCenterBoardingTime = 0;
+
+const TimeValue kShuttleCenterCheckTime = 40;
+
+const TimeValue kShuttleCenterNavCompTime = 80;
+
+const TimeValue kShuttleCenterCommTime = 120;
+
+const TimeValue kShuttleCenterWeaponsTime = 160;
+
+const TimeValue kShuttleCenterAllSystemsTime = 200;
+
+const TimeValue kShuttleCenterSecureLooseTime = 240;
+
+const TimeValue kShuttleCenterAutoTestTime = 280;
+
+const TimeValue kShuttleCenterLaunchTime = 320;
+
+const TimeValue kShuttleCenterEnterTubeTime = 360;
+
+const TimeValue kShuttleCenterTargetSightedTime = 400;
+
+const TimeValue kShuttleCenterVerifyingTime = 440;
+
+const TimeValue kShuttleCenterScanningTime = 480;
+
+const TimeValue kShuttleCenterSafeTime = 520;
+
+//	Upper Left shuttle.
+
+const TimeValue kShuttleUpperLeftDimTime = 0;
+
+const TimeValue kShuttleUpperLeftDampingTime = 40;
+
+const TimeValue kShuttleUpperLeftGravitonTime = 80;
+
+const TimeValue kShuttleUpperLeftTractorTime = 120;
+
+//	Upper Right shuttle.
+
+const TimeValue kShuttleUpperRightLockedTime = 0;
+
+const TimeValue kShuttleUpperRightArmedTime = 40;
+
+const TimeValue kShuttleUpperRightAlienDestroyedTime = 80;
+
+const TimeValue kShuttleUpperRightOverloadTime = 120;
+
+const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
+
+//	Shuttle distance
+
+const int kShuttleDistance = 500;
+
+const int kJunkMaxDistance = kShuttleDistance;
+const int kJunkMinDistance = 40;
+
+const int kEnergyBeamMaxDistance = kShuttleDistance;
+const int kEnergyBeamMinDistance = 40;
+
+const int kGravitonMaxDistance = kShuttleDistance;
+const int kGravitonMinDistance = 40;
+
+
 class InventoryItem;
 class Mars;
 
-enum tMarsTimerCode {
+enum MarsTimerCode {
 	kMarsLaunchTubeReached,
 	kMarsCanyonChaseFinished,
 	kMarsSpaceChaseFinished // Player ran out of time...
 };
 
-struct tMarsTimerEvent {
+struct MarsTimerEvent {
 	Mars *mars;
-	tMarsTimerCode event;
+	MarsTimerCode event;
 };
 
-enum tShuttleWeaponSelection {
+enum ShuttleWeaponSelection {
 	kNoWeapon,
 	kEnergyBeam,
 	kGravitonCannon,
@@ -68,6 +298,7 @@ friend void lockThawTimerExpiredFunction(FunctionPtr *, void *);
 friend void bombTimerExpiredFunction(FunctionPtr *, void *);
 friend void bombTimerExpiredInGameFunction(FunctionPtr *, void *);
 friend void airStageExpiredFunction(FunctionPtr *, void *);
+friend void marsTimerFunction(FunctionPtr *, void *);
 
 public:
 	Mars(InputHandler *, PegasusEngine *);
@@ -91,6 +322,8 @@ public:
 
 	void checkContinuePoint(const tRoomID, const tDirectionConstant);
 
+	void setSoundFXLevel(const uint16);
+
 	bool canSolve();
 	void doSolve();
 
@@ -170,6 +403,10 @@ protected:
 	void timerExpired(const uint32);
 	void spotCompleted();
 
+	void doCanyonChase(void);
+	void startMarsTimer(TimeValue, TimeScale, MarsTimerCode);
+	void marsTimerExpired(MarsTimerEvent &);
+
 	// TODO: Space chase functions
 
 	Common::String getSoundSpotsName();
@@ -193,6 +430,19 @@ protected:
 	Picture _shuttleInterface4;
 	Movie _canyonChaseMovie;
 
+	MarsTimerEvent _marsEvent;
+
+	Movie _leftShuttleMovie;
+	Movie _rightShuttleMovie;
+	Movie _lowerLeftShuttleMovie;
+	Movie _lowerRightShuttleMovie;
+	Movie _centerShuttleMovie;
+	Movie _upperLeftShuttleMovie;
+	Movie _upperRightShuttleMovie;
+	Movie _leftDamageShuttleMovie;
+	Movie _rightDamageShuttleMovie;
+	ShuttleEnergyMeter _shuttleEnergyMeter;
+
 	// TODO: Space chase variables
 };
 
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp b/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
new file mode 100755
index 0000000..f16735d
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
@@ -0,0 +1,116 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/shuttleenergymeter.h"
+
+namespace Pegasus {
+
+ShuttleEnergyMeter::ShuttleEnergyMeter() : FaderAnimation(kNoDisplayElement) {
+	setBounds(kShuttleEnergyLeft, kShuttleEnergyTop, kShuttleEnergyLeft + kShuttleEnergyWidth,
+			kShuttleEnergyTop + kShuttleEnergyHeight);
+	setDisplayOrder(kShuttleStatusOrder);
+	setFaderValue(0);
+}
+
+void ShuttleEnergyMeter::initShuttleEnergyMeter() {
+	_meterImage.getImageFromPICTFile("Images/Mars/Shuttle Energy.pict");
+	_lowWarning.getImageFromPICTFile("Images/Mars/Shuttle Low Energy.pict");
+	startDisplaying();
+	show();
+}
+
+void ShuttleEnergyMeter::disposeShuttleEnergyMeter() {
+	stopFader();
+	hide();
+	stopDisplaying();
+	_meterImage.deallocateSurface();
+	_lowWarning.deallocateSurface();
+}
+
+void ShuttleEnergyMeter::draw(const Common::Rect &) {
+	int32 currentValue = getFaderValue();
+
+	Common::Rect r1, r2, bounds;
+	getBounds(bounds);
+
+	if (currentValue < kLowShuttleEnergy) {
+		_lowWarning.getSurfaceBounds(r1);
+		r2 = r1;
+		r2.moveTo(bounds.left, bounds.top);
+		_lowWarning.copyToCurrentPort(r1, r2);
+	}
+
+	_meterImage.getSurfaceBounds(r1);
+	r1.right = r1.left + r1.width() * currentValue / kFullShuttleEnergy;
+	r2 = r1;
+	r2.moveTo(bounds.left + 102, bounds.top + 6);
+	_meterImage.copyToCurrentPort(r1, r2);
+}
+
+void ShuttleEnergyMeter::powerUpMeter() {
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(kThirtyTicksPerSecond, 0, 0, 45, kFullShuttleEnergy);
+	startFader(moveSpec);
+}
+
+void ShuttleEnergyMeter::setEnergyValue(const int32 value) {
+	stopFader();
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(kFifteenTicksPerSecond, value * 3, value, kFullShuttleEnergy * 3, kFullShuttleEnergy);
+	startFader(moveSpec);
+}
+
+void ShuttleEnergyMeter::drainForTractorBeam() {	
+	stopFader();
+	TimeValue startTime = 0, stopTime;
+	int32 startValue = getFaderValue(), stopValue;
+
+	if (startValue < kTractorBeamEnergy) {
+		stopTime = startValue * kTractorBeamTime / kTractorBeamEnergy;
+		stopValue = 0;
+	} else {
+		stopTime = kTractorBeamTime;
+		stopValue = startValue - kTractorBeamEnergy;
+	}
+
+	FaderMoveSpec moveSpec;
+	moveSpec.makeTwoKnotFaderSpec(kTractorBeamScale, startTime, startValue, stopTime, stopValue);
+	startFader(moveSpec);
+}
+
+int32 ShuttleEnergyMeter::getEnergyValue() const {
+	return getFaderValue();
+}
+
+void ShuttleEnergyMeter::dropEnergyValue(const int32 delta) {
+	setEnergyValue(getFaderValue() - delta);
+}
+
+bool ShuttleEnergyMeter::enoughEnergyForTractorBeam() const {
+	return getEnergyValue() >= kTractorBeamEnergy;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.h b/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
new file mode 100755
index 0000000..169a0f6
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
@@ -0,0 +1,73 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEENERGYMETER_H
+#define PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEENERGYMETER_H
+
+#include "pegasus/fader.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+
+const int32 kFullShuttleEnergy = 100;
+// Low is 20 percent
+const int32 kLowShuttleEnergy = kFullShuttleEnergy * 20 / 100;
+
+const int32 kMinDampingEnergy = 15;
+const int32 kMinGravitonEnergy = 63;
+
+const TimeScale kTractorBeamScale = kFifteenTicksPerSecond;
+const TimeValue kTractorBeamTime = kFiveSeconds * kTractorBeamScale;
+const int32 kTractorBeamEnergy = kLowShuttleEnergy;
+
+class ShuttleEnergyMeter : public FaderAnimation {
+public:
+	ShuttleEnergyMeter();
+	~ShuttleEnergyMeter() {}
+
+	void initShuttleEnergyMeter();
+	void disposeShuttleEnergyMeter();
+
+	void powerUpMeter();
+
+	void setEnergyValue(const int32);
+	int32 getEnergyValue() const;
+
+	void dropEnergyValue(const int32);
+
+	void drainForTractorBeam();
+
+	bool enoughEnergyForTractorBeam() const;
+
+	void draw(const Common::Rect &);
+
+protected:
+	Surface _meterImage;
+	Surface _lowWarning;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 13145f3..f792194 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -109,6 +109,7 @@ public:
 	uint getRandomBit();
 	uint getRandomNumber(uint max);
 	void shuffleArray(int32 *arr, int32 count);
+	void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
@@ -246,7 +247,6 @@ private:
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
 	Common::RandomSource *_rnd;
 	void doSubChase();
-	void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: c3d9a1cb358e868b6af0a2c010dea017004aa90f
    https://github.com/scummvm/scummvm/commit/c3d9a1cb358e868b6af0a2c010dea017004aa90f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T17:52:22-07:00

Commit Message:
PEGASUS: Add the hermite code for the space chase

Changed paths:
  A engines/pegasus/neighborhood/mars/hermite.cpp
  A engines/pegasus/neighborhood/mars/hermite.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index c4f0f5e..27ba5b2 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -57,6 +57,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
+	neighborhood/mars/hermite.o \
 	neighborhood/mars/mars.o \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/shuttleenergymeter.o \
diff --git a/engines/pegasus/neighborhood/mars/hermite.cpp b/engines/pegasus/neighborhood/mars/hermite.cpp
new file mode 100755
index 0000000..814e92f
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/hermite.cpp
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/mars/hermite.h"
+
+namespace Pegasus {
+
+tCoordType hermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 time, int32 duration) {	
+	float t = (float)time / duration;
+	float tsq = t * t;
+	float tcu = t * tsq;
+	float tcu2 = tcu + tcu;
+	float tsq2 = tsq + tsq;
+	float tsq3 = tsq2 + tsq;
+	return (tCoordType)((tcu2 - tsq3 + 1) * p1 + (tsq3 - tcu2) * p4 + (tcu - tsq2 + t) * r1 + (tcu - tsq) * r4);
+}
+
+tCoordType dHermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 time, int32 duration) {	
+	float t = (float)time / duration;
+	float t2 = t + t;
+	float t4 = t2 + t2;
+	float t6 = t4 + t2;
+	float tsq = t * t;
+	float tsq3 = tsq + tsq + tsq;
+	float tsq6 = tsq3 + tsq3;
+	return (tCoordType)((tsq6 - t6) * p1 + (t6 - tsq6) * p4 + (tsq3 - t4 + 1) * r1 + (tsq3 - t2) * r4);
+}
+
+void hermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 time, int32 duration, Common::Point &result) {	
+	float t = (float)time / duration;
+	float tsq = t * t;
+	float tcu = t * tsq;
+	float tcu2 = tcu + tcu;
+	float tsq2 = tsq + tsq;
+	float tsq3 = tsq2 + tsq;
+
+	result.x = (int16)((tcu2 - tsq3 + 1) * p1.x + (tsq3 - tcu2) * p4.x + (tcu - tsq2 + t) * r1.x + (tcu - tsq) * r4.x);
+	result.y = (int16)((tcu2 - tsq3 + 1) * p1.y + (tsq3 - tcu2) * p4.y + (tcu - tsq2 + t) * r1.y + (tcu - tsq) * r4.y);
+}
+
+void dHermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 time, int32 duration, Common::Point &result) {	
+	float t = (float)time / duration;
+	float t2 = t + t;
+	float t4 = t2 + t2;
+	float t6 = t4 + t2;
+	float tsq = t * t;
+	float tsq3 = tsq + tsq + tsq;
+	float tsq6 = tsq3 + tsq3;
+
+	result.x = (int16)((tsq6 - t6) * p1.x + (t6 - tsq6) * p4.x + (tsq3 - t4 + 1) * r1.x + (tsq3 - t2) * r4.x);
+	result.y = (int16)((tsq6 - t6) * p1.y + (t6 - tsq6) * p4.y + (tsq3 - t4 + 1) * r1.y + (tsq3 - t2) * r4.y);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/hermite.h b/engines/pegasus/neighborhood/mars/hermite.h
new file mode 100755
index 0000000..de0122f
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/hermite.h
@@ -0,0 +1,41 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_HERMITE_H
+#define PEGASUS_NEIGHBORHOOD_MARS_HERMITE_H
+
+#include "common/rect.h"
+#include "pegasus/types.h"
+
+namespace Pegasus {
+
+tCoordType hermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 t, int32 duration);
+tCoordType dHermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 t, int32 duration);
+void hermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 t, int32 duration, Common::Point &result);
+void dHermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 t, int32 duration, Common::Point &result);
+
+} // End of namespace Pegasus
+
+#endif


Commit: cbcdf9909223d220e94829cd57a0e76b573bb1f9
    https://github.com/scummvm/scummvm/commit/cbcdf9909223d220e94829cd57a0e76b573bb1f9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T18:38:40-07:00

Commit Message:
PEGASUS: Add the basic 3D logic for the space chase

Changed paths:
  A engines/pegasus/neighborhood/mars/spacechase3d.cpp
  A engines/pegasus/neighborhood/mars/spacechase3d.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 27ba5b2..ae0552e 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -61,6 +61,7 @@ MODULE_OBJS = \
 	neighborhood/mars/mars.o \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/shuttleenergymeter.o \
+	neighborhood/mars/spacechase3d.o \
 	neighborhood/norad/norad.o \
 	neighborhood/norad/noradelevator.o \
 	neighborhood/norad/pressuredoor.o \
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.cpp b/engines/pegasus/neighborhood/mars/spacechase3d.cpp
new file mode 100755
index 0000000..a15898f
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/spacechase3d.cpp
@@ -0,0 +1,90 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/mars/spacechase3d.h"
+
+namespace Pegasus {
+
+void project3DTo2D(const Point3D &pt3D, Common::Point &pt2D) {
+	pt2D.x = (int)convertSpaceXToScreenH(pt3D.x, pt3D.z);
+	pt2D.y = (int)convertSpaceYToScreenV(pt3D.y, pt3D.z);
+}
+
+void project2DTo3D(const Common::Point &pt2D, const float screenDistance, Point3D &pt3D) {
+	pt3D.x = convertScreenHToSpaceX(pt2D.x, screenDistance);
+	pt3D.y = convertScreenVToSpaceY(pt2D.y, screenDistance);
+	pt3D.z = screenDistance;
+}
+
+void linearInterp(const Point3D &pt1, const Point3D &pt2, const float t, Point3D &pt3) {
+	pt3.x = pt1.x + (pt2.x - pt1.x) * t;
+	pt3.y = pt1.y + (pt2.y - pt1.y) * t;
+	pt3.z = pt1.z + (pt2.z - pt1.z) * t;
+}
+
+void linearInterp(const Point3D &pt1, const float x2, const float y2, const float z2, const float t, Point3D &pt3) {
+	pt3.x = pt1.x + (x2 - pt1.x) * t;
+	pt3.y = pt1.y + (y2 - pt1.y) * t;
+	pt3.z = pt1.z + (z2 - pt1.z) * t;
+}
+
+void linearInterp(const float x1, const float y1, const float z1, const Point3D &pt2, const float t, Point3D &pt3) {
+	pt3.x = x1 + (pt2.x - x1) * t;
+	pt3.y = y1 + (pt2.y - y1) * t;
+	pt3.z = z1 + (pt2.z - z1) * t;
+}
+
+void linearInterp(const float x1, const float y1, const float z1, const float x2, const float y2, const float z2,
+		const float t, Point3D &pt3) {
+	pt3.x = x1 + (x2 - x1) * t;
+	pt3.y = y1 + (y2 - y1) * t;
+	pt3.z = z1 + (z2 - z1) * t;
+}
+
+void linearInterp(const Common::Point &pt1, const Common::Point &pt2, const float t, Common::Point &pt3) {
+	pt3.x = (int)(pt1.x + (pt2.x - pt1.x) * t);
+	pt3.y = (int)(pt1.y + (pt2.y - pt1.y) * t);
+}
+
+void linearInterp(const Common::Point &pt1, const float h2, const float v2, const float t, Common::Point &pt3) {
+	pt3.x = (int)(pt1.x + (h2 - pt1.x) * t);
+	pt3.y = (int)(pt1.y + (v2 - pt1.y) * t);
+}
+
+void linearInterp(const float h1, const float v1, const Common::Point &pt2, const float t, Common::Point &pt3) {
+	pt3.x = (int)(h1 + (pt2.x - h1) * t);
+	pt3.y = (int)(v1 + (pt2.y - v1) * t);
+}
+
+void linearInterp(const float h1, const float v1, const float h2, const float v2, const float t, Common::Point &pt3) {
+	pt3.x = (int)(h1 + (h2 - h1) * t);
+	pt3.y = (int)(v1 + (v2 - v1) * t);
+}
+
+float linearInterp(const float arg1, const float arg2, const float t) {
+	return arg1 + (arg2 - arg1) * t;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.h b/engines/pegasus/neighborhood/mars/spacechase3d.h
new file mode 100755
index 0000000..3f22ba6
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/spacechase3d.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
+#define PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
+
+#include "pegasus/neighborhood/mars/mars.h"
+
+namespace Pegasus {
+
+// This is approximately right for a field of view of 72 degrees
+// (Should be set to the tangent of FOV).
+//const float kTangentFOV = 0.76254;
+const float kTangentFOV = 1.0;
+
+// Define these as macros and they can be used to define constants...
+#define convertSpaceXToScreenH(x, z) \
+	((x) / (z) * (kScreenWidth / (2 * kTangentFOV)) + kShuttleWindowMidH)
+
+#define convertSpaceYToScreenV(y, z) \
+	(kShuttleWindowMidV - (y) / (z) * (kScreenWidth / (2 * kTangentFOV)))
+
+#define convertScreenHToSpaceX(x, d) \
+	(((2.0 * kTangentFOV) / kScreenWidth) * ((float)(x) - kShuttleWindowMidH) * (d))
+
+#define convertScreenVToSpaceY(y, d) \
+	(((2.0 * kTangentFOV) / kScreenWidth) *	((float)kShuttleWindowMidV - (y)) * (d))
+
+struct Point3D {
+	float x, y, z;
+
+	Point3D() : x(0), y(0), z(0) {}
+	Point3D(float x1, float y1, float z1) : x(x1), y(y1), z(z1) {}
+	bool operator==(const Point3D &p) const { return x == p.x && y == p.y && z == p.z; }
+	bool operator!=(const Point3D &p) const { return x != p.x || y != p.y || z != p.z; }
+
+	void translate(float dx, float dy, float dz) {
+		x += dx;
+		y += dy;
+		z += dz;
+	}
+};
+
+const int kScreenWidth = kShuttleWindowWidth;
+
+bool isNegative(int a);
+bool isPositive(int a);
+int sign(int a);
+bool sameSign(int a, int b);
+
+void project3DTo2D(const Point3D &pt3D, Common::Point &pt2D);
+void project2DTo3D(const Common::Point &pt2D, const float screenDistance, Point3D &pt3D);
+
+void linearInterp(const Point3D &pt1, const Point3D &pt2, const float t, Point3D &pt3);
+void linearInterp(const Point3D &pt1, const float x2, const float y2, const float z2, const float t, Point3D &pt3);
+void linearInterp(const float x1, const float y1, const float z1, const Point3D &pt2, const float t, Point3D &pt3);
+void linearInterp(const float x1, const float y1, const float z1, const float x2,
+		const float y2, const float z2, const float t, Point3D &pt3);
+
+void linearInterp(const Common::Point &pt1, const Common::Point &pt2, const float t, Common::Point &pt3);
+void linearInterp(const Common::Point &pt1, const float h2, const float v2, const float t, Common::Point &pt3);
+void linearInterp(const float h1, const float v1, const Common::Point &pt2, const float t, Common::Point &pt3);
+void linearInterp(const float h1, const float v1, const float h2, const float v2, const float t, Common::Point &pt3);
+
+float linearInterp(const float arg1, const float arg2, const float t);
+
+} // End of namespace Pegasus
+
+#endif


Commit: 841f96868aed34a0edc02c4b32d66849cd9f350c
    https://github.com/scummvm/scummvm/commit/841f96868aed34a0edc02c4b32d66849cd9f350c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T18:54:13-07:00

Commit Message:
PEGASUS: Add the planet mover for the space chase

Changed paths:
  A engines/pegasus/neighborhood/mars/planetmover.cpp
  A engines/pegasus/neighborhood/mars/planetmover.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index ae0552e..904bc1f 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -59,6 +59,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/mars/hermite.o \
 	neighborhood/mars/mars.o \
+	neighborhood/mars/planetmover.o \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/shuttleenergymeter.o \
 	neighborhood/mars/spacechase3d.o \
diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
new file mode 100755
index 0000000..368c295
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/planetmover.cpp
@@ -0,0 +1,106 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/movie.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/hermite.h"
+#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/planetmover.h"
+
+namespace Pegasus {
+
+const TimeScale kRovingScale = kTractorBeamScale;
+const TimeValue kRovingTime = kTenSeconds * kRovingScale;
+const TimeValue kRovingSlop = kTwoSeconds * kRovingScale;
+
+const tCoordType kMaxVelocity = 20;
+
+PlanetMover::PlanetMover() {
+	setScale(kRovingScale);
+	_dropping = false;
+	_planetMovie = 0;
+}
+
+void PlanetMover::startMoving(Movie *planetMovie) {
+	_planetMovie = planetMovie;
+	_p4 = kPlanetStartTop;
+	_r4 = ((PegasusEngine *)g_engine)->getRandomNumber(kMaxVelocity - 1);
+	if (_r4 + _p4 < kPlanetStopTop)
+		_r4 = kPlanetStopTop - _p4;
+	newDestination();
+}
+
+void PlanetMover::stopMoving() {
+	stop();
+}
+
+void PlanetMover::dropPlanetOutOfSight() {	
+	stop();
+	tCoordType currentLoc = hermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
+	tCoordType currentV = dHermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
+	_p1 = currentLoc;
+	_r1 = currentV;
+	_p4 = kPlanetStartTop;
+	_r4 = 0;
+	_duration = kTractorBeamTime - kTractorBeamScale;
+	_dropping = true;
+	setSegment(0, _duration);
+	setTime(0);
+	start();
+}
+
+void PlanetMover::newDestination() {
+	_p1 = _p4;
+	_r1 = _r4;
+
+	// Slightly worked differently than the original to work into our random number stuff
+	uint diff = ABS(kPlanetStopTop - kPlanetStartTop);
+	_p4 = kPlanetStopTop + (diff != 0) ? ((PegasusEngine *)g_engine)->getRandomNumber(diff - 1) : 0;
+
+	_r4 = ((PegasusEngine *)g_engine)->getRandomNumber(kMaxVelocity - 1);
+
+	if (_r4 + _p4 < kPlanetStopTop)
+		_r4 = kPlanetStopTop - _p4;
+
+	stop();
+	_duration = kRovingTime + ((PegasusEngine *)g_engine)->getRandomNumber(kRovingSlop - 1);
+	setSegment(0, _duration);
+	setTime(0);
+	start();
+}
+
+void PlanetMover::timeChanged(const TimeValue) {
+	if (_planetMovie) {
+		_planetMovie->moveElementTo(kPlanetStartLeft, hermite(_p1, _p4, _r1, _r4, _lastTime, _duration));
+		if (_lastTime == _duration) {
+			if (_dropping)
+				stop();
+			else
+				newDestination();
+		}
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/planetmover.h b/engines/pegasus/neighborhood/mars/planetmover.h
new file mode 100755
index 0000000..faf76cd
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/planetmover.h
@@ -0,0 +1,57 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_PLANETMOVER_H
+#define PEGASUS_NEIGHBORHOOD_MARS_PLANETMOVER_H
+
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class Movie;
+
+class PlanetMover : IdlerTimeBase {
+public:
+	PlanetMover();
+	virtual ~PlanetMover() {}
+
+	void startMoving(Movie *);
+	void stopMoving();
+
+	void dropPlanetOutOfSight();
+
+protected:
+	void newDestination();
+	virtual void timeChanged(const TimeValue);
+	
+	Movie *_planetMovie;
+	tCoordType _p1, _p4, _r1, _r4;
+	TimeValue _duration;
+	bool _dropping;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: b3059e75e2597671abe501e62e73138f0825976b
    https://github.com/scummvm/scummvm/commit/b3059e75e2597671abe501e62e73138f0825976b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-23T19:50:54-07:00

Commit Message:
PEGASUS: Add the space junk stuff

Changed paths:
  A engines/pegasus/neighborhood/mars/spacejunk.cpp
  A engines/pegasus/neighborhood/mars/spacejunk.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 904bc1f..aca065a 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -63,6 +63,7 @@ MODULE_OBJS = \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/shuttleenergymeter.o \
 	neighborhood/mars/spacechase3d.o \
+	neighborhood/mars/spacejunk.o \
 	neighborhood/norad/norad.o \
 	neighborhood/norad/noradelevator.o \
 	neighborhood/norad/pressuredoor.o \
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 7404e1e..b5564bb 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -778,7 +778,7 @@ Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextH
 		_leftShuttleMovie(kNoDisplayElement), _rightShuttleMovie(kNoDisplayElement), _lowerLeftShuttleMovie(kNoDisplayElement),
 		_lowerRightShuttleMovie(kNoDisplayElement), _centerShuttleMovie(kNoDisplayElement),
 		_upperLeftShuttleMovie(kNoDisplayElement), _upperRightShuttleMovie(kNoDisplayElement),
-		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement) {
+		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement), _explosions(kNoDisplayElement) {
 	_noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
 	setIsItemTaken(kMarsCard);
 	setIsItemTaken(kAirMask);
@@ -2991,6 +2991,8 @@ void Mars::receiveNotification(Notification *notification, const tNotificationFl
 	} else if ((flag & kTimeForCanyonChaseFlag) != 0) {
 		doCanyonChase();
 	} else if ((flag & kExplosionFinishedFlag) != 0) {
+		_explosions.stop();
+		_explosions.hide();
 		// TODO
 	} else if ((flag & kTimeToTransportFlag) != 0) {
 		// TODO
@@ -3170,7 +3172,8 @@ void Mars::setSoundFXLevel(const uint16 level) {
 	if (_canyonChaseMovie.isMovieValid())
 		_canyonChaseMovie.setVolume(level);
 
-	// TODO: Explosions
+	if (_explosions.isMovieValid())
+		_explosions.setVolume(level);
 }
 
 void Mars::startMarsTimer(TimeValue time, TimeScale scale, MarsTimerCode code) {
@@ -3181,7 +3184,10 @@ void Mars::startMarsTimer(TimeValue time, TimeScale scale, MarsTimerCode code) {
 	_utilityFuse.lightFuse();
 }
 
-void Mars::marsTimerExpired(MarsTimerEvent &event) {	
+void Mars::marsTimerExpired(MarsTimerEvent &event) {
+	Common::Rect r;
+	uint16 x, y;
+
 	switch (event.event) {
 	case kMarsLaunchTubeReached:
 		_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftTubeTime);
@@ -3205,7 +3211,38 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
 		break;			
 	case kMarsSpaceChaseFinished:
 		// Player failed to stop the robot in time...
-		// TODO
+		_interruptionFilter = kFilterNoInput;
+
+		_rightShuttleMovie.setTime(kShuttleRightTargetLockTime);
+		_rightShuttleMovie.redrawMovieWorld();
+
+		_upperRightShuttleMovie.show();
+		_upperRightShuttleMovie.setTime(kShuttleUpperRightLockedTime);
+		_upperRightShuttleMovie.redrawMovieWorld();
+
+		_rightShuttleMovie.setTime(kShuttleRightGravitonTime);
+		_rightShuttleMovie.redrawMovieWorld();
+		_upperRightShuttleMovie.setTime(kShuttleUpperRightArmedTime);
+		_upperRightShuttleMovie.redrawMovieWorld();
+
+		_vm->delayShell(3, 1);
+
+		x = _vm->getRandomNumber(19);
+		y = _vm->getRandomNumber(19);
+
+		r = Common::Rect(kShuttleWindowMidH - x, kShuttleWindowMidV - y,
+				kShuttleWindowMidH - x + 20, kShuttleWindowMidV - y + 20);
+		showBigExplosion(r, kShuttleAlienShipOrder);
+			
+		while (_explosions.isRunning()) {
+			_vm->checkCallBacks();
+			_vm->refreshDisplay();
+			g_system->delayMillis(10);
+		}
+
+		throwAwayMarsShuttle();
+		reinstateMonocleInterface();
+		recallToTSAFailure();
 		break;
 	default:
 		break;
@@ -3214,6 +3251,92 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
 	_interruptionFilter = kFilterAllInput;
 }
 
+void Mars::throwAwayMarsShuttle() {
+	_shuttleInterface1.deallocateSurface();
+	_shuttleInterface1.stopDisplaying();
+	_shuttleInterface2.deallocateSurface();
+	_shuttleInterface2.stopDisplaying();
+	_shuttleInterface3.deallocateSurface();
+	_shuttleInterface3.stopDisplaying();
+	_shuttleInterface4.deallocateSurface();
+	_shuttleInterface4.stopDisplaying();
+
+	_spotSounds.disposeSound();
+	
+	_canyonChaseMovie.releaseMovie();
+	_canyonChaseMovie.stopDisplaying();
+	_leftShuttleMovie.releaseMovie();
+	_leftShuttleMovie.stopDisplaying();
+	_rightShuttleMovie.releaseMovie();
+	_rightShuttleMovie.stopDisplaying();
+	_lowerLeftShuttleMovie.releaseMovie();
+	_lowerLeftShuttleMovie.stopDisplaying();
+	_lowerRightShuttleMovie.releaseMovie();
+	_lowerRightShuttleMovie.stopDisplaying();
+	_centerShuttleMovie.releaseMovie();
+	_centerShuttleMovie.stopDisplaying();
+	_upperLeftShuttleMovie.releaseMovie();
+	_upperLeftShuttleMovie.stopDisplaying();
+	_upperRightShuttleMovie.releaseMovie();
+	_upperRightShuttleMovie.stopDisplaying();
+	_leftDamageShuttleMovie.releaseMovie();
+	_leftDamageShuttleMovie.stopDisplaying();
+	_rightDamageShuttleMovie.releaseMovie();
+	_rightDamageShuttleMovie.stopDisplaying();
+	
+	// TODO: Some more to do here
+
+	_explosions.releaseMovie();
+	_explosions.stopDisplaying();
+
+	loadLoopSound1("");
+}
+
+void Mars::showBigExplosion(const Common::Rect &r, const tDisplayOrder order) {
+	if (_explosions.isMovieValid()) {
+		_explosions.setDisplayOrder(order);
+
+		Common::Rect r2 = r;
+		int dx = r.width() / 2;
+		int dy = r.height() / 2;
+		r2.left -= dx;
+		r2.right += dx;
+		r2.top -= dy;
+		r2.bottom += dy;		
+
+		_explosions.setBounds(r2);
+		_explosions.show();
+		_explosions.stop();
+		_explosions.setSegment(kBigExplosionStart, kBigExplosionStop);
+		_explosions.setTime(kBigExplosionStart);
+		_explosionCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		_explosions.start();
+	}
+}
+
+void Mars::hitByJunk() {	
+	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
+	playSpotSoundSync(kMarsJunkCollisionIn, kMarsJunkCollisionOut);
+
+	if (_leftDamageShuttleMovie.getTime() == 0) {
+		die(kDeathRanIntoSpaceJunk);
+	} else {
+		TimeValue t = _leftDamageShuttleMovie.getTime() / 40;
+
+		if (t == 1)
+			playSpotSoundSync(kShuttleHullBreachIn, kShuttleHullBreachOut);
+
+		t = _leftShuttleMovie.getTime();
+		_leftShuttleMovie.setTime(kShuttleLeftDamagedTime);
+		_vm->delayShell(1, 3);
+		_leftShuttleMovie.setTime(t);
+	}
+}
+
+void Mars::setUpNextDropTime() {
+	// TODO
+}
+
 tAirQuality Mars::getAirQuality(const tRoomID room) {
 	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
 		return kAirQualityVacuum;
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index 1b29cdf..f2d7b33 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -312,6 +312,10 @@ public:
 
 	void checkAirMask();
 
+	void showBigExplosion(const Common::Rect &, const tDisplayOrder);
+	void hitByJunk();
+	void setUpNextDropTime();
+
 	Common::String getBriefingMovie();
 	Common::String getEnvScanMovie();
 	uint getNumHints();
@@ -406,6 +410,7 @@ protected:
 	void doCanyonChase(void);
 	void startMarsTimer(TimeValue, TimeScale, MarsTimerCode);
 	void marsTimerExpired(MarsTimerEvent &);
+	void throwAwayMarsShuttle();
 
 	// TODO: Space chase functions
 
@@ -442,6 +447,8 @@ protected:
 	Movie _leftDamageShuttleMovie;
 	Movie _rightDamageShuttleMovie;
 	ShuttleEnergyMeter _shuttleEnergyMeter;
+	ScalingMovie _explosions;
+	NotificationCallBack _explosionCallBack;
 
 	// TODO: Space chase variables
 };
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
new file mode 100755
index 0000000..8c78db4
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -0,0 +1,213 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/spacejunk.h"
+
+namespace Pegasus {
+
+//const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
+//const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
+const tCoordType kMaxBounceSize = 90;
+const tCoordType kBounceTargetHRange = 640 - kMaxBounceSize - 2;
+const tCoordType kBounceTargetVRange = 480 - kMaxBounceSize - 2;
+
+const float kJunkXTarget = 0;
+const float kJunkYTarget = 0;
+const float kJunkZTarget = kJunkMinDistance;
+
+SpaceJunk *g_spaceJunk = 0;
+
+SpaceJunk::SpaceJunk(const tDisplayElementID id) : ScalingMovie(id) {
+	_timer.setScale(kJunkTimeScale);
+	_bouncing = false;
+	g_spaceJunk = this;
+}
+
+SpaceJunk::~SpaceJunk() {
+	g_spaceJunk = 0;
+}
+
+void SpaceJunk::launchJunk(int16 whichJunk, tCoordType xOrigin, tCoordType yOrigin) {	
+	_bouncing = false;
+	TimeValue startTime = whichJunk * 16 * 40;
+	TimeValue stopTime = startTime + 16 * 40;
+
+	_launchPoint = Point3D(convertScreenHToSpaceX(xOrigin, kJunkMaxDistance),
+			convertScreenVToSpaceY(yOrigin, kJunkMaxDistance), kJunkMaxDistance);
+	startIdling();
+	stop();
+	setFlags(0);
+	setSegment(startTime, stopTime);
+	setFlags(kLoopTimeBase);
+	setTime(startTime);
+	start();
+	show();
+	_timer.stop();
+	_timer.setSegment(0, kJunkTravelTime);
+	_timer.setTime(0);
+
+	// Force it to set up correctly from the get-go
+	useIdleTime();
+
+	_timer.start();
+}
+
+void SpaceJunk::setCenter(const tCoordType centerX, const tCoordType centerY) {
+	_center.x = centerX;
+	_center.y = centerY;
+
+	Common::Rect r;
+	getBounds(r);
+	r.moveTo(centerX - (r.width() >> 1), centerY - (r.height() >> 1));
+	setBounds(r);
+}
+
+void SpaceJunk::setScaleSize(const tCoordType size) {
+	Common::Rect r;
+	r.left = _center.x - (size >> 1);
+	r.top = _center.y - (size >> 1);
+	r.right = r.left + size;
+	r.bottom = r.top + size;
+	setBounds(r);
+}
+
+void SpaceJunk::useIdleTime() {	
+	if (_bouncing) {
+		TimeValue time = _timer.getTime();
+		Common::Point pt;
+		pt.x = linearInterp(0, _bounceTime, time, _bounceStart.x, _bounceStop.x);
+		pt.y = linearInterp(0, _bounceTime, time, _bounceStart.y, _bounceStop.y);
+		tCoordType size = linearInterp(0, _bounceTime, time, _bounceSizeStart, _bounceSizeStop);
+		setCenter(pt.x, pt.y);
+		setScaleSize(size);
+
+		if (time == _bounceTime) {
+			stop();
+			stopIdling();
+			hide();
+			((Mars *)g_neighborhood)->setUpNextDropTime();
+		}
+	} else {
+		float t = (float)_timer.getTime() / kJunkTravelTime;
+		linearInterp(_launchPoint, kJunkXTarget, kJunkYTarget, kJunkZTarget, t, _junkPosition);
+
+		Common::Point pt2D;
+		project3DTo2D(_junkPosition, pt2D);
+		setCenter(pt2D.x, pt2D.y);
+		setScaleSize((int)(convertSpaceYToScreenV(_junkPosition.y - kJunkSize / 2, _junkPosition.z) - 
+				convertSpaceYToScreenV(_junkPosition.y + kJunkSize / 2, _junkPosition.z)));
+
+		if (t == 1.0) {
+			rebound(kCollisionReboundTime);
+			((Mars *)g_neighborhood)->hitByJunk();
+		}
+	}
+}
+
+bool SpaceJunk::pointInJunk(const Common::Point &pt) {
+	Common::Rect r;
+	getBounds(r);
+
+	int dx = r.width() / 4;
+	int dy = r.height() / 4;
+
+	r.left += dx;
+	r.right -= dx;
+	r.top += dy;
+	r.top -= dy;
+
+	return r.contains(pt);
+}
+
+void SpaceJunk::rebound(const TimeValue reboundTime) {
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	_bounceStart.x = (bounds.left + bounds.right) >> 1;
+	_bounceStart.y = (bounds.top + bounds.bottom) >> 1;
+
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	switch (vm->getRandomNumber(3)) {
+	case 0:
+		_bounceStop.x = kMaxBounceSize / 2 + 1 + vm->getRandomNumber(kBounceTargetHRange - 1);
+		_bounceStop.y = kMaxBounceSize / 2 + 1;
+		break;
+	case 1:
+		_bounceStop.x = kMaxBounceSize / 2 + 1 + vm->getRandomNumber(kBounceTargetHRange - 1);
+		_bounceStop.y = 480 - kMaxBounceSize / 2 + 1;
+		break;
+	case 2:
+		_bounceStop.x = kMaxBounceSize / 2 + 1;
+		_bounceStop.y = kMaxBounceSize / 2 + 1 + vm->getRandomNumber(kBounceTargetVRange - 1);
+		break;
+	case 3:
+		_bounceStop.x = 640 - kMaxBounceSize / 2 + 1;
+		_bounceStop.y = kMaxBounceSize / 2 + 1 + vm->getRandomNumber(kBounceTargetVRange - 1);
+		break;
+	}
+	
+	_bounceSizeStart = bounds.width();
+	_bounceSizeStop = MIN(_bounceSizeStart, kMaxBounceSize);
+
+	_timer.stop();
+	_timer.setSegment(0, reboundTime);
+	_bounceTime = reboundTime;
+	_timer.setTime(0);
+	_timer.start();
+
+	_bouncing = true;
+}
+
+void SpaceJunk::hitByEnergyBeam(Common::Point) {
+	rebound(kWeaponReboundTime);
+	setGlowing(true);
+	((PegasusEngine *)g_engine)->delayShell(1, 3);
+	setGlowing(false);
+}
+
+void SpaceJunk::hitByGravitonCannon(Common::Point impactPoint) {	
+	stop();
+	stopIdling();
+	hide();
+
+	Common::Rect r;
+	getBounds(r);
+	r = Common::Rect::center(impactPoint.x, impactPoint.y, r.width(), r.height());
+
+	((Mars *)g_neighborhood)->showBigExplosion(r, kShuttleJunkOrder);
+	((Mars *)g_neighborhood)->setUpNextDropTime();
+}
+
+void SpaceJunk::getJunkPosition(Point3D &position) {
+	position = _junkPosition;
+}
+
+bool SpaceJunk::isJunkFlying() {
+	return isIdling();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.h b/engines/pegasus/neighborhood/mars/spacejunk.h
new file mode 100755
index 0000000..d3315b0
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/spacejunk.h
@@ -0,0 +1,76 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_SPACEJUNK_H
+#define PEGASUS_NEIGHBORHOOD_MARS_SPACEJUNK_H
+
+#include "pegasus/neighborhood/mars/spacechase3d.h"
+
+namespace Pegasus {
+
+const tCoordType kJunkMaxScreenSize = 250;
+
+const float kJunkSize = convertScreenVToSpaceY(kShuttleWindowMidV - kJunkMaxScreenSize / 2, kJunkMinDistance) -
+		convertScreenVToSpaceY(kShuttleWindowMidV + kJunkMaxScreenSize / 2, kJunkMinDistance);
+
+class SpaceJunk : public ScalingMovie, public Idler {
+public:
+	SpaceJunk(const tDisplayElementID);
+	virtual ~SpaceJunk();
+
+	void setCenter(const tCoordType, const tCoordType);
+	void setScaleSize(const tCoordType);
+
+	void useIdleTime();
+	
+	void launchJunk(int16, tCoordType, tCoordType);
+	
+	void getJunkPosition(Point3D &);
+	bool isJunkFlying();
+
+	bool pointInJunk(const Common::Point &);
+
+	void hitByEnergyBeam(Common::Point impactPoint);
+	void hitByGravitonCannon(Common::Point impactPoint);
+
+	bool junkFlying() { return _timer.isRunning(); }
+
+protected:
+	void rebound(const TimeValue);
+
+	TimeBase _timer;
+	Point3D _launchPoint, _junkPosition;
+	Common::Point _center;
+	bool _bouncing;
+	Common::Point _bounceStart, _bounceStop;
+	tCoordType _bounceSizeStart, _bounceSizeStop;
+	TimeValue _bounceTime;
+};
+
+extern SpaceJunk *g_spaceJunk;
+
+} // End of namespace Pegasus
+
+#endif


Commit: 61311a2648f973c4ceb534243918d6462fea0488
    https://github.com/scummvm/scummvm/commit/61311a2648f973c4ceb534243918d6462fea0488
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-24T13:23:32-07:00

Commit Message:
PEGASUS: Add the robot ship

Changed paths:
  A engines/pegasus/neighborhood/mars/robotship.cpp
  A engines/pegasus/neighborhood/mars/robotship.h
    engines/pegasus/module.mk
    engines/pegasus/movie.h
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/neighborhood/mars/spacechase3d.cpp



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index aca065a..034ccaa 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -61,6 +61,7 @@ MODULE_OBJS = \
 	neighborhood/mars/mars.o \
 	neighborhood/mars/planetmover.o \
 	neighborhood/mars/reactor.o \
+	neighborhood/mars/robotship.o \
 	neighborhood/mars/shuttleenergymeter.o \
 	neighborhood/mars/spacechase3d.o \
 	neighborhood/mars/spacejunk.o \
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index b248cc1..db7b640 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -84,7 +84,7 @@ public:
 
 	void setBounds(const Common::Rect &);
 
-	void setGlowing(const bool);
+	void setGlowing(const bool glowing) { _glowing = glowing; }
 
 protected:
 	bool _glowing;
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index b5564bb..b6b9211 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -2993,7 +2993,19 @@ void Mars::receiveNotification(Notification *notification, const tNotificationFl
 	} else if ((flag & kExplosionFinishedFlag) != 0) {
 		_explosions.stop();
 		_explosions.hide();
-		// TODO
+		if (g_robotShip->isDead()) {
+			GameState.setMarsFinished(true);
+			_centerShuttleMovie.hide();
+			_upperRightShuttleMovie.show();
+			_upperRightShuttleMovie.setTime(kShuttleUpperRightTargetDestroyedTime);
+			_upperRightShuttleMovie.redrawMovieWorld();
+			_rightDamageShuttleMovie.hide();
+			playMovieSegment(&_rightShuttleMovie, kShuttleRightDestroyedStart, kShuttleRightDestroyedStop);
+			playSpotSoundSync(kShuttleDestroyedIn, kShuttleDestroyedOut);
+			throwAwayMarsShuttle();
+			reinstateMonocleInterface();
+			recallToTSASuccess();
+		}
 	} else if ((flag & kTimeToTransportFlag) != 0) {
 		// TODO
 	}
@@ -3285,7 +3297,8 @@ void Mars::throwAwayMarsShuttle() {
 	_rightDamageShuttleMovie.stopDisplaying();
 	
 	// TODO: Some more to do here
-
+	_shuttleEnergyMeter.disposeShuttleEnergyMeter();
+	_robotShip.cleanUpRobotShip();
 	_explosions.releaseMovie();
 	_explosions.stopDisplaying();
 
@@ -3314,6 +3327,28 @@ void Mars::showBigExplosion(const Common::Rect &r, const tDisplayOrder order) {
 	}
 }
 
+void Mars::showLittleExplosion(const Common::Rect &r, const tDisplayOrder order) {	
+	if (_explosions.isMovieValid()) {
+		_explosions.setDisplayOrder(order);
+
+		Common::Rect r2 = r;
+		int dx = r.width() / 2;
+		int dy = r.height() / 2;
+		r2.left -= dx;
+		r2.right += dx;
+		r2.top -= dy;
+		r2.bottom += dy;
+		_explosions.setBounds(r2);
+
+		_explosions.show();
+		_explosions.stop();
+		_explosions.setSegment(kLittleExplosionStart, kLittleExplosionStop);
+		_explosions.setTime(kLittleExplosionStart);
+		_explosionCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+		_explosions.start();
+	}
+}
+
 void Mars::hitByJunk() {	
 	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
 	playSpotSoundSync(kMarsJunkCollisionIn, kMarsJunkCollisionOut);
@@ -3334,7 +3369,39 @@ void Mars::hitByJunk() {
 }
 
 void Mars::setUpNextDropTime() {
-	// TODO
+	_robotShip.setUpNextDropTime();
+}
+
+void Mars::decreaseRobotShuttleEnergy(const int delta, Common::Point impactPoint) {	
+	_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getTime() - 40 * delta);
+	_rightDamageShuttleMovie.redrawMovieWorld();
+
+	if (_rightDamageShuttleMovie.getTime() == 0) {
+		Common::Rect r;
+		_robotShip.getShuttleBounds(r);
+		int size = MAX(r.width(), r.height());
+		r = Common::Rect::center(impactPoint.x, impactPoint.y, size, size);
+		_robotShip.killRobotShip();
+		showBigExplosion(r, kShuttleRobotShipOrder);
+	} else if (delta > 1) {
+		Common::Rect r;
+		_robotShip.getShuttleBounds(r);
+		int size = MIN(r.width(), r.height());
+		r = Common::Rect::center(impactPoint.x, impactPoint.y, size, size);
+		showLittleExplosion(r, kShuttleWeaponBackOrder);
+		TimeValue t = _rightShuttleMovie.getTime();
+		_rightShuttleMovie.setTime(kShuttleRightDamagedTime);
+		_rightShuttleMovie.redrawMovieWorld();
+		_vm->delayShell(1, 3);
+		_rightShuttleMovie.setTime(t);
+		_rightShuttleMovie.redrawMovieWorld();
+	}
+
+	if (_rightDamageShuttleMovie.getTime() <= 40) {
+		GameState.setScoringStoppedRobotsShuttle();
+		if (!GameState.getMarsHitRobotWithCannon())
+			GameState.setScoringMarsGandhi();
+	}
 }
 
 tAirQuality Mars::getAirQuality(const tRoomID room) {
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index f2d7b33..8e199d1 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -28,6 +28,7 @@
 
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/mars/reactor.h"
+#include "pegasus/neighborhood/mars/robotship.h"
 #include "pegasus/neighborhood/mars/shuttleenergymeter.h"
 
 namespace Pegasus {
@@ -313,7 +314,9 @@ public:
 	void checkAirMask();
 
 	void showBigExplosion(const Common::Rect &, const tDisplayOrder);
+	void showLittleExplosion(const Common::Rect &, const tDisplayOrder);
 	void hitByJunk();
+	void decreaseRobotShuttleEnergy(const int, Common::Point impactPoint);
 	void setUpNextDropTime();
 
 	Common::String getBriefingMovie();
@@ -447,6 +450,7 @@ protected:
 	Movie _leftDamageShuttleMovie;
 	Movie _rightDamageShuttleMovie;
 	ShuttleEnergyMeter _shuttleEnergyMeter;
+	RobotShip _robotShip;
 	ScalingMovie _explosions;
 	NotificationCallBack _explosionCallBack;
 
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
new file mode 100755
index 0000000..279bdd8
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -0,0 +1,269 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/hermite.h"
+#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/robotship.h"
+#include "pegasus/neighborhood/mars/spacechase3d.h"
+#include "pegasus/neighborhood/mars/spacejunk.h"
+
+namespace Pegasus {
+
+const TimeScale kRovingScale = kTractorBeamScale;
+const TimeValue kRovingTime = kSixSeconds * kRovingScale;
+const TimeValue kRovingSlop = kThreeSeconds * kRovingScale;
+
+const int kNumSpriteColumns = 15;
+const int kNumSpriteRows = 16;
+
+const tCoordType kInitialLocationLeft = kShuttleWindowLeft - 50;
+const tCoordType kInitialLocationTop = kShuttleWindowTop - 50;
+const tCoordType kInitialLocationWidth = kShuttleWindowWidth + 100;
+const tCoordType kInitialLocationHeight = kShuttleWindowHeight + 100;
+
+const tCoordType kVelocityVectorLength = 100;
+const tCoordType kVelocityVectorSlop = 50;
+
+const tCoordType kRovingLeft = kShuttleWindowLeft + 20;
+const tCoordType kRovingTop = kShuttleWindowTop + 20;
+const tCoordType kRovingWidth = kShuttleWindowMidH - kRovingLeft;
+const tCoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
+
+RobotShip* g_robotShip = 0;
+
+void timeToDropJunkFunction(FunctionPtr *, void *robotShip) {
+	((RobotShip *)robotShip)->timeToDropJunk();
+}
+
+RobotShip::RobotShip() : _spritesMovie(kNoDisplayElement) {
+	g_robotShip = this;
+	_shipRange = Common::Rect(kShuttleWindowLeft, kShuttleWindowTop, kShuttleWindowLeft + kShuttleWindowWidth,
+			kShuttleWindowTop + kShuttleWindowHeight);
+	setScale(kRovingScale);
+	_currentLocation.x = 0;
+	_currentLocation.y = 0;
+	_snaring = false;
+	_dropJunkFuse.setFunctionPtr(&timeToDropJunkFunction, (void *)this);
+}
+
+RobotShip::~RobotShip() {
+	g_robotShip = 0;
+}
+
+void RobotShip::initRobotShip() {	
+	_spritesMovie.initFromMovieFile("Images/Mars/Ship.movie", true);
+	_spritesMovie.setDisplayOrder(kShuttleRobotShipOrder);
+	_spritesMovie.moveElementTo(kPlanetStartLeft, kPlanetStartTop);
+	_spritesMovie.startDisplaying();
+	_spritesMovie.show();
+
+	Common::Rect r;
+	_spritesMovie.getBounds(r);
+	_shipWidth = r.width();
+	_shipHeight = r.height();
+	_dead = false;
+}
+
+void RobotShip::cleanUpRobotShip() {
+	_dropJunkFuse.stopFuse();
+	_spritesMovie.stopDisplaying();
+	_spritesMovie.releaseMovie();
+}
+
+void RobotShip::startMoving() {
+	if (((PegasusEngine *)g_engine)->getRandomBit()) {
+		_p4.x = kInitialLocationLeft + ((PegasusEngine *)g_engine)->getRandomNumber(kInitialLocationWidth - 1);
+		if (((PegasusEngine *)g_engine)->getRandomBit())
+			_p4.y = kInitialLocationTop;
+		else
+			_p4.y = kInitialLocationTop + kInitialLocationHeight;
+	} else {
+		_p4.y = kInitialLocationTop + ((PegasusEngine *)g_engine)->getRandomNumber(kInitialLocationHeight - 1);
+		if (((PegasusEngine *)g_engine)->getRandomBit())
+			_p4.x = kInitialLocationLeft;
+		else
+			_p4.x = kInitialLocationLeft + kInitialLocationWidth;
+	}
+
+	makeVelocityVector(_p4.x, _p4.y, kShuttleWindowLeft + kShuttleWindowWidth / 2,
+			kShuttleWindowTop + kShuttleWindowHeight / 2, _r4);
+	newDestination();
+	setUpNextDropTime();
+}
+
+void RobotShip::killRobotShip() {
+	cleanUpRobotShip();
+	_dead = true;
+}
+
+void RobotShip::setUpNextDropTime() {
+	if (!isSnared()) {
+		_dropJunkFuse.primeFuse(kJunkDropBaseTime + ((PegasusEngine *)g_engine)->getRandomNumber(kJunkDropSlopTime));
+		_dropJunkFuse.lightFuse();
+	}
+}
+
+void RobotShip::timeToDropJunk() {	
+	if (g_spaceJunk) {
+		tCoordType x, y;
+		_spritesMovie.getCenter(x, y);
+		g_spaceJunk->launchJunk(((PegasusEngine *)g_engine)->getRandomNumber(24), x, y);
+	}
+}
+
+void RobotShip::newDestination() {
+	_p1 = _p4;
+	_r1 = _r4;
+
+	_p4.x = kRovingLeft + ((PegasusEngine *)g_engine)->getRandomNumber(kRovingWidth - 1);
+	_p4.y = kRovingTop + ((PegasusEngine *)g_engine)->getRandomNumber(kRovingHeight - 1);
+
+	if (((PegasusEngine *)g_engine)->getRandomNumber(7) < 6) {
+		if (!sameSign(_p4.x - kShuttleWindowMidH, kShuttleWindowMidH - _p1.x)) {
+			if (sign(_p4.x - kShuttleWindowMidH) > 0)
+				_p4.x -= kRovingWidth;
+			else
+				_p4.x += kRovingWidth;
+		}
+	}
+
+	if (((PegasusEngine *)g_engine)->getRandomNumber(7) < 6) {
+		if (!sameSign(_p4.y - kShuttleWindowMidV, kShuttleWindowMidV - _p1.y)) {
+			if (sign(_p4.y - kShuttleWindowMidV) > 0)
+				_p4.y -= kRovingHeight;
+			else
+				_p4.y += kRovingHeight;
+		}
+	}
+	
+	makeVelocityVector(_p4.x, _p4.y, kShuttleWindowLeft + kShuttleWindowWidth / 2,
+			kShuttleWindowTop + kShuttleWindowHeight / 2, _r4);
+	stop();
+	_duration = kRovingTime + ((PegasusEngine *)g_engine)->getRandomNumber(kRovingSlop - 1);
+	setSegment(0, _duration);
+	setTime(0);
+	start();
+}
+
+void RobotShip::moveRobotTo(tCoordType x, tCoordType y) {
+	_currentLocation.x = x;
+	_currentLocation.y = y;
+
+	if (_spritesMovie.isMovieValid()) {
+		_spritesMovie.moveElementTo(x - (_shipWidth >> 1), y - (_shipHeight >> 1));
+
+		if (x < _shipRange.left)
+			x = 0;
+		else if (x > _shipRange.right - 1)
+			x = _shipRange.width() - 1;
+		else
+			x -= _shipRange.left;
+
+		if (y < _shipRange.top)
+			y = 0;
+		else if (y > _shipRange.bottom - 1)
+			y = _shipRange.height() - 1;
+		else
+			y -= _shipRange.top;
+
+		x = kNumSpriteColumns * x / _shipRange.width();
+		y = kNumSpriteRows * y / _shipRange.height();
+
+		_spritesMovie.setTime(40 * (x + y * kNumSpriteColumns));
+	}
+}
+
+bool RobotShip::pointInShuttle(Common::Point &pt) {
+	Common::Rect r;
+	_spritesMovie.getBounds(r);
+
+	int dx = r.width() / 4;
+	int dy = r.height() / 6;
+
+	r.left += dx;
+	r.right -= dx;
+	r.top += dy;
+	r.bottom -= dy;
+
+	return r.contains(pt);
+}
+
+void RobotShip::hitByEnergyBeam(Common::Point impactPoint) {
+	((Mars *)g_neighborhood)->decreaseRobotShuttleEnergy(1, impactPoint);
+	setGlowing(true);
+	((PegasusEngine *)g_engine)->delayShell(1, 3);
+	setGlowing(false);
+}
+
+void RobotShip::hitByGravitonCannon(Common::Point impactPoint) {
+	GameState.setMarsHitRobotWithCannon(true);
+	((Mars *)g_neighborhood)->decreaseRobotShuttleEnergy(6, impactPoint);
+}
+
+void RobotShip::snareByTractorBeam() {	
+	_dropJunkFuse.stopFuse();
+	stop();
+
+	Common::Point currentV;
+	dHermite(_p1, _p4, _r1, _r4, _lastTime, _duration, currentV);
+
+	_p1 = _currentLocation;
+	_r1 = currentV;
+	_p4.x = kShuttleWindowMidH;
+	_p4.y = kShuttleWindowMidV;
+	_r4.x = 0;
+	_r4.y = 0;
+	_duration = kTractorBeamTime;
+	_snaring = true;
+	setSegment(0, _duration);
+	setTime(0);
+	start();
+}
+
+void RobotShip::timeChanged(const TimeValue) {
+	Common::Point newLocation;
+	hermite(_p1, _p4, _r1, _r4, _lastTime, _duration, newLocation);
+	moveRobotTo(newLocation.x, newLocation.y);
+
+	if (_lastTime == _duration) {
+		if (_snaring)
+			stop();
+		else
+			newDestination();
+	}
+}
+
+void RobotShip::makeVelocityVector(tCoordType x1, tCoordType y1, tCoordType x2, tCoordType y2, Common::Point &vector) {	
+	tCoordType length = ((PegasusEngine *)g_engine)->getRandomNumber(kVelocityVectorSlop - 1) + kVelocityVectorLength;
+	vector.x = x2 - x1;
+	vector.y = y2 - y1;
+	float oldLength = sqrt(vector.x * vector.x + vector.y * vector.y);
+	vector.x = (int)(vector.x * length / oldLength);
+	vector.y = (int)(vector.y * length / oldLength);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/robotship.h b/engines/pegasus/neighborhood/mars/robotship.h
new file mode 100755
index 0000000..7c6d996
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/robotship.h
@@ -0,0 +1,86 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_ROBOTSHIP_H
+#define PEGASUS_NEIGHBORHOOD_MARS_ROBOTSHIP_H
+
+#include "pegasus/movie.h"
+
+namespace Pegasus {
+
+const tCoordType kShuttleMovieWidth = 114;
+const tCoordType kShuttleMovieHeight = 42;
+
+class RobotShip : IdlerTimeBase {
+friend void timeToDropJunkFunction(FunctionPtr *, void *);
+
+public:
+	RobotShip();
+	virtual ~RobotShip();
+
+	void initRobotShip();
+	void cleanUpRobotShip();
+
+	void startMoving();
+
+	void killRobotShip();
+
+	bool pointInShuttle(Common::Point&);
+
+	void hitByEnergyBeam(Common::Point impactPoint);
+	void hitByGravitonCannon(Common::Point impactPoint);
+
+	void getShuttleBounds(Common::Rect &r) { _spritesMovie.getBounds(r); }
+
+	void setGlowing(const bool glowing) { _spritesMovie.setGlowing(glowing); }
+
+	void snareByTractorBeam();
+	bool isSnared() { return _snaring && getTime() == _duration; }
+
+	bool isDead() { return _dead; }
+
+	void setUpNextDropTime();
+
+protected:
+	void newDestination();
+	void moveRobotTo(tCoordType, tCoordType);
+	void timeToDropJunk();
+	virtual void timeChanged(const TimeValue);
+	void makeVelocityVector(tCoordType, tCoordType, tCoordType, tCoordType, Common::Point &);
+
+	GlowingMovie _spritesMovie;
+	Common::Rect _shipRange;
+	int _shipWidth, _shipHeight;
+	Common::Point _p1, _p4, _r1, _r4, _currentLocation;
+	FuseFunction _dropJunkFuse;
+	TimeValue _duration;
+	bool _snaring, _dead;
+};
+
+extern RobotShip *g_robotShip;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.cpp b/engines/pegasus/neighborhood/mars/spacechase3d.cpp
index a15898f..05f8233 100755
--- a/engines/pegasus/neighborhood/mars/spacechase3d.cpp
+++ b/engines/pegasus/neighborhood/mars/spacechase3d.cpp
@@ -87,4 +87,20 @@ float linearInterp(const float arg1, const float arg2, const float t) {
 	return arg1 + (arg2 - arg1) * t;
 }
 
+bool isNegative(int a) {
+	return a < 0;
+}
+
+bool isPositive(int a) {
+	return a > 0;
+}
+
+int sign(int a) {
+	return isNegative(a) ? -1 : isPositive(a) ? 1 : 0;
+}
+
+bool sameSign(int a, int b) {
+	return sign(a) == sign(b);
+}
+
 } // End of namespace Pegasus


Commit: 9f1d9f369769ce550dc8e7f3fac55c02bb9ad7c4
    https://github.com/scummvm/scummvm/commit/9f1d9f369769ce550dc8e7f3fac55c02bb9ad7c4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T11:43:18-07:00

Commit Message:
PEGASUS: Add the shuttle weapon base class

Changed paths:
  A engines/pegasus/neighborhood/mars/shuttleweapon.cpp
  A engines/pegasus/neighborhood/mars/shuttleweapon.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 034ccaa..2103827 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -63,6 +63,7 @@ MODULE_OBJS = \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/robotship.o \
 	neighborhood/mars/shuttleenergymeter.o \
+	neighborhood/mars/shuttleweapon.o \
 	neighborhood/mars/spacechase3d.o \
 	neighborhood/mars/spacejunk.o \
 	neighborhood/norad/norad.o \
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
new file mode 100755
index 0000000..799cca8
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/mars/shuttleweapon.h"
+#include "pegasus/neighborhood/mars/spacejunk.h"
+
+namespace Pegasus {
+
+ShuttleWeapon::ShuttleWeapon() : IdlerAnimation(kNoDisplayElement) {
+	setScale(kShuttleWeaponScale);
+	_weaponDuration = kShuttleWeaponScale * 2;
+	setSegment(0, _weaponDuration);
+	setBounds(kShuttleWindowLeft, kShuttleWindowTop, kShuttleWindowLeft + kShuttleWindowWidth,
+			kShuttleWindowTop + kShuttleWindowHeight);
+	setDisplayOrder(kShuttleWeaponFrontOrder);
+}
+
+void ShuttleWeapon::initShuttleWeapon() {
+	startDisplaying();
+}
+
+void ShuttleWeapon::cleanUpShuttleWeapon() {
+	stop();
+	hide();
+	stopDisplaying();
+}
+
+bool ShuttleWeapon::canFireWeapon() {
+	return !isRunning();
+}
+
+void ShuttleWeapon::fireWeapon(const tCoordType hStop, const tCoordType vStop) {	
+	if (!isRunning()) {
+		stop();
+		setTime(0);
+		show();
+
+		Common::Point pt2D(hStop, vStop);
+		project2DTo3D(pt2D, kShuttleDistance, _weaponTarget);
+		_weaponTime = 0;
+		setDisplayOrder(kShuttleWeaponFrontOrder);
+		start();
+	}
+}
+
+void ShuttleWeapon::updateWeaponPosition() {
+	_weaponTime = (float)_lastTime / _weaponDuration;
+	linearInterp(_weaponOrigin, _weaponTarget, _weaponTime, _weaponLocation);
+
+	if (_weaponTime == 1.0) {
+		stop();
+		hide();
+	} else {
+		triggerRedraw();
+	}
+}
+
+void ShuttleWeapon::timeChanged(const TimeValue) {
+	updateWeaponPosition();
+
+	bool hit = false;
+	Common::Point impactPoint;
+
+	if (g_spaceJunk->isJunkFlying()) {
+		hit = collisionWithJunk(impactPoint);
+		if (hit) {
+			stop();
+			hide();
+			hitJunk(impactPoint);
+		}
+	}
+
+	if (!hit && _weaponTime == 1.0 && collisionWithShuttle(impactPoint))
+		hitShuttle(impactPoint);
+}
+
+bool ShuttleWeapon::collisionWithJunk(Common::Point &impactPoint) {
+	if (getDisplayOrder() == kShuttleWeaponFrontOrder) {
+		Point3D junkPosition;
+		g_spaceJunk->getJunkPosition(junkPosition);
+
+		if (junkPosition.z < _weaponLocation.z) {
+			setDisplayOrder(kShuttleWeaponBackOrder);
+			project3DTo2D(_weaponLocation, impactPoint);
+			return g_spaceJunk->pointInJunk(impactPoint);
+		}
+	}
+
+	return false;
+}
+
+bool ShuttleWeapon::collisionWithShuttle(Common::Point &impactPoint) {
+	project3DTo2D(_weaponLocation, impactPoint);
+	return g_robotShip->pointInShuttle(impactPoint);
+}
+
+void ShuttleWeapon::hitJunk(Common::Point impactPoint) {
+	g_spaceJunk->hitByEnergyBeam(impactPoint);
+}
+
+void ShuttleWeapon::hitShuttle(Common::Point impactPoint) {
+	g_robotShip->hitByEnergyBeam(impactPoint);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.h b/engines/pegasus/neighborhood/mars/shuttleweapon.h
new file mode 100755
index 0000000..b43dc92
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEWEAPON_H
+#define PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEWEAPON_H
+
+#include "pegasus/timers.h"
+#include "pegasus/neighborhood/mars/spacechase3d.h"
+
+namespace Pegasus {
+
+// Can fire multiple times?
+// For now, no...
+// clone2727 adds: And now forever
+
+const TimeScale kShuttleWeaponScale = kFifteenTicksPerSecond;
+
+class ShuttleWeapon : public IdlerAnimation {
+public:
+	ShuttleWeapon();
+	virtual ~ShuttleWeapon() {}
+
+	virtual void initShuttleWeapon();
+	virtual void cleanUpShuttleWeapon();
+
+	virtual void fireWeapon(const tCoordType, const tCoordType);
+
+	bool canFireWeapon();
+
+protected:
+	void timeChanged(const TimeValue);
+	virtual void updateWeaponPosition();
+	virtual bool collisionWithJunk(Common::Point &impactPoint);
+	bool collisionWithShuttle(Common::Point &impactPoint);
+	virtual void hitJunk(Common::Point impactPoint);
+	virtual void hitShuttle(Common::Point impactPoint);
+
+	Point3D _weaponOrigin, _weaponTarget;
+	Point3D _weaponLocation;
+	float _weaponTime;
+	TimeValue _weaponDuration;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 099070377965e2ec897355e89080491c42da0935
    https://github.com/scummvm/scummvm/commit/099070377965e2ec897355e89080491c42da0935
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T13:02:20-07:00

Commit Message:
PEGASUS: Add the graviton cannon!

Changed paths:
  A engines/pegasus/neighborhood/mars/gravitoncannon.cpp
  A engines/pegasus/neighborhood/mars/gravitoncannon.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2103827..5c86aeb 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -57,6 +57,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
+	neighborhood/mars/gravitoncannon.o \
 	neighborhood/mars/hermite.o \
 	neighborhood/mars/mars.o \
 	neighborhood/mars/planetmover.o \
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
new file mode 100755
index 0000000..e56fddc
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
@@ -0,0 +1,134 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/mars/gravitoncannon.h"
+#include "pegasus/neighborhood/mars/robotship.h"
+#include "pegasus/neighborhood/mars/spacejunk.h"
+
+namespace Pegasus {
+
+const TimeValue kGravitonTime = kOneSecond * kShuttleWeaponScale;
+
+const tCoordType kGravitonOriginH = kShuttleWindowLeft - 1;
+const tCoordType kGravitonOriginV = kShuttleWindowMidV;
+
+const float kGravitonXOrigin = convertScreenHToSpaceX(kGravitonOriginH, kGravitonMinDistance);
+const float kGravitonYOrigin = convertScreenVToSpaceY(kGravitonOriginV, kGravitonMinDistance);
+const float kGravitonZOrigin = kGravitonMinDistance;
+
+//	Width of graviton sprite...
+const tCoordType kGravitonMaxScreenWidth = 78;
+const tCoordType kGravitonMaxScreenHeight = 46;
+
+const float kGravitonWidth = convertScreenHToSpaceX(kShuttleWindowMidH + kGravitonMaxScreenWidth / 2, kGravitonMinDistance)
+		- convertScreenHToSpaceX(kShuttleWindowMidH - kGravitonMaxScreenWidth / 2, kGravitonMinDistance);
+const float kGravitonHeight = convertScreenVToSpaceY(kShuttleWindowMidV - kGravitonMaxScreenHeight / 2, kGravitonMinDistance)
+		- convertScreenVToSpaceY(kShuttleWindowMidV + kGravitonMaxScreenHeight / 2, kGravitonMinDistance);
+
+GravitonCannon::GravitonCannon() {
+	_weaponDuration = kGravitonTime;
+	setSegment(0, kGravitonTime);
+	_weaponOrigin = Point3D(kGravitonXOrigin, kGravitonYOrigin, kGravitonZOrigin);
+	_rightOrigin = Point3D(-kGravitonXOrigin, kGravitonYOrigin, kGravitonZOrigin);
+}
+
+void GravitonCannon::initShuttleWeapon() {
+	ShuttleWeapon::initShuttleWeapon();
+	_gravitonImage.getImageFromPICTFile("Images/Mars/Graviton Cannon");
+	_gravitonImage.getSurfaceBounds(_gravitonBounds);
+}
+
+void GravitonCannon::cleanUpShuttleWeapon() {
+	_gravitonImage.deallocateSurface();
+	ShuttleWeapon::cleanUpShuttleWeapon();
+}
+
+void GravitonCannon::draw(const Common::Rect &) {	
+	// Left graviton...
+	Point3D pt3D = _weaponLocation;
+	pt3D.translate(-kGravitonWidth / 2, kGravitonHeight / 2, 0);
+	Common::Point pt2D;
+	project3DTo2D(pt3D, pt2D);
+	Common::Rect gravitonRect;
+	gravitonRect.left = pt2D.x;
+	gravitonRect.top = pt2D.y;
+	
+	pt3D.translate(kGravitonWidth, -kGravitonHeight, 0);
+	project3DTo2D(pt3D, pt2D);
+	gravitonRect.right = pt2D.x;
+	gravitonRect.bottom = pt2D.y;
+
+	_gravitonImage.scaleTransparentCopy(_gravitonBounds, gravitonRect);
+	
+	// Right graviton...
+	pt3D = _rightLocation;
+	pt3D.translate(-kGravitonWidth / 2, kGravitonHeight / 2, 0);
+	project3DTo2D(pt3D, pt2D);
+	gravitonRect.left = pt2D.x;
+	gravitonRect.top = pt2D.y;
+	
+	pt3D.translate(kGravitonWidth, -kGravitonHeight, 0);
+	project3DTo2D(pt3D, pt2D);
+	gravitonRect.right = pt2D.x;
+	gravitonRect.bottom = pt2D.y;
+
+	_gravitonImage.scaleTransparentCopy(_gravitonBounds, gravitonRect);
+}
+
+void GravitonCannon::updateWeaponPosition() {
+	ShuttleWeapon::updateWeaponPosition();
+	if (_weaponTime != 1.0)
+		linearInterp(_rightOrigin, _weaponTarget, _weaponTime, _rightLocation);
+}
+
+bool GravitonCannon::collisionWithJunk(Common::Point &impactPoint) {	
+	if (getDisplayOrder() == kShuttleWeaponFrontOrder) {
+		Point3D junkPosition;
+		g_spaceJunk->getJunkPosition(junkPosition);
+
+		if (junkPosition.z < _weaponLocation.z) {
+			setDisplayOrder(kShuttleWeaponBackOrder);
+			project3DTo2D(_weaponLocation, impactPoint);
+
+			if (g_spaceJunk->pointInJunk(impactPoint))
+				return true;
+
+			project3DTo2D(_rightLocation, impactPoint);
+			return g_spaceJunk->pointInJunk(impactPoint);
+		}
+	}
+
+	return false;
+}
+
+void GravitonCannon::hitJunk(Common::Point impactPoint) {
+	g_spaceJunk->hitByGravitonCannon(impactPoint);
+}
+
+void GravitonCannon::hitShuttle(Common::Point impactPoint) {
+	g_robotShip->hitByGravitonCannon(impactPoint);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.h b/engines/pegasus/neighborhood/mars/gravitoncannon.h
new file mode 100755
index 0000000..1919c03
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_GRAVITONCANNON_H
+#define PEGASUS_NEIGHBORHOOD_MARS_GRAVITONCANNON_H
+
+#include "pegasus/neighborhood/mars/shuttleweapon.h"
+
+namespace Pegasus {
+
+class GravitonCannon : public ShuttleWeapon {
+	GravitonCannon();
+	virtual ~GravitonCannon() {}
+
+	void initShuttleWeapon();
+	void cleanUpShuttleWeapon();
+
+	void draw(const Common::Rect &);
+
+protected:
+	virtual void updateWeaponPosition();
+	virtual bool collisionWithJunk(Common::Point &impactPoint);
+	virtual void hitJunk(Common::Point impactPoint);
+	virtual void hitShuttle(Common::Point impactPoint);
+
+	Surface _gravitonImage;
+	Common::Rect _gravitonBounds;
+	Point3D _rightOrigin, _rightLocation;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 1bd2480f5f3de254928bbf68127a219a04fb0158
    https://github.com/scummvm/scummvm/commit/1bd2480f5f3de254928bbf68127a219a04fb0158
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T13:41:54-07:00

Commit Message:
PEGASUS: Add the tractor beam class

Changed paths:
  A engines/pegasus/neighborhood/mars/tractorbeam.cpp
  A engines/pegasus/neighborhood/mars/tractorbeam.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 5c86aeb..349ae8c 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -67,6 +67,7 @@ MODULE_OBJS = \
 	neighborhood/mars/shuttleweapon.o \
 	neighborhood/mars/spacechase3d.o \
 	neighborhood/mars/spacejunk.o \
+	neighborhood/mars/tractorbeam.o \
 	neighborhood/norad/norad.o \
 	neighborhood/norad/noradelevator.o \
 	neighborhood/norad/pressuredoor.o \
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.cpp b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
new file mode 100755
index 0000000..5c04b25
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
@@ -0,0 +1,139 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/tractorbeam.h"
+
+namespace Pegasus {
+
+TractorBeam::TractorBeam() : DisplayElement(kNoDisplayElement) {
+	setBounds(kShuttleTractorLeft, kShuttleTractorTop, kShuttleTractorLeft + kShuttleTractorWidth,
+			kShuttleTractorTop + kShuttleTractorHeight);
+	setDisplayOrder(kShuttleTractorBeamOrder);
+
+}
+
+const int kHalfWidth = kShuttleTractorWidth >> 1;
+const int kHalfHeight = kShuttleTractorHeight >> 1;
+
+const int kW3Vert = kHalfHeight * kHalfHeight * kHalfHeight;
+const int kW3Div2Vert = kW3Vert >> 1;
+
+const int kW3Horiz = kHalfWidth * kHalfWidth * kHalfWidth;
+const int kW3Div2Horiz = kW3Horiz >> 1;
+
+const int kMaxLevel = 50;
+
+const int kAVert = -2 * kMaxLevel;
+const int kBVert = 3 * kMaxLevel * kHalfHeight;
+
+#define READ_PIXEL(ptr) \
+	if (screen->format.bytesPerPixel == 2) \
+		color = READ_UINT16(ptr); \
+	else \
+		color = READ_UINT32(ptr); \
+	screen->format.colorToRGB(color, r, g, b)
+
+#define WRITE_PIXEL(ptr) \
+	color = screen->format.RGBToColor(r, g, b); \
+	if (screen->format.bytesPerPixel == 2) \
+		WRITE_UINT16(ptr, color); \
+	else \
+		WRITE_UINT32(ptr, color)
+
+#define DO_BLEND(ptr) \
+	READ_PIXEL(ptr); \
+	g += (((0xff - g) * blendHoriz) >> 8); \
+	b += (((0xff - b) * blendHoriz) >> 8); \
+	WRITE_PIXEL(ptr)
+
+void TractorBeam::draw(const Common::Rect &) {
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+
+	// Set up vertical DDA.
+	int blendVert = 0;
+	int dVert = 0;
+	int d1Vert = kAVert + kBVert;
+	int d2Vert = 6 * kAVert + 2 * kBVert;
+	int d3Vert = 6 * kAVert;
+
+	byte *rowPtrTop = (byte *)screen->getBasePtr(_bounds.left, _bounds.top);
+	byte *rowPtrBottom = (byte *)screen->getBasePtr(_bounds.left, _bounds.top + ((kHalfHeight << 1) - 1));
+
+	for (int y = kHalfHeight; y > 0; y--) {
+		// Set up horizontal DDA
+		int A = -2 * blendVert;
+		int B = 3 * blendVert * kHalfWidth;
+		int blendHoriz = 0;
+		int dHoriz = 0;
+		int d1Horiz = A + B;
+		int d2Horiz = 6 * A + 2 * B;
+		int d3Horiz = 6 * A;
+
+		byte *pTopLeft = rowPtrTop;
+		byte *pTopRight = rowPtrTop + (kHalfWidth * 2 - 1) * screen->format.bytesPerPixel;
+		byte *pBottomLeft = rowPtrBottom;
+		byte *pBottomRight = rowPtrBottom + (kHalfWidth * 2 - 1) * screen->format.bytesPerPixel;
+		
+		for (int x = kHalfWidth; x > 0; x--) {
+			byte r, g, b;
+			uint32 color;
+
+			DO_BLEND(pTopLeft);
+			DO_BLEND(pTopRight);
+			DO_BLEND(pBottomLeft);
+			DO_BLEND(pBottomRight);
+			
+			pTopLeft += screen->format.bytesPerPixel;
+			pBottomLeft += screen->format.bytesPerPixel;
+			pTopRight -= screen->format.bytesPerPixel;
+			pBottomRight -= screen->format.bytesPerPixel;
+			
+			while (dHoriz > kW3Div2Horiz) {
+				blendHoriz++;
+				dHoriz -= kW3Horiz;
+			}
+
+			dHoriz += d1Horiz;
+			d1Horiz += d2Horiz;
+			d2Horiz += d3Horiz;
+		}
+		
+		rowPtrTop += screen->pitch;
+		rowPtrBottom -= screen->pitch;
+		
+		while (dVert > kW3Div2Vert) {
+			blendVert++;
+			dVert -= kW3Vert;
+		}
+
+		dVert += d1Vert;
+		d1Vert += d2Vert;
+		d2Vert += d3Vert;
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.h b/engines/pegasus/neighborhood/mars/tractorbeam.h
new file mode 100755
index 0000000..cd87992
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/tractorbeam.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_TRACTORBEAM_H
+#define PEGASUS_NEIGHBORHOOD_MARS_TRACTORBEAM_H
+
+#include "pegasus/elements.h"
+
+namespace Pegasus {
+
+class TractorBeam : public DisplayElement {
+public:
+	TractorBeam();
+	virtual ~TractorBeam() {}
+
+	void draw(const Common::Rect &);
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 627684ca73833117425f3fd9d2257efb2157cb3c
    https://github.com/scummvm/scummvm/commit/627684ca73833117425f3fd9d2257efb2157cb3c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T16:20:02-07:00

Commit Message:
GRAPHICS: Make drawThickLine take a thickness in both x and y directions

Changed paths:
    engines/scumm/he/wiz_he.cpp
    graphics/primitives.cpp
    graphics/primitives.h



diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index f67922c..3995aba 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -2286,8 +2286,7 @@ void Wiz::fillWizLine(const WizParameters *params) {
 			lineP.depth = bitDepth;
 
 			if (params->processFlags & kWPFParams) {
-				assert (params->params2 == 1); // Catch untested usage
-				Graphics::drawThickLine(x1, y1, x2, y2, params->params1, color, drawProc, &lineP);
+				Graphics::drawThickLine(x1, y1, x2, y2, params->params1, params->params2, color, drawProc, &lineP);
 			} else {
 				Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP);
 			}
diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp
index 9834af6..b88db39 100644
--- a/graphics/primitives.cpp
+++ b/graphics/primitives.cpp
@@ -61,59 +61,21 @@ void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, i
 	}
 }
 
+void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color, void (*plotProc)(int, int, int, void *), void *data) {
+	assert(penX > 0 && penY > 0);
 
-// FIXME: This is a limited version of thick line drawing
-// it draws striped lines at some angles. Better algorithm could
-// be found here:
-//
-//   http://homepages.enterprise.net/murphy/thickline/index.html
-//
-// Feel free to replace it with better implementation
-void drawThickLine(int x0, int y0, int x1, int y1, int thickness, int color, void (*plotProc)(int, int, int, void *), void *data) {
-	const bool steep = ABS(y1 - y0) > ABS(x1 - x0);
-
-	if (steep) {
-		SWAP(x0, y0);
-		SWAP(x1, y1);
-	}
-
-	float dx = x1 - x0;
-	float dy = y1 - y0;
-	float d = (float)sqrt(dx * dx + dy * dy);
-
-	if (!d)
+	// Shortcut
+	if (penX == 1 && penY == 1) {
+		drawLine(x0, y0, x1, y1, color, plotProc, data);
 		return;
-
-	int thickX = (int)((float)thickness * dy / d / 2);
-	int thickY = (int)((float)thickness * dx / d / 2);
-
-	const int delta_x = ABS(x1 - x0);
-	const int delta_y = ABS(y1 - y0);
-	const int delta_err = delta_y;
-	int x = x0;
-	int y = y0;
-	int err = 0;
-
-	const int x_step = (x0 < x1) ? 1 : -1;
-	const int y_step = (y0 < y1) ? 1 : -1;
-
-	if (steep)
-		drawLine(y - thickY, x + thickX, y + thickY, x - thickX, color, plotProc, data);
-	else
-		drawLine(x - thickX, y + thickY, x + thickX, y - thickY, color, plotProc, data);
-
-	while (x != x1) {
-		x += x_step;
-		err += delta_err;
-		if (2 * err > delta_x) {
-			y += y_step;
-			err -= delta_x;
-		}
-		if (steep)
-			drawLine(y - thickY, x + thickX, y + thickY, x - thickX, color, plotProc, data);
-		else
-			drawLine(x - thickX, y + thickY, x + thickX, y - thickY, color, plotProc, data);
 	}
+
+	// TODO: Optimize this. It currently is a very naive way of handling
+	// thick lines since quite often it will be drawing to the same pixel
+	// multiple times.
+	for (int x = 0; x < penX; x++)
+		for (int y = 0; y < penY; y++)
+			drawLine(x0 + x, y0 + y, x1 + x, y1 + y, color, plotProc, data);
 }
 
 }	// End of namespace Graphics
diff --git a/graphics/primitives.h b/graphics/primitives.h
index 0ab2dab..f0780af 100644
--- a/graphics/primitives.h
+++ b/graphics/primitives.h
@@ -25,7 +25,7 @@
 namespace Graphics {
 
 void drawLine(int x0, int y0, int x1, int y1, int color, void (*plotProc)(int, int, int, void *), void *data);
-void drawThickLine(int x0, int y0, int x1, int y1, int thickness, int color, void (*plotProc)(int, int, int, void *), void *data);
+void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color, void (*plotProc)(int, int, int, void *), void *data);
 
 }	// End of namespace Graphics
 


Commit: c2af197edb7719ca4d4ad77d778c135db6149ba4
    https://github.com/scummvm/scummvm/commit/c2af197edb7719ca4d4ad77d778c135db6149ba4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T16:20:28-07:00

Commit Message:
GRAPHICS: Add a Surface wrapper for drawThickLine

Changed paths:
    graphics/surface.cpp
    graphics/surface.h



diff --git a/graphics/surface.cpp b/graphics/surface.cpp
index e0b25f2..c1c676e 100644
--- a/graphics/surface.cpp
+++ b/graphics/surface.cpp
@@ -48,6 +48,17 @@ void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
 		error("Surface::drawLine: bytesPerPixel must be 1, 2, or 4");
 }
 
+void Surface::drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color) {
+	if (format.bytesPerPixel == 1)
+		Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<byte>, this);
+	else if (format.bytesPerPixel == 2)
+		Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<uint16>, this);
+	else if (format.bytesPerPixel == 4)
+		Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<uint32>, this);
+	else
+		error("Surface::drawThickLine: bytesPerPixel must be 1, 2, or 4");
+}
+
 void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
 	free();
 
diff --git a/graphics/surface.h b/graphics/surface.h
index 018a283..9d91a60 100644
--- a/graphics/surface.h
+++ b/graphics/surface.h
@@ -142,10 +142,26 @@ struct Surface {
 	 * @param x1 The x coordinate of the end point.
 	 * @param y1 The y coordinate of the end point.
 	 * @param color The color of the line.
+	 * @note This is just a wrapper around Graphics::drawLine
 	 */
 	void drawLine(int x0, int y0, int x1, int y1, uint32 color);
 
 	/**
+	 * Draw a thick line.
+	 *
+	 * @param x0 The x coordinate of the start point.
+	 * @param y0 The y coordiante of the start point.
+	 * @param x1 The x coordinate of the end point.
+	 * @param y1 The y coordinate of the end point.
+	 * @param penX The width of the pen (thickness in the x direction)
+	 * @param penY The height of the pen (thickness in the y direction)
+	 * @param color The color of the line.
+	 * @note This is just a wrapper around Graphics::drawThickLine
+	 * @note The x/y coordinates of the start and end points are the upper-left most part of the pen
+	 */
+	void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color);
+
+	/**
 	 * Draw a horizontal line.
 	 *
 	 * @param x The start x coordinate of the line.


Commit: 015d81b742b2f83b8eab12f88741fe42b87f8d18
    https://github.com/scummvm/scummvm/commit/015d81b742b2f83b8eab12f88741fe42b87f8d18
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T16:24:11-07:00

Commit Message:
PEGASUS: Add the energy beam weapon

Changed paths:
  A engines/pegasus/neighborhood/mars/energybeam.cpp
  A engines/pegasus/neighborhood/mars/energybeam.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 349ae8c..acccd87 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -57,6 +57,7 @@ MODULE_OBJS = \
 	neighborhood/caldoria/caldoria4dsystem.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
+	neighborhood/mars/energybeam.o \
 	neighborhood/mars/gravitoncannon.o \
 	neighborhood/mars/hermite.o \
 	neighborhood/mars/mars.o \
diff --git a/engines/pegasus/neighborhood/mars/energybeam.cpp b/engines/pegasus/neighborhood/mars/energybeam.cpp
new file mode 100755
index 0000000..6a30c48
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/energybeam.cpp
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/energybeam.h"
+
+namespace Pegasus {
+
+const TimeValue kEnergyBeamTime = kOneSecond * kShuttleWeaponScale / 2;
+
+const tCoordType kEnergyBeamOriginH = kShuttleWindowMidH;
+const tCoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
+
+const float kBeamXOrigin = convertScreenHToSpaceX(kEnergyBeamOriginH, kEnergyBeamMinDistance);
+const float kBeamYOrigin = convertScreenVToSpaceY(kEnergyBeamOriginV, kEnergyBeamMinDistance);
+const float kBeamZOrigin = kEnergyBeamMinDistance;
+
+EnergyBeam::EnergyBeam() {
+	_weaponDuration = kEnergyBeamTime;
+	setSegment(0, kEnergyBeamTime);
+	_weaponOrigin = Point3D(kBeamXOrigin, kBeamYOrigin, kBeamZOrigin);
+}
+
+void EnergyBeam::draw(const Common::Rect &) {
+	static const int kBeamColorRed1 = 224;
+	static const int kBeamColorRed2 = 64;
+
+	Graphics::Surface *surface = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+
+	byte red = linearInterp(0, kEnergyBeamTime, _lastTime, kBeamColorRed1, kBeamColorRed2);
+	uint32 color = surface->format.RGBToColor(red, 0, 0);
+
+	Point3D startPoint;
+	if (_weaponTime < 0.1)
+		startPoint = _weaponOrigin;
+	else
+		linearInterp(_weaponOrigin, _weaponTarget, _weaponTime - 0.1, startPoint);
+
+	Common::Point lineStart;
+	project3DTo2D(startPoint, lineStart);
+
+	Common::Point lineEnd;
+	project3DTo2D(_weaponLocation, lineEnd);
+
+	surface->drawThickLine(lineStart.x, lineStart.y, lineEnd.x, lineEnd.y, 2, 1, color);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/energybeam.h b/engines/pegasus/neighborhood/mars/energybeam.h
new file mode 100755
index 0000000..715ed4b
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/energybeam.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_ENERGYBEAM_H
+#define PEGASUS_NEIGHBORHOOD_MARS_ENERGYBEAM_H
+
+#include "pegasus/neighborhood/mars/shuttleweapon.h"
+
+namespace Pegasus {
+
+class EnergyBeam : public ShuttleWeapon {
+public:
+	EnergyBeam();
+	virtual ~EnergyBeam() {}
+
+	void draw(const Common::Rect &);
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: e29d00e6b6020dffcd80419e707ec4b0e58bef46
    https://github.com/scummvm/scummvm/commit/e29d00e6b6020dffcd80419e707ec4b0e58bef46
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T16:56:52-07:00

Commit Message:
PEGASUS: Add the Shuttle HUD

Changed paths:
  A engines/pegasus/neighborhood/mars/shuttlehud.cpp
  A engines/pegasus/neighborhood/mars/shuttlehud.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index acccd87..eaf36b8 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -65,6 +65,7 @@ MODULE_OBJS = \
 	neighborhood/mars/reactor.o \
 	neighborhood/mars/robotship.o \
 	neighborhood/mars/shuttleenergymeter.o \
+	neighborhood/mars/shuttlehud.o \
 	neighborhood/mars/shuttleweapon.o \
 	neighborhood/mars/spacechase3d.o \
 	neighborhood/mars/spacejunk.o \
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
new file mode 100755
index 0000000..71f5b1e
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -0,0 +1,246 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/robotship.h"
+#include "pegasus/neighborhood/mars/shuttlehud.h"
+
+namespace Pegasus {
+
+const tCoordType kHUDTargetGridLeft = kShuttleWindowLeft + 16;
+const tCoordType kHUDTargetGridTop = kShuttleWindowTop + 8;
+const tCoordType kHUDTargetGridWidth = 328;
+const tCoordType kHUDTargetGridHeight = 206;
+
+const tCoordType kHUDRS232Left = kHUDTargetGridLeft + 264;
+const tCoordType kHUDRS232Top = kHUDTargetGridTop + 2;
+
+const tCoordType kHUDLockLeft = kShuttleWindowLeft + 101;
+const tCoordType kHUDLockTop = kShuttleWindowTop + 49;
+const tCoordType kHUDLockWidth = 145;
+const tCoordType kHUDLockHeight = 124;
+
+const tCoordType kTractorLockWidth = 50;
+const tCoordType kTractorLockHeight = 30;
+
+const tCoordType kTractorLockLeft = kShuttleWindowMidH - kTractorLockWidth / 2;
+const tCoordType kTractorLockTop = kShuttleWindowMidV - kTractorLockHeight / 2;
+const tCoordType kTractorLockRight = kTractorLockLeft + kTractorLockWidth;
+const tCoordType kTractorLockBottom = kTractorLockTop + kTractorLockHeight;
+
+static const uint16 s_RS232Data[] = {
+	0xF0E1, 0xCE70,
+	0xF9E1, 0xEF78,
+	0x4900, 0x2108,
+	0x79C0, 0xE738,
+	0x70E1, 0xC770,
+	0x5821, 0x0140,
+	0x4DE1, 0xEF78,
+	0x45C1, 0xEE78
+};
+
+static const uint16 s_lockData[] = {
+	0xE007, 0xFE1F, 0xF8E0, 0x7000,
+	0xE00F, 0xFF3F, 0xFCE0, 0xE000,
+	0xE00E, 0x0738, 0x1CE1, 0xC000,
+	0xE00E, 0x0738, 0x00FF, 0x8000,
+	0xE00E, 0x0738, 0x00FF, 0x0000,
+	0xE00E, 0x0738, 0x00E3, 0x8000,
+	0xE00E, 0x0738, 0x1CE1, 0xC000,
+	0xFFCF, 0xFF3F, 0xFCE0, 0xE000,
+	0xFFC7, 0xFE1F, 0xF8E0, 0x7000
+};
+
+#define drawHUDLockLine(x1, y1, x2, y2, penX, penY, color) \
+	screen->drawThickLine((x1) + kHUDLockLeft, (y1) + kHUDLockTop, \
+			(x2) + kHUDLockLeft, (y2) + kHUDLockTop, penX, penY, color)
+
+#define drawHUDLockArrows(offset, color) \
+	drawHUDLockLine(63, 0 + (offset), 68, 5 + (offset), 1, 3, color); \
+	drawHUDLockLine(71, 8 + (offset), 77, 14 + (offset), 1, 3, color); \
+	drawHUDLockLine(78, 14 + (offset), 84, 8 + (offset), 1, 3, color); \
+	drawHUDLockLine(87, 5 + (offset), 92, 0 + (offset), 1, 3, color); \
+	drawHUDLockLine(63, 121 - (offset), 68, 116 - (offset), 1, 3, color); \
+	drawHUDLockLine(71, 113 - (offset), 77, 107 - (offset), 1, 3, color); \
+	drawHUDLockLine(78, 107 - (offset), 84, 113 - (offset), 1, 3, color); \
+	drawHUDLockLine(87, 116 - (offset), 92, 121 - (offset), 1, 3, color); \
+\
+	drawHUDLockLine(13 + (offset), 47, 18 + (offset), 52, 3, 1, color); \
+	drawHUDLockLine(21 + (offset), 55, 27 + (offset), 61, 3, 1, color); \
+	drawHUDLockLine(27 + (offset), 62, 21 + (offset), 68, 3, 1, color); \
+	drawHUDLockLine(18 + (offset), 71, 13 + (offset), 76, 3, 1, color); \
+	drawHUDLockLine(142 - (offset), 47, 137 - (offset), 52, 3, 1, color); \
+	drawHUDLockLine(134 - (offset), 55, 128 - (offset), 61, 3, 1, color); \
+	drawHUDLockLine(128 - (offset), 62, 134 - (offset), 68, 3, 1, color); \
+	drawHUDLockLine(137 - (offset), 71, 142 - (offset), 76, 3, 1, color)
+
+ShuttleHUD::ShuttleHUD() : DisplayElement(kNoDisplayElement) {
+	_lightGreen = g_system->getScreenFormat().RGBToColor(0, 204, 0);
+	_gridDarkGreen = g_system->getScreenFormat().RGBToColor(0, 85, 0);
+	_lockDarkGreen1 = g_system->getScreenFormat().RGBToColor(0, 68, 0);
+	_lockDarkGreen2 = g_system->getScreenFormat().RGBToColor(0, 65, 0);
+
+	_targetLocked = false;
+	setBounds(kShuttleWindowLeft, kShuttleWindowTop, kShuttleWindowLeft + kShuttleWindowWidth,
+			kShuttleWindowTop + kShuttleWindowHeight);
+	setDisplayOrder(kShuttleHUDOrder);
+}
+
+void ShuttleHUD::initShuttleHUD() {
+	startDisplaying();
+	startIdling();
+}
+
+void ShuttleHUD::cleanUpShuttleHUD() {
+	stopIdling();
+	stopDisplaying();
+}
+
+void ShuttleHUD::showTargetGrid() {
+	show();
+}
+
+void ShuttleHUD::hideTargetGrid() {
+	hide();
+	unlockOnTarget();
+}
+
+void ShuttleHUD::useIdleTime() {	
+	if (isVisible()) {
+		Common::Rect r;
+		g_robotShip->getShuttleBounds(r);
+		if (r.left < kTractorLockRight && r.right > kTractorLockLeft && r.top < kTractorLockBottom && r.bottom > kTractorLockTop)
+			lockOnTarget();
+		else
+			unlockOnTarget();
+	}
+}
+
+void ShuttleHUD::lockOnTarget() {
+	if (!_targetLocked) {
+		_targetLocked = true;
+		triggerRedraw();
+	}
+}
+
+void ShuttleHUD::unlockOnTarget() {
+	if (_targetLocked) {
+		_targetLocked = false;
+		triggerRedraw();
+	}
+}
+
+void ShuttleHUD::draw(const Common::Rect &) {
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getWorkArea();
+
+	for (int y = 0; y < 35; y++) {
+		Common::Rect r;
+
+		if (y & 1) {
+			if (y == 17) {
+				r = Common::Rect(0, 0, 4, 2);
+				r.moveTo(kHUDTargetGridLeft + 8, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 12, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+
+				r = Common::Rect(0, 0, 6, 2);
+				r.moveTo(kHUDTargetGridLeft + 2, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _lightGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 8, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _lightGreen);
+
+				r = Common::Rect(0, 0, 23, 2);
+				r.moveTo(kHUDTargetGridLeft + 12, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _lightGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 35, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _lightGreen);
+			} else if (y == 1 || y == 15 || y == 19 || y == 33) {
+				r = Common::Rect(0, 0, 4, 2);
+				r.moveTo(kHUDTargetGridLeft + 2, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 6, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+
+				r = Common::Rect(0, 0, 15, 2);
+				r.moveTo(kHUDTargetGridLeft + 8, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 23, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+			} else {
+				r = Common::Rect(0, 0, 4, 2);
+				r.moveTo(kHUDTargetGridLeft + 2, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 6, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+
+				r = Common::Rect(0, 0, 10, 2);
+				r.moveTo(kHUDTargetGridLeft + 8, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+				r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 18, y * 6 + kHUDTargetGridTop);
+				screen->fillRect(r, _gridDarkGreen);
+			}
+		} else {
+			r = Common::Rect(0, 0, 2, 2);
+			r.moveTo(kHUDTargetGridLeft, y * 6 + kHUDTargetGridTop);
+			screen->fillRect(r, _gridDarkGreen);
+			r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 2, y * 6 + kHUDTargetGridTop);
+			screen->fillRect(r, _gridDarkGreen);
+
+			r = Common::Rect(0, 0, 4, 2);
+			r.moveTo(kHUDTargetGridLeft + 8, y * 6 + kHUDTargetGridTop);
+			screen->fillRect(r, _gridDarkGreen);
+			r.moveTo(kHUDTargetGridLeft + kHUDTargetGridWidth - 12, y * 6 + kHUDTargetGridTop);
+			screen->fillRect(r, _gridDarkGreen);
+		}
+	}
+
+	drawOneBitImageOr(screen, s_lockData, 4, Common::Rect(kHUDRS232Left, kHUDRS232Top,
+			kHUDRS232Left + 29, kHUDRS232Top + 8), _gridDarkGreen);
+
+	if (_targetLocked) {
+		drawHUDLockArrows(0, _lockDarkGreen2);
+		drawHUDLockArrows(12, _lockDarkGreen1);
+		drawHUDLockArrows(24, _lightGreen);
+		drawOneBitImageOr(screen, s_lockData, 8, Common::Rect(kHUDLockLeft, kHUDLockTop + 115,
+				kHUDLockLeft + 52, kHUDLockTop + 115 + 9), _lightGreen);
+	}
+}
+
+void ShuttleHUD::drawOneBitImageOr(Graphics::Surface *screen, const uint16 *data, int pitch, const Common::Rect &bounds, uint32 color) {
+	for (int y = 0; y < bounds.height(); y++) {
+		for (int x = 0; x < bounds.width(); x++) {
+			if ((data[y * pitch + x / 16] & (1 << (15 - (x % 16)))) != 0) {
+				if (screen->format.bytesPerPixel == 2)
+					WRITE_UINT16((byte *)screen->getBasePtr(x + bounds.left, y + bounds.top), color);
+				else
+					WRITE_UINT32((byte *)screen->getBasePtr(x + bounds.left, y + bounds.top), color);
+			}
+		}
+	}
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.h b/engines/pegasus/neighborhood/mars/shuttlehud.h
new file mode 100755
index 0000000..7cab9ed
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEHUD_H
+#define PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEHUD_H
+
+#include "pegasus/elements.h"
+#include "pegasus/timers.h"
+
+namespace Pegasus {
+
+class ShuttleHUD : public DisplayElement, public Idler {
+public:
+	ShuttleHUD();
+	virtual ~ShuttleHUD();
+
+	void showTargetGrid();
+	void hideTargetGrid();
+
+	void initShuttleHUD();
+	void cleanUpShuttleHUD();
+
+	bool isTargetLocked() { return _targetLocked; }
+
+	void draw(const Common::Rect &);
+
+protected:
+	void useIdleTime();
+	void lockOnTarget();
+	void unlockOnTarget();
+	void drawOneBitImageOr(Graphics::Surface *, const uint16 *, int, const Common::Rect &, uint32);
+
+	bool _targetLocked;
+	uint32 _lightGreen, _gridDarkGreen, _lockDarkGreen1, _lockDarkGreen2;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: 3f69c195ae5824a7f3037add447cca40e8827e6c
    https://github.com/scummvm/scummvm/commit/3f69c195ae5824a7f3037add447cca40e8827e6c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T22:24:57-07:00

Commit Message:
PEGASUS: Allow for initial support of the space chase

It's not ready yet, but it's slowly becoming playable. For instance, scaling, the shuttle HUD, and the energy beam work on the first try which is nothing short of a miracle.

This commit also moved around some Mars constants because the previous include setup did not work; I hope to make the other neighborhoods have a separate constants file too.

Changed paths:
  A engines/pegasus/neighborhood/mars/constants.h
    engines/pegasus/items/biochips/mapimage.h
    engines/pegasus/neighborhood/mars/gravitoncannon.h
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/neighborhood/mars/planetmover.cpp
    engines/pegasus/neighborhood/mars/robotship.cpp
    engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
    engines/pegasus/neighborhood/mars/shuttlehud.cpp
    engines/pegasus/neighborhood/mars/shuttlehud.h
    engines/pegasus/neighborhood/mars/shuttleweapon.cpp
    engines/pegasus/neighborhood/mars/shuttleweapon.h
    engines/pegasus/neighborhood/mars/spacechase3d.h
    engines/pegasus/neighborhood/mars/spacejunk.cpp
    engines/pegasus/neighborhood/mars/spacejunk.h
    engines/pegasus/neighborhood/mars/tractorbeam.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.cpp



diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
index 43a13ac..d21d29c 100755
--- a/engines/pegasus/items/biochips/mapimage.h
+++ b/engines/pegasus/items/biochips/mapimage.h
@@ -28,7 +28,7 @@
 
 #include "pegasus/elements.h"
 #include "pegasus/util.h"
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 
 namespace Common {
 	class ReadStream;
diff --git a/engines/pegasus/neighborhood/mars/constants.h b/engines/pegasus/neighborhood/mars/constants.h
new file mode 100755
index 0000000..c96a8a1
--- /dev/null
+++ b/engines/pegasus/neighborhood/mars/constants.h
@@ -0,0 +1,941 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_MARS_CONSTANTS_H
+#define PEGASUS_NEIGHBORHOOD_MARS_CONSTANTS_H
+
+#include "pegasus/constants.h"
+
+namespace Pegasus {
+
+//	Element Coordinates
+
+const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
+const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
+
+const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
+
+const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+
+const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
+
+const tCoordType kAnswerLeft = kNavAreaLeft + 304;
+const tCoordType kAnswerTop = kNavAreaTop + 180;
+
+const tCoordType kShuttle1Left = 0;
+const tCoordType kShuttle1Top = 0;
+
+const tCoordType kShuttle2Left = 0;
+const tCoordType kShuttle2Top = 96;
+
+const tCoordType kShuttle3Left = 500;
+const tCoordType kShuttle3Top = 96;
+
+const tCoordType kShuttle4Left = 0;
+const tCoordType kShuttle4Top = 320;
+
+const tCoordType kShuttleWindowLeft = 140;
+const tCoordType kShuttleWindowTop = 96;
+const tCoordType kShuttleWindowWidth = 360;
+const tCoordType kShuttleWindowHeight = 224;
+
+const tCoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
+const tCoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
+
+const tCoordType kShuttleLeftLeft = 0;
+const tCoordType kShuttleLeftTop = 128;
+
+const tCoordType kShuttleRightLeft = 506;
+const tCoordType kShuttleRightTop = 128;
+
+const tCoordType kShuttleLowerLeftLeft = 74;
+const tCoordType kShuttleLowerLeftTop = 358;
+
+const tCoordType kShuttleLowerRightLeft = 486;
+const tCoordType kShuttleLowerRightTop = 354;
+
+const tCoordType kShuttleCenterLeft = 260;
+const tCoordType kShuttleCenterTop = 336;
+
+const tCoordType kShuttleUpperLeftLeft = 30;
+const tCoordType kShuttleUpperLeftTop = 32;
+
+const tCoordType kShuttleUpperRightLeft = 506;
+const tCoordType kShuttleUpperRightTop = 52;
+
+const tCoordType kShuttleLeftEnergyLeft = 110;
+const tCoordType kShuttleLeftEnergyTop = 186;
+
+const tCoordType kShuttleRightEnergyLeft = 510;
+const tCoordType kShuttleRightEnergyTop = 186;
+
+const tCoordType kShuttleEnergyLeft = 186;
+const tCoordType kShuttleEnergyTop = 60;
+const tCoordType kShuttleEnergyWidth = 252;
+const tCoordType kShuttleEnergyHeight = 22;
+
+const tCoordType kPlanetStartLeft = kShuttleWindowLeft;
+const tCoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
+
+const tCoordType kPlanetStopLeft = kShuttleWindowLeft;
+const tCoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
+
+const tCoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
+const tCoordType kShuttleTractorTop = kShuttleWindowTop + 56;
+const tCoordType kShuttleTractorWidth = 348;
+const tCoordType kShuttleTractorHeight = 112;
+
+const tCoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
+const tCoordType kShuttleJunkTop = kShuttleWindowTop + 6;
+
+const tDisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
+const tDisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
+const tDisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
+const tDisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
+const tDisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
+const tDisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
+const tDisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
+const tDisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
+const tDisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
+const tDisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
+const tDisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
+const tDisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
+
+const TimeValue kShuttleSwingStart = 0;
+const TimeValue kShuttleSwingStop = 5 * 600;
+
+const TimeValue kCanyonChaseStart = kShuttleSwingStop;
+const TimeValue kCanyonChaseStop = 60 * 600 + 43 * 600 + 14 * 40;
+
+const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonChaseStart;
+const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
+											kLaunchTubeReachedTime;
+
+//	Left shuttle.
+
+const TimeValue kShuttleLeftIntroStart = 0;
+const TimeValue kShuttleLeftIntroStop = 400;
+
+const TimeValue kShuttleLeftBlankTime = 400;
+
+const TimeValue kShuttleLeftNormalTime = 440;
+
+const TimeValue kShuttleLeftAutoTestTime = 480;
+
+const TimeValue kShuttleLeftDamagedTime = 520;
+
+const TimeValue kShuttleLeftDampingTime = 560;
+
+const TimeValue kShuttleLeftGravitonTime = 600;
+
+const TimeValue kShuttleLeftTractorTime = 640;
+
+//	Right shuttle.
+
+const TimeValue kShuttleRightIntroStart = 0;
+const TimeValue kShuttleRightIntroStop = 400;
+
+const TimeValue kShuttleRightDestroyedStart = 400;
+const TimeValue kShuttleRightDestroyedStop = 840;
+
+const TimeValue kShuttleRightBlankTime = 840;
+
+const TimeValue kShuttleRightNormalTime = 880;
+
+const TimeValue kShuttleRightDamagedTime = 920;
+
+const TimeValue kShuttleRightTargetLockTime = 960;
+
+const TimeValue kShuttleRightGravitonTime = 1000;
+
+const TimeValue kShuttleRightOverloadTime = 1040;
+
+//	Lower Left shuttle.
+
+const TimeValue kShuttleLowerLeftCollisionTime = 0;
+
+const TimeValue kShuttleLowerLeftTubeTime = 40;
+
+const TimeValue kShuttleLowerLeftAutopilotTime = 80;
+
+//	Lower Right shuttle.
+
+const TimeValue kShuttleLowerRightOffTime = 0;
+
+const TimeValue kShuttleLowerRightTrackingTime = 40;
+
+const TimeValue kShuttleLowerRightTransportTime = 80;
+
+const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
+
+//	Center shuttle.
+
+const TimeValue kShuttleCenterBoardingTime = 0;
+
+const TimeValue kShuttleCenterCheckTime = 40;
+
+const TimeValue kShuttleCenterNavCompTime = 80;
+
+const TimeValue kShuttleCenterCommTime = 120;
+
+const TimeValue kShuttleCenterWeaponsTime = 160;
+
+const TimeValue kShuttleCenterAllSystemsTime = 200;
+
+const TimeValue kShuttleCenterSecureLooseTime = 240;
+
+const TimeValue kShuttleCenterAutoTestTime = 280;
+
+const TimeValue kShuttleCenterLaunchTime = 320;
+
+const TimeValue kShuttleCenterEnterTubeTime = 360;
+
+const TimeValue kShuttleCenterTargetSightedTime = 400;
+
+const TimeValue kShuttleCenterVerifyingTime = 440;
+
+const TimeValue kShuttleCenterScanningTime = 480;
+
+const TimeValue kShuttleCenterSafeTime = 520;
+
+//	Upper Left shuttle.
+
+const TimeValue kShuttleUpperLeftDimTime = 0;
+
+const TimeValue kShuttleUpperLeftDampingTime = 40;
+
+const TimeValue kShuttleUpperLeftGravitonTime = 80;
+
+const TimeValue kShuttleUpperLeftTractorTime = 120;
+
+//	Upper Right shuttle.
+
+const TimeValue kShuttleUpperRightLockedTime = 0;
+
+const TimeValue kShuttleUpperRightArmedTime = 40;
+
+const TimeValue kShuttleUpperRightAlienDestroyedTime = 80;
+
+const TimeValue kShuttleUpperRightOverloadTime = 120;
+
+const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
+
+//	Shuttle distance
+
+const int kShuttleDistance = 500;
+
+const int kJunkMaxDistance = kShuttleDistance;
+const int kJunkMinDistance = 40;
+
+const int kEnergyBeamMaxDistance = kShuttleDistance;
+const int kEnergyBeamMinDistance = 40;
+
+const int kGravitonMaxDistance = kShuttleDistance;
+const int kGravitonMinDistance = 40;
+
+const TimeValue kMarsOxyMaskOnIn = 0;
+const TimeValue kMarsOxyMaskOnOut = 1560;
+
+const TimeValue kMarsAirlockButtonBeepIn = 1560;
+const TimeValue kMarsAirlockButtonBeepOut = 1620;
+
+const TimeValue kMarsColorMatchingButtonBeepIn = 1620;
+const TimeValue kMarsColorMatchingButtonBeepOut = 1680;
+
+const TimeValue kMarsKioskBeepIn = 1680;
+const TimeValue kMarsKioskBeepOut = 1740;
+
+const TimeValue kMarsBumpIntoWallIn = 1740;
+const TimeValue kMarsBumpIntoWallOut = 1888;
+
+const TimeValue kMarsGantryDoorCloseIn = 1888;
+const TimeValue kMarsGantryDoorCloseOut = 2866;
+
+const TimeValue kMarsTransportDoorCloseIn = 2866;
+const TimeValue kMarsTransportDoorCloseOut = 3593;
+
+const TimeValue kMarsAirlockPressurizeIn = 3593;
+const TimeValue kMarsAirlockPressurizeOut = 4766;
+
+const TimeValue kMarsBigAirlockDoorCloseIn = 4766;
+const TimeValue kMarsBigAirlockDoorCloseOut = 7872;
+
+const TimeValue kMarsSmallAirlockDoorCloseIn = 7872;
+const TimeValue kMarsSmallAirlockDoorCloseOut = 10000;
+
+const TimeValue kMarsMazeDoorCloseIn = 10000;
+const TimeValue kMarsMazeDoorCloseOut = 10969;
+
+const TimeValue kMarsRobotTakesTransportIn = 10969;
+const TimeValue kMarsRobotTakesTransportOut = 12802;
+
+const TimeValue kMarsPodDepartedUpperPlatformIn = 12802;
+const TimeValue kMarsPodDepartedUpperPlatformOut = 15783;
+
+const TimeValue kMarsPodDepartedLowerPlatformIn = 15783;
+const TimeValue kMarsPodDepartedLowerPlatformOut = 18736;
+
+const TimeValue kMarsPodArrivedUpperPlatformIn = 18736;
+const TimeValue kMarsPodArrivedUpperPlatformOut = 21605;
+
+const TimeValue kMarsCheckInRequiredIn = 21605;
+const TimeValue kMarsCheckInRequiredOut = 27463;
+
+const TimeValue kMarsCantOpenShuttleIn = 27463;
+const TimeValue kMarsCantOpenShuttleOut = 29214;
+
+const TimeValue kMarsShuttleLockOverrideIn = 29214;
+const TimeValue kMarsShuttleLockOverrideOut = 30330;
+
+const TimeValue kMarsNoShuttleIn = 30330;
+const TimeValue kMarsNoShuttleOut = 31502;
+
+const TimeValue kMustBeUnlockedIn = 31502;
+const TimeValue kMustBeUnlockedOut = 33960;
+
+const TimeValue kColorMatchBlueIn = 33960;
+const TimeValue kColorMatchBlueOut = 34240;
+
+const TimeValue kColorMatchRedIn = 34240;
+const TimeValue kColorMatchRedOut = 34538;
+
+const TimeValue kColorMatchGreenIn = 34538;
+const TimeValue kColorMatchGreenOut = 34827;
+
+const TimeValue kColorMatchYellowIn = 34827;
+const TimeValue kColorMatchYellowOut = 35162;
+
+const TimeValue kColorMatchPurpleIn = 35162;
+const TimeValue kColorMatchPurpleOut = 35426;
+
+const TimeValue kColorMatchZeroNodesIn = 35426;
+const TimeValue kColorMatchZeroNodesOut = 36376;
+
+const TimeValue kColorMatchOneNodeIn = 36376;
+const TimeValue kColorMatchOneNodeOut = 37209;
+
+const TimeValue kColorMatchTwoNodesIn = 37209;
+const TimeValue kColorMatchTwoNodesOut = 37983;
+
+const TimeValue kColorMatchThreeNodesIn = 37983;
+const TimeValue kColorMatchThreeNodesOut = 38784;
+
+const TimeValue kMarsShuttle1DepartedIn = 38784;
+const TimeValue kMarsShuttle1DepartedOut = 40323;
+
+const TimeValue kMarsShuttle2DepartedIn = 40323;
+const TimeValue kMarsShuttle2DepartedOut = 41824;
+
+const TimeValue kShuttleCockpitIn = 41824;
+const TimeValue kShuttleCockpitOut = 43126;
+
+const TimeValue kShuttleOnboardIn = 43126;
+const TimeValue kShuttleOnboardOut = 44284;
+
+const TimeValue kShuttleNavigationIn = 44284;
+const TimeValue kShuttleNavigationOut = 46049;
+
+const TimeValue kShuttleCommunicationIn = 46049;
+const TimeValue kShuttleCommunicationOut = 47288;
+
+const TimeValue kShuttleAutoTestingIn = 47288;
+const TimeValue kShuttleAutoTestingOut = 48179;
+
+const TimeValue kMarsThrusterAutoTestIn = 48179;
+const TimeValue kMarsThrusterAutoTestOut = 49979;
+
+const TimeValue kShuttleAllSystemsIn = 49979;
+const TimeValue kShuttleAllSystemsOut = 51065;
+
+const TimeValue kShuttleSecureLooseIn = 51065;
+const TimeValue kShuttleSecureLooseOut = 52346;
+
+const TimeValue kShuttlePrepareForDropIn = 52346;
+const TimeValue kShuttlePrepareForDropOut = 53216;
+
+const TimeValue kShuttleAllClearIn = 53216;
+const TimeValue kShuttleAllClearOut = 54031;
+
+const TimeValue kShuttleConfiguringIn = 54031;
+const TimeValue kShuttleConfiguringOut = 54994;
+
+const TimeValue kShuttleGeneratingIn = 54994;
+const TimeValue kShuttleGeneratingOut = 56033;
+
+const TimeValue kShuttleBreakawayIn = 56033;
+const TimeValue kShuttleBreakawayOut = 57346;
+
+const TimeValue kMarsAtmosphericBreakawayIn = 57346;
+const TimeValue kMarsAtmosphericBreakawayOut = 59237;
+
+const TimeValue kMarsCockpitChatterIn = 59237;
+const TimeValue kMarsCockpitChatterOut = 70344;
+
+const TimeValue kShuttleDamperDescIn = 70344;
+const TimeValue kShuttleDamperDescOut = 73262;
+
+const TimeValue kShuttleGravitonDescIn = 73262;
+const TimeValue kShuttleGravitonDescOut = 75296;
+
+const TimeValue kShuttleTractorDescIn = 75296;
+const TimeValue kShuttleTractorDescOut = 78381;
+
+const TimeValue kShuttleTargetSightedIn = 78381;
+const TimeValue kShuttleTargetSightedOut = 79074;
+
+const TimeValue kShuttleAutopilotEngagedIn = 79074;
+const TimeValue kShuttleAutopilotEngagedOut = 80414;
+
+const TimeValue kMarsEDBBlastIn = 80414;
+const TimeValue kMarsEDBBlastOut = 80705;
+
+const TimeValue kMarsGravitonBlastIn = 80705;
+const TimeValue kMarsGravitonBlastOut = 81199;
+
+const TimeValue kMarsJunkCollisionIn = 81199;
+const TimeValue kMarsJunkCollisionOut = 81961;
+
+const TimeValue kShuttleGravitonIn = 81961;
+const TimeValue kShuttleGravitonOut = 82587;
+
+const TimeValue kShuttleDampingBeamIn = 82587;
+const TimeValue kShuttleDampingBeamOut = 83331;
+
+const TimeValue kShuttleTractorBeamIn = 83331;
+const TimeValue kShuttleTractorBeamOut = 83802;
+
+const TimeValue kShuttleHullBreachIn = 83802;
+const TimeValue kShuttleHullBreachOut = 84721;
+
+const TimeValue kShuttleWingDamageIn = 84721;
+const TimeValue kShuttleWingDamageOut = 85640;
+
+const TimeValue kShuttleHullDamageIn = 85640;
+const TimeValue kShuttleHullDamageOut = 86513;
+
+const TimeValue kShuttleEnergyTooLowIn = 86513;
+const TimeValue kShuttleEnergyTooLowOut = 87578;
+
+const TimeValue kShuttleTractorLimitedIn = 87578;
+const TimeValue kShuttleTractorLimitedOut = 89164;
+
+const TimeValue kShuttleCantHoldIn = 89164;
+const TimeValue kShuttleCantHoldOut = 90945;
+
+const TimeValue kShuttleBrokeFreeIn = 90945;
+const TimeValue kShuttleBrokeFreeOut = 92322;
+
+const TimeValue kShuttleDestroyedIn = 92322;
+const TimeValue kShuttleDestroyedOut = 93189;
+
+const TimeValue kShuttleCoordinatesIn = 93189;
+const TimeValue kShuttleCoordinatesOut = 94018;
+
+const TimeValue kShuttleScanningIn = 94018;
+const TimeValue kShuttleScanningOut = 94975;
+
+const TimeValue kShuttleSafeIn = 94975;
+const TimeValue kShuttleSafeOut = 96176;
+
+const TimeValue kShuttleOverloadedIn = 96176;
+const TimeValue kShuttleOverloadedOut = 101308;
+
+const TimeScale kMarsMovieScale = 600;
+const TimeScale kMarsFramesPerSecond = 15;
+const TimeScale kMarsFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltMarsNormal = 0;
+const tAlternateID kAltMarsPodAtMars34 = 1;
+const tAlternateID kAltMarsTookCard = 2;
+const tAlternateID kAltMars35AirlockEast = 3;
+const tAlternateID kAltMars35AirlockWest = 4;
+const tAlternateID kAltMarsPodAtMars45 = 5;
+const tAlternateID kAltMarsTookMask = 6;
+const tAlternateID kAltMarsMaskOnFiller = 7;
+const tAlternateID kAltMars60AirlockEast = 8;
+const tAlternateID kAltMars60AirlockWest = 9;
+
+//	Room IDs.
+
+const tRoomID kMars0A = 0;
+const tRoomID kMars00 = 1;
+const tRoomID kMars01 = 2;
+const tRoomID kMars02 = 3;
+const tRoomID kMars03 = 4;
+const tRoomID kMars04 = 5;
+const tRoomID kMars05 = 6;
+const tRoomID kMars06 = 7;
+const tRoomID kMars07 = 8;
+const tRoomID kMars08 = 9;
+const tRoomID kMars09 = 10;
+const tRoomID kMars10 = 11;
+const tRoomID kMars11 = 12;
+const tRoomID kMars12 = 13;
+const tRoomID kMars13 = 14;
+const tRoomID kMars14 = 15;
+const tRoomID kMars15 = 16;
+const tRoomID kMars16 = 17;
+const tRoomID kMars17 = 18;
+const tRoomID kMars18 = 19;
+const tRoomID kMars19 = 20;
+const tRoomID kMars20 = 21;
+const tRoomID kMars21 = 22;
+const tRoomID kMars22 = 23;
+const tRoomID kMars23 = 24;
+const tRoomID kMars24 = 25;
+const tRoomID kMars25 = 26;
+const tRoomID kMars26 = 27;
+const tRoomID kMars27 = 28;
+const tRoomID kMars28 = 29;
+const tRoomID kMars29 = 30;
+const tRoomID kMars30 = 31;
+const tRoomID kMars31 = 32;
+const tRoomID kMars31South = 33;
+const tRoomID kMars32 = 34;
+const tRoomID kMars33 = 35;
+const tRoomID kMars33North = 36;
+const tRoomID kMars34 = 37;
+const tRoomID kMars35 = 38;
+const tRoomID kMars36 = 39;
+const tRoomID kMars37 = 40;
+const tRoomID kMars38 = 41;
+const tRoomID kMars39 = 42;
+const tRoomID kMars41 = 43;
+const tRoomID kMars42 = 44;
+const tRoomID kMars43 = 45;
+const tRoomID kMars44 = 46;
+const tRoomID kMars45 = 47;
+const tRoomID kMars46 = 48;
+const tRoomID kMars47 = 49;
+const tRoomID kMars48 = 50;
+const tRoomID kMars49 = 51;
+const tRoomID kMars50 = 52;
+const tRoomID kMars51 = 53;
+const tRoomID kMars52 = 54;
+const tRoomID kMars54 = 55;
+const tRoomID kMars56 = 56;
+const tRoomID kMars58 = 57;
+const tRoomID kMars60 = 58;
+const tRoomID kMarsRobotShuttle = 59;
+const tRoomID kMarsMaze004 = 60;
+const tRoomID kMarsMaze005 = 61;
+const tRoomID kMarsMaze006 = 62;
+const tRoomID kMarsMaze007 = 63;
+const tRoomID kMarsMaze008 = 64;
+const tRoomID kMarsMaze009 = 65;
+const tRoomID kMarsMaze010 = 66;
+const tRoomID kMarsMaze011 = 67;
+const tRoomID kMarsMaze012 = 68;
+const tRoomID kMarsMaze015 = 69;
+const tRoomID kMarsMaze016 = 70;
+const tRoomID kMarsMaze017 = 71;
+const tRoomID kMarsMaze018 = 72;
+const tRoomID kMarsMaze019 = 73;
+const tRoomID kMarsMaze020 = 74;
+const tRoomID kMarsMaze021 = 75;
+const tRoomID kMarsMaze022 = 76;
+const tRoomID kMarsMaze023 = 77;
+const tRoomID kMarsMaze024 = 78;
+const tRoomID kMarsMaze025 = 79;
+const tRoomID kMarsMaze026 = 80;
+const tRoomID kMarsMaze027 = 81;
+const tRoomID kMarsMaze028 = 82;
+const tRoomID kMarsMaze031 = 83;
+const tRoomID kMarsMaze032 = 84;
+const tRoomID kMarsMaze033 = 85;
+const tRoomID kMarsMaze034 = 86;
+const tRoomID kMarsMaze035 = 87;
+const tRoomID kMarsMaze036 = 88;
+const tRoomID kMarsMaze037 = 89;
+const tRoomID kMarsMaze038 = 90;
+const tRoomID kMarsMaze039 = 91;
+const tRoomID kMarsMaze042 = 92;
+const tRoomID kMarsMaze043 = 93;
+const tRoomID kMarsMaze044 = 94;
+const tRoomID kMarsMaze045 = 95;
+const tRoomID kMarsMaze046 = 96;
+const tRoomID kMarsMaze047 = 97;
+const tRoomID kMarsMaze049 = 98;
+const tRoomID kMarsMaze050 = 99;
+const tRoomID kMarsMaze051 = 100;
+const tRoomID kMarsMaze052 = 101;
+const tRoomID kMarsMaze053 = 102;
+const tRoomID kMarsMaze054 = 103;
+const tRoomID kMarsMaze055 = 104;
+const tRoomID kMarsMaze056 = 105;
+const tRoomID kMarsMaze057 = 106;
+const tRoomID kMarsMaze058 = 107;
+const tRoomID kMarsMaze059 = 108;
+const tRoomID kMarsMaze060 = 109;
+const tRoomID kMarsMaze061 = 110;
+const tRoomID kMarsMaze063 = 111;
+const tRoomID kMarsMaze064 = 112;
+const tRoomID kMarsMaze065 = 113;
+const tRoomID kMarsMaze066 = 114;
+const tRoomID kMarsMaze067 = 115;
+const tRoomID kMarsMaze068 = 116;
+const tRoomID kMarsMaze069 = 117;
+const tRoomID kMarsMaze070 = 118;
+const tRoomID kMarsMaze071 = 119;
+const tRoomID kMarsMaze072 = 120;
+const tRoomID kMarsMaze074 = 121;
+const tRoomID kMarsMaze076 = 122;
+const tRoomID kMarsMaze078 = 123;
+const tRoomID kMarsMaze079 = 124;
+const tRoomID kMarsMaze081 = 125;
+const tRoomID kMarsMaze083 = 126;
+const tRoomID kMarsMaze084 = 127;
+const tRoomID kMarsMaze085 = 128;
+const tRoomID kMarsMaze086 = 129;
+const tRoomID kMarsMaze087 = 130;
+const tRoomID kMarsMaze088 = 131;
+const tRoomID kMarsMaze089 = 132;
+const tRoomID kMarsMaze090 = 133;
+const tRoomID kMarsMaze091 = 134;
+const tRoomID kMarsMaze092 = 135;
+const tRoomID kMarsMaze093 = 136;
+const tRoomID kMarsMaze098 = 137;
+const tRoomID kMarsMaze099 = 138;
+const tRoomID kMarsMaze100 = 139;
+const tRoomID kMarsMaze101 = 140;
+const tRoomID kMarsMaze104 = 141;
+const tRoomID kMarsMaze105 = 142;
+const tRoomID kMarsMaze106 = 143;
+const tRoomID kMarsMaze107 = 144;
+const tRoomID kMarsMaze108 = 145;
+const tRoomID kMarsMaze111 = 146;
+const tRoomID kMarsMaze113 = 147;
+const tRoomID kMarsMaze114 = 148;
+const tRoomID kMarsMaze115 = 149;
+const tRoomID kMarsMaze116 = 150;
+const tRoomID kMarsMaze117 = 151;
+const tRoomID kMarsMaze118 = 152;
+const tRoomID kMarsMaze119 = 153;
+const tRoomID kMarsMaze120 = 154;
+const tRoomID kMarsMaze121 = 155;
+const tRoomID kMarsMaze122 = 156;
+const tRoomID kMarsMaze123 = 157;
+const tRoomID kMarsMaze124 = 158;
+const tRoomID kMarsMaze125 = 159;
+const tRoomID kMarsMaze126 = 160;
+const tRoomID kMarsMaze127 = 161;
+const tRoomID kMarsMaze128 = 162;
+const tRoomID kMarsMaze129 = 163;
+const tRoomID kMarsMaze130 = 164;
+const tRoomID kMarsMaze131 = 165;
+const tRoomID kMarsMaze132 = 166;
+const tRoomID kMarsMaze133 = 167;
+const tRoomID kMarsMaze136 = 168;
+const tRoomID kMarsMaze137 = 169;
+const tRoomID kMarsMaze138 = 170;
+const tRoomID kMarsMaze139 = 171;
+const tRoomID kMarsMaze140 = 172;
+const tRoomID kMarsMaze141 = 173;
+const tRoomID kMarsMaze142 = 174;
+const tRoomID kMarsMaze143 = 175;
+const tRoomID kMarsMaze144 = 176;
+const tRoomID kMarsMaze145 = 177;
+const tRoomID kMarsMaze146 = 178;
+const tRoomID kMarsMaze147 = 179;
+const tRoomID kMarsMaze148 = 180;
+const tRoomID kMarsMaze149 = 181;
+const tRoomID kMarsMaze152 = 182;
+const tRoomID kMarsMaze153 = 183;
+const tRoomID kMarsMaze154 = 184;
+const tRoomID kMarsMaze155 = 185;
+const tRoomID kMarsMaze156 = 186;
+const tRoomID kMarsMaze157 = 187;
+const tRoomID kMarsMaze159 = 188;
+const tRoomID kMarsMaze160 = 189;
+const tRoomID kMarsMaze161 = 190;
+const tRoomID kMarsMaze162 = 191;
+const tRoomID kMarsMaze163 = 192;
+const tRoomID kMarsMaze164 = 193;
+const tRoomID kMarsMaze165 = 194;
+const tRoomID kMarsMaze166 = 195;
+const tRoomID kMarsMaze167 = 196;
+const tRoomID kMarsMaze168 = 197;
+const tRoomID kMarsMaze169 = 198;
+const tRoomID kMarsMaze170 = 199;
+const tRoomID kMarsMaze171 = 200;
+const tRoomID kMarsMaze172 = 201;
+const tRoomID kMarsMaze173 = 202;
+const tRoomID kMarsMaze174 = 203;
+const tRoomID kMarsMaze175 = 204;
+const tRoomID kMarsMaze177 = 205;
+const tRoomID kMarsMaze178 = 206;
+const tRoomID kMarsMaze179 = 207;
+const tRoomID kMarsMaze180 = 208;
+const tRoomID kMarsMaze181 = 209;
+const tRoomID kMarsMaze182 = 210;
+const tRoomID kMarsMaze183 = 211;
+const tRoomID kMarsMaze184 = 212;
+const tRoomID kMarsMaze187 = 213;
+const tRoomID kMarsMaze188 = 214;
+const tRoomID kMarsMaze189 = 215;
+const tRoomID kMarsMaze190 = 216;
+const tRoomID kMarsMaze191 = 217;
+const tRoomID kMarsMaze192 = 218;
+const tRoomID kMarsMaze193 = 219;
+const tRoomID kMarsMaze194 = 220;
+const tRoomID kMarsMaze195 = 221;
+const tRoomID kMarsMaze198 = 222;
+const tRoomID kMarsMaze199 = 223;
+const tRoomID kMarsMaze200 = 224;
+const tRoomID kMarsDeathRoom = 225;
+
+//	Hot Spot Activation IDs.
+
+const tHotSpotActivationID kActivationReadyForKiosk = 1;
+const tHotSpotActivationID kActivationKioskChoice = 2;
+const tHotSpotActivationID kActivationTunnelMapReady = 3;
+const tHotSpotActivationID kActivateMarsPodClosed = 4;
+const tHotSpotActivationID kActivateMarsPodOpen = 5;
+const tHotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
+const tHotSpotActivationID kActivateAirlockPressurized = 7;
+const tHotSpotActivationID kActivateMaskOnHolder = 8;
+const tHotSpotActivationID kActivateMaskOnFiller = 9;
+const tHotSpotActivationID kActivateReactorPlatformOut = 10;
+const tHotSpotActivationID kActivateReactorPlatformIn = 11;
+const tHotSpotActivationID kActivateReactorAskLowerScreen = 12;
+const tHotSpotActivationID kActivateReactorReadyForNitrogen = 13;
+const tHotSpotActivationID kActivateReactorReadyForCrowBar = 14;
+const tHotSpotActivationID kActivateReactorAskOperation = 15;
+const tHotSpotActivationID kActivateReactorRanEvaluation = 16;
+const tHotSpotActivationID kActivateReactorRanDiagnostics = 17;
+const tHotSpotActivationID kActivateReactorAnalyzed = 18;
+const tHotSpotActivationID kActivateReactorInstructions = 19;
+const tHotSpotActivationID kActivateReactorInGame = 20;
+const tHotSpotActivationID kActivateReactorBombSafe = 21;
+const tHotSpotActivationID kActivateReactorBombExposed = 22;
+const tHotSpotActivationID kActivationRobotHeadClosed = 23;
+const tHotSpotActivationID kActivationRobotHeadOpen = 24;
+
+//	Hot Spot IDs.
+
+const tHotSpotID kMars11NorthKioskSpotID = 5000;
+const tHotSpotID kMars11NorthKioskSightsSpotID = 5001;
+const tHotSpotID kMars11NorthKioskColonySpotID = 5002;
+const tHotSpotID kMars12NorthKioskSpotID = 5003;
+const tHotSpotID kMars12NorthKioskSightsSpotID = 5004;
+const tHotSpotID kMars12NorthKioskColonySpotID = 5005;
+const tHotSpotID kMars31SouthSpotID = 5006;
+const tHotSpotID kMars31SouthOutSpotID = 5007;
+const tHotSpotID kMars31SouthCardSpotID = 5008;
+const tHotSpotID kMars33NorthSpotID = 5009;
+const tHotSpotID kMars33NorthOutSpotID = 5010;
+const tHotSpotID kMars33NorthMonitorSpotID = 5011;
+const tHotSpotID kMars34NorthCardDropSpotID = 5012;
+const tHotSpotID kMars34SouthOpenStorageSpotID = 5013;
+const tHotSpotID kMars34SouthCloseStorageSpotID = 5014;
+const tHotSpotID kMars34SouthCrowbarSpotID = 5015;
+const tHotSpotID kMars35EastPressurizeSpotID = 5016;
+const tHotSpotID kMars35EastSpinSpotID = 5017;
+const tHotSpotID kMars35WestPressurizeSpotID = 5018;
+const tHotSpotID kMars35WestSpinSpotID = 5019;
+const tHotSpotID kMars45NorthOpenStorageSpotID = 5020;
+const tHotSpotID kMars45NorthCloseStorageSpotID = 5021;
+const tHotSpotID kMars45NorthCrowbarSpotID = 5022;
+const tHotSpotID kAttackRobotHotSpotID = 5023;
+const tHotSpotID kMars49AirMaskSpotID = 5024;
+const tHotSpotID kMars49AirMaskFilledSpotID = 5025;
+const tHotSpotID kMars49AirFillingDropSpotID = 5026;
+const tHotSpotID kMars52MoveLeftSpotID = 5027;
+const tHotSpotID kMars52MoveRightSpotID = 5028;
+const tHotSpotID kMars52ExtractSpotID = 5029;
+const tHotSpotID kMars53RetractSpotID = 5030;
+const tHotSpotID kMars54MoveLeftSpotID = 5031;
+const tHotSpotID kMars54MoveRightSpotID = 5032;
+const tHotSpotID kMars54ExtractSpotID = 5033;
+const tHotSpotID kMars55RetractSpotID = 5034;
+const tHotSpotID kMars56MoveLeftSpotID = 5035;
+const tHotSpotID kMars56MoveRightSpotID = 5036;
+const tHotSpotID kMars56ExtractSpotID = 5037;
+const tHotSpotID kMars57RetractSpotID = 5038;
+const tHotSpotID kMars57LowerScreenSpotID = 5039;
+const tHotSpotID kMars57Retract2SpotID = 5040;
+const tHotSpotID kMars57DropNitrogenSpotID = 5041;
+const tHotSpotID kMars57DropCrowBarSpotID = 5042;
+const tHotSpotID kMars57CantOpenPanelSpotID = 5043;
+const tHotSpotID kMars57ShieldEvaluationSpotID = 5044;
+const tHotSpotID kMars57MeasureOutputSpotID = 5045;
+const tHotSpotID kMars57RunDiagnosticsSpotID = 5046;
+const tHotSpotID kMars57BackToOperationMenuSpotID = 5047;
+const tHotSpotID kMars57AnalyzeObjectSpotID = 5048;
+const tHotSpotID kMars57RemoveObjectMenuSpotID = 5049;
+const tHotSpotID kMars57CircuitLinkSpotID = 5050;
+const tHotSpotID kMars57CancelCircuitLinkSpotID = 5051;
+const tHotSpotID kMars57GameInstructionsSpotID = 5052;
+const tHotSpotID kMars57UndoMoveSpotID = 5053;
+const tHotSpotID kMars57RedMoveSpotID = 5054;
+const tHotSpotID kMars57YellowMoveSpotID = 5055;
+const tHotSpotID kMars57GreenMoveSpotID = 5056;
+const tHotSpotID kMars57BlueMoveSpotID = 5057;
+const tHotSpotID kMars57PurpleMoveSpotID = 5058;
+const tHotSpotID kMars57LowerScreenSafelySpotID = 5059;
+const tHotSpotID kMars57GrabBombSpotID = 5060;
+const tHotSpotID kMars58MoveLeftSpotID = 5061;
+const tHotSpotID kMars58MoveRightSpotID = 5062;
+const tHotSpotID kMars58ExtractSpotID = 5063;
+const tHotSpotID kMars59RetractSpotID = 5064;
+const tHotSpotID kMars60EastPressurizeSpotID = 5065;
+const tHotSpotID kMars60EastSpinSpotID = 5066;
+const tHotSpotID kMars60WestPressurizeSpotID = 5067;
+const tHotSpotID kMars60WestSpinSpotID = 5068;
+const tHotSpotID kRobotShuttleOpenHeadSpotID = 5069;
+const tHotSpotID kRobotShuttleMapChipSpotID = 5070;
+const tHotSpotID kRobotShuttleOpticalChipSpotID = 5071;
+const tHotSpotID kRobotShuttleShieldChipSpotID = 5072;
+
+//	Extra sequence IDs.
+
+const tExtraID kMarsArrivalFromTSA = 0;
+const tExtraID kMars0AWatchShuttleDepart = 1;
+const tExtraID kRobotThrowsPlayer = 2;
+const tExtraID kMarsInfoKioskIntro = 3;
+const tExtraID kMarsColonyInfo = 4;
+const tExtraID kMarsSightsInfo = 5;
+const tExtraID kRobotOnWayToShuttle = 6;
+const tExtraID kMars31SouthZoomInNoCard = 7;
+const tExtraID kMars31SouthViewNoCard = 8;
+const tExtraID kMars31SouthZoomOutNoCard = 9;
+const tExtraID kMars31SouthZoomViewNoCard = 10;
+const tExtraID kMars33SlideShow1 = 11;
+const tExtraID kMars33SlideShow2 = 12;
+const tExtraID kMars33SlideShow3 = 13;
+const tExtraID kMars33SlideShow4 = 14;
+const tExtraID kMars34SpotOpenWithBar = 15;
+const tExtraID kMars34SpotCloseWithBar = 16;
+const tExtraID kMars34SpotOpenNoBar = 17;
+const tExtraID kMars34SpotCloseNoBar = 18;
+const tExtraID kMars34ViewOpenWithBar = 19;
+const tExtraID kMars34ViewOpenNoBar = 20;
+const tExtraID kMars34NorthPodGreeting = 21;
+const tExtraID kMarsTurnOnPod = 22;
+const tExtraID kMarsTakePodToMars45 = 23;
+const tExtraID kMars35WestSpinAirlockToEast = 24;
+const tExtraID kMars35EastSpinAirlockToWest = 25;
+const tExtraID kMars45SpotOpenWithBar = 26;
+const tExtraID kMars45SpotCloseWithBar = 27;
+const tExtraID kMars45SpotOpenNoBar = 28;
+const tExtraID kMars45SpotCloseNoBar = 29;
+const tExtraID kMars45ViewOpenWithBar = 30;
+const tExtraID kMars45ViewOpenNoBar = 31;
+const tExtraID kMars48RobotApproaches = 32;
+const tExtraID kMars48RobotKillsPlayer = 33;
+const tExtraID kMars48RobotLoops = 34;
+const tExtraID kMars48RobotView = 35;
+const tExtraID kMars48RobotDefends = 36;
+const tExtraID kMars49SouthViewMaskFilling = 37;
+const tExtraID kMars52SpinLeft = 38;
+const tExtraID kMars52SpinRight = 39;
+const tExtraID kMars52Extend = 40;
+const tExtraID kMars53Retract = 41;
+const tExtraID kMars54SpinLeft = 42;
+const tExtraID kMars54SpinRight = 43;
+const tExtraID kMars54Extend = 44;
+const tExtraID kMars55Retract = 45;
+const tExtraID kMars56SpinLeft = 46;
+const tExtraID kMars56SpinRight = 47;
+const tExtraID kMars56ExtendWithBomb = 48;
+const tExtraID kMars56ExtendNoBomb = 49;
+const tExtraID kMars57RetractWithBomb = 50;
+const tExtraID kMars57RetractNoBomb = 51;
+const tExtraID kMars57LowerScreenClosed = 52;
+const tExtraID kMars57CantOpenPanel = 53;
+const tExtraID kMars57FreezeLock = 54;
+const tExtraID kMars57BreakLock = 55;
+const tExtraID kMars57LockFrozenView = 56;
+const tExtraID kMars57ThawLock = 57;
+const tExtraID kMars57OpenPanel = 58;
+const tExtraID kMars57OpenPanelChoices = 59;
+const tExtraID kMars57ShieldEvaluation = 60;
+const tExtraID kMars57MeasureOutput = 61;
+const tExtraID kMars57ShieldOkayLoop = 62;
+const tExtraID kMars57RunDiagnostics = 63;
+const tExtraID kMars57BombExplodes = 64;
+const tExtraID kMars57BombAnalysis = 65;
+const tExtraID kMars57DontLink = 66;
+const tExtraID kMars57CircuitLink = 67;
+const tExtraID kMars57GameLevel1 = 68;
+const tExtraID kMars57GameLevel2 = 69;
+const tExtraID kMars57GameLevel3 = 70;
+const tExtraID kMars57BombExplodesInGame = 71;
+const tExtraID kMars57GameSolved = 72;
+const tExtraID kMars57ExposeBomb = 73;
+const tExtraID kMars57BackToNormal = 74;
+const tExtraID kMars57ViewOpenNoBomb = 75;
+const tExtraID kMars58SpinLeft = 76;
+const tExtraID kMars58SpinRight = 77;
+const tExtraID kMars58Extend = 78;
+const tExtraID kMars59Retract = 79;
+const tExtraID kMars60WestSpinAirlockToEast = 80;
+const tExtraID kMars60EastSpinAirlockToWest = 81;
+const tExtraID kMarsRobotHeadOpen = 82;
+const tExtraID kMarsRobotHeadClose = 83;
+const tExtraID kMarsRobotHead000 = 84;
+const tExtraID kMarsRobotHead001 = 85;
+const tExtraID kMarsRobotHead010 = 86;
+const tExtraID kMarsRobotHead011 = 87;
+const tExtraID kMarsRobotHead100 = 88;
+const tExtraID kMarsRobotHead101 = 89;
+const tExtraID kMarsRobotHead110 = 90;
+const tExtraID kMarsRobotHead111 = 91;
+const tExtraID kMarsMaze007RobotApproach = 92;
+const tExtraID kMarsMaze007RobotLoop = 93;
+const tExtraID kMarsMaze007RobotDeath = 94;
+const tExtraID kMarsMaze015SouthRobotApproach = 95;
+const tExtraID kMarsMaze015SouthRobotLoop = 96;
+const tExtraID kMarsMaze015SouthRobotDeath = 97;
+const tExtraID kMarsMaze101EastRobotApproach = 98;
+const tExtraID kMarsMaze101EastRobotLoop = 99;
+const tExtraID kMarsMaze101EastRobotDeath = 100;
+const tExtraID kMarsMaze104WestLoop = 101;
+const tExtraID kMarsMaze104WestDeath = 102;
+const tExtraID kMarsMaze133SouthApproach = 103;
+const tExtraID kMarsMaze133SouthLoop = 104;
+const tExtraID kMarsMaze133SouthDeath = 105;
+const tExtraID kMarsMaze136NorthApproach = 106;
+const tExtraID kMarsMaze136NorthLoop = 107;
+const tExtraID kMarsMaze136NorthDeath = 108;
+const tExtraID kMarsMaze184WestLoop = 109;
+const tExtraID kMarsMaze184WestDeath = 110;
+const tExtraID kMars200DeathInBucket = 111;
+
+const tResIDType kReactorUndoHilitePICTID = 900;
+
+const int16 kMars52Compass = 90;
+const int16 kMars54Compass = 180;
+const int16 kMars56Compass = 270;
+const int16 kMars58Compass = 0;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.h b/engines/pegasus/neighborhood/mars/gravitoncannon.h
index 1919c03..b94fd55 100755
--- a/engines/pegasus/neighborhood/mars/gravitoncannon.h
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.h
@@ -26,11 +26,13 @@
 #ifndef PEGASUS_NEIGHBORHOOD_MARS_GRAVITONCANNON_H
 #define PEGASUS_NEIGHBORHOOD_MARS_GRAVITONCANNON_H
 
+#include "pegasus/surface.h"
 #include "pegasus/neighborhood/mars/shuttleweapon.h"
 
 namespace Pegasus {
 
 class GravitonCannon : public ShuttleWeapon {
+public:
 	GravitonCannon();
 	virtual ~GravitonCannon() {}
 
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index b6b9211..5c36638 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -38,675 +38,6 @@
 
 namespace Pegasus {
 
-const TimeValue kMarsOxyMaskOnIn = 0;
-const TimeValue kMarsOxyMaskOnOut = 1560;
-
-const TimeValue kMarsAirlockButtonBeepIn = 1560;
-const TimeValue kMarsAirlockButtonBeepOut = 1620;
-
-const TimeValue kMarsColorMatchingButtonBeepIn = 1620;
-const TimeValue kMarsColorMatchingButtonBeepOut = 1680;
-
-const TimeValue kMarsKioskBeepIn = 1680;
-const TimeValue kMarsKioskBeepOut = 1740;
-
-const TimeValue kMarsBumpIntoWallIn = 1740;
-const TimeValue kMarsBumpIntoWallOut = 1888;
-
-const TimeValue kMarsGantryDoorCloseIn = 1888;
-const TimeValue kMarsGantryDoorCloseOut = 2866;
-
-const TimeValue kMarsTransportDoorCloseIn = 2866;
-const TimeValue kMarsTransportDoorCloseOut = 3593;
-
-const TimeValue kMarsAirlockPressurizeIn = 3593;
-const TimeValue kMarsAirlockPressurizeOut = 4766;
-
-const TimeValue kMarsBigAirlockDoorCloseIn = 4766;
-const TimeValue kMarsBigAirlockDoorCloseOut = 7872;
-
-const TimeValue kMarsSmallAirlockDoorCloseIn = 7872;
-const TimeValue kMarsSmallAirlockDoorCloseOut = 10000;
-
-const TimeValue kMarsMazeDoorCloseIn = 10000;
-const TimeValue kMarsMazeDoorCloseOut = 10969;
-
-const TimeValue kMarsRobotTakesTransportIn = 10969;
-const TimeValue kMarsRobotTakesTransportOut = 12802;
-
-const TimeValue kMarsPodDepartedUpperPlatformIn = 12802;
-const TimeValue kMarsPodDepartedUpperPlatformOut = 15783;
-
-const TimeValue kMarsPodDepartedLowerPlatformIn = 15783;
-const TimeValue kMarsPodDepartedLowerPlatformOut = 18736;
-
-const TimeValue kMarsPodArrivedUpperPlatformIn = 18736;
-const TimeValue kMarsPodArrivedUpperPlatformOut = 21605;
-
-const TimeValue kMarsCheckInRequiredIn = 21605;
-const TimeValue kMarsCheckInRequiredOut = 27463;
-
-const TimeValue kMarsCantOpenShuttleIn = 27463;
-const TimeValue kMarsCantOpenShuttleOut = 29214;
-
-const TimeValue kMarsShuttleLockOverrideIn = 29214;
-const TimeValue kMarsShuttleLockOverrideOut = 30330;
-
-const TimeValue kMarsNoShuttleIn = 30330;
-const TimeValue kMarsNoShuttleOut = 31502;
-
-const TimeValue kMustBeUnlockedIn = 31502;
-const TimeValue kMustBeUnlockedOut = 33960;
-
-const TimeValue kColorMatchBlueIn = 33960;
-const TimeValue kColorMatchBlueOut = 34240;
-
-const TimeValue kColorMatchRedIn = 34240;
-const TimeValue kColorMatchRedOut = 34538;
-
-const TimeValue kColorMatchGreenIn = 34538;
-const TimeValue kColorMatchGreenOut = 34827;
-
-const TimeValue kColorMatchYellowIn = 34827;
-const TimeValue kColorMatchYellowOut = 35162;
-
-const TimeValue kColorMatchPurpleIn = 35162;
-const TimeValue kColorMatchPurpleOut = 35426;
-
-const TimeValue kColorMatchZeroNodesIn = 35426;
-const TimeValue kColorMatchZeroNodesOut = 36376;
-
-const TimeValue kColorMatchOneNodeIn = 36376;
-const TimeValue kColorMatchOneNodeOut = 37209;
-
-const TimeValue kColorMatchTwoNodesIn = 37209;
-const TimeValue kColorMatchTwoNodesOut = 37983;
-
-const TimeValue kColorMatchThreeNodesIn = 37983;
-const TimeValue kColorMatchThreeNodesOut = 38784;
-
-const TimeValue kMarsShuttle1DepartedIn = 38784;
-const TimeValue kMarsShuttle1DepartedOut = 40323;
-
-const TimeValue kMarsShuttle2DepartedIn = 40323;
-const TimeValue kMarsShuttle2DepartedOut = 41824;
-
-const TimeValue kShuttleCockpitIn = 41824;
-const TimeValue kShuttleCockpitOut = 43126;
-
-const TimeValue kShuttleOnboardIn = 43126;
-const TimeValue kShuttleOnboardOut = 44284;
-
-const TimeValue kShuttleNavigationIn = 44284;
-const TimeValue kShuttleNavigationOut = 46049;
-
-const TimeValue kShuttleCommunicationIn = 46049;
-const TimeValue kShuttleCommunicationOut = 47288;
-
-const TimeValue kShuttleAutoTestingIn = 47288;
-const TimeValue kShuttleAutoTestingOut = 48179;
-
-const TimeValue kMarsThrusterAutoTestIn = 48179;
-const TimeValue kMarsThrusterAutoTestOut = 49979;
-
-const TimeValue kShuttleAllSystemsIn = 49979;
-const TimeValue kShuttleAllSystemsOut = 51065;
-
-const TimeValue kShuttleSecureLooseIn = 51065;
-const TimeValue kShuttleSecureLooseOut = 52346;
-
-const TimeValue kShuttlePrepareForDropIn = 52346;
-const TimeValue kShuttlePrepareForDropOut = 53216;
-
-const TimeValue kShuttleAllClearIn = 53216;
-const TimeValue kShuttleAllClearOut = 54031;
-
-const TimeValue kShuttleConfiguringIn = 54031;
-const TimeValue kShuttleConfiguringOut = 54994;
-
-const TimeValue kShuttleGeneratingIn = 54994;
-const TimeValue kShuttleGeneratingOut = 56033;
-
-const TimeValue kShuttleBreakawayIn = 56033;
-const TimeValue kShuttleBreakawayOut = 57346;
-
-const TimeValue kMarsAtmosphericBreakawayIn = 57346;
-const TimeValue kMarsAtmosphericBreakawayOut = 59237;
-
-const TimeValue kMarsCockpitChatterIn = 59237;
-const TimeValue kMarsCockpitChatterOut = 70344;
-
-const TimeValue kShuttleDamperDescIn = 70344;
-const TimeValue kShuttleDamperDescOut = 73262;
-
-const TimeValue kShuttleGravitonDescIn = 73262;
-const TimeValue kShuttleGravitonDescOut = 75296;
-
-const TimeValue kShuttleTractorDescIn = 75296;
-const TimeValue kShuttleTractorDescOut = 78381;
-
-const TimeValue kShuttleTargetSightedIn = 78381;
-const TimeValue kShuttleTargetSightedOut = 79074;
-
-const TimeValue kShuttleAutopilotEngagedIn = 79074;
-const TimeValue kShuttleAutopilotEngagedOut = 80414;
-
-const TimeValue kMarsEDBBlastIn = 80414;
-const TimeValue kMarsEDBBlastOut = 80705;
-
-const TimeValue kMarsGravitonBlastIn = 80705;
-const TimeValue kMarsGravitonBlastOut = 81199;
-
-const TimeValue kMarsJunkCollisionIn = 81199;
-const TimeValue kMarsJunkCollisionOut = 81961;
-
-const TimeValue kShuttleGravitonIn = 81961;
-const TimeValue kShuttleGravitonOut = 82587;
-
-const TimeValue kShuttleDampingBeamIn = 82587;
-const TimeValue kShuttleDampingBeamOut = 83331;
-
-const TimeValue kShuttleTractorBeamIn = 83331;
-const TimeValue kShuttleTractorBeamOut = 83802;
-
-const TimeValue kShuttleHullBreachIn = 83802;
-const TimeValue kShuttleHullBreachOut = 84721;
-
-const TimeValue kShuttleWingDamageIn = 84721;
-const TimeValue kShuttleWingDamageOut = 85640;
-
-const TimeValue kShuttleHullDamageIn = 85640;
-const TimeValue kShuttleHullDamageOut = 86513;
-
-const TimeValue kShuttleEnergyTooLowIn = 86513;
-const TimeValue kShuttleEnergyTooLowOut = 87578;
-
-const TimeValue kShuttleTractorLimitedIn = 87578;
-const TimeValue kShuttleTractorLimitedOut = 89164;
-
-const TimeValue kShuttleCantHoldIn = 89164;
-const TimeValue kShuttleCantHoldOut = 90945;
-
-const TimeValue kShuttleBrokeFreeIn = 90945;
-const TimeValue kShuttleBrokeFreeOut = 92322;
-
-const TimeValue kShuttleDestroyedIn = 92322;
-const TimeValue kShuttleDestroyedOut = 93189;
-
-const TimeValue kShuttleCoordinatesIn = 93189;
-const TimeValue kShuttleCoordinatesOut = 94018;
-
-const TimeValue kShuttleScanningIn = 94018;
-const TimeValue kShuttleScanningOut = 94975;
-
-const TimeValue kShuttleSafeIn = 94975;
-const TimeValue kShuttleSafeOut = 96176;
-
-const TimeValue kShuttleOverloadedIn = 96176;
-const TimeValue kShuttleOverloadedOut = 101308;
-
-const TimeScale kMarsMovieScale = 600;
-const TimeScale kMarsFramesPerSecond = 15;
-const TimeScale kMarsFrameDuration = 40;
-
-//	Alternate IDs.
-
-const tAlternateID kAltMarsNormal = 0;
-const tAlternateID kAltMarsPodAtMars34 = 1;
-const tAlternateID kAltMarsTookCard = 2;
-const tAlternateID kAltMars35AirlockEast = 3;
-const tAlternateID kAltMars35AirlockWest = 4;
-const tAlternateID kAltMarsPodAtMars45 = 5;
-const tAlternateID kAltMarsTookMask = 6;
-const tAlternateID kAltMarsMaskOnFiller = 7;
-const tAlternateID kAltMars60AirlockEast = 8;
-const tAlternateID kAltMars60AirlockWest = 9;
-
-//	Room IDs.
-
-const tRoomID kMars00 = 1;
-const tRoomID kMars01 = 2;
-const tRoomID kMars02 = 3;
-const tRoomID kMars03 = 4;
-const tRoomID kMars04 = 5;
-const tRoomID kMars05 = 6;
-const tRoomID kMars06 = 7;
-const tRoomID kMars07 = 8;
-const tRoomID kMars08 = 9;
-const tRoomID kMars09 = 10;
-const tRoomID kMars10 = 11;
-const tRoomID kMars11 = 12;
-const tRoomID kMars12 = 13;
-const tRoomID kMars13 = 14;
-const tRoomID kMars14 = 15;
-const tRoomID kMars15 = 16;
-const tRoomID kMars16 = 17;
-const tRoomID kMars17 = 18;
-const tRoomID kMars18 = 19;
-const tRoomID kMars19 = 20;
-const tRoomID kMars20 = 21;
-const tRoomID kMars21 = 22;
-const tRoomID kMars22 = 23;
-const tRoomID kMars23 = 24;
-const tRoomID kMars24 = 25;
-const tRoomID kMars25 = 26;
-const tRoomID kMars26 = 27;
-const tRoomID kMars27 = 28;
-const tRoomID kMars28 = 29;
-const tRoomID kMars29 = 30;
-const tRoomID kMars30 = 31;
-const tRoomID kMars31 = 32;
-const tRoomID kMars32 = 34;
-const tRoomID kMars33 = 35;
-const tRoomID kMars33North = 36;
-const tRoomID kMars36 = 39;
-const tRoomID kMars37 = 40;
-const tRoomID kMars38 = 41;
-const tRoomID kMars41 = 43;
-const tRoomID kMars42 = 44;
-const tRoomID kMars43 = 45;
-const tRoomID kMars44 = 46;
-const tRoomID kMars45 = 47;
-const tRoomID kMars46 = 48;
-const tRoomID kMars47 = 49;
-const tRoomID kMars48 = 50;
-const tRoomID kMars50 = 52;
-const tRoomID kMars51 = 53;
-const tRoomID kMars52 = 54;
-const tRoomID kMars54 = 55;
-const tRoomID kMars56 = 56;
-const tRoomID kMars58 = 57;
-const tRoomID kMarsRobotShuttle = 59;
-const tRoomID kMarsMaze005 = 61;
-const tRoomID kMarsMaze006 = 62;
-const tRoomID kMarsMaze007 = 63;
-const tRoomID kMarsMaze008 = 64;
-const tRoomID kMarsMaze009 = 65;
-const tRoomID kMarsMaze010 = 66;
-const tRoomID kMarsMaze011 = 67;
-const tRoomID kMarsMaze012 = 68;
-const tRoomID kMarsMaze015 = 69;
-const tRoomID kMarsMaze016 = 70;
-const tRoomID kMarsMaze017 = 71;
-const tRoomID kMarsMaze018 = 72;
-const tRoomID kMarsMaze019 = 73;
-const tRoomID kMarsMaze020 = 74;
-const tRoomID kMarsMaze021 = 75;
-const tRoomID kMarsMaze022 = 76;
-const tRoomID kMarsMaze023 = 77;
-const tRoomID kMarsMaze024 = 78;
-const tRoomID kMarsMaze025 = 79;
-const tRoomID kMarsMaze026 = 80;
-const tRoomID kMarsMaze027 = 81;
-const tRoomID kMarsMaze028 = 82;
-const tRoomID kMarsMaze031 = 83;
-const tRoomID kMarsMaze032 = 84;
-const tRoomID kMarsMaze033 = 85;
-const tRoomID kMarsMaze034 = 86;
-const tRoomID kMarsMaze035 = 87;
-const tRoomID kMarsMaze036 = 88;
-const tRoomID kMarsMaze037 = 89;
-const tRoomID kMarsMaze038 = 90;
-const tRoomID kMarsMaze039 = 91;
-const tRoomID kMarsMaze042 = 92;
-const tRoomID kMarsMaze043 = 93;
-const tRoomID kMarsMaze044 = 94;
-const tRoomID kMarsMaze045 = 95;
-const tRoomID kMarsMaze046 = 96;
-const tRoomID kMarsMaze047 = 97;
-const tRoomID kMarsMaze049 = 98;
-const tRoomID kMarsMaze050 = 99;
-const tRoomID kMarsMaze051 = 100;
-const tRoomID kMarsMaze052 = 101;
-const tRoomID kMarsMaze053 = 102;
-const tRoomID kMarsMaze054 = 103;
-const tRoomID kMarsMaze055 = 104;
-const tRoomID kMarsMaze056 = 105;
-const tRoomID kMarsMaze057 = 106;
-const tRoomID kMarsMaze058 = 107;
-const tRoomID kMarsMaze059 = 108;
-const tRoomID kMarsMaze060 = 109;
-const tRoomID kMarsMaze061 = 110;
-const tRoomID kMarsMaze063 = 111;
-const tRoomID kMarsMaze064 = 112;
-const tRoomID kMarsMaze065 = 113;
-const tRoomID kMarsMaze066 = 114;
-const tRoomID kMarsMaze067 = 115;
-const tRoomID kMarsMaze068 = 116;
-const tRoomID kMarsMaze069 = 117;
-const tRoomID kMarsMaze070 = 118;
-const tRoomID kMarsMaze071 = 119;
-const tRoomID kMarsMaze072 = 120;
-const tRoomID kMarsMaze074 = 121;
-const tRoomID kMarsMaze076 = 122;
-const tRoomID kMarsMaze078 = 123;
-const tRoomID kMarsMaze079 = 124;
-const tRoomID kMarsMaze081 = 125;
-const tRoomID kMarsMaze083 = 126;
-const tRoomID kMarsMaze084 = 127;
-const tRoomID kMarsMaze085 = 128;
-const tRoomID kMarsMaze086 = 129;
-const tRoomID kMarsMaze087 = 130;
-const tRoomID kMarsMaze088 = 131;
-const tRoomID kMarsMaze089 = 132;
-const tRoomID kMarsMaze090 = 133;
-const tRoomID kMarsMaze091 = 134;
-const tRoomID kMarsMaze092 = 135;
-const tRoomID kMarsMaze093 = 136;
-const tRoomID kMarsMaze098 = 137;
-const tRoomID kMarsMaze099 = 138;
-const tRoomID kMarsMaze100 = 139;
-const tRoomID kMarsMaze101 = 140;
-const tRoomID kMarsMaze104 = 141;
-const tRoomID kMarsMaze105 = 142;
-const tRoomID kMarsMaze106 = 143;
-const tRoomID kMarsMaze107 = 144;
-const tRoomID kMarsMaze108 = 145;
-const tRoomID kMarsMaze111 = 146;
-const tRoomID kMarsMaze113 = 147;
-const tRoomID kMarsMaze114 = 148;
-const tRoomID kMarsMaze115 = 149;
-const tRoomID kMarsMaze116 = 150;
-const tRoomID kMarsMaze117 = 151;
-const tRoomID kMarsMaze118 = 152;
-const tRoomID kMarsMaze119 = 153;
-const tRoomID kMarsMaze120 = 154;
-const tRoomID kMarsMaze121 = 155;
-const tRoomID kMarsMaze122 = 156;
-const tRoomID kMarsMaze123 = 157;
-const tRoomID kMarsMaze124 = 158;
-const tRoomID kMarsMaze125 = 159;
-const tRoomID kMarsMaze126 = 160;
-const tRoomID kMarsMaze127 = 161;
-const tRoomID kMarsMaze128 = 162;
-const tRoomID kMarsMaze129 = 163;
-const tRoomID kMarsMaze130 = 164;
-const tRoomID kMarsMaze131 = 165;
-const tRoomID kMarsMaze132 = 166;
-const tRoomID kMarsMaze133 = 167;
-const tRoomID kMarsMaze136 = 168;
-const tRoomID kMarsMaze137 = 169;
-const tRoomID kMarsMaze138 = 170;
-const tRoomID kMarsMaze139 = 171;
-const tRoomID kMarsMaze140 = 172;
-const tRoomID kMarsMaze141 = 173;
-const tRoomID kMarsMaze142 = 174;
-const tRoomID kMarsMaze143 = 175;
-const tRoomID kMarsMaze144 = 176;
-const tRoomID kMarsMaze145 = 177;
-const tRoomID kMarsMaze146 = 178;
-const tRoomID kMarsMaze147 = 179;
-const tRoomID kMarsMaze148 = 180;
-const tRoomID kMarsMaze149 = 181;
-const tRoomID kMarsMaze152 = 182;
-const tRoomID kMarsMaze153 = 183;
-const tRoomID kMarsMaze154 = 184;
-const tRoomID kMarsMaze155 = 185;
-const tRoomID kMarsMaze156 = 186;
-const tRoomID kMarsMaze157 = 187;
-const tRoomID kMarsMaze159 = 188;
-const tRoomID kMarsMaze160 = 189;
-const tRoomID kMarsMaze161 = 190;
-const tRoomID kMarsMaze162 = 191;
-const tRoomID kMarsMaze163 = 192;
-const tRoomID kMarsMaze164 = 193;
-const tRoomID kMarsMaze165 = 194;
-const tRoomID kMarsMaze166 = 195;
-const tRoomID kMarsMaze167 = 196;
-const tRoomID kMarsMaze168 = 197;
-const tRoomID kMarsMaze169 = 198;
-const tRoomID kMarsMaze170 = 199;
-const tRoomID kMarsMaze171 = 200;
-const tRoomID kMarsMaze172 = 201;
-const tRoomID kMarsMaze173 = 202;
-const tRoomID kMarsMaze174 = 203;
-const tRoomID kMarsMaze175 = 204;
-const tRoomID kMarsMaze177 = 205;
-const tRoomID kMarsMaze178 = 206;
-const tRoomID kMarsMaze179 = 207;
-const tRoomID kMarsMaze180 = 208;
-const tRoomID kMarsMaze181 = 209;
-const tRoomID kMarsMaze182 = 210;
-const tRoomID kMarsMaze183 = 211;
-const tRoomID kMarsMaze184 = 212;
-const tRoomID kMarsMaze187 = 213;
-const tRoomID kMarsMaze188 = 214;
-const tRoomID kMarsMaze189 = 215;
-const tRoomID kMarsMaze190 = 216;
-const tRoomID kMarsMaze191 = 217;
-const tRoomID kMarsMaze192 = 218;
-const tRoomID kMarsMaze193 = 219;
-const tRoomID kMarsMaze194 = 220;
-const tRoomID kMarsMaze195 = 221;
-const tRoomID kMarsMaze198 = 222;
-const tRoomID kMarsMaze199 = 223;
-const tRoomID kMarsDeathRoom = 225;
-
-//	Hot Spot Activation IDs.
-
-const tHotSpotActivationID kActivationReadyForKiosk = 1;
-const tHotSpotActivationID kActivationKioskChoice = 2;
-const tHotSpotActivationID kActivationTunnelMapReady = 3;
-const tHotSpotActivationID kActivateMarsPodClosed = 4;
-const tHotSpotActivationID kActivateMarsPodOpen = 5;
-const tHotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
-const tHotSpotActivationID kActivateAirlockPressurized = 7;
-const tHotSpotActivationID kActivateMaskOnHolder = 8;
-const tHotSpotActivationID kActivateMaskOnFiller = 9;
-const tHotSpotActivationID kActivateReactorPlatformOut = 10;
-const tHotSpotActivationID kActivateReactorPlatformIn = 11;
-const tHotSpotActivationID kActivateReactorAskLowerScreen = 12;
-const tHotSpotActivationID kActivateReactorReadyForNitrogen = 13;
-const tHotSpotActivationID kActivateReactorReadyForCrowBar = 14;
-const tHotSpotActivationID kActivateReactorAskOperation = 15;
-const tHotSpotActivationID kActivateReactorRanEvaluation = 16;
-const tHotSpotActivationID kActivateReactorRanDiagnostics = 17;
-const tHotSpotActivationID kActivateReactorAnalyzed = 18;
-const tHotSpotActivationID kActivateReactorInstructions = 19;
-const tHotSpotActivationID kActivateReactorInGame = 20;
-const tHotSpotActivationID kActivateReactorBombSafe = 21;
-const tHotSpotActivationID kActivateReactorBombExposed = 22;
-const tHotSpotActivationID kActivationRobotHeadClosed = 23;
-const tHotSpotActivationID kActivationRobotHeadOpen = 24;
-
-//	Hot Spot IDs.
-
-const tHotSpotID kMars11NorthKioskSpotID = 5000;
-const tHotSpotID kMars11NorthKioskSightsSpotID = 5001;
-const tHotSpotID kMars11NorthKioskColonySpotID = 5002;
-const tHotSpotID kMars12NorthKioskSpotID = 5003;
-const tHotSpotID kMars12NorthKioskSightsSpotID = 5004;
-const tHotSpotID kMars12NorthKioskColonySpotID = 5005;
-const tHotSpotID kMars31SouthSpotID = 5006;
-const tHotSpotID kMars31SouthOutSpotID = 5007;
-const tHotSpotID kMars31SouthCardSpotID = 5008;
-const tHotSpotID kMars33NorthSpotID = 5009;
-const tHotSpotID kMars33NorthOutSpotID = 5010;
-const tHotSpotID kMars33NorthMonitorSpotID = 5011;
-const tHotSpotID kMars34NorthCardDropSpotID = 5012;
-const tHotSpotID kMars34SouthOpenStorageSpotID = 5013;
-const tHotSpotID kMars34SouthCloseStorageSpotID = 5014;
-const tHotSpotID kMars34SouthCrowbarSpotID = 5015;
-const tHotSpotID kMars35EastPressurizeSpotID = 5016;
-const tHotSpotID kMars35EastSpinSpotID = 5017;
-const tHotSpotID kMars35WestPressurizeSpotID = 5018;
-const tHotSpotID kMars35WestSpinSpotID = 5019;
-const tHotSpotID kMars45NorthOpenStorageSpotID = 5020;
-const tHotSpotID kMars45NorthCloseStorageSpotID = 5021;
-const tHotSpotID kMars45NorthCrowbarSpotID = 5022;
-const tHotSpotID kAttackRobotHotSpotID = 5023;
-const tHotSpotID kMars49AirMaskSpotID = 5024;
-const tHotSpotID kMars49AirMaskFilledSpotID = 5025;
-const tHotSpotID kMars49AirFillingDropSpotID = 5026;
-const tHotSpotID kMars52MoveLeftSpotID = 5027;
-const tHotSpotID kMars52MoveRightSpotID = 5028;
-const tHotSpotID kMars52ExtractSpotID = 5029;
-const tHotSpotID kMars53RetractSpotID = 5030;
-const tHotSpotID kMars54MoveLeftSpotID = 5031;
-const tHotSpotID kMars54MoveRightSpotID = 5032;
-const tHotSpotID kMars54ExtractSpotID = 5033;
-const tHotSpotID kMars55RetractSpotID = 5034;
-const tHotSpotID kMars56MoveLeftSpotID = 5035;
-const tHotSpotID kMars56MoveRightSpotID = 5036;
-const tHotSpotID kMars56ExtractSpotID = 5037;
-const tHotSpotID kMars57RetractSpotID = 5038;
-const tHotSpotID kMars57LowerScreenSpotID = 5039;
-const tHotSpotID kMars57Retract2SpotID = 5040;
-const tHotSpotID kMars57DropNitrogenSpotID = 5041;
-const tHotSpotID kMars57DropCrowBarSpotID = 5042;
-const tHotSpotID kMars57CantOpenPanelSpotID = 5043;
-const tHotSpotID kMars57ShieldEvaluationSpotID = 5044;
-const tHotSpotID kMars57MeasureOutputSpotID = 5045;
-const tHotSpotID kMars57RunDiagnosticsSpotID = 5046;
-const tHotSpotID kMars57BackToOperationMenuSpotID = 5047;
-const tHotSpotID kMars57AnalyzeObjectSpotID = 5048;
-const tHotSpotID kMars57RemoveObjectMenuSpotID = 5049;
-const tHotSpotID kMars57CircuitLinkSpotID = 5050;
-const tHotSpotID kMars57CancelCircuitLinkSpotID = 5051;
-const tHotSpotID kMars57GameInstructionsSpotID = 5052;
-const tHotSpotID kMars57UndoMoveSpotID = 5053;
-const tHotSpotID kMars57RedMoveSpotID = 5054;
-const tHotSpotID kMars57YellowMoveSpotID = 5055;
-const tHotSpotID kMars57GreenMoveSpotID = 5056;
-const tHotSpotID kMars57BlueMoveSpotID = 5057;
-const tHotSpotID kMars57PurpleMoveSpotID = 5058;
-const tHotSpotID kMars57LowerScreenSafelySpotID = 5059;
-const tHotSpotID kMars57GrabBombSpotID = 5060;
-const tHotSpotID kMars58MoveLeftSpotID = 5061;
-const tHotSpotID kMars58MoveRightSpotID = 5062;
-const tHotSpotID kMars58ExtractSpotID = 5063;
-const tHotSpotID kMars59RetractSpotID = 5064;
-const tHotSpotID kMars60EastPressurizeSpotID = 5065;
-const tHotSpotID kMars60EastSpinSpotID = 5066;
-const tHotSpotID kMars60WestPressurizeSpotID = 5067;
-const tHotSpotID kMars60WestSpinSpotID = 5068;
-const tHotSpotID kRobotShuttleOpenHeadSpotID = 5069;
-const tHotSpotID kRobotShuttleMapChipSpotID = 5070;
-const tHotSpotID kRobotShuttleOpticalChipSpotID = 5071;
-const tHotSpotID kRobotShuttleShieldChipSpotID = 5072;
-
-//	Extra sequence IDs.
-
-const tExtraID kMarsArrivalFromTSA = 0;
-const tExtraID kMars0AWatchShuttleDepart = 1;
-const tExtraID kRobotThrowsPlayer = 2;
-const tExtraID kMarsInfoKioskIntro = 3;
-const tExtraID kMarsColonyInfo = 4;
-const tExtraID kMarsSightsInfo = 5;
-const tExtraID kRobotOnWayToShuttle = 6;
-const tExtraID kMars31SouthZoomInNoCard = 7;
-const tExtraID kMars31SouthViewNoCard = 8;
-const tExtraID kMars31SouthZoomOutNoCard = 9;
-const tExtraID kMars31SouthZoomViewNoCard = 10;
-const tExtraID kMars33SlideShow1 = 11;
-const tExtraID kMars33SlideShow2 = 12;
-const tExtraID kMars33SlideShow3 = 13;
-const tExtraID kMars33SlideShow4 = 14;
-const tExtraID kMars34SpotOpenWithBar = 15;
-const tExtraID kMars34SpotCloseWithBar = 16;
-const tExtraID kMars34SpotOpenNoBar = 17;
-const tExtraID kMars34SpotCloseNoBar = 18;
-const tExtraID kMars34ViewOpenWithBar = 19;
-const tExtraID kMars34ViewOpenNoBar = 20;
-const tExtraID kMars34NorthPodGreeting = 21;
-const tExtraID kMarsTurnOnPod = 22;
-const tExtraID kMarsTakePodToMars45 = 23;
-const tExtraID kMars35WestSpinAirlockToEast = 24;
-const tExtraID kMars35EastSpinAirlockToWest = 25;
-const tExtraID kMars45SpotOpenWithBar = 26;
-const tExtraID kMars45SpotCloseWithBar = 27;
-const tExtraID kMars45SpotOpenNoBar = 28;
-const tExtraID kMars45SpotCloseNoBar = 29;
-const tExtraID kMars45ViewOpenWithBar = 30;
-const tExtraID kMars45ViewOpenNoBar = 31;
-const tExtraID kMars48RobotApproaches = 32;
-const tExtraID kMars48RobotKillsPlayer = 33;
-const tExtraID kMars48RobotLoops = 34;
-const tExtraID kMars48RobotView = 35;
-const tExtraID kMars48RobotDefends = 36;
-const tExtraID kMars49SouthViewMaskFilling = 37;
-const tExtraID kMars52SpinLeft = 38;
-const tExtraID kMars52SpinRight = 39;
-const tExtraID kMars52Extend = 40;
-const tExtraID kMars53Retract = 41;
-const tExtraID kMars54SpinLeft = 42;
-const tExtraID kMars54SpinRight = 43;
-const tExtraID kMars54Extend = 44;
-const tExtraID kMars55Retract = 45;
-const tExtraID kMars56SpinLeft = 46;
-const tExtraID kMars56SpinRight = 47;
-const tExtraID kMars56ExtendWithBomb = 48;
-const tExtraID kMars56ExtendNoBomb = 49;
-const tExtraID kMars57RetractWithBomb = 50;
-const tExtraID kMars57RetractNoBomb = 51;
-const tExtraID kMars57LowerScreenClosed = 52;
-const tExtraID kMars57CantOpenPanel = 53;
-const tExtraID kMars57FreezeLock = 54;
-const tExtraID kMars57BreakLock = 55;
-const tExtraID kMars57LockFrozenView = 56;
-const tExtraID kMars57ThawLock = 57;
-const tExtraID kMars57OpenPanel = 58;
-const tExtraID kMars57OpenPanelChoices = 59;
-const tExtraID kMars57ShieldEvaluation = 60;
-const tExtraID kMars57MeasureOutput = 61;
-const tExtraID kMars57ShieldOkayLoop = 62;
-const tExtraID kMars57RunDiagnostics = 63;
-const tExtraID kMars57BombExplodes = 64;
-const tExtraID kMars57BombAnalysis = 65;
-const tExtraID kMars57DontLink = 66;
-const tExtraID kMars57CircuitLink = 67;
-const tExtraID kMars57GameLevel1 = 68;
-const tExtraID kMars57GameLevel2 = 69;
-const tExtraID kMars57GameLevel3 = 70;
-const tExtraID kMars57BombExplodesInGame = 71;
-const tExtraID kMars57GameSolved = 72;
-const tExtraID kMars57ExposeBomb = 73;
-const tExtraID kMars57BackToNormal = 74;
-const tExtraID kMars57ViewOpenNoBomb = 75;
-const tExtraID kMars58SpinLeft = 76;
-const tExtraID kMars58SpinRight = 77;
-const tExtraID kMars58Extend = 78;
-const tExtraID kMars59Retract = 79;
-const tExtraID kMars60WestSpinAirlockToEast = 80;
-const tExtraID kMars60EastSpinAirlockToWest = 81;
-const tExtraID kMarsRobotHeadOpen = 82;
-const tExtraID kMarsRobotHeadClose = 83;
-const tExtraID kMarsRobotHead000 = 84;
-const tExtraID kMarsRobotHead001 = 85;
-const tExtraID kMarsRobotHead010 = 86;
-const tExtraID kMarsRobotHead011 = 87;
-const tExtraID kMarsRobotHead100 = 88;
-const tExtraID kMarsRobotHead101 = 89;
-const tExtraID kMarsRobotHead110 = 90;
-const tExtraID kMarsRobotHead111 = 91;
-const tExtraID kMarsMaze007RobotApproach = 92;
-const tExtraID kMarsMaze007RobotLoop = 93;
-const tExtraID kMarsMaze007RobotDeath = 94;
-const tExtraID kMarsMaze015SouthRobotApproach = 95;
-const tExtraID kMarsMaze015SouthRobotLoop = 96;
-const tExtraID kMarsMaze015SouthRobotDeath = 97;
-const tExtraID kMarsMaze101EastRobotApproach = 98;
-const tExtraID kMarsMaze101EastRobotLoop = 99;
-const tExtraID kMarsMaze101EastRobotDeath = 100;
-const tExtraID kMarsMaze104WestLoop = 101;
-const tExtraID kMarsMaze104WestDeath = 102;
-const tExtraID kMarsMaze133SouthApproach = 103;
-const tExtraID kMarsMaze133SouthLoop = 104;
-const tExtraID kMarsMaze133SouthDeath = 105;
-const tExtraID kMarsMaze136NorthApproach = 106;
-const tExtraID kMarsMaze136NorthLoop = 107;
-const tExtraID kMarsMaze136NorthDeath = 108;
-const tExtraID kMarsMaze184WestLoop = 109;
-const tExtraID kMarsMaze184WestDeath = 110;
-const tExtraID kMars200DeathInBucket = 111;
-
-const tResIDType kReactorUndoHilitePICTID = 900;
-
-const int16 kMars52Compass = 90;
-const int16 kMars54Compass = 180;
-const int16 kMars56Compass = 270;
-const int16 kMars58Compass = 0;
-
 // This should really be 22.5.
 // Probably no one will know the difference.
 const int16 kMarsShieldPanelOffsetAngle = 22;
@@ -747,6 +78,13 @@ enum {
 	kMaze184RobotLoopingTime = 96 * kMarsFrameDuration
 };
 
+// I've made a couple macros for these rects so we don't
+// have to globally construct them or whatnot
+#define kShuttleEnergyBeamBounds Common::Rect(24, 27, 24 + 112, 27 + 46)
+#define kShuttleGravitonBounds Common::Rect(24, 73, 24 + 112, 73 + 30)
+#define kShuttleTractorBounds Common::Rect(24, 103, 24 + 112, 103 + 30)
+#define kShuttleTransportBounds Common::Rect(484, 353, 89 + 484, 79 + 353)
+
 void robotTimerExpiredFunction(FunctionPtr *, void *mars) {
 	((Mars *)mars)->robotTiredOfWaiting();
 }
@@ -778,7 +116,10 @@ Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextH
 		_leftShuttleMovie(kNoDisplayElement), _rightShuttleMovie(kNoDisplayElement), _lowerLeftShuttleMovie(kNoDisplayElement),
 		_lowerRightShuttleMovie(kNoDisplayElement), _centerShuttleMovie(kNoDisplayElement),
 		_upperLeftShuttleMovie(kNoDisplayElement), _upperRightShuttleMovie(kNoDisplayElement),
-		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement), _explosions(kNoDisplayElement) {
+		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement), _explosions(kNoDisplayElement),
+		_planetMovie(kNoDisplayElement), _junk(kNoDisplayElement), _energyChoiceSpot(kShuttleEnergySpotID),
+		_gravitonChoiceSpot(kShuttleGravitonSpotID), _tractorChoiceSpot(kShuttleTractorSpotID),
+		_shuttleViewSpot(kShuttleViewSpotID), _shuttleTransportSpot(kShuttleTransportSpotID) {
 	_noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
 	setIsItemTaken(kMarsCard);
 	setIsItemTaken(kAirMask);
@@ -787,6 +128,11 @@ Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextH
 }
 
 Mars::~Mars() {
+	g_allHotspots.remove(&_energyChoiceSpot);
+	g_allHotspots.remove(&_gravitonChoiceSpot);
+	g_allHotspots.remove(&_tractorChoiceSpot);
+	g_allHotspots.remove(&_shuttleViewSpot);
+	g_allHotspots.remove(&_shuttleTransportSpot);
 }
 
 void Mars::init() {	
@@ -1880,8 +1226,12 @@ void Mars::arriveAt(const tRoomID room, const tDirectionConstant direction) {
 		}
 		break;
 	case MakeRoomView(kMars44, kWest):
-		// TODO: Space Chase
-		_neighborhoodNotification.setNotificationFlags(kTimeForCanyonChaseFlag, kTimeForCanyonChaseFlag);
+		if (GameState.getMarsReadyForShuttleTransport())
+			startUpFromFinishedSpaceChase();
+		else if (GameState.getMarsFinishedCanyonChase())
+			startUpFromSpaceChase();
+		else
+			_neighborhoodNotification.setNotificationFlags(kTimeForCanyonChaseFlag, kTimeForCanyonChaseFlag);
 		break;
 	case MakeRoomView(kMars10, kNorth):
 		if (!GameState.getMarsRobotThrownPlayer())
@@ -2306,7 +1656,15 @@ void Mars::activateHotspots() {
 		break;
 	default:
 		if (_privateFlags.getFlag(kMarsPrivateInSpaceChaseFlag)) {
-			// TODO
+			if (GameState.getMarsReadyForShuttleTransport()) {
+				_shuttleTransportSpot.setActive();
+			} else {
+				_energyChoiceSpot.setActive();
+				_gravitonChoiceSpot.setActive();
+				_tractorChoiceSpot.setActive();
+				if (_weaponSelection != kNoWeapon)
+					_shuttleViewSpot.setActive();
+			}
 		}
 		break;
 	}
@@ -2414,6 +1772,13 @@ void Mars::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 		doReactorGuess(4);
 		break;
+	case kShuttleEnergySpotID:
+	case kShuttleGravitonSpotID:
+	case kShuttleTractorSpotID:
+	case kShuttleViewSpotID:
+	case kShuttleTransportSpotID:
+		spaceChaseClick(input, clickedSpot->getObjectID());
+		break;
 	default:
 		Neighborhood::clickInHotspot(input, clickedSpot);
 		break;
@@ -2450,7 +1815,8 @@ tInputBits Mars::getInputFilter() {
 			result &= ~kFilterAllDirections;
 		break;
 	case MakeRoomView(kMars44, kWest):
-		// TODO
+		if (_canyonChaseMovie.isMovieValid() && _canyonChaseMovie.isRunning())
+			result &= ~kFilterAllDirections;
 		break;
 	}
 
@@ -3007,7 +2373,7 @@ void Mars::receiveNotification(Notification *notification, const tNotificationFl
 			recallToTSASuccess();
 		}
 	} else if ((flag & kTimeToTransportFlag) != 0) {
-		// TODO
+		transportToRobotShip();
 	}
 
 	if (g_AIArea)
@@ -3128,6 +2494,7 @@ void Mars::doCanyonChase() {
 	// Take it down a tick initially. This sets the time to the time of the last tick,
 	// so that subsequence drops will drop it down a tick.
 	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
+	_leftDamageShuttleMovie.redrawMovieWorld();
 	
 	_lowerRightShuttleMovie.show();
 	_lowerRightShuttleMovie.setTime(kShuttleLowerRightOffTime);
@@ -3178,6 +2545,242 @@ void Mars::doCanyonChase() {
 	startMarsTimer(kLaunchTubeReachedTime, kMovieTicksPerSecond, kMarsLaunchTubeReached);
 }
 
+void Mars::startUpFromFinishedSpaceChase() {
+	setNextHandler(_vm);
+	throwAwayInterface();
+
+	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
+							kShuttle1Top, true);
+	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
+							kShuttle2Top, true);
+	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
+							kShuttle3Top, true);
+	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
+							kShuttle4Top, true);
+	
+	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
+	
+	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
+	
+	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
+	
+	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
+	
+	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
+	
+	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
+	
+	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
+	
+	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
+	
+	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
+
+	_centerShuttleMovie.show();
+
+	_shuttleEnergyMeter.initShuttleEnergyMeter();
+	_shuttleEnergyMeter.setEnergyValue(kFullShuttleEnergy);
+
+	_leftShuttleMovie.show();
+	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
+	_leftShuttleMovie.redrawMovieWorld();
+
+	_leftDamageShuttleMovie.show();
+	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getDuration() - 40);
+	_leftDamageShuttleMovie.redrawMovieWorld();
+
+	_lowerRightShuttleMovie.show();
+
+	_lowerLeftShuttleMovie.show();
+
+	loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
+
+	initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft,
+			kShuttleJunkTop, false);
+
+	initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+	_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
+
+	_energyBeam.initShuttleWeapon();
+	_gravitonCannon.initShuttleWeapon();
+
+	_upperLeftShuttleMovie.show();
+	_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
+	_upperLeftShuttleMovie.redrawMovieWorld();
+
+	_rightShuttleMovie.show();
+	_rightShuttleMovie.setTime(kShuttleRightIntroStop - 1);
+	_rightShuttleMovie.redrawMovieWorld();
+
+	_rightDamageShuttleMovie.show();
+	_rightDamageShuttleMovie.setTime(40);
+	_rightDamageShuttleMovie.redrawMovieWorld();
+
+	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
+	_lowerLeftShuttleMovie.redrawMovieWorld();
+	
+	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
+	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_shuttleTransportSpot);
+
+	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
+
+	_upperRightShuttleMovie.show();
+	_upperRightShuttleMovie.setTime(kShuttleUpperRightOverloadTime);
+	_upperRightShuttleMovie.redrawMovieWorld();
+
+	_centerShuttleMovie.setTime(kShuttleCenterSafeTime);
+	_centerShuttleMovie.redrawMovieWorld();
+
+	_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportTime);
+	_lowerRightShuttleMovie.redrawMovieWorld();
+
+	initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
+			kShuttleWindowLeft, kShuttleWindowTop, true);
+	_canyonChaseMovie.setTime(_canyonChaseMovie.getDuration());
+	_canyonChaseMovie.redrawMovieWorld();
+}
+
+void Mars::startUpFromSpaceChase() {
+	setNextHandler(_vm);
+	throwAwayInterface();
+	
+	// Open the spot sounds movie again...
+	_spotSounds.initFromQuickTime(getSoundSpotsName());
+	_spotSounds.setVolume(_vm->getSoundFXLevel());;
+	
+	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
+							kShuttle1Top, true);
+	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
+							kShuttle2Top, true);
+	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
+							kShuttle3Top, true);
+	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
+							kShuttle4Top, true);
+	
+	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
+	
+	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
+	
+	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
+	
+	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
+	
+	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
+			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
+	
+	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
+	
+	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
+			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
+	
+	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
+	
+	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
+			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
+
+	_centerShuttleMovie.show();
+
+	_shuttleEnergyMeter.initShuttleEnergyMeter();
+	_shuttleEnergyMeter.setEnergyValue(kFullShuttleEnergy);
+
+	_leftShuttleMovie.show();
+	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
+	_leftShuttleMovie.redrawMovieWorld();
+	
+	_leftDamageShuttleMovie.show();
+	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getDuration() - 40);
+	_leftDamageShuttleMovie.redrawMovieWorld();
+
+	_lowerRightShuttleMovie.show();
+
+	_lowerLeftShuttleMovie.show();
+
+	loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
+	
+	initOneMovie(&_planetMovie, "Images/Mars/Planet.movie", kShuttlePlanetOrder,
+			kPlanetStartLeft, kPlanetStartTop, true);
+	_planetMovie.setFlags(kLoopTimeBase);
+
+	initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft,
+			kShuttleJunkTop, false);
+	
+	initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+	_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
+
+	_energyBeam.initShuttleWeapon();
+	_gravitonCannon.initShuttleWeapon();
+
+	_upperLeftShuttleMovie.show();
+
+	_robotShip.initRobotShip();
+
+	_planetMovie.start();
+	_planetMover.startMoving(&_planetMovie);
+
+	_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
+	_upperLeftShuttleMovie.redrawMovieWorld();
+
+	_centerShuttleMovie.setTime(kShuttleCenterTargetSightedTime);
+	_centerShuttleMovie.redrawMovieWorld();
+
+	_lowerRightShuttleMovie.setTime(kShuttleLowerRightTrackingTime);
+	_lowerRightShuttleMovie.redrawMovieWorld();
+
+	_rightShuttleMovie.show();
+	_rightShuttleMovie.setTime(kShuttleRightIntroStop - 1);
+	_rightShuttleMovie.redrawMovieWorld();
+
+	_rightDamageShuttleMovie.show();
+	_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getDuration() - 40);
+	_rightDamageShuttleMovie.redrawMovieWorld();
+
+	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
+	_lowerLeftShuttleMovie.redrawMovieWorld();
+
+	_robotShip.startMoving();
+
+	_shuttleHUD.initShuttleHUD();
+
+	_tractorBeam.startDisplaying();
+
+	_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
+	_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_energyChoiceSpot);
+	_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
+	_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_gravitonChoiceSpot);
+	_tractorChoiceSpot.setArea(kShuttleTractorBounds);
+	_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_tractorChoiceSpot);
+	_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
+			kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
+	_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_shuttleViewSpot);
+	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
+	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+	g_allHotspots.push_back(&_shuttleTransportSpot);
+
+	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
+
+	startMarsTimer(kSpaceChaseTimeLimit, kOneTickPerSecond, kMarsSpaceChaseFinished);
+}
+
 void Mars::setSoundFXLevel(const uint16 level) {
 	Neighborhood::setSoundFXLevel(level);
 
@@ -3219,7 +2822,101 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
 		_canyonChaseMovie.stopDisplaying();
 		_canyonChaseMovie.releaseMovie();
 
-		error("STUB: Space chase");
+		loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
+
+		playSpotSoundSync(kShuttleConfiguringIn, kShuttleConfiguringOut);
+		playSpotSoundSync(kShuttleGeneratingIn, kShuttleGeneratingOut);
+		playSpotSoundSync(kShuttleBreakawayIn, kShuttleBreakawayOut);
+		playSpotSoundSync(kMarsAtmosphericBreakawayIn, kMarsAtmosphericBreakawayOut);
+
+		initOneMovie(&_planetMovie, "Images/Mars/Planet.movie", kShuttlePlanetOrder, kPlanetStartLeft, kPlanetStartTop, true);
+		_planetMovie.setFlags(kLoopTimeBase);
+
+		initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft, kShuttleJunkTop, false);
+
+		initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
+		_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
+
+		_energyBeam.initShuttleWeapon();
+		_gravitonCannon.initShuttleWeapon();
+
+		_centerShuttleMovie.setTime(kShuttleCenterWeaponsTime);
+		_centerShuttleMovie.redrawMovieWorld();
+
+		_upperLeftShuttleMovie.show();
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDampingTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+
+		_robotShip.initRobotShip();
+
+		_planetMovie.start();
+		_planetMover.startMoving(&_planetMovie);
+
+		playSpotSoundSync(kShuttleDamperDescIn, kShuttleDamperDescOut);
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftGravitonTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+
+		playSpotSoundSync(kShuttleGravitonDescIn, kShuttleGravitonDescOut);
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftTractorTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+
+		playSpotSoundSync(kShuttleTractorDescIn, kShuttleTractorDescOut);
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+			
+		_centerShuttleMovie.setTime(kShuttleCenterTargetSightedTime);
+		_centerShuttleMovie.redrawMovieWorld();
+		playSpotSoundSync(kShuttleTargetSightedIn, kShuttleTargetSightedOut);
+
+		_lowerRightShuttleMovie.setTime(kShuttleLowerRightTrackingTime);
+		_lowerRightShuttleMovie.redrawMovieWorld();
+		_rightShuttleMovie.show();
+		playMovieSegment(&_rightShuttleMovie, kShuttleRightIntroStart, kShuttleRightIntroStop);
+
+		_rightDamageShuttleMovie.show();
+		playMovieSegment(&_rightDamageShuttleMovie);
+
+		// Take it down a tick initially. This sets the time to the time of the last tick,
+		// so that subsequence drops will drop it down a tick.
+		_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getTime() - 40);
+		_rightDamageShuttleMovie.redrawMovieWorld();
+
+		_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
+		_lowerLeftShuttleMovie.redrawMovieWorld();
+		playSpotSoundSync(kShuttleAutopilotEngagedIn, kShuttleAutopilotEngagedOut);
+
+		_robotShip.startMoving();
+
+		_shuttleHUD.initShuttleHUD();
+
+		_tractorBeam.startDisplaying();
+
+		_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
+		_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(&_energyChoiceSpot);
+		_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
+		_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(&_gravitonChoiceSpot);
+		_tractorChoiceSpot.setArea(kShuttleTractorBounds);
+		_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(&_tractorChoiceSpot);
+		_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
+				kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
+		_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(&_shuttleViewSpot);
+		_shuttleTransportSpot.setArea(kShuttleTransportBounds);
+		_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(&_shuttleTransportSpot);
+
+		_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
+
+		playSpotSoundSync(kMarsCockpitChatterIn, kMarsCockpitChatterOut);
+
+		GameState.setMarsFinishedCanyonChase(true);
+
+		startMarsTimer(kSpaceChaseTimeLimit, kOneTickPerSecond, kMarsSpaceChaseFinished);
+
+		_vm->_cursor->hideUntilMoved();
 		break;			
 	case kMarsSpaceChaseFinished:
 		// Player failed to stop the robot in time...
@@ -3295,16 +2992,226 @@ void Mars::throwAwayMarsShuttle() {
 	_leftDamageShuttleMovie.stopDisplaying();
 	_rightDamageShuttleMovie.releaseMovie();
 	_rightDamageShuttleMovie.stopDisplaying();
-	
-	// TODO: Some more to do here
+
 	_shuttleEnergyMeter.disposeShuttleEnergyMeter();
 	_robotShip.cleanUpRobotShip();
+	_shuttleHUD.cleanUpShuttleHUD();
+	_tractorBeam.stopDisplaying();
+	_junk.releaseMovie();
+	_junk.stopDisplaying();
+	_energyBeam.cleanUpShuttleWeapon();
+	_gravitonCannon.cleanUpShuttleWeapon();
+	g_allHotspots.remove(&_energyChoiceSpot);
+	g_allHotspots.remove(&_gravitonChoiceSpot);
+	g_allHotspots.remove(&_tractorChoiceSpot);
+	g_allHotspots.remove(&_shuttleViewSpot);
+	g_allHotspots.remove(&_shuttleTransportSpot);
 	_explosions.releaseMovie();
 	_explosions.stopDisplaying();
 
 	loadLoopSound1("");
 }
 
+void Mars::transportToRobotShip() {
+	throwAwayMarsShuttle();
+
+	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
+	if (!video->loadFile("Images/Mars/M98EAE.movie"))
+		error("Could not load shuttle->interface transition video");
+
+	while (!_vm->shouldQuit() && !video->endOfVideo()) {
+		if (video->needsUpdate()) {
+			const Graphics::Surface *frame = video->decodeNextFrame();
+
+			if (frame)
+				_vm->drawScaledFrame(frame, 0, 0);
+		}
+
+		Common::Event event;
+		while (g_system->getEventManager()->pollEvent(event))
+			;
+
+		g_system->delayMillis(10);
+	}
+
+	delete video;
+
+	if (_vm->shouldQuit())
+		return;
+
+	reinstateMonocleInterface();
+
+	g_energyMonitor->stopEnergyDraining();
+	g_energyMonitor->restoreLastEnergyValue();
+	_vm->resetEnergyDeathReason();
+	g_energyMonitor->startEnergyDraining();
+
+	arriveAt(kMarsRobotShuttle, kEast);
+
+	_navMovie.stop();
+	_navMovie.setTime(_navMovie.getStart());
+	_navMovie.start();
+}
+
+const int kRobotTooStrong = 1;
+const int kTractorTooWeak = 2;
+const int kCapturedRobotShip = 3;
+
+void Mars::spaceChaseClick(const Input &input, const tHotSpotID id) {
+	Common::Point pt;
+
+	switch (id) {
+	case kShuttleEnergySpotID:
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDampingTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+		_leftShuttleMovie.setTime(kShuttleLeftDampingTime);
+		_leftShuttleMovie.redrawMovieWorld();
+		_shuttleHUD.hide();
+		_weaponSelection = kEnergyBeam;
+		playSpotSoundSync(kShuttleDampingBeamIn, kShuttleDampingBeamOut);
+		break;
+	case kShuttleGravitonSpotID:
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftGravitonTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+		_leftShuttleMovie.setTime(kShuttleLeftGravitonTime);
+		_leftShuttleMovie.redrawMovieWorld();
+		_shuttleHUD.hide();
+		_weaponSelection = kGravitonCannon;
+		playSpotSoundSync(kShuttleGravitonIn, kShuttleGravitonOut);
+		break;
+	case kShuttleTractorSpotID:
+		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftTractorTime);
+		_upperLeftShuttleMovie.redrawMovieWorld();
+		_leftShuttleMovie.setTime(kShuttleLeftTractorTime);
+		_leftShuttleMovie.redrawMovieWorld();
+		_shuttleHUD.show();
+		_weaponSelection = kTractorBeam;
+		playSpotSoundSync(kShuttleTractorBeamIn, kShuttleTractorBeamOut);
+		break;
+	case kShuttleViewSpotID:
+		switch (_weaponSelection) {
+		case kEnergyBeam:
+			if (_shuttleEnergyMeter.getEnergyValue() < kMinDampingEnergy) {
+				playSpotSoundSync(kShuttleEnergyTooLowIn, kShuttleEnergyTooLowOut);
+			} else {
+				if (_energyBeam.canFireWeapon()) {
+					_shuttleEnergyMeter.dropEnergyValue(kMinDampingEnergy);
+					input.getInputLocation(pt);
+					_energyBeam.fireWeapon(pt.x, pt.y);
+					playSpotSoundSync(kMarsEDBBlastIn, kMarsEDBBlastOut);
+				}
+			}
+			break;
+		case kGravitonCannon:
+			if (_shuttleEnergyMeter.getEnergyValue() < kMinGravitonEnergy) {
+				playSpotSoundSync(kShuttleEnergyTooLowIn, kShuttleEnergyTooLowOut);
+			} else {
+				if (_gravitonCannon.canFireWeapon()) {
+					_shuttleEnergyMeter.dropEnergyValue(kMinGravitonEnergy);
+					input.getInputLocation(pt);
+					_gravitonCannon.fireWeapon(pt.x, pt.y);
+					playSpotSoundSync(kMarsGravitonBlastIn, kMarsGravitonBlastOut);
+				}
+			}
+			break;
+		case kTractorBeam:
+			if (_shuttleHUD.isTargetLocked()) {
+				// play tractor beam sound?
+				_utilityFuse.stopFuse();
+
+				_tractorBeam.show();
+
+				int capture;
+				if (_rightDamageShuttleMovie.getTime() > 40) {
+					capture = kRobotTooStrong;
+				} else if (!_shuttleEnergyMeter.enoughEnergyForTractorBeam()) {
+					capture = kTractorTooWeak;
+				} else {
+					_robotShip.snareByTractorBeam();
+					capture = kCapturedRobotShip;
+					_planetMover.dropPlanetOutOfSight();
+				}
+
+				_shuttleEnergyMeter.drainForTractorBeam();
+
+				while (_shuttleEnergyMeter.isFading()) {
+					_vm->checkCallBacks();
+					_vm->refreshDisplay();
+					_vm->_system->delayMillis(10);
+				}
+
+				_shuttleEnergyMeter.setEnergyValue(_shuttleEnergyMeter.getEnergyValue());
+
+				switch (capture) {
+				case kRobotTooStrong:
+					_tractorBeam.hide();
+					playSpotSoundSync(kShuttleBrokeFreeIn, kShuttleBrokeFreeOut);
+					_utilityFuse.lightFuse();
+					break;
+				case kTractorTooWeak:
+					playSpotSoundSync(kShuttleCantHoldIn, kShuttleCantHoldOut);
+					_tractorBeam.hide();
+					_utilityFuse.lightFuse();
+					break;
+				case kCapturedRobotShip:
+					_tractorBeam.hide();
+					_shuttleHUD.hide();
+					_robotShip.cleanUpRobotShip();
+					_planetMovie.stop();
+					_planetMovie.stopDisplaying();
+					_planetMovie.releaseMovie();
+
+					// Shameless reuse of a variable :P
+					initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
+							kShuttleWindowLeft, kShuttleWindowTop, true);
+					_canyonChaseMovie.redrawMovieWorld();
+					playMovieSegment(&_canyonChaseMovie, 0, _canyonChaseMovie.getDuration());
+
+					// wait here until any junk clears...
+					while (_junk.junkFlying()) {
+						_vm->checkCallBacks();
+						_vm->refreshDisplay();
+						_vm->_system->delayMillis(10);
+					}
+
+					_upperRightShuttleMovie.show();
+					_upperRightShuttleMovie.setTime(kShuttleUpperRightOverloadTime);
+					_upperRightShuttleMovie.redrawMovieWorld();
+
+					playSpotSoundSync(kShuttleOverloadedIn, kShuttleOverloadedOut);
+					_centerShuttleMovie.setTime(kShuttleCenterVerifyingTime);
+					_centerShuttleMovie.redrawMovieWorld();
+
+					playSpotSoundSync(kShuttleCoordinatesIn, kShuttleCoordinatesOut);
+					_centerShuttleMovie.setTime(kShuttleCenterScanningTime);
+					_centerShuttleMovie.redrawMovieWorld();
+
+					playSpotSoundSync(kShuttleScanningIn, kShuttleScanningOut);
+					_centerShuttleMovie.setTime(kShuttleCenterSafeTime);
+					_centerShuttleMovie.redrawMovieWorld();
+
+					playSpotSoundSync(kShuttleSafeIn, kShuttleSafeOut);
+					_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportTime);
+					_lowerRightShuttleMovie.redrawMovieWorld();
+					GameState.setMarsReadyForShuttleTransport(true);
+					break;
+				}
+			} else {
+				playSpotSoundSync(kShuttleTractorLimitedIn, kShuttleTractorLimitedOut);
+			}
+			break;
+		default:
+			break;
+		}
+		break;
+	case kShuttleTransportSpotID:
+		_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportHiliteTime);
+		_lowerRightShuttleMovie.redrawMovieWorld();
+		_neighborhoodNotification.setNotificationFlags(kTimeToTransportFlag, kTimeToTransportFlag);
+		break;
+	}
+}
+
 void Mars::showBigExplosion(const Common::Rect &r, const tDisplayOrder order) {
 	if (_explosions.isMovieValid()) {
 		_explosions.setDisplayOrder(order);
@@ -3351,6 +3258,8 @@ void Mars::showLittleExplosion(const Common::Rect &r, const tDisplayOrder order)
 
 void Mars::hitByJunk() {	
 	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
+	_leftDamageShuttleMovie.redrawMovieWorld();
+
 	playSpotSoundSync(kMarsJunkCollisionIn, kMarsJunkCollisionOut);
 
 	if (_leftDamageShuttleMovie.getTime() == 0) {
@@ -3363,8 +3272,10 @@ void Mars::hitByJunk() {
 
 		t = _leftShuttleMovie.getTime();
 		_leftShuttleMovie.setTime(kShuttleLeftDamagedTime);
+		_leftShuttleMovie.redrawMovieWorld();
 		_vm->delayShell(1, 3);
 		_leftShuttleMovie.setTime(t);
+		_leftShuttleMovie.redrawMovieWorld();
 	}
 }
 
@@ -3404,6 +3315,17 @@ void Mars::decreaseRobotShuttleEnergy(const int delta, Common::Point impactPoint
 	}
 }
 
+void Mars::updateCursor(const Common::Point cursorLocation, const Hotspot *cursorSpot) {
+	if (cursorSpot && cursorSpot->getObjectID() == kShuttleViewSpotID) {
+		if (_weaponSelection != kNoWeapon)
+			_vm->_cursor->setCurrentFrameIndex(6);
+		else
+			_vm->_cursor->setCurrentFrameIndex(0);
+	} else {
+		Neighborhood::updateCursor(cursorLocation, cursorSpot);
+	}
+}
+
 tAirQuality Mars::getAirQuality(const tRoomID room) {
 	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
 		return kAirQualityVacuum;
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index 8e199d1..01474ab 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -27,241 +27,19 @@
 #define PEGASUS_NEIGHBORHOOD_MARS_MARS_H
 
 #include "pegasus/neighborhood/neighborhood.h"
+#include "pegasus/neighborhood/mars/constants.h"
+#include "pegasus/neighborhood/mars/energybeam.h"
+#include "pegasus/neighborhood/mars/gravitoncannon.h"
+#include "pegasus/neighborhood/mars/planetmover.h"
 #include "pegasus/neighborhood/mars/reactor.h"
 #include "pegasus/neighborhood/mars/robotship.h"
 #include "pegasus/neighborhood/mars/shuttleenergymeter.h"
+#include "pegasus/neighborhood/mars/shuttlehud.h"
+#include "pegasus/neighborhood/mars/spacejunk.h"
+#include "pegasus/neighborhood/mars/tractorbeam.h"
 
 namespace Pegasus {
 
-//	Element Coordinates
-
-const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
-const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
-
-const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
-const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
-
-const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
-const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
-
-const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
-const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
-
-const tCoordType kAnswerLeft = kNavAreaLeft + 304;
-const tCoordType kAnswerTop = kNavAreaTop + 180;
-
-const tCoordType kShuttle1Left = 0;
-const tCoordType kShuttle1Top = 0;
-
-const tCoordType kShuttle2Left = 0;
-const tCoordType kShuttle2Top = 96;
-
-const tCoordType kShuttle3Left = 500;
-const tCoordType kShuttle3Top = 96;
-
-const tCoordType kShuttle4Left = 0;
-const tCoordType kShuttle4Top = 320;
-
-const tCoordType kShuttleWindowLeft = 140;
-const tCoordType kShuttleWindowTop = 96;
-const tCoordType kShuttleWindowWidth = 360;
-const tCoordType kShuttleWindowHeight = 224;
-
-const tCoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
-const tCoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
-
-const tCoordType kShuttleLeftLeft = 0;
-const tCoordType kShuttleLeftTop = 128;
-
-const tCoordType kShuttleRightLeft = 506;
-const tCoordType kShuttleRightTop = 128;
-
-const tCoordType kShuttleLowerLeftLeft = 74;
-const tCoordType kShuttleLowerLeftTop = 358;
-
-const tCoordType kShuttleLowerRightLeft = 486;
-const tCoordType kShuttleLowerRightTop = 354;
-
-const tCoordType kShuttleCenterLeft = 260;
-const tCoordType kShuttleCenterTop = 336;
-
-const tCoordType kShuttleUpperLeftLeft = 30;
-const tCoordType kShuttleUpperLeftTop = 32;
-
-const tCoordType kShuttleUpperRightLeft = 506;
-const tCoordType kShuttleUpperRightTop = 52;
-
-const tCoordType kShuttleLeftEnergyLeft = 110;
-const tCoordType kShuttleLeftEnergyTop = 186;
-
-const tCoordType kShuttleRightEnergyLeft = 510;
-const tCoordType kShuttleRightEnergyTop = 186;
-
-const tCoordType kShuttleEnergyLeft = 186;
-const tCoordType kShuttleEnergyTop = 60;
-const tCoordType kShuttleEnergyWidth = 252;
-const tCoordType kShuttleEnergyHeight = 22;
-
-const tCoordType kPlanetStartLeft = kShuttleWindowLeft;
-const tCoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
-
-const tCoordType kPlanetStopLeft = kShuttleWindowLeft;
-const tCoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
-
-const tCoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
-const tCoordType kShuttleTractorTop = kShuttleWindowTop + 56;
-const tCoordType kShuttleTractorWidth = 348;
-const tCoordType kShuttleTractorHeight = 112;
-
-const tCoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
-const tCoordType kShuttleJunkTop = kShuttleWindowTop + 6;
-
-const tDisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
-const tDisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
-const tDisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
-const tDisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
-const tDisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
-const tDisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
-const tDisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
-const tDisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
-const tDisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
-const tDisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
-const tDisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
-const tDisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
-
-const TimeValue kShuttleSwingStart = 0;
-const TimeValue kShuttleSwingStop = 5 * 600;
-
-const TimeValue kCanyonChaseStart = kShuttleSwingStop;
-const TimeValue kCanyonChaseStop = 60 * 600 + 43 * 600 + 14 * 40;
-
-const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonChaseStart;
-const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
-											kLaunchTubeReachedTime;
-
-//	Left shuttle.
-
-const TimeValue kShuttleLeftIntroStart = 0;
-const TimeValue kShuttleLeftIntroStop = 400;
-
-const TimeValue kShuttleLeftBlankTime = 400;
-
-const TimeValue kShuttleLeftNormalTime = 440;
-
-const TimeValue kShuttleLeftAutoTestTime = 480;
-
-const TimeValue kShuttleLeftDamagedTime = 520;
-
-const TimeValue kShuttleLeftDampingTime = 560;
-
-const TimeValue kShuttleLeftGravitonTime = 600;
-
-const TimeValue kShuttleLeftTractorTime = 640;
-
-//	Right shuttle.
-
-const TimeValue kShuttleRightIntroStart = 0;
-const TimeValue kShuttleRightIntroStop = 400;
-
-const TimeValue kShuttleRightDestroyedStart = 400;
-const TimeValue kShuttleRightDestroyedStop = 840;
-
-const TimeValue kShuttleRightBlankTime = 840;
-
-const TimeValue kShuttleRightNormalTime = 880;
-
-const TimeValue kShuttleRightDamagedTime = 920;
-
-const TimeValue kShuttleRightTargetLockTime = 960;
-
-const TimeValue kShuttleRightGravitonTime = 1000;
-
-const TimeValue kShuttleRightOverloadTime = 1040;
-
-//	Lower Left shuttle.
-
-const TimeValue kShuttleLowerLeftCollisionTime = 0;
-
-const TimeValue kShuttleLowerLeftTubeTime = 40;
-
-const TimeValue kShuttleLowerLeftAutopilotTime = 80;
-
-//	Lower Right shuttle.
-
-const TimeValue kShuttleLowerRightOffTime = 0;
-
-const TimeValue kShuttleLowerRightTrackingTime = 40;
-
-const TimeValue kShuttleLowerRightTransportTime = 80;
-
-const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
-
-//	Center shuttle.
-
-const TimeValue kShuttleCenterBoardingTime = 0;
-
-const TimeValue kShuttleCenterCheckTime = 40;
-
-const TimeValue kShuttleCenterNavCompTime = 80;
-
-const TimeValue kShuttleCenterCommTime = 120;
-
-const TimeValue kShuttleCenterWeaponsTime = 160;
-
-const TimeValue kShuttleCenterAllSystemsTime = 200;
-
-const TimeValue kShuttleCenterSecureLooseTime = 240;
-
-const TimeValue kShuttleCenterAutoTestTime = 280;
-
-const TimeValue kShuttleCenterLaunchTime = 320;
-
-const TimeValue kShuttleCenterEnterTubeTime = 360;
-
-const TimeValue kShuttleCenterTargetSightedTime = 400;
-
-const TimeValue kShuttleCenterVerifyingTime = 440;
-
-const TimeValue kShuttleCenterScanningTime = 480;
-
-const TimeValue kShuttleCenterSafeTime = 520;
-
-//	Upper Left shuttle.
-
-const TimeValue kShuttleUpperLeftDimTime = 0;
-
-const TimeValue kShuttleUpperLeftDampingTime = 40;
-
-const TimeValue kShuttleUpperLeftGravitonTime = 80;
-
-const TimeValue kShuttleUpperLeftTractorTime = 120;
-
-//	Upper Right shuttle.
-
-const TimeValue kShuttleUpperRightLockedTime = 0;
-
-const TimeValue kShuttleUpperRightArmedTime = 40;
-
-const TimeValue kShuttleUpperRightAlienDestroyedTime = 80;
-
-const TimeValue kShuttleUpperRightOverloadTime = 120;
-
-const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
-
-//	Shuttle distance
-
-const int kShuttleDistance = 500;
-
-const int kJunkMaxDistance = kShuttleDistance;
-const int kJunkMinDistance = 40;
-
-const int kEnergyBeamMaxDistance = kShuttleDistance;
-const int kEnergyBeamMinDistance = 40;
-
-const int kGravitonMaxDistance = kShuttleDistance;
-const int kGravitonMinDistance = 40;
-
-
 class InventoryItem;
 class Mars;
 
@@ -283,16 +61,6 @@ enum ShuttleWeaponSelection {
 	kTractorBeam
 };
 
-const tRoomID kMars0A = 0;
-const tRoomID kMars31South = 33;
-const tRoomID kMars34 = 37;
-const tRoomID kMars35 = 38;
-const tRoomID kMars39 = 42;
-const tRoomID kMars49 = 51;
-const tRoomID kMars60 = 58;
-const tRoomID kMarsMaze004 = 60;
-const tRoomID kMarsMaze200 = 224;
-
 class Mars : public Neighborhood {
 friend void robotTimerExpiredFunction(FunctionPtr *, void *);
 friend void lockThawTimerExpiredFunction(FunctionPtr *, void *);
@@ -336,8 +104,6 @@ public:
 
 	bool inColorMatchingGame();
 
-	// TODO: Space chase functions
-
 protected:
 	enum {
 		kMarsPrivatePodStorageOpenFlag,
@@ -414,8 +180,11 @@ protected:
 	void startMarsTimer(TimeValue, TimeScale, MarsTimerCode);
 	void marsTimerExpired(MarsTimerEvent &);
 	void throwAwayMarsShuttle();
-
-	// TODO: Space chase functions
+	void startUpFromFinishedSpaceChase();
+	void startUpFromSpaceChase();
+	void transportToRobotShip();
+	void spaceChaseClick(const Input &, const tHotSpotID);
+	void updateCursor(const Common::Point, const Hotspot *);
 
 	Common::String getSoundSpotsName();
 	Common::String getNavMovieName();
@@ -450,11 +219,22 @@ protected:
 	Movie _leftDamageShuttleMovie;
 	Movie _rightDamageShuttleMovie;
 	ShuttleEnergyMeter _shuttleEnergyMeter;
+	Movie _planetMovie;
+	PlanetMover _planetMover;
 	RobotShip _robotShip;
+	ShuttleHUD _shuttleHUD;
+	TractorBeam _tractorBeam;
+	SpaceJunk _junk;
+	EnergyBeam _energyBeam;
+	GravitonCannon _gravitonCannon;
+	Hotspot _energyChoiceSpot;
+	Hotspot _gravitonChoiceSpot;
+	Hotspot _tractorChoiceSpot;
+	Hotspot _shuttleViewSpot;
+	Hotspot _shuttleTransportSpot;
+	ShuttleWeaponSelection _weaponSelection;
 	ScalingMovie _explosions;
 	NotificationCallBack _explosionCallBack;
-
-	// TODO: Space chase variables
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
index 368c295..2fa8a77 100755
--- a/engines/pegasus/neighborhood/mars/planetmover.cpp
+++ b/engines/pegasus/neighborhood/mars/planetmover.cpp
@@ -25,9 +25,10 @@
 
 #include "pegasus/movie.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/mars/hermite.h"
-#include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/mars/planetmover.h"
+#include "pegasus/neighborhood/mars/shuttleenergymeter.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
index 279bdd8..862a8b2 100755
--- a/engines/pegasus/neighborhood/mars/robotship.cpp
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -194,6 +194,7 @@ void RobotShip::moveRobotTo(tCoordType x, tCoordType y) {
 		y = kNumSpriteRows * y / _shipRange.height();
 
 		_spritesMovie.setTime(40 * (x + y * kNumSpriteColumns));
+		_spritesMovie.redrawMovieWorld();
 	}
 }
 
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp b/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
index f16735d..21bb1fb 100755
--- a/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
@@ -23,7 +23,7 @@
  *
  */
 
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/mars/shuttleenergymeter.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
index 71f5b1e..dfdb381 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "pegasus/pegasus.h"
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/mars/robotship.h"
 #include "pegasus/neighborhood/mars/shuttlehud.h"
 
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.h b/engines/pegasus/neighborhood/mars/shuttlehud.h
index 7cab9ed..dc1c759 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.h
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.h
@@ -34,7 +34,7 @@ namespace Pegasus {
 class ShuttleHUD : public DisplayElement, public Idler {
 public:
 	ShuttleHUD();
-	virtual ~ShuttleHUD();
+	virtual ~ShuttleHUD() {}
 
 	void showTargetGrid();
 	void hideTargetGrid();
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
index 799cca8..14614d1 100755
--- a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
@@ -23,6 +23,8 @@
  *
  */
 
+#include "pegasus/neighborhood/mars/constants.h"
+#include "pegasus/neighborhood/mars/robotship.h"
 #include "pegasus/neighborhood/mars/shuttleweapon.h"
 #include "pegasus/neighborhood/mars/spacejunk.h"
 
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.h b/engines/pegasus/neighborhood/mars/shuttleweapon.h
index b43dc92..c62cee1 100755
--- a/engines/pegasus/neighborhood/mars/shuttleweapon.h
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.h
@@ -26,7 +26,7 @@
 #ifndef PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEWEAPON_H
 #define PEGASUS_NEIGHBORHOOD_MARS_SHUTTLEWEAPON_H
 
-#include "pegasus/timers.h"
+#include "pegasus/elements.h"
 #include "pegasus/neighborhood/mars/spacechase3d.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.h b/engines/pegasus/neighborhood/mars/spacechase3d.h
index 3f22ba6..1e145a1 100755
--- a/engines/pegasus/neighborhood/mars/spacechase3d.h
+++ b/engines/pegasus/neighborhood/mars/spacechase3d.h
@@ -26,7 +26,7 @@
 #ifndef PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
 #define PEGASUS_NEIGHBORHOOD_MARS_SPACECHASE3D_H
 
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 
 namespace Pegasus {
 
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index 8c78db4..8ae36ce 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/mars/mars.h"
 #include "pegasus/neighborhood/mars/spacejunk.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.h b/engines/pegasus/neighborhood/mars/spacejunk.h
index d3315b0..ba5aa75 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.h
+++ b/engines/pegasus/neighborhood/mars/spacejunk.h
@@ -26,6 +26,8 @@
 #ifndef PEGASUS_NEIGHBORHOOD_MARS_SPACEJUNK_H
 #define PEGASUS_NEIGHBORHOOD_MARS_SPACEJUNK_H
 
+#include "pegasus/movie.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/mars/spacechase3d.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.cpp b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
index 5c04b25..5ea63a0 100755
--- a/engines/pegasus/neighborhood/mars/tractorbeam.cpp
+++ b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
@@ -24,7 +24,7 @@
  */
 
 #include "pegasus/pegasus.h"
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/mars/tractorbeam.h"
 
 namespace Pegasus {
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 0ce533c..3d19cc3 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -33,7 +33,7 @@
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"
 
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index 831ab08..a2e2ef8 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -29,7 +29,7 @@
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
-#include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"


Commit: 0ec655f410a0b0ed485f7e6235b8054e97891fd8
    https://github.com/scummvm/scummvm/commit/0ec655f410a0b0ed485f7e6235b8054e97891fd8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T22:32:23-07:00

Commit Message:
PEGASUS: Fix timers not updating in playSpotSoundSync

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index fb95b07..36ae486 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -473,6 +473,7 @@ void Neighborhood::requestSpotSound(const TimeValue in, const TimeValue out, con
 void Neighborhood::playSpotSoundSync(const TimeValue in, const TimeValue out) {
 	// Let the action queue play out first...
 	while (!actionQueueEmpty()) {
+		_vm->checkCallBacks();
 		_vm->refreshDisplay();
 		_vm->checkNotifications();
 		_vm->_system->delayMillis(10);
@@ -482,6 +483,7 @@ void Neighborhood::playSpotSoundSync(const TimeValue in, const TimeValue out) {
 	_spotSounds.playSoundSegment(in, out);
 
 	while (_spotSounds.isPlaying()) {
+		_vm->checkCallBacks();
 		_vm->refreshDisplay();
 		_vm->_system->delayMillis(10);
 	}


Commit: 59f7d432d11f7527a01e04be09c8afaef3d1cb1d
    https://github.com/scummvm/scummvm/commit/59f7d432d11f7527a01e04be09c8afaef3d1cb1d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-27T22:43:05-07:00

Commit Message:
PEGASUS: Implement dirty rect erase code (as used by the space chase)

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/neighborhood/mars/mars.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index cc6dcf0..06db31f 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -45,6 +45,7 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_workArea.create(640, 480, _vm->_system->getScreenFormat());
 	_modifiedScreen = false;
 	_curSurface = &_workArea;
+	_erase = false;
 }
 	
 GraphicsManager::~GraphicsManager() {
@@ -150,6 +151,10 @@ void GraphicsManager::updateDisplay() {
 	bool screenDirty = false;
 
 	if (!_dirtyRect.isEmpty()) {
+		// Fill the dirty area with black if erase mode is enabled
+		if (_erase)
+			_workArea.fillRect(_dirtyRect, _workArea.format.RGBToColor(0, 0, 0));
+
 		for (DisplayElement *runner = _firstDisplayElement; runner != 0; runner = runner->_nextElement) {
 			Common::Rect bounds;
 			runner->getBounds(bounds);
@@ -320,5 +325,13 @@ void GraphicsManager::shakeTheWorld(TimeValue duration, TimeScale scale) {
 
 	oldScreen.free();
 }
+
+void GraphicsManager::enableErase() {
+	_erase = true;
+}
+
+void GraphicsManager::disableErase() {
+	_erase = false;
+}
 	
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 18dfd3f..0e5de47 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -60,6 +60,8 @@ public:
 	void clearScreen();
 	DisplayElement *findDisplayElement(const tDisplayElementID id);
 	void shakeTheWorld(TimeValue time, TimeScale scale);
+	void enableErase();
+	void disableErase();
 
 	// These default to black
 	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
@@ -71,7 +73,7 @@ protected:
 private:		
 	PegasusEngine *_vm;
 
-	bool _modifiedScreen;
+	bool _modifiedScreen, _erase;
 	Common::Rect _dirtyRect;
 	tDisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 5c36638..a781618 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -2822,6 +2822,8 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
 		_canyonChaseMovie.stopDisplaying();
 		_canyonChaseMovie.releaseMovie();
 
+		_vm->_gfx->enableErase();
+
 		loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
 
 		playSpotSoundSync(kShuttleConfiguringIn, kShuttleConfiguringOut);


Commit: 88360741bdcc8a5456dd719bac8678d9cbaddfe3
    https://github.com/scummvm/scummvm/commit/88360741bdcc8a5456dd719bac8678d9cbaddfe3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T08:19:27-07:00

Commit Message:
PEGASUS: Fix the planet mover

Changed paths:
    engines/pegasus/neighborhood/mars/planetmover.cpp



diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
index 2fa8a77..2b28754 100755
--- a/engines/pegasus/neighborhood/mars/planetmover.cpp
+++ b/engines/pegasus/neighborhood/mars/planetmover.cpp
@@ -76,10 +76,7 @@ void PlanetMover::newDestination() {
 	_p1 = _p4;
 	_r1 = _r4;
 
-	// Slightly worked differently than the original to work into our random number stuff
-	uint diff = ABS(kPlanetStopTop - kPlanetStartTop);
-	_p4 = kPlanetStopTop + (diff != 0) ? ((PegasusEngine *)g_engine)->getRandomNumber(diff - 1) : 0;
-
+	_p4 = kPlanetStopTop + ((PegasusEngine *)g_engine)->getRandomNumber(kPlanetStartTop - kPlanetStopTop - 1);
 	_r4 = ((PegasusEngine *)g_engine)->getRandomNumber(kMaxVelocity - 1);
 
 	if (_r4 + _p4 < kPlanetStopTop)


Commit: 514d93622dd05bee743e565c5ad1dadd42af3c04
    https://github.com/scummvm/scummvm/commit/514d93622dd05bee743e565c5ad1dadd42af3c04
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T08:31:05-07:00

Commit Message:
PEGASUS: Fix RS232 draw call

Changed paths:
    engines/pegasus/neighborhood/mars/shuttlehud.cpp



diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
index dfdb381..8451260 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -218,7 +218,7 @@ void ShuttleHUD::draw(const Common::Rect &) {
 		}
 	}
 
-	drawOneBitImageOr(screen, s_lockData, 4, Common::Rect(kHUDRS232Left, kHUDRS232Top,
+	drawOneBitImageOr(screen, s_RS232Data, 4, Common::Rect(kHUDRS232Left, kHUDRS232Top,
 			kHUDRS232Left + 29, kHUDRS232Top + 8), _gridDarkGreen);
 
 	if (_targetLocked) {


Commit: 020f3842478b6eaa67e2b8efbc16502db3fe4599
    https://github.com/scummvm/scummvm/commit/020f3842478b6eaa67e2b8efbc16502db3fe4599
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T08:45:00-07:00

Commit Message:
PEGASUS: Fix pitch of one bit images in the shuttle HUD

Changed paths:
    engines/pegasus/neighborhood/mars/shuttlehud.cpp



diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
index 8451260..1850926 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -218,14 +218,14 @@ void ShuttleHUD::draw(const Common::Rect &) {
 		}
 	}
 
-	drawOneBitImageOr(screen, s_RS232Data, 4, Common::Rect(kHUDRS232Left, kHUDRS232Top,
+	drawOneBitImageOr(screen, s_RS232Data, 2, Common::Rect(kHUDRS232Left, kHUDRS232Top,
 			kHUDRS232Left + 29, kHUDRS232Top + 8), _gridDarkGreen);
 
 	if (_targetLocked) {
 		drawHUDLockArrows(0, _lockDarkGreen2);
 		drawHUDLockArrows(12, _lockDarkGreen1);
 		drawHUDLockArrows(24, _lightGreen);
-		drawOneBitImageOr(screen, s_lockData, 8, Common::Rect(kHUDLockLeft, kHUDLockTop + 115,
+		drawOneBitImageOr(screen, s_lockData, 4, Common::Rect(kHUDLockLeft, kHUDLockTop + 115,
 				kHUDLockLeft + 52, kHUDLockTop + 115 + 9), _lightGreen);
 	}
 }


Commit: 6550d851843d794f0b50185e1fdbb4f1108734a3
    https://github.com/scummvm/scummvm/commit/6550d851843d794f0b50185e1fdbb4f1108734a3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T10:26:43-07:00

Commit Message:
PEGASUS: Fix 1bpp cicn cursors

Changed paths:
    engines/pegasus/cursor.cpp



diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
index ee3ab87..430b319 100755
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@ -169,7 +169,7 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
 	cicnStream->readUint16BE(); // always 0
 	cursorInfo.colorCount = cicnStream->readUint16BE() + 1;
 	
-	cursorInfo.palette = new byte[256 * cursorInfo.colorCount];
+	cursorInfo.palette = new byte[cursorInfo.colorCount * 3];
 	for (uint16 i = 0; i < cursorInfo.colorCount; i++) {
 		cicnStream->readUint16BE();
 		cursorInfo.palette[i * 3] = cicnStream->readUint16BE() >> 8;
@@ -178,8 +178,34 @@ void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
 	}
 	
 	// PixMap data
-	cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
-	cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height());
+	if (pixMap.pixelSize == 8) {
+		cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
+		cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height());
+
+		// While this looks sensible, it actually doesn't work for some cursors
+		// (ie. the 'can grab' hand)
+		//cursorInfo.surface->w = pixMap.bounds.width();
+	} else if (pixMap.pixelSize == 1) {
+		cursorInfo.surface->create(pixMap.bounds.width(), pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
+
+		for (int y = 0; y < pixMap.bounds.height(); y++) {
+			byte *line = (byte *)cursorInfo.surface->getBasePtr(0, y);
+
+			for (int x = 0; x < pixMap.bounds.width();) {
+				byte b = cicnStream->readByte();
+
+				for (int i = 0; i < 8; i++) {
+					*line++ = ((b & (1 << (7 - i))) != 0) ? 1 : 0;
+
+					if (++x == pixMap.bounds.width())
+						break;
+				}
+			}
+		}
+	} else {
+		error("Unhandled %dbpp cicn images", pixMap.pixelSize);
+	}
+
 	delete cicnStream;
 }
 


Commit: 2f1c67ab5982e75fc0f63bc12e3c8431481128c7
    https://github.com/scummvm/scummvm/commit/2f1c67ab5982e75fc0f63bc12e3c8431481128c7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T12:37:17-07:00

Commit Message:
PEGASUS: Clear movie bounds on release

Fixes reinitializing the interface after the space chase sequence

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index dbdb63f..1c07c48 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -50,6 +50,8 @@ void Movie::releaseMovie() {
 		disposeAllCallBacks();
 		deallocateSurface();
 	}
+
+	setBounds(Common::Rect(0, 0, 0, 0));
 }
 
 void Movie::initFromMovieFile(const Common::String &fileName, bool transparent) {


Commit: 6d01961158e663a6720d2139853dae5f15a4d75c
    https://github.com/scummvm/scummvm/commit/6d01961158e663a6720d2139853dae5f15a4d75c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T12:38:24-07:00

Commit Message:
PEGASUS: Disable erase when reinstating the monocle

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 36ae486..00abb02 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1718,7 +1718,7 @@ void Neighborhood::initOneMovie(Movie *movie, const Common::String &movieName, t
 }
 
 void Neighborhood::reinstateMonocleInterface() {
-	// TODO: Disable erase?
+	_vm->_gfx->disableErase();
 
 	_vm->createInterface();
 


Commit: 1ca6da46ad55a26dab7b8d9b8ad5d8e354f99097
    https://github.com/scummvm/scummvm/commit/1ca6da46ad55a26dab7b8d9b8ad5d8e354f99097
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-28T19:21:30-07:00

Commit Message:
PEGASUS: Fix destroying the robot shuttle

Changed paths:
    engines/pegasus/neighborhood/mars/mars.cpp



diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index a781618..3a9273e 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -145,6 +145,9 @@ void Mars::init() {
 	forceStridingStop(kMars08, kNorth, kAltMarsNormal);
 
 	_neighborhoodNotification.notifyMe(this, kMarsNotificationFlags, kMarsNotificationFlags);
+
+	_explosionCallBack.setNotification(&_neighborhoodNotification);
+	_explosionCallBack.setCallBackFlag(kExplosionFinishedFlag);
 }
 
 void Mars::flushGameState() {


Commit: bcf5ea1dc246b86a06ca9f1f97fa5525bd0a006b
    https://github.com/scummvm/scummvm/commit/bcf5ea1dc246b86a06ca9f1f97fa5525bd0a006b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-29T09:19:58-07:00

Commit Message:
PEGASUS: Keep the space junk from flying beyond the screen boundary

Changed paths:
    engines/pegasus/neighborhood/mars/spacejunk.cpp



diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index 8ae36ce..a1f9bf7 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -82,7 +82,7 @@ void SpaceJunk::setCenter(const tCoordType centerX, const tCoordType centerY) {
 
 	Common::Rect r;
 	getBounds(r);
-	r.moveTo(centerX - (r.width() >> 1), centerY - (r.height() >> 1));
+	r.moveTo(MAX<int>(centerX - (r.width() >> 1), 0), MAX<int>(centerY - (r.height() >> 1), 0));
 	setBounds(r);
 }
 
@@ -170,7 +170,7 @@ void SpaceJunk::rebound(const TimeValue reboundTime) {
 		_bounceStop.y = kMaxBounceSize / 2 + 1 + vm->getRandomNumber(kBounceTargetVRange - 1);
 		break;
 	}
-	
+
 	_bounceSizeStart = bounds.width();
 	_bounceSizeStop = MIN(_bounceSizeStart, kMaxBounceSize);
 


Commit: 60ecf84365935d32fe840dc4d055629745a63b00
    https://github.com/scummvm/scummvm/commit/60ecf84365935d32fe840dc4d055629745a63b00
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-29T09:28:47-07:00

Commit Message:
PEGASUS: Fix dying when no interface is set up

Now you can die in the space chase

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index b823ff2..61a2383 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1127,12 +1127,12 @@ void PegasusEngine::doDeath() {
 }
 
 void PegasusEngine::throwAwayEverything() {
-	if (_items.getNumItems() != 0)
+	if (_items.getNumItems() != 0 && g_interface)
 		_currentItemID = g_interface->getCurrentInventoryItem()->getObjectID();
 	else
 		_currentItemID = kNoItemID;
 
-	if (_biochips.getNumItems() != 0)
+	if (_biochips.getNumItems() != 0 && g_interface)
 		_currentItemID = g_interface->getCurrentBiochip()->getObjectID();
 	else
 		_currentItemID = kNoItemID;


Commit: 74d08a1543b9200f22e609576bdc5c97cdd7e8ed
    https://github.com/scummvm/scummvm/commit/74d08a1543b9200f22e609576bdc5c97cdd7e8ed
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-30T16:23:33-07:00

Commit Message:
PEGASUS: Fix redrawMovieWorld() to only update when needed

A partial revert of 2bba1d0c11d2ceb8a1ec1dc5a9f1910a90b5cf5a

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 1c07c48..8d6f0fa 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -87,7 +87,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 }
 
 void Movie::redrawMovieWorld() {
-	if (_video) {
+	if (_video && _video->needsUpdate()) {
 		const Graphics::Surface *frame = _video->decodeNextFrame();
 
 		if (!frame)
@@ -194,8 +194,7 @@ void Movie::updateTime() {
 	// The reason why we overrode TimeBase's updateTime():
 	// Again, avoiding timers and handling it here
 	if (_video && !_video->isPaused()) {
-		if (_video->needsUpdate())
-			redrawMovieWorld();
+		redrawMovieWorld();
 
 		uint32 startTime = _startTime * getScale() / _startScale;
 		uint32 stopTime = _stopTime * getScale() / _stopScale;


Commit: 0d6dbfa2cbaa568464a18071484ab411cddba4f9
    https://github.com/scummvm/scummvm/commit/0d6dbfa2cbaa568464a18071484ab411cddba4f9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-31T20:20:54-07:00

Commit Message:
PEGASUS: Add ability to draw masked surfaces

Changed paths:
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h



diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
index 2bf9895..f0c97d6 100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@ -205,6 +205,37 @@ void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Co
 	}
 }
 
+void Surface::copyToCurrentPortMasked(const Common::Rect &srcRect, const Common::Rect &dstRect, const Surface *mask) const {
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
+	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
+
+	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
+
+	for (int y = 0; y < srcRect.height(); y++) {
+		byte *maskSrc = (byte *)mask->getSurface()->getBasePtr(0, y);
+
+		for (int x = 0; x < srcRect.width(); x++) {
+			if (g_system->getScreenFormat().bytesPerPixel == 2) {
+				uint16 color = READ_UINT16(maskSrc);
+				if (!isTransparent(color))
+					memcpy(dst, src, 2);
+			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
+				uint32 color = READ_UINT32(maskSrc);
+				if (!isTransparent(color))
+					memcpy(dst, src, 4);
+			}
+
+			src += g_system->getScreenFormat().bytesPerPixel;
+			maskSrc += g_system->getScreenFormat().bytesPerPixel;
+			dst += g_system->getScreenFormat().bytesPerPixel;
+		}
+
+		src += _surface->pitch - lineSize;
+		dst += screen->pitch - lineSize;
+	}
+}
+
 void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
 	// pixel all the way up.
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index 9270de0..ca14810 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -70,6 +70,7 @@ public:
 	void copyToCurrentPortTransparent(const Common::Rect &) const;
 	void copyToCurrentPort(const Common::Rect &, const Common::Rect &) const;
 	void copyToCurrentPortTransparent(const Common::Rect &, const Common::Rect &) const;
+	void copyToCurrentPortMasked(const Common::Rect &, const Common::Rect &, const Surface *) const;
 	void copyToCurrentPortTransparentGlow(const Common::Rect &, const Common::Rect &) const;
 	void scaleTransparentCopy(const Common::Rect &, const Common::Rect &) const;
 	void scaleTransparentCopyGlow(const Common::Rect &, const Common::Rect &) const;


Commit: b3eb2c65e36258d0018455962e610052b1569748
    https://github.com/scummvm/scummvm/commit/b3eb2c65e36258d0018455962e610052b1569748
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-31T20:25:37-07:00

Commit Message:
PEGASUS: Fix some old Surface comments

Changed paths:
    engines/pegasus/surface.h



diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
index ca14810..3ccbf59 100755
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@ -61,9 +61,8 @@ public:
 	Graphics::Surface *getSurface() const { return _surface; }
 	void getSurfaceBounds(Common::Rect &r) { r = _bounds; }
 
-	//	None of the CopyToCurrentPort functions do any sanity checks.
-	//	For speed, they just call CopyBits.
-	//	It's up to clients to make sure that the GWorld is valid.
+	// None of the copyToCurrentPort* functions do any sanity checks.
+	// It's up to clients to make sure that the Surface is valid.
 	void copyToCurrentPort() const;
 	void copyToCurrentPortTransparent() const;
 	void copyToCurrentPort(const Common::Rect &) const;


Commit: ae59e34446a425fc1e638e10846190100b10a722
    https://github.com/scummvm/scummvm/commit/ae59e34446a425fc1e638e10846190100b10a722
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-31T20:28:42-07:00

Commit Message:
PEGASUS: Fix some code formatting

Changed paths:
    engines/pegasus/menu.cpp



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index ce95e6b..50a208e 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -489,37 +489,37 @@ CreditsMenu::CreditsMenu() : GameMenu(kCreditsMenuID), _menuBackground(0), _cred
 void CreditsMenu::newMenuSelection(const int newSelection) {
 	if (newSelection != _menuSelection) {
 		switch (newSelection) {
-			case kCreditsMenuCoreTeam:
-				_smallSelect.moveElementTo(kCoreTeamSelectLeft, kCoreTeamSelectTop);
-				_creditsMovie.setTime(kCoreTeamTime);
-				_creditsMovie.redrawMovieWorld();
-				break;
-			case kCreditsMenuSupportTeam:
-				_smallSelect.moveElementTo(kSupportTeamSelectLeft, kSupportTeamSelectTop);
-				_creditsMovie.setTime(kSupportTeamTime);
-				_creditsMovie.redrawMovieWorld();
-				break;
-			case kCreditsMenuOriginalTeam:
-				_smallSelect.moveElementTo(kOriginalTeamSelectLeft, kOriginalTeamSelectTop);
-				_creditsMovie.setTime(kOriginalTeamTime);
-				_creditsMovie.redrawMovieWorld();
-				break;
-			case kCreditsMenuTalent:
-				_smallSelect.moveElementTo(kTalentSelectLeft, kTalentSelectTop);
-				_creditsMovie.setTime(kTalentTime);
-				_creditsMovie.redrawMovieWorld();
-				break;
-			case kCreditsMenuOtherTitles:
-				_smallSelect.moveElementTo(kOtherTitlesSelectLeft, kOtherTitlesSelectTop);
-				_smallSelect.show();
-				_largeSelect.hide();
-				_creditsMovie.setTime(kOtherTitlesTime);
-				_creditsMovie.redrawMovieWorld();
-				break;
-			case kCreditsMenuMainMenu:
-				_smallSelect.hide();
-				_largeSelect.show();
-				break;
+		case kCreditsMenuCoreTeam:
+			_smallSelect.moveElementTo(kCoreTeamSelectLeft, kCoreTeamSelectTop);
+			_creditsMovie.setTime(kCoreTeamTime);
+			_creditsMovie.redrawMovieWorld();
+			break;
+		case kCreditsMenuSupportTeam:
+			_smallSelect.moveElementTo(kSupportTeamSelectLeft, kSupportTeamSelectTop);
+			_creditsMovie.setTime(kSupportTeamTime);
+			_creditsMovie.redrawMovieWorld();
+			break;
+		case kCreditsMenuOriginalTeam:
+			_smallSelect.moveElementTo(kOriginalTeamSelectLeft, kOriginalTeamSelectTop);
+			_creditsMovie.setTime(kOriginalTeamTime);
+			_creditsMovie.redrawMovieWorld();
+			break;
+		case kCreditsMenuTalent:
+			_smallSelect.moveElementTo(kTalentSelectLeft, kTalentSelectTop);
+			_creditsMovie.setTime(kTalentTime);
+			_creditsMovie.redrawMovieWorld();
+			break;
+		case kCreditsMenuOtherTitles:
+			_smallSelect.moveElementTo(kOtherTitlesSelectLeft, kOtherTitlesSelectTop);
+			_smallSelect.show();
+			_largeSelect.hide();
+			_creditsMovie.setTime(kOtherTitlesTime);
+			_creditsMovie.redrawMovieWorld();
+			break;
+		case kCreditsMenuMainMenu:
+			_smallSelect.hide();
+			_largeSelect.show();
+			break;
 		}
 
 		_menuSelection = newSelection;


Commit: 963f209931f374146d9d9c29f2f78a129846ee2e
    https://github.com/scummvm/scummvm/commit/963f209931f374146d9d9c29f2f78a129846ee2e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-31T20:31:44-07:00

Commit Message:
PEGASUS: Fix 4D system sprites

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp



diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
index f6fa399..252979a 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -227,7 +227,8 @@ void Caldoria4DSystem::setSpritesMovie() {
 		_4DSpritesMovie.setTime(_4DSpritesScale * _videoChoice);
 	else if (_whichMenu == k4DAudioMenu)
 		_4DSpritesMovie.setTime(_4DSpritesScale * _audioChoice);
-	_4DSpritesMovie.triggerRedraw();
+
+	_4DSpritesMovie.redrawMovieWorld();
 }
 
 void Caldoria4DSystem::handleInput(const Input &input, const Hotspot *cursorSpot) {


Commit: 48cabb18d626e6d2d6596c6af7a3c1adb20bde06
    https://github.com/scummvm/scummvm/commit/48cabb18d626e6d2d6596c6af7a3c1adb20bde06
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-10-31T21:09:43-07:00

Commit Message:
PEGASUS: Implement the rest of the mapping biochip

Changed paths:
    engines/pegasus/items/biochips/mapimage.cpp
    engines/pegasus/items/biochips/mapimage.h



diff --git a/engines/pegasus/items/biochips/mapimage.cpp b/engines/pegasus/items/biochips/mapimage.cpp
index c33bce3..6e4a8ec 100755
--- a/engines/pegasus/items/biochips/mapimage.cpp
+++ b/engines/pegasus/items/biochips/mapimage.cpp
@@ -23,6 +23,8 @@
  *
  */
 
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/items/biochips/mapimage.h"
 
 namespace Pegasus {
@@ -47,11 +49,11 @@ namespace Pegasus {
 
 #define FLAG_TO_DIRECTION(flag) ((flag) & 3)
 
-static const long kGearRoomFlagLow = ROOM_TO_FLAG(kMars35, kNorth);
-static const long kGearRoomFlagHigh = ROOM_TO_FLAG(kMars39, kWest);
+static const int kGearRoomFlagLow = ROOM_TO_FLAG(kMars35, kNorth);
+static const int kGearRoomFlagHigh = ROOM_TO_FLAG(kMars39, kWest);
 
-static const long kMazeFlagLow = ROOM_TO_FLAG(kMars60, kNorth);
-static const long kMazeFlagHigh = ROOM_TO_FLAG(kMarsMaze200, kWest);
+static const int kMazeFlagLow = ROOM_TO_FLAG(kMars60, kNorth);
+static const int kMazeFlagHigh = ROOM_TO_FLAG(kMarsMaze200, kWest);
 
 static const tCoordType kGearRoomScreenOffsetX = 49;
 static const tCoordType kGearRoomScreenOffsetY = 47;
@@ -68,6 +70,9 @@ static const tCoordType kMazeGridOriginY = 1;
 static const tCoordType kGridWidth = 4;
 static const tCoordType kGridHeight = 4;
 
+static const uint16 kMapOfMazePICTID = 906;
+static const uint16 kMapOfGearRoomPICTID = 907;
+
 static const int s_mapCoords[MapImage::kNumMappingRooms][2] = {
 	/* kMars35 */      { 0, 0 },
 	/* kMars36 */      { 1, 0 },
@@ -260,42 +265,178 @@ void MapImage::readFromStream(Common::ReadStream *stream) {
 	_mappedRooms.readFromStream(stream);
 }
 
-void MapImage::loadGearRoomIfNecessary() {
-	// TODO
+void MapImage::loadGearRoomIfNecessary() {	
+	if (_whichArea != kMapGearRoom) {
+		_mapImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMapOfGearRoomPICTID);
+
+		Common::Rect bounds;
+		_mapImage.getSurfaceBounds(bounds);
+		_mapMask.allocateSurface(bounds);
+		_whichArea = kMapGearRoom;
+
+		GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+		gfx->setCurSurface(_mapMask.getSurface());
+
+		gfx->getCurSurface()->fillRect(bounds, g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff));
+
+		for (int i = kGearRoomFlagLow; i <= kGearRoomFlagHigh; i++)
+			if (_mappedRooms.getFlag(i))
+				addFlagToMask(i);
+
+		gfx->setCurSurface(gfx->getWorkArea());
+		show();
+	}
 }
 
-void MapImage::loadMazeIfNecessary() {
-	// TODO
+void MapImage::loadMazeIfNecessary() {	
+	if (_whichArea != kMapMaze) {
+		_mapImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMapOfMazePICTID);
+
+		Common::Rect bounds;
+		_mapImage.getSurfaceBounds(bounds);
+		_mapMask.allocateSurface(bounds);
+		_whichArea = kMapMaze;
+
+		GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+		gfx->setCurSurface(_mapMask.getSurface());
+
+		gfx->getCurSurface()->fillRect(bounds, g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff));
+
+		for (int i = kMazeFlagLow; i <= kMazeFlagHigh; i++)
+			if (_mappedRooms.getFlag(i))
+				addFlagToMask(i);
+
+		gfx->setCurSurface(gfx->getWorkArea());
+		show();
+	}
 }
 
 void MapImage::unloadImage() {
-	// TODO: Unload surfaces
+	_mapImage.deallocateSurface();
+	_mapMask.deallocateSurface();
 	hide();
 	_whichArea = kMapNoArea;
 }
 
 void MapImage::moveToMapLocation(const tNeighborhoodID, const tRoomID room, const tDirectionConstant dir) {
-	// TODO
+	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+
+	int flag = ROOM_TO_FLAG(room, dir);
+
+	if (!_mappedRooms.getFlag(flag)) {
+		_mappedRooms.setFlag(flag, true);
+
+		if (_mapMask.isSurfaceValid()) {
+			gfx->setCurSurface(_mapMask.getSurface());
+			addFlagToMask(flag);
+			gfx->setCurSurface(gfx->getWorkArea());
+		}
+	}
 
 	if (isDisplaying())
 		triggerRedraw();
 }
 
 void MapImage::addFlagToMask(const int flag) {
-	// TODO
+	Common::Rect r1;
+	getRevealedRects(flag, r1);
+	((PegasusEngine *)g_engine)->_gfx->getCurSurface()->fillRect(r1, g_system->getScreenFormat().RGBToColor(0, 0, 0));
 }
 
 // This function can even be sensitive to open doors.
+// clone2727 notices that it's not, though
 void MapImage::getRevealedRects(const uint32 flag, Common::Rect &r1) {	
-	// TODO
+	tCoordType gridX, gridY;
+
+	switch (_whichArea) {
+	case kMapMaze:
+		gridX = kMazeGridOriginX;
+		gridY = kMazeGridOriginY;
+		break;
+	case kMapGearRoom:
+		gridX = kGearRoomGridOriginX;
+		gridY = kGearRoomGridOriginY;
+		break;
+	default:
+		return;
+	}
+
+	int index = FLAG_TO_INDEX(flag);
+	gridX += s_mapCoords[index][0] * kGridWidth;
+	gridY += s_mapCoords[index][1] * kGridHeight;
+
+	r1 = Common::Rect(gridX - 1, gridY - 1, gridX + kGridWidth + 1, gridY + kGridHeight + 1);
 }
 
 void MapImage::drawPlayer() {
-	// TODO
+	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
+
+	tCoordType gridX, gridY;
+
+	switch (_whichArea) {
+	case kMapMaze:
+		gridX = _bounds.left + kMazeScreenOffsetX + kMazeGridOriginX;
+		gridY = _bounds.top + kMazeScreenOffsetY + kMazeGridOriginY;
+		break;
+	case kMapGearRoom:
+		gridX = _bounds.left + kGearRoomScreenOffsetX + kGearRoomGridOriginX;
+		gridY = _bounds.top + kGearRoomScreenOffsetY + kGearRoomGridOriginY;
+		break;
+	default:
+		return;
+	}
+
+	int index = ROOM_TO_INDEX(GameState.getCurrentRoom());
+	gridX += s_mapCoords[index][0] * kGridWidth;
+	gridY += s_mapCoords[index][1] * kGridHeight;
+
+	// This was intended to make little arrows
+	switch (GameState.getCurrentDirection()) {
+	case kNorth:
+		screen->drawLine(gridX + 1, gridY, gridX + 2, gridY, _darkGreen);
+		screen->drawLine(gridX, gridY + 1, gridX + 3, gridY + 1, _darkGreen);
+		screen->drawLine(gridX + 1, gridY + 1, gridX + 2, gridY + 1, _lightGreen);
+		screen->drawLine(gridX, gridY + 2, gridX + 3, gridY + 2, _lightGreen);
+		break;
+	case kSouth:
+		screen->drawLine(gridX + 1, gridY + 3, gridX + 2, gridY + 3, _darkGreen);
+		screen->drawLine(gridX, gridY + 2, gridX + 3, gridY + 2, _darkGreen);
+		screen->drawLine(gridX + 1, gridY + 2, gridX + 2, gridY + 2, _lightGreen);
+		screen->drawLine(gridX, gridY + 1, gridX + 3, gridY + 1, _lightGreen);
+		break;
+	case kEast:
+		screen->drawLine(gridX + 3, gridY + 1, gridX + 3, gridY + 2, _darkGreen);
+		screen->drawLine(gridX + 2, gridY, gridX + 2, gridY + 3, _darkGreen);
+		screen->drawLine(gridX + 2, gridY + 1, gridX + 2, gridY + 2, _lightGreen);
+		screen->drawLine(gridX + 1, gridY, gridX + 1, gridY + 3, _lightGreen);
+		break;
+	case kWest:
+		screen->drawLine(gridX, gridY + 1, gridX, gridY + 2, _darkGreen);
+		screen->drawLine(gridX + 1, gridY, gridX + 1, gridY + 3, _darkGreen);
+		screen->drawLine(gridX + 1, gridY + 1, gridX + 1, gridY + 2, _lightGreen);
+		screen->drawLine(gridX + 2, gridY, gridX + 2, gridY + 3, _lightGreen);
+		break;
+	}
 }
 
 void MapImage::draw(const Common::Rect &) {
-	// TODO
+	Common::Rect r1;
+	_mapImage.getSurfaceBounds(r1);
+
+	Common::Rect r2 = r1;
+	switch (_whichArea) {
+	case kMapMaze:
+		r2.moveTo(_bounds.left + kMazeScreenOffsetX, _bounds.top + kMazeScreenOffsetY);
+		break;
+	case kMapGearRoom:
+		r2.moveTo(_bounds.left + kGearRoomScreenOffsetX, _bounds.top + kGearRoomScreenOffsetY);
+		break;
+	default:
+		return;
+	}
+
+	_mapImage.copyToCurrentPortMasked(r1, r2, &_mapMask);
+
 	drawPlayer();
 }
 
diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
index d21d29c..359d67c 100755
--- a/engines/pegasus/items/biochips/mapimage.h
+++ b/engines/pegasus/items/biochips/mapimage.h
@@ -27,6 +27,7 @@
 #define PEGASUS_ITEMS_BIOCHIPS_MAPIMAGE_H
 
 #include "pegasus/elements.h"
+#include "pegasus/surface.h"
 #include "pegasus/util.h"
 #include "pegasus/neighborhood/mars/constants.h"
 
@@ -59,7 +60,7 @@ public:
 	static const uint32 kNumMappingFlags = kNumMappingRooms * 4;
 
 protected:
-	enum tMapArea {
+	enum MapArea {
 		kMapNoArea,
 		kMapMaze,
 		kMapGearRoom
@@ -69,11 +70,13 @@ protected:
 	void getRevealedRects(const uint32, Common::Rect &);
 	void drawPlayer();
 
-	tMapArea _whichArea;
+	MapArea _whichArea;
 
 	FlagsArray<byte, kNumMappingFlags> _mappedRooms;
 
 	uint32 _darkGreen, _lightGreen;
+
+	Surface _mapImage, _mapMask;
 };
 
 } // End of namespace Pegasus


Commit: dec8fcdbbd439acfd4cb5f38815fd6a7db02ed4c
    https://github.com/scummvm/scummvm/commit/dec8fcdbbd439acfd4cb5f38815fd6a7db02ed4c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-01T09:17:22-07:00

Commit Message:
PEGASUS: Add the panorama class

Changed paths:
  A engines/pegasus/neighborhood/norad/alpha/panorama.cpp
  A engines/pegasus/neighborhood/norad/alpha/panorama.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index eaf36b8..2f207ea 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -78,6 +78,7 @@ MODULE_OBJS = \
 	neighborhood/norad/subplatform.o \
 	neighborhood/norad/alpha/fillingstation.o \
 	neighborhood/norad/alpha/noradalpha.o \
+	neighborhood/norad/alpha/panorama.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
new file mode 100755
index 0000000..46b21eb
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
@@ -0,0 +1,240 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/macresman.h"
+#include "common/stream.h"
+#include "pegasus/neighborhood/norad/alpha/panorama.h"
+
+namespace Pegasus {
+
+Panorama::Panorama() : _panoramaMovie(kNoDisplayElement) {
+	blankFields();
+}
+
+Panorama::~Panorama() {
+	releasePanorama();
+}
+
+void Panorama::blankFields() {
+	_viewBounds = Common::Rect();
+	_drawBounds = Common::Rect();
+	_mask = 0;
+	_panoramaWidth = 0;
+	_panoramaHeight = 0;
+	_stripWidth = 0;
+	_stripLeft = -1;
+	_stripRight = -1;
+}
+
+void Panorama::releasePanorama() {
+	if (_panoramaMovie.isMovieValid()) {
+		_panoramaMovie.releaseMovie();
+		_panoramaWorld.deallocateSurface();
+		blankFields();
+	}
+}
+
+static const uint32 kPanoramaResType = MKTAG('P', 'a', 'n', 'I'); // Panorama Information.
+static const uint16 kPanoramaResID = 128;
+
+void Panorama::initFromMovieFile(const Common::String &fileName) {
+	// First, we need the resource fork for other reasons -- PanI resource
+	Common::MacResManager *resFork = new Common::MacResManager();
+	if (!resFork->open(fileName) || !resFork->hasResFork())
+		error("Could not open the resource fork of '%s'", fileName.c_str());
+
+	Common::SeekableReadStream *resource = resFork->getResource(kPanoramaResType, kPanoramaResID);
+	if (!resource)
+		error("No panorama information in the resource fork of '%s'", fileName.c_str());
+
+	_panoramaWidth = resource->readUint16BE();
+	_panoramaHeight = resource->readUint16BE();
+	_stripWidth = resource->readUint16BE();
+
+	delete resource;
+	delete resFork;
+
+	// Now we open the movie like normal
+	_panoramaMovie.initFromMovieFile(fileName);
+}
+
+void Panorama::setMask(Surface *mask) {
+	_mask = mask;
+}
+
+// If the panorama is not open, do nothing and return.
+// Otherwise, set up the view bounds.
+void Panorama::setViewBounds(const Common::Rect &newView) {	
+	if (!isPanoramaOpen())
+		return;
+
+	if (newView.isEmpty())
+		return;
+
+	Common::Rect r = newView;
+
+	if (r.width() > _panoramaWidth) {
+		r.left = 0;
+		r.right = _panoramaWidth;
+	} else {
+		if (r.right > _panoramaWidth)
+			r.translate(_panoramaWidth - r.right, 0);
+
+		if (r.left < 0)
+			r.translate(-r.left, 0);
+	}
+
+	if (r.height() > _panoramaHeight) {
+		r.top = 0;
+		r.bottom = _panoramaHeight;
+	} else {
+		if (r.bottom > _panoramaHeight)
+			r.translate(0, _panoramaHeight - r.bottom);
+
+		if (r.top < 0)
+			r.translate(0, -r.top);
+	}
+
+	if (_viewBounds != r) {
+		tCoordType stripLeft = 0;
+
+		if (r.width() != _viewBounds.width() || !_panoramaWorld.isSurfaceValid()) {
+			_panoramaWorld.deallocateSurface();
+			makeNewSurface(r);
+		} else {
+			tCoordType stripRight;
+			calcStripRange(r, stripLeft, stripRight);
+			loadStrips(stripLeft, stripRight);
+		}
+
+		_viewBounds = r;
+		_drawBounds = r;
+		_drawBounds.translate(-stripLeft * _stripWidth, 0);
+	}
+}
+
+void Panorama::getViewBounds(Common::Rect &r) const {
+	r = _viewBounds;
+}
+
+void Panorama::getPanoramaBounds(Common::Rect &r) const {
+	r = Common::Rect(0, 0, _panoramaWidth, _panoramaHeight);
+}
+
+void Panorama::drawPanorama(const Common::Rect &destRect) {
+	if (_panoramaWorld.isSurfaceValid()) {
+		if (_mask)
+			_panoramaWorld.copyToCurrentPortMasked(_drawBounds, destRect, _mask);
+		else
+			_panoramaWorld.copyToCurrentPortTransparent(_drawBounds, destRect);
+	}
+}
+
+// Make a new Surface big enough to show r, which is assumed to be a valid view bounds.
+// Assumptions:
+//      r is a valid view bounds.
+//      _panoramaWorld is not allocated.
+//      _panoramaHeight, _stripWidth is correct.
+//      _panoramaMovie is allocated.
+void Panorama::makeNewSurface(const Common::Rect& view) {
+	tCoordType stripLeft, stripRight;	
+	calcStripRange(view, stripLeft, stripRight);
+
+	Common::Rect r(0, 0, (stripRight - stripLeft + 1) * _stripWidth, _panoramaHeight);
+	_panoramaWorld.allocateSurface(r);
+	_panoramaMovie.shareSurface(&_panoramaWorld);
+	loadStrips(stripLeft, stripRight);
+}
+
+// Assumes view is not empty.
+void Panorama::calcStripRange(const Common::Rect &view, tCoordType &stripLeft, tCoordType &stripRight) {
+	stripLeft = view.left / _stripWidth;
+	stripRight = (view.left - view.left % _stripWidth + _stripWidth - 1 + view.width()) / _stripWidth;
+}
+
+// Load in all needed strips to put range (stripLeft, stripRight) into the
+// panorama's Surface. Try to optimize by saving any pixels already in the Surface.
+// Assumptions:
+//      Surface is allocated and is big enough for maximum range of
+//          stripLeft and stripRight
+void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {	
+	if (_stripLeft == -1) {
+		// Surface has just been allocated.
+		// Load in all strips.
+		for (tCoordType i = stripLeft; i <= stripRight; i++)
+			loadOneStrip(i, stripLeft);
+
+		_stripLeft = stripLeft;
+		_stripRight = stripRight;
+	} else if (stripLeft != _stripLeft) {
+		tCoordType overlapLeft = MAX(stripLeft, _stripLeft);
+		tCoordType overlapRight = MIN(stripRight, _stripRight);
+
+		if (overlapLeft <= overlapRight) {
+			Common::Rect r1((overlapLeft - _stripLeft) * _stripWidth, 0,
+					(overlapRight - _stripLeft + 1) * _stripWidth, _panoramaHeight);
+			Common::Rect r2 = r1;
+
+			if (stripLeft < _stripLeft) {
+				Common::Rect bounds;
+				_panoramaWorld.getSurfaceBounds(bounds);
+				_panoramaWorld.getSurface()->move(bounds.right - r1.right, 0, _panoramaHeight);
+
+				for (tCoordType i = stripLeft; i < _stripLeft; i++)
+					loadOneStrip(i, stripLeft);
+			} else {
+				_panoramaWorld.getSurface()->move(-r1.left, 0, _panoramaHeight);
+
+				for (tCoordType i = _stripRight + 1; i <= stripRight; i++)
+					loadOneStrip(i, stripLeft);
+			}
+		} else {
+			// No overlap.
+			// Load everything.
+			for (tCoordType i = stripLeft; i <= stripRight; i++)
+				loadOneStrip(i, stripLeft);
+		}
+
+		_stripLeft = stripLeft;
+		_stripRight = stripRight;
+	} else if (stripRight > _stripRight) {
+		// Need to add one or more strips.
+		for (tCoordType i = _stripRight + 1; i <= stripRight; i++)
+			loadOneStrip(i, _stripLeft);
+
+		_stripRight = stripRight;
+	} else if (stripRight < _stripRight) {
+		// Need to chop off one strip.
+		_stripRight = stripRight;
+	}
+}
+
+void Panorama::loadOneStrip(tCoordType stripToLoad, tCoordType leftStrip) {
+	_panoramaMovie.moveMovieBoxTo((stripToLoad - leftStrip) * _stripWidth, 0);
+	_panoramaMovie.setTime(stripToLoad);
+	_panoramaMovie.redrawMovieWorld();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.h b/engines/pegasus/neighborhood/norad/alpha/panorama.h
new file mode 100755
index 0000000..a773da9
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.h
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_PANORAMA_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_PANORAMA_H
+
+#include "pegasus/movie.h"
+
+namespace Pegasus {
+
+/*
+
+	Panorama implements a wide image using a specially constructed movie file.
+	The movie holds the image as a series of vertical strips, say 16 or 32 pixels wide.
+	
+	The panorama bounds defines the entire panorama. The view bounds represents the
+	area on the panorama that is kept in memory.
+	
+	The panorama bounds is also stored in the movie file; it cannot be changed. The
+	view bounds must always be a subset of the panorama bounds.
+	
+	In actuality, the area kept in memory is at least as wide as the view bounds (but
+	may be wider to coincide with the width of the movies slices), and is as tall as
+	the panorama bounds. The view bounds is used by the drawPanorama function to draw
+	a piece of the panorama to the current screen.
+	
+	The panorama movie is built at a time scale of 1, with each strip lasting for one
+	second, so that strip number corresponds exactly with the time value at which the
+	strip is stored.
+	
+	TO USE:
+	
+	Call one initFromMovieFile to open the movie. Then set up a view rect by
+	calling setViewBounds. Once these two functions have been called, drawPanorama
+	will draw the panorama.
+
+*/
+
+class Panorama {
+public:
+	Panorama();
+	virtual ~Panorama();
+
+	void initFromMovieFile(const Common::String &);
+	void releasePanorama();
+	bool isPanoramaOpen() { return _panoramaMovie.isMovieValid(); }
+
+	void setViewBounds(const Common::Rect &);
+	void getViewBounds(Common::Rect &) const;
+
+	void setMask(Surface *);
+
+	void getPanoramaBounds(Common::Rect &) const;
+
+	void drawPanorama(const Common::Rect &);
+
+protected:
+	void blankFields();
+	void makeNewSurface(const Common::Rect &);
+	void calcStripRange(const Common::Rect &, tCoordType &, tCoordType &);
+	void loadStrips(tCoordType, tCoordType);
+	void loadOneStrip(tCoordType, tCoordType);
+	
+	Movie _panoramaMovie;
+	Surface _panoramaWorld, *_mask;
+	Common::Rect _viewBounds;
+	Common::Rect _drawBounds;
+	tCoordType _panoramaWidth, _panoramaHeight;
+	tCoordType _stripWidth; // Pixels per strip.
+	tCoordType _numStrips;
+	tCoordType _stripLeft, _stripRight;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: e781066cecc5a25794e26a149bf7ea8b16949fbd
    https://github.com/scummvm/scummvm/commit/e781066cecc5a25794e26a149bf7ea8b16949fbd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-01T09:32:50-07:00

Commit Message:
PEGASUS: Add the panorama scroll class

Changed paths:
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
    engines/pegasus/module.mk



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index 2f207ea..e4f1172 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -79,6 +79,7 @@ MODULE_OBJS = \
 	neighborhood/norad/alpha/fillingstation.o \
 	neighborhood/norad/alpha/noradalpha.o \
 	neighborhood/norad/alpha/panorama.o \
+	neighborhood/norad/alpha/panoramascroll.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
new file mode 100755
index 0000000..2b8ff49
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/neighborhood/norad/alpha/panoramascroll.h"
+
+namespace Pegasus {
+
+PanoramaScroll::PanoramaScroll(const tDisplayElementID id) : IdlerAnimation(id) {
+	_boundsWidth = 0;
+	_totalWidth = 0;
+}
+
+void PanoramaScroll::initFromMovieFile(const Common::String &fileName) {	
+	_panorama.initFromMovieFile(fileName);
+
+	Common::Rect r;
+	_panorama.getPanoramaBounds(r);
+	_totalWidth = r.width();
+}
+
+void PanoramaScroll::initMaskFromPICTFile(const Common::String &fileName) {	
+	if (!_panorama.isPanoramaOpen())
+		return;
+
+	_mask.getImageFromPICTFile(fileName);
+	_panorama.setMask(&_mask);
+}
+
+void PanoramaScroll::releasePanorama() {
+	if (_panorama.isPanoramaOpen())
+		_panorama.releasePanorama();
+
+	_mask.deallocateSurface();
+}
+
+void PanoramaScroll::setBounds(const Common::Rect &r) {
+	Animation::setBounds(r);
+
+	_boundsWidth = r.width();
+
+	Common::Rect r2;
+	_panorama.getViewBounds(r2);
+	r2.right = r2.left + _boundsWidth;
+	r2.bottom = r2.top + r.height();
+	_panorama.setViewBounds(r2);
+}
+
+void PanoramaScroll::draw(const Common::Rect &) {
+	_panorama.drawPanorama(_bounds);
+}
+
+void PanoramaScroll::timeChanged(const TimeValue newTime) {	
+	tCoordType leftPixel = (_totalWidth - _boundsWidth) * newTime / getDuration();
+
+	Common::Rect r;
+	_panorama.getViewBounds(r);
+	if (leftPixel != r.left) {
+		_panorama.getViewBounds(r);
+		r.moveTo(leftPixel, 0);
+		_panorama.setViewBounds(r);
+		triggerRedraw();
+	}
+}
+
+void PanoramaScroll::getPanoramaBounds(Common::Rect &r) const {
+	_panorama.getPanoramaBounds(r);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
new file mode 100755
index 0000000..8496181
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_PANORAMASCROLL_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_PANORAMASCROLL_H
+
+#include "pegasus/neighborhood/norad/alpha/panorama.h"
+
+namespace Pegasus {
+
+class PanoramaScroll : public IdlerAnimation {
+public:
+	PanoramaScroll(const tDisplayElementID);
+	virtual ~PanoramaScroll() {}
+
+	void initFromMovieFile(const Common::String &);
+	void initMaskFromPICTFile(const Common::String &);
+
+	void releasePanorama();
+
+	bool isPanoramaOpen() { return _panorama.isPanoramaOpen(); }
+	void getPanoramaBounds(Common::Rect &) const;
+
+	void setBounds(const Common::Rect&);
+
+	void draw(const Common::Rect &);
+
+protected:
+	void timeChanged(const TimeValue);
+
+	Panorama _panorama;
+	Surface _mask;
+	tCoordType _totalWidth, _boundsWidth;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: faa6018cad43c89c415397112e9fd7ca46fff5da
    https://github.com/scummvm/scummvm/commit/faa6018cad43c89c415397112e9fd7ca46fff5da
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-01T17:38:22-07:00

Commit Message:
PEGASUS: Just clip the junk from going off right or bottom too

Changed paths:
    engines/pegasus/neighborhood/mars/spacejunk.cpp



diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index a1f9bf7..a751dc2 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -82,7 +82,7 @@ void SpaceJunk::setCenter(const tCoordType centerX, const tCoordType centerY) {
 
 	Common::Rect r;
 	getBounds(r);
-	r.moveTo(MAX<int>(centerX - (r.width() >> 1), 0), MAX<int>(centerY - (r.height() >> 1), 0));
+	r.moveTo(CLIP<int>(centerX - (r.width() >> 1), 0, 640), CLIP<int>(centerY - (r.height() >> 1), 0, 480));
 	setBounds(r);
 }
 


Commit: 59421ff1c67155e2236fb78b2b2290e63d2c613f
    https://github.com/scummvm/scummvm/commit/59421ff1c67155e2236fb78b2b2290e63d2c613f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-01T18:11:21-07:00

Commit Message:
PEGASUS: Add the ECR monitor

Panorama not 100% working yet, but the mask does :P

Changed paths:
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index e4f1172..d4ea537 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -76,6 +76,7 @@ MODULE_OBJS = \
 	neighborhood/norad/pressuretracker.o \
 	neighborhood/norad/subcontrolroom.o \
 	neighborhood/norad/subplatform.o \
+	neighborhood/norad/alpha/ecrmonitor.o \
 	neighborhood/norad/alpha/fillingstation.o \
 	neighborhood/norad/alpha/noradalpha.o \
 	neighborhood/norad/alpha/panorama.o \
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
new file mode 100755
index 0000000..1dc770a
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
@@ -0,0 +1,218 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/norad.h"
+#include "pegasus/neighborhood/norad/alpha/ecrmonitor.h"
+
+namespace Pegasus {
+
+static const tNotificationFlags kECRSection1FinishedFlag = 1;
+static const tNotificationFlags kECRPanFinishedFlag = kECRSection1FinishedFlag << 1;
+static const tNotificationFlags kECRSection2FinishedFlag = kECRPanFinishedFlag << 1;
+static const tNotificationFlags kECRNotificationFlags = kECRSection1FinishedFlag |
+													kECRPanFinishedFlag |
+													kECRSection2FinishedFlag;
+
+static const TimeValue kSection1Start = 0;
+static const TimeValue kSection1Stop = 25;
+static const TimeValue kPanStart = 0;
+static const TimeValue kPanStop = 20;
+static const TimeValue kSection2Start = 26;
+static const TimeValue kSection2Stop = 1000;
+
+// Seems to be a good value for a 20 second pan.
+static const tCoordType kPanPixelsPerFrame = 8;
+
+// Interesting times are in seconds.
+static const TimeValue s_ECRInterestingTimes[] = {
+	0, 1, 2, 10, 25, 26, 56, 64, 72, 80, 88, 94, 102, 108, 116, 999
+};
+
+// Index into s_ECRInterestingTimes of interesting time before security pan.
+static const int kBeforePanTime = 3;
+
+// Index into s_ECRInterestingTimes of interesting time after security pan.
+static const int kAfterPanTime = 5;
+
+NoradAlphaECRMonitor::NoradAlphaECRMonitor(Neighborhood *nextHandler) : GameInteraction(kNoradECRMonitorInteractionID, nextHandler),
+		_ecrSlideShowNotification(kNoradECRNotificationID, (PegasusEngine *)g_engine), _ecrMovie(kECRSlideShowMovieID),
+		_ecrPan(kECRPanID) {
+}
+
+void NoradAlphaECRMonitor::receiveNotification(Notification *, const tNotificationFlags flags) {
+	if (flags & kECRSection1FinishedFlag)
+		ecrSection1Finished();
+	else if (flags & kECRPanFinishedFlag)
+		ecrPanFinished();
+	else if (flags & kECRSection2FinishedFlag)
+		ecrSection2Finished();
+}
+
+int NoradAlphaECRMonitor::findCurrentInterestingTime() {	
+	TimeValue time = _ecrMovie.getTime();
+	TimeScale scale = _ecrMovie.getScale();
+
+	for (int i = ARRAYSIZE(s_ECRInterestingTimes) - 1; i >= 0; i--)
+		if (time >= s_ECRInterestingTimes[i] * scale)
+			return i;
+
+	return 0;
+}
+
+void NoradAlphaECRMonitor::skipToNextInterestingTime() {
+	if (_ecrMovie.isRunning()) {
+		int interestingTime = findCurrentInterestingTime();
+		_ecrMovie.setTime(s_ECRInterestingTimes[interestingTime + 1] * _ecrMovie.getScale());
+		_ecrMovie.redrawMovieWorld();
+	} else if (_ecrPan.isRunning()) {
+		_ecrPanCallBack.cancelCallBack();
+		ecrPanFinished();
+	}
+}
+
+void NoradAlphaECRMonitor::skipToPreviousInterestingTime() {
+	if (_ecrPan.isRunning()) {
+		_ecrPan.stop();
+		_ecrPan.stopDisplaying();
+		_ecrPanCallBack.cancelCallBack();
+
+		_ecrMovieCallBack.setCallBackFlag(kECRSection1FinishedFlag);
+		_ecrMovieCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+		TimeScale scale = _ecrMovie.getScale();
+		_ecrMovie.setSegment(kSection1Start * scale, kSection1Stop * scale + 1);
+		_ecrMovie.setTime(s_ECRInterestingTimes[kBeforePanTime] * scale);
+		_ecrMovie.start();
+	} else {
+		int interestingTime = findCurrentInterestingTime();
+
+		if (interestingTime == kAfterPanTime) {
+			_ecrMovieCallBack.cancelCallBack();
+			TimeScale scale = _ecrMovie.getScale();
+			_ecrMovie.setSegment(kSection1Start * scale, kSection1Stop * scale + 1);
+			_ecrMovie.setTime(kSection1Stop * scale);
+			ecrSection1Finished();
+		} else if (interestingTime == 0) {
+			_ecrMovie.setTime(kSection1Start * _ecrMovie.getScale());
+			_ecrMovie.redrawMovieWorld();
+		} else {
+			_ecrMovie.setTime(s_ECRInterestingTimes[interestingTime - 1] * _ecrMovie.getScale());
+			_ecrMovie.redrawMovieWorld();
+		}
+	}
+}
+
+void NoradAlphaECRMonitor::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	if (isInteracting()) {
+		if (input.rightButtonDown())
+			skipToNextInterestingTime();
+		else if (input.leftButtonDown())
+			skipToPreviousInterestingTime();
+		else
+			InputHandler::handleInput(input, cursorSpot);
+	} else {
+		InputHandler::handleInput(input, cursorSpot);
+	}
+}
+
+void NoradAlphaECRMonitor::ecrSection1Finished() {
+	_ecrMovie.stop();
+	_ecrPanCallBack.setNotification(&_ecrSlideShowNotification);
+	_ecrPanCallBack.initCallBack(&_ecrPan, kCallBackAtExtremes);
+	_ecrPanCallBack.setCallBackFlag(kECRPanFinishedFlag);
+	_ecrSlideShowNotification.notifyMe(this, kECRNotificationFlags, kECRNotificationFlags);
+	_ecrPanCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_ecrPan.startDisplaying();
+	_ecrPan.show();
+
+	TimeScale scale = _ecrPan.getScale();
+	_ecrPan.setSegment(kPanStart * scale, kPanStop * scale);
+	_ecrPan.setTime(0);
+	_ecrPan.start();
+}
+
+void NoradAlphaECRMonitor::ecrPanFinished() {	
+	_ecrPan.stop();
+	_ecrPan.stopDisplaying();
+	_ecrMovieCallBack.setCallBackFlag(kECRSection2FinishedFlag);
+	_ecrMovieCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+	TimeScale scale = _ecrMovie.getScale();
+	_ecrMovie.setSegment(kSection2Start * scale, kSection2Stop * scale);
+	_ecrMovie.start();
+}
+
+void NoradAlphaECRMonitor::ecrSection2Finished() {
+	_ecrMovie.stop();
+	_ecrMovie.stopDisplaying();
+}
+
+void NoradAlphaECRMonitor::openInteraction() {
+	// Initialize the security pan.
+	_ecrPan.initFromMovieFile("Images/Norad Alpha/Security Pan.pano");
+	_ecrPan.initMaskFromPICTFile("Images/Norad Alpha/Security Pan Mask");
+	_ecrPan.setBounds(Common::Rect(kECRPanLeft, kECRPanTop, kECRPanRight, kECRPanBottom));
+	_ecrPan.setDisplayOrder(kECRPanOrder);
+	_ecrPan.setScale(15); // 15 fps.
+
+	// Begin the lame ECR slide show.
+	// clone2727: I didn't say it :P
+	_ecrMovie.initFromMovieFile("Images/Norad Alpha/ECR Monitor Movie");
+
+	_ecrMovieCallBack.setNotification(&_ecrSlideShowNotification);
+	_ecrMovieCallBack.initCallBack(&_ecrMovie, kCallBackAtExtremes);
+	_ecrMovieCallBack.setCallBackFlag(kECRSection1FinishedFlag);
+
+	_ecrSlideShowNotification.notifyMe(this, kECRNotificationFlags, kECRNotificationFlags);
+	_ecrMovieCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+	_ecrMovie.moveElementTo(kECRSlideShowLeft, kECRSlideShowTop);
+	_ecrMovie.setDisplayOrder(kECRMonitorOrder);
+	_ecrMovie.startDisplaying();
+	_ecrMovie.show();
+	_ecrMovie.redrawMovieWorld();
+
+	TimeScale scale = _ecrMovie.getScale();	
+	_ecrMovie.setSegment(kSection1Start * scale, kSection1Stop * scale + 1);
+
+	_ecrMovie.start();
+}
+
+void NoradAlphaECRMonitor::closeInteraction() {
+	_ecrMovieCallBack.releaseCallBack();
+	_ecrMovie.stop();
+	_ecrMovie.stopDisplaying();
+	_ecrMovie.releaseMovie();
+	_ecrMovieCallBack.releaseCallBack();
+
+	_ecrPanCallBack.releaseCallBack();
+	_ecrPan.stop();
+	_ecrPan.stopDisplaying();
+	_ecrPan.releasePanorama();
+	_ecrPanCallBack.releaseCallBack();
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
new file mode 100755
index 0000000..329dae7
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
@@ -0,0 +1,65 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_ecrMONITOR_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_ALPHA_ecrMONITOR_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/notification.h"
+#include "pegasus/neighborhood/norad/alpha/panoramascroll.h"
+
+namespace Pegasus {
+
+class NoradAlphaECRMonitor : public GameInteraction, public NotificationReceiver {
+public:
+	NoradAlphaECRMonitor(Neighborhood *);
+	virtual ~NoradAlphaECRMonitor() {}
+
+	virtual void handleInput(const Input &, const Hotspot *);
+
+protected:
+	virtual void openInteraction();
+	virtual void closeInteraction();
+
+	virtual void receiveNotification(Notification *, const tNotificationFlags);
+
+	void ecrSection1Finished();
+	void ecrPanFinished();
+	void ecrSection2Finished();
+
+	int findCurrentInterestingTime();
+	void skipToNextInterestingTime();
+	void skipToPreviousInterestingTime();
+
+	Notification _ecrSlideShowNotification;
+	Movie _ecrMovie;
+	NotificationCallBack _ecrMovieCallBack;
+	PanoramaScroll _ecrPan;
+	NotificationCallBack _ecrPanCallBack;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index c12623f..46bebf6 100755
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -29,6 +29,7 @@
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/inventory/airmask.h"
 #include "pegasus/neighborhood/norad/subcontrolroom.h"
+#include "pegasus/neighborhood/norad/alpha/ecrmonitor.h"
 #include "pegasus/neighborhood/norad/alpha/fillingstation.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 
@@ -212,9 +213,7 @@ void NoradAlpha::playClawMonitorIntro() {
 GameInteraction *NoradAlpha::makeInteraction(const tInteractionID interactionID) {
 	switch (interactionID) {
 	case kNoradECRMonitorInteractionID:
-		// TODO
-		warning("Unhandled ECR monitor interaction");
-		break;
+		return new NoradAlphaECRMonitor(this);
 	case kNoradFillingStationInteractionID:
 		return new NoradAlphaFillingStation(this);
 	}


Commit: 423ce6c442069a16251b89dd363ce0862a5f3004
    https://github.com/scummvm/scummvm/commit/423ce6c442069a16251b89dd363ce0862a5f3004
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-01T19:47:40-07:00

Commit Message:
PEGASUS: Fix the panorama time scale

Changed paths:
    engines/pegasus/neighborhood/norad/alpha/panorama.cpp



diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
index 46b21eb..417305c 100755
--- a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
@@ -233,7 +233,7 @@ void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {
 
 void Panorama::loadOneStrip(tCoordType stripToLoad, tCoordType leftStrip) {
 	_panoramaMovie.moveMovieBoxTo((stripToLoad - leftStrip) * _stripWidth, 0);
-	_panoramaMovie.setTime(stripToLoad);
+	_panoramaMovie.setTime(stripToLoad, 1);
 	_panoramaMovie.redrawMovieWorld();
 }
 


Commit: 8b62693c82a38d01a80f764e13a1bb1e6177bccb
    https://github.com/scummvm/scummvm/commit/8b62693c82a38d01a80f764e13a1bb1e6177bccb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-02T17:37:53-07:00

Commit Message:
PEGASUS: Add a minimalist SoundTimeBase class

For use with spot sounds only. Also, remove an unused Sound class function

Changed paths:
    engines/pegasus/sound.cpp
    engines/pegasus/sound.h



diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
index 847106a..3fd7a2a 100755
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@ -116,17 +116,6 @@ void Sound::playSoundSegment(uint32 start, uint32 end) {
 	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, subStream, -1, _volume, 0, DisposeAfterUse::YES);
 }
 
-void Sound::loopSoundSegment(uint32 start, uint32 end) {
-	if (!isSoundLoaded())
-		return;
-
-	stopSound();
-
-	Audio::AudioStream *subLoopStream = new Audio::SubLoopingAudioStream(_stream, 0, Audio::Timestamp(0, start, 600), Audio::Timestamp(0, end, 600), DisposeAfterUse::NO);
-
-	g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, &_handle, subLoopStream, -1, _volume, 0, DisposeAfterUse::YES);
-}
-
 void Sound::stopSound() {
 	g_system->getMixer()->stopHandle(_handle);
 }
@@ -147,4 +136,42 @@ bool Sound::isSoundLoaded() const {
 	return _stream != 0;
 }
 
+SoundTimeBase::SoundTimeBase() {
+	setScale(600);
+	_startScale = 600;
+	_stopScale = 600;
+	_setToStart = false;
+}
+
+void SoundTimeBase::playSoundSegment(uint32 startTime, uint32 endTime) {
+	_startTime = startTime;
+	_stopTime = endTime;
+	_setToStart = true;
+	_time = Common::Rational(startTime, getScale());
+	setRate(1);
+	Sound::playSoundSegment(startTime, endTime);
+}
+
+void SoundTimeBase::updateTime() {
+	if (_setToStart) {
+		if (isPlaying()) {
+			// Not at the end, let's get the time
+			uint numFrames = g_system->getMixer()->getSoundElapsedTime(_handle) * 600 / 1000;
+
+			// WORKAROUND: Our mixer is woefully inaccurate and quite often returns
+			// times that exceed the actual length of the clip. We'll just fake times
+			// that are under the final time to ensure any trigger for the end time is
+			// only sent when the sound has actually stopped.
+			if (numFrames >= (_stopTime - _startTime))
+				numFrames = _stopTime - _startTime - 1;
+
+			_time = Common::Rational(_startTime + numFrames, getScale());
+		} else {
+			// Assume we reached the end
+			_setToStart = false;
+			_time = Common::Rational(_stopTime, getScale());
+		}
+	}
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
index f66c3f4..f6e175d 100755
--- a/engines/pegasus/sound.h
+++ b/engines/pegasus/sound.h
@@ -28,6 +28,7 @@
 
 #include "audio/mixer.h"
 #include "common/str.h"
+#include "pegasus/timers.h"
 
 namespace Audio {
 	class SeekableAudioStream;
@@ -67,7 +68,6 @@ public:
 	void playSound();
 	void loopSound();
 	void playSoundSegment(uint32 start, uint32 end);
-	void loopSoundSegment(uint32 start, uint32 end);
 	void stopSound();
 	void setVolume(const uint16 volume);
 	bool isPlaying();
@@ -82,6 +82,27 @@ protected:
 	SoundFader *_fader;
 };
 
+// TODO: Make this class follow TimeBase better
+// Right now it's just a loose wrapper to plug callbacks
+// into sounds. Since this is only used for spot sounds,
+// I'm not too worried about it right now as its usage
+// is very limited.
+// At the very least, the regular TimeBase functions for
+// setting/getting should be neutered.
+class SoundTimeBase : public Sound, public TimeBase {
+public:
+	SoundTimeBase();
+	~SoundTimeBase() {}
+
+	void playSoundSegment(uint32 start, uint32 end);
+
+protected:
+	void updateTime();
+
+private:
+	bool _setToStart;
+};
+
 } // End of namespace Pegasus
 
 #endif


Commit: 476f4b513dd7d69a4d31b464dbc2981a353671c4
    https://github.com/scummvm/scummvm/commit/476f4b513dd7d69a4d31b464dbc2981a353671c4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-02T17:39:06-07:00

Commit Message:
PEGASUS: Switch spot sounds to using SoundTimeBase

Spot sound requests no longer freeze the game in some way

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 00abb02..ae7f80d 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -91,9 +91,7 @@ void Neighborhood::init() {
 	_navMovieCallBack.setNotification(&_neighborhoodNotification);
 	_turnPushCallBack.setNotification(&_neighborhoodNotification);
 	_delayCallBack.setNotification(&_neighborhoodNotification);
-
-	// TODO
-	//_spotSoundCallBack.setNotification(&_neighborhoodNotification);
+	_spotSoundCallBack.setNotification(&_neighborhoodNotification);
 
 	debug(0, "Loading '%s' neighborhood resources", _resName.c_str());
 
@@ -172,9 +170,7 @@ void Neighborhood::init() {
 	_stridingCallBack.initCallBack(&_navMovie, kCallBackAtTime);
 	_turnPushCallBack.initCallBack(&_turnPush, kCallBackAtExtremes);
 	_delayCallBack.initCallBack(&_delayTimer, kCallBackAtExtremes);
-
-	// TODO
-	//_spotSoundCallBack.initCallBack(&_spotSounds, kCallBackAtExtremes);
+	_spotSoundCallBack.initCallBack(&_spotSounds, kCallBackAtExtremes);
 
 	setUpAIRules();
 
@@ -426,7 +422,8 @@ void Neighborhood::serviceActionQueue() {
 				_spotSounds.stopSound();
 				_spotSounds.playSoundSegment(topRequest.start, topRequest.stop);
 				_interruptionFilter = topRequest.interruptionFilter;
-				// TODO: stop trigger
+				_spotSoundCallBack.setCallBackFlag(topRequest.flags);
+				_spotSoundCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
 				break;
 			case kDelayRequest:
 				_delayTimer.stop();
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index e95f76c..c11fe78 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -372,7 +372,7 @@ protected:
 	HotspotList _neighborhoodHotspots;
 
 	// Sounds
-	Sound _spotSounds;
+	SoundTimeBase _spotSounds;
 
 	// Action queue
 	NeighborhoodActionQueue _actionQueue;


Commit: 57405cee9e715fb23ed8faf9fbc21f62d1c87393
    https://github.com/scummvm/scummvm/commit/57405cee9e715fb23ed8faf9fbc21f62d1c87393
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-02T17:50:07-07:00

Commit Message:
PEGASUS: Fix pressure door movie updates

Changed paths:
    engines/pegasus/neighborhood/norad/pressuredoor.cpp



diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
index 0fd5f45..59adb09 100755
--- a/engines/pegasus/neighborhood/norad/pressuredoor.cpp
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
@@ -135,6 +135,7 @@ void PressureDoor::openInteraction() {
 	_levelsMovie.startDisplaying();
 	_levelsMovie.setSegment(kLevelsSplashStart * _levelsScale, kLevelsSplashStop * _levelsScale);
 	_levelsMovie.setTime(kLevelsSplashStart * _levelsScale);
+	_levelsMovie.redrawMovieWorld();
 	_levelsMovie.show();
 	
 	_pressureCallBack.setNotification(&_pressureNotification);
@@ -156,6 +157,7 @@ void PressureDoor::openInteraction() {
 	_typeMovie.setDisplayOrder(kPressureTypeOrder);
 	_typeMovie.startDisplaying();
 	_typeMovie.setTime(kDoorSealedTime * _typeScale);
+	_typeMovie.redrawMovieWorld();
 
 	SpriteFrame *frame = new SpriteFrame();
 	if (_isUpperDoor)
@@ -326,6 +328,7 @@ void PressureDoor::receiveNotification(Notification *notification, const tNotifi
 				_typeMovie.stop();
 				_typeMovie.setSegment(0, _typeMovie.getDuration());
 				_typeMovie.setTime(kDecreasingPressureTime * _typeScale);
+				_typeMovie.redrawMovieWorld();
 				_typeMovie.show();
 				_downButton.show();
 				_downButton.setCurrentFrameIndex(1);
@@ -346,6 +349,7 @@ void PressureDoor::receiveNotification(Notification *notification, const tNotifi
 			switch (_gameState) {
 			case kPlayingPressureMessage:
 				_typeMovie.setTime(kEqualizeTime * _typeScale);
+				_typeMovie.redrawMovieWorld();
 				owner->requestDelay(1, 5, kFilterNoInput, 0);
 				owner->requestSpotSound(_equalizeSoundIn, _equalizeSoundOut, kFilterNoInput, 0);
 				owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
@@ -371,6 +375,7 @@ void PressureDoor::receiveNotification(Notification *notification, const tNotifi
 			_levelsMovie.stop();
 			_levelsMovie.setSegment(0, _levelsMovie.getDuration());
 			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+			_levelsMovie.redrawMovieWorld();
 
 			if (GameState.getNoradSubRoomPressure() != kNormalSubRoomPressure) {
 				_typeMovie.show();
@@ -460,7 +465,9 @@ void PressureDoor::incrementPressure(const tHotSpotID id) {
 		if (GameState.getNoradSubRoomPressure() < kMaxPressure) {
 			GameState.setNoradSubRoomPressure(GameState.getNoradSubRoomPressure() + 1);
 			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+			_levelsMovie.redrawMovieWorld();
 			_typeMovie.setTime(kIncreasingPressureTime * _typeScale);
+			_typeMovie.redrawMovieWorld();
 			_typeMovie.show();
 			g_AIArea->checkMiddleArea();
 		} else {
@@ -470,7 +477,9 @@ void PressureDoor::incrementPressure(const tHotSpotID id) {
 		if (GameState.getNoradSubRoomPressure() > kMinPressure) {
 			GameState.setNoradSubRoomPressure(GameState.getNoradSubRoomPressure() - 1);
 			_levelsMovie.setTime((GameState.getNoradSubRoomPressure() + kPressureBase) * _levelsScale);
+			_levelsMovie.redrawMovieWorld();
 			_typeMovie.setTime(kDecreasingPressureTime * _typeScale);
+			_typeMovie.redrawMovieWorld();
 			_typeMovie.show();
 			g_AIArea->checkMiddleArea();
 		} else {
@@ -521,6 +530,7 @@ void PressureDoor::doSolve() {
 	if (_playingAgainstRobot) {
 		GameState.setNoradSubRoomPressure(11);
 		_levelsMovie.setTime((11 + kPressureBase) * _levelsScale);
+		_levelsMovie.redrawMovieWorld();
 		_typeMovie.setSegment(kMaxPressureLoopStart * _typeScale, kMaxPressureLoopStop * _typeScale);
 		_typeMovie.setFlags(kLoopTimeBase);
 		_typeMovie.show();
@@ -529,6 +539,7 @@ void PressureDoor::doSolve() {
 	} else {
 		GameState.setNoradSubRoomPressure(kNormalSubRoomPressure);
 		_levelsMovie.setTime((kNormalSubRoomPressure + kPressureBase) * _levelsScale);
+		_levelsMovie.redrawMovieWorld();
 		_typeMovie.setSegment(kOpeningDoorLoopStart * _typeScale, kOpeningDoorLoopStop * _typeScale);
 		_typeMovie.setFlags(kLoopTimeBase);
 		_typeMovie.show();


Commit: 053e1d6529753728710b5b29d789e24b0b9c4776
    https://github.com/scummvm/scummvm/commit/053e1d6529753728710b5b29d789e24b0b9c4776
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-02T18:10:00-07:00

Commit Message:
PEGASUS: Some sub control room interaction fixes

Changed paths:
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp



diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index 69244bc..9174a72 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -928,6 +928,7 @@ void SubControlRoom::setControlMonitorToTime(const TimeValue newTime, const int
 	_subControlMovie.stop();
 	_subControlMovie.setSegment(0, _subControlMovie.getDuration());
 	_subControlMovie.setTime(newTime);
+	_subControlMovie.redrawMovieWorld();
 	_gameState = newState;
 	allowInput(shouldAllowInput);
 }
@@ -969,6 +970,7 @@ void SubControlRoom::setClawMonitorToTime(const TimeValue newTime) {
 	_clawMonitorMovie.stop();
 	_clawMonitorMovie.setSegment(0, _clawMonitorMovie.getDuration());
 	_clawMonitorMovie.setTime(newTime);
+	_clawMonitorMovie.redrawMovieWorld();
 }
 
 void SubControlRoom::playClawMonitorSection(const TimeValue in, const TimeValue out, const tNotificationFlags flags,


Commit: d932df79bed5aac97e17c0920a5e75cb5ce733ee
    https://github.com/scummvm/scummvm/commit/d932df79bed5aac97e17c0920a5e75cb5ce733ee
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-11-03T12:00:22-07:00

Commit Message:
PEGASUS: Fix segfault after sub chase sequence

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 61a2383..de2e7f4 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1255,17 +1255,22 @@ void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 	}
 }
 
-void PegasusEngine::performJump(const tNeighborhoodID neighborhoodID) {
+void PegasusEngine::performJump(tNeighborhoodID neighborhoodID) {
+	if (_neighborhood)
+		useNeighborhood(0);
+
 	// Sub chase is special
 	if (neighborhoodID == kNoradSubChaseID) {
 		throwAwayEverything();
 		doSubChase();
-		jumpToNewEnvironment(kNoradDeltaID, kNorad41, kEast);
-		return;
-	}
 
-	if (_neighborhood)
-		useNeighborhood(0);
+		if (shouldQuit())
+			return;
+
+		neighborhoodID = kNoradDeltaID;
+		GameState.setNextRoom(kNorad41);
+		GameState.setNextDirection(kEast);
+	}
 
 	Neighborhood *neighborhood;
 	makeNeighborhood(neighborhoodID, neighborhood);
@@ -1273,10 +1278,10 @@ void PegasusEngine::performJump(const tNeighborhoodID neighborhoodID) {
 }
 
 void PegasusEngine::startNeighborhood() {
-	if (_currentItemID != kNoItemID)
+	if (g_interface && _currentItemID != kNoItemID)
 		g_interface->setCurrentInventoryItemID(_currentItemID);
 	
-	if (_currentBiochipID != kNoItemID)
+	if (g_interface && _currentBiochipID != kNoItemID)
 		g_interface->setCurrentBiochipID(_currentBiochipID);
 	
 	setGameMode(kModeNavigation);
@@ -1344,7 +1349,7 @@ void PegasusEngine::startNewGame() {
 
 void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhood *&neighborhood) {
 	// TODO: CD check
-	
+
 	switch (neighborhoodID) {
 	case kCaldoriaID:
 		neighborhood = new Caldoria(g_AIArea, this);
@@ -1367,8 +1372,12 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 	case kNoradAlphaID:
 		neighborhood = new NoradAlpha(g_AIArea, this);
 		break;
+	case kNoradDeltaID:
+		createInterface();
+		error("TODO: Norad Delta");
+		break;
 	default:
-		error("Unhandled neighborhood %d", neighborhoodID);
+		error("Unknown neighborhood %d", neighborhoodID);
 	}
 }
 
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index f792194..2dcd317 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -265,7 +265,7 @@ private:
 	// Neighborhood
 	Neighborhood *_neighborhood;
 	void useNeighborhood(Neighborhood *neighborhood);
-	void performJump(const tNeighborhoodID start);
+	void performJump(tNeighborhoodID start);
 	void startNewGame();
 	void startNeighborhood();
 	void makeNeighborhood(tNeighborhoodID, Neighborhood *&);


Commit: 00279659b22cbd5db739d5351e83a9fc2a2ae408
    https://github.com/scummvm/scummvm/commit/00279659b22cbd5db739d5351e83a9fc2a2ae408
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-12T12:25:28-08:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Conflicts:
	video/qt_decoder.cpp

Changed paths:
  A backends/graphics/maemosdl/maemosdl-graphics.cpp
  A backends/graphics/maemosdl/maemosdl-graphics.h
  A backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java
  A backends/platform/android/org/scummvm/scummvm/PluginProvider.java
  A backends/platform/android/org/scummvm/scummvm/ScummVM.java
  A backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
  A backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java
  A backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
  A backends/platform/android/org/scummvm/scummvm/Unpacker.java
  A backends/platform/maemo/maemo-common.h
  A backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
  A backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3_split.pkg
  A common/memory.h
  A dists/debian/changelog
  A dists/debian/compat
  A dists/debian/control
  A dists/debian/copyright
  A dists/debian/rules
  A dists/debian/scummvm-data.install
  A dists/debian/scummvm.dirs
  A dists/debian/scummvm.docs
  A dists/debian/scummvm.install
  A dists/debian/scummvm.manpages
  A dists/debian/scummvm.menu
  A doc/cz/PrectiMe
  A doc/es/InicioRapido
  A doc/it/GuidaRapida
  A doc/se/LasMig
  A doc/se/Snabbstart
  A engines/dreamweb/dreambase.h
  A engines/dreamweb/keypad.cpp
  A engines/dreamweb/monitor.cpp
  A engines/dreamweb/object.cpp
  A engines/dreamweb/people.cpp
  A engines/dreamweb/segment.h
  A engines/dreamweb/sound.cpp
  A engines/dreamweb/talk.cpp
  A engines/dreamweb/vgafades.cpp
  A engines/mohawk/livingbooks_lbx.cpp
  A engines/mohawk/livingbooks_lbx.h
  A engines/sci/graphics/controls16.cpp
  A engines/sci/graphics/controls16.h
  A engines/sci/graphics/controls32.cpp
  A engines/sci/graphics/controls32.h
  A engines/sci/sound/drivers/fmtowns.cpp
  A engines/toltecs/animation.cpp
  A engines/toltecs/animation.h
  A engines/toltecs/detection.cpp
  A engines/toltecs/menu.cpp
  A engines/toltecs/menu.h
  A engines/toltecs/microtiles.cpp
  A engines/toltecs/microtiles.h
  A engines/toltecs/module.mk
  A engines/toltecs/movie.cpp
  A engines/toltecs/movie.h
  A engines/toltecs/music.cpp
  A engines/toltecs/music.h
  A engines/toltecs/palette.cpp
  A engines/toltecs/palette.h
  A engines/toltecs/render.cpp
  A engines/toltecs/render.h
  A engines/toltecs/resource.cpp
  A engines/toltecs/resource.h
  A engines/toltecs/saveload.cpp
  A engines/toltecs/screen.cpp
  A engines/toltecs/screen.h
  A engines/toltecs/script.cpp
  A engines/toltecs/script.h
  A engines/toltecs/segmap.cpp
  A engines/toltecs/segmap.h
  A engines/toltecs/sound.cpp
  A engines/toltecs/sound.h
  A engines/toltecs/sprite.cpp
  A engines/toltecs/toltecs.cpp
  A engines/toltecs/toltecs.h
  A engines/tsage/ringworld2/ringworld2_dialogs.cpp
  A engines/tsage/ringworld2/ringworld2_dialogs.h
  A engines/tsage/ringworld2/ringworld2_logic.cpp
  A engines/tsage/ringworld2/ringworld2_logic.h
  A engines/tsage/ringworld2/ringworld2_scenes0.cpp
  A engines/tsage/ringworld2/ringworld2_scenes0.h
  A engines/tsage/ringworld2/ringworld2_scenes2.cpp
  A engines/tsage/ringworld2/ringworld2_scenes2.h
  A engines/tsage/ringworld2/ringworld2_speakers.cpp
  A engines/tsage/ringworld2/ringworld2_speakers.h
  A engines/tsage/user_interface.cpp
  A engines/tsage/user_interface.h
  A gui/themes/scummmodern/eraser.bmp
  R devtools/create_mads/parser.h
  R backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java
  R backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java
  R backends/platform/android/org/inodes/gus/scummvm/ScummVM.java
  R backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java
  R backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java
  R backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java
  R backends/platform/android/org/inodes/gus/scummvm/Unpacker.java
  R common/bitstream.cpp
  R devtools/create_mads/main.cpp
  R devtools/create_mads/module.mk
  R devtools/create_mads/parser.cpp
  R devtools/create_mads/scripts/rex_nebular.txt
  R dists/engine-data/m4.dat
  R dists/engine-data/mads.dat
  R engines/m4/actor.cpp
  R engines/m4/actor.h
  R engines/m4/animation.cpp
  R engines/m4/animation.h
  R engines/m4/assets.cpp
  R engines/m4/assets.h
  R engines/m4/burger_data.h
  R engines/m4/compression.cpp
  R engines/m4/compression.h
  R engines/m4/console.cpp
  R engines/m4/console.h
  R engines/m4/converse.cpp
  R engines/m4/converse.h
  R engines/m4/detection.cpp
  R engines/m4/dialogs.cpp
  R engines/m4/dialogs.h
  R engines/m4/events.cpp
  R engines/m4/events.h
  R engines/m4/font.cpp
  R engines/m4/font.h
  R engines/m4/globals.cpp
  R engines/m4/globals.h
  R engines/m4/graphics.cpp
  R engines/m4/graphics.h
  R engines/m4/gui.cpp
  R engines/m4/gui.h
  R engines/m4/hotspot.cpp
  R engines/m4/hotspot.h
  R engines/m4/m4.cpp
  R engines/m4/m4.h
  R engines/m4/m4_menus.cpp
  R engines/m4/m4_menus.h
  R engines/m4/m4_scene.cpp
  R engines/m4/m4_scene.h
  R engines/m4/m4_views.cpp
  R engines/m4/m4_views.h
  R engines/m4/mads_anim.cpp
  R engines/m4/mads_anim.h
  R engines/m4/mads_logic.cpp
  R engines/m4/mads_logic.h
  R engines/m4/mads_menus.cpp
  R engines/m4/mads_menus.h
  R engines/m4/mads_player.cpp
  R engines/m4/mads_player.h
  R engines/m4/mads_scene.cpp
  R engines/m4/mads_scene.h
  R engines/m4/mads_views.cpp
  R engines/m4/mads_views.h
  R engines/m4/midi.cpp
  R engines/m4/module.mk
  R engines/m4/rails.cpp
  R engines/m4/rails.h
  R engines/m4/resource.cpp
  R engines/m4/resource.h
  R engines/m4/saveload.cpp
  R engines/m4/scene.cpp
  R engines/m4/scene.h
  R engines/m4/script.cpp
  R engines/m4/script.h
  R engines/m4/scripttab.h
  R engines/m4/sound.cpp
  R engines/m4/sound.h
  R engines/m4/sprite.cpp
  R engines/m4/sprite.h
  R engines/m4/viewmgr.cpp
  R engines/m4/viewmgr.h
  R engines/m4/woodscript.cpp
  R engines/m4/woodscript.h
  R engines/m4/ws_machine.cpp
  R engines/m4/ws_sequence.cpp
  R engines/m4/saveload.h
  R engines/sci/graphics/controls.cpp
  R engines/sci/graphics/controls.h
  R engines/m4/staticres.h
  R engines/m4/staticres.cpp
  R engines/m4/midi.h
  R engines/tsage/blue_force/blueforce_ui.cpp
  R engines/tsage/blue_force/blueforce_ui.h
    .gitignore
    AUTHORS
    Makefile.common
    NEWS
    README
    audio/audiostream.h
    audio/decoders/aac.h
    audio/decoders/adpcm.h
    audio/decoders/adpcm_intern.h
    audio/decoders/aiff.h
    audio/decoders/flac.h
    audio/decoders/iff_sound.h
    audio/decoders/mac_snd.h
    audio/decoders/mp3.h
    audio/decoders/qdm2.cpp
    audio/decoders/quicktime.cpp
    audio/decoders/raw.cpp
    audio/decoders/raw.h
    audio/decoders/voc.cpp
    audio/decoders/voc.h
    audio/decoders/vorbis.h
    audio/decoders/wave.h
    audio/fmopl.h
    audio/mididrv.cpp
    audio/mididrv.h
    audio/midiparser.h
    audio/midiplayer.h
    audio/mixer.h
    audio/mixer_intern.h
    audio/mods/infogrames.h
    audio/mods/maxtrax.cpp
    audio/mods/maxtrax.h
    audio/mods/module.h
    audio/mods/paula.h
    audio/mods/protracker.h
    audio/mods/rjp1.h
    audio/mods/soundfx.h
    audio/mods/tfmx.cpp
    audio/mods/tfmx.h
    audio/mpu401.h
    audio/musicplugin.h
    audio/null.h
    audio/rate.h
    audio/rate_arm_asm.s
    audio/softsynth/adlib.cpp
    audio/softsynth/cms.h
    audio/softsynth/emumidi.h
    audio/softsynth/fmtowns_pc98/towns_audio.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/mt32/synth.cpp
    audio/softsynth/opl/dbopl.h
    audio/softsynth/opl/dosbox.h
    audio/softsynth/opl/mame.h
    audio/softsynth/pcspk.h
    audio/softsynth/sid.cpp
    audio/softsynth/sid.h
    audio/softsynth/wave6581.cpp
    audio/timestamp.h
    backends/events/maemosdl/maemosdl-events.cpp
    backends/events/maemosdl/maemosdl-events.h
    backends/events/openpandora/op-events.cpp
    backends/events/webossdl/webossdl-events.cpp
    backends/events/webossdl/webossdl-events.h
    backends/fs/amigaos4/amigaos4-fs.h
    backends/fs/ps2/ps2-fs.h
    backends/fs/psp/psp-fs-factory.h
    backends/graphics/opengl/gltexture.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/openpandora/op-graphics.h
    backends/keymapper/keymap.cpp
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    backends/keymapper/remap-dialog.cpp
    backends/keymapper/remap-dialog.h
    backends/module.mk
    backends/platform/android/android.cpp
    backends/platform/android/android.mk
    backends/platform/android/jni.cpp
    backends/platform/android/texture.cpp
    backends/platform/bada/README.TXT
    backends/platform/bada/application.cpp
    backends/platform/bada/audio.cpp
    backends/platform/bada/form.cpp
    backends/platform/bada/form.h
    backends/platform/bada/fs.cpp
    backends/platform/bada/graphics.cpp
    backends/platform/bada/graphics.h
    backends/platform/bada/portdefs.h
    backends/platform/bada/sscanf.cpp
    backends/platform/bada/system.cpp
    backends/platform/bada/system.h
    backends/platform/dc/dc-fs.cpp
    backends/platform/dc/portdefs.h
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/ds/arm9/source/portdefs.h
    backends/platform/maemo/debian/changelog
    backends/platform/maemo/debian/control
    backends/platform/maemo/debian/rules
    backends/platform/maemo/maemo.cpp
    backends/platform/maemo/maemo.h
    backends/platform/maemo/main.cpp
    backends/platform/n64/portdefs.h
    backends/platform/openpandora/op-backend.cpp
    backends/platform/openpandora/op-main.cpp
    backends/platform/openpandora/op-options.cpp
    backends/platform/openpandora/op-options.h
    backends/platform/openpandora/op-sdl.h
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Gs2dScreen.h
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/README.PSP
    backends/platform/psp/portdefs.h
    backends/platform/symbian/README
    backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
    backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
    backends/platform/symbian/S60v3/scummvm-CVS-SymbianS60v3.pkg
    backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/scummvm-CVS-SymbianUIQ3.pkg
    backends/platform/symbian/mmp/scummvm_agi.mmp.in
    backends/platform/symbian/mmp/scummvm_agos.mmp.in
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/mmp/scummvm_cine.mmp.in
    backends/platform/symbian/mmp/scummvm_cruise.mmp.in
    backends/platform/symbian/mmp/scummvm_draci.mmp.in
    backends/platform/symbian/mmp/scummvm_drascula.mmp.in
    backends/platform/symbian/mmp/scummvm_gob.mmp.in
    backends/platform/symbian/mmp/scummvm_groovie.mmp.in
    backends/platform/symbian/mmp/scummvm_hugo.mmp.in
    backends/platform/symbian/mmp/scummvm_kyra.mmp.in
    backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
    backends/platform/symbian/mmp/scummvm_lure.mmp.in
    backends/platform/symbian/mmp/scummvm_m4.mmp.in
    backends/platform/symbian/mmp/scummvm_made.mmp.in
    backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
    backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
    backends/platform/symbian/mmp/scummvm_queen.mmp.in
    backends/platform/symbian/mmp/scummvm_saga.mmp.in
    backends/platform/symbian/mmp/scummvm_sci.mmp.in
    backends/platform/symbian/mmp/scummvm_scumm.mmp.in
    backends/platform/symbian/mmp/scummvm_sky.mmp.in
    backends/platform/symbian/mmp/scummvm_sword1.mmp.in
    backends/platform/symbian/mmp/scummvm_sword2.mmp.in
    backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
    backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
    backends/platform/symbian/mmp/scummvm_toon.mmp.in
    backends/platform/symbian/mmp/scummvm_touche.mmp.in
    backends/platform/symbian/mmp/scummvm_tsage.mmp.in
    backends/platform/symbian/mmp/scummvm_tucker.mmp.in
    backends/platform/symbian/src/portdefs.h
    backends/platform/webos/webos.mk
    backends/platform/wince/README-WinCE.txt
    backends/platform/wince/portdefs.h
    backends/platform/wince/wince-sdl.cpp
    backends/platform/wince/wince.mk
    backends/timer/bada/timer.cpp
    backends/timer/default/default-timer.cpp
    base/commandLine.cpp
    base/internal_version.h
    base/main.cpp
    base/plugins.cpp
    common/algorithm.h
    common/array.h
    common/bitstream.h
    common/fs.cpp
    common/keyboard.h
    common/macresman.cpp
    common/module.mk
    common/quicktime.cpp
    common/quicktime.h
    common/scummsys.h
    common/translation.cpp
    common/translation.h
    common/util.cpp
    common/util.h
    config.guess
    config.sub
    configure
    devtools/create_hugo/enums.h
    devtools/create_hugo/staticdata.h
    devtools/create_lure/process_actions.cpp
    devtools/create_project/create_project.cpp
    devtools/create_project/create_project.h
    devtools/create_project/xcode.cpp
    devtools/credits.pl
    devtools/md5table.c
    devtools/sci/musicplayer.cpp
    devtools/scumm-md5.txt
    devtools/tasmrecover/dreamweb/dreamweb.asm
    devtools/tasmrecover/dreamweb/object.asm
    devtools/tasmrecover/dreamweb/saveload.asm
    devtools/tasmrecover/tasm-recover
    devtools/tasmrecover/tasm/cpp.py
    devtools/tasmrecover/tasm/parser.py
    dists/android/AndroidManifest.xml
    dists/android/AndroidManifest.xml.in
    dists/android/plugin-manifest.xml
    dists/android/plugin-manifest.xml.in
    dists/android/res/layout/main.xml
    dists/iphone/Info.plist
    dists/irix/scummvm.idb
    dists/irix/scummvm.spec
    dists/macosx/Info.plist
    dists/redhat/scummvm-tools.spec
    dists/redhat/scummvm.spec
    dists/scummvm.rc
    dists/scummvm.rc.in
    dists/slackware/scummvm.SlackBuild
    dists/wii/meta.xml
    dists/win32/ScummVM.iss
    dists/win32/scummvm.nsi
    dists/win32/scummvm.nsi.in
    doc/QuickStart
    doc/de/Liesmich
    doc/de/Neues
    doc/de/Schnellstart
    doc/fr/DemarrageRapide
    doc/no-nb/HurtigStart
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/cycle.cpp
    engines/agi/detection.cpp
    engines/agi/detection_tables.h
    engines/agi/graphics.cpp
    engines/agi/op_cmd.cpp
    engines/agi/opcodes.cpp
    engines/agi/saveload.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_2gs.h
    engines/agi/text.cpp
    engines/agi/words.cpp
    engines/agos/agos.h
    engines/agos/animation.cpp
    engines/agos/detection.cpp
    engines/agos/detection_tables.h
    engines/agos/draw.cpp
    engines/agos/installshield_cab.cpp
    engines/agos/midi.cpp
    engines/agos/res.cpp
    engines/agos/res_snd.cpp
    engines/agos/saveload.cpp
    engines/agos/sound.cpp
    engines/agos/subroutine.cpp
    engines/cge/bitmap.cpp
    engines/cge/bitmap.h
    engines/cge/cge.cpp
    engines/cge/cge.h
    engines/cge/cge_main.cpp
    engines/cge/cge_main.h
    engines/cge/console.cpp
    engines/cge/console.h
    engines/cge/detection.cpp
    engines/cge/events.cpp
    engines/cge/events.h
    engines/cge/fileio.cpp
    engines/cge/snail.cpp
    engines/cge/snail.h
    engines/cge/talk.cpp
    engines/cge/talk.h
    engines/cge/text.cpp
    engines/cge/vga13h.cpp
    engines/cge/vga13h.h
    engines/cge/walk.cpp
    engines/cge/walk.h
    engines/cine/cine.cpp
    engines/cine/detection.cpp
    engines/cine/detection_tables.h
    engines/cine/main_loop.cpp
    engines/cine/saveload.cpp
    engines/cine/sound.cpp
    engines/cine/various.cpp
    engines/composer/composer.cpp
    engines/composer/composer.h
    engines/composer/detection.cpp
    engines/composer/graphics.cpp
    engines/composer/resource.cpp
    engines/composer/resource.h
    engines/composer/scripting.cpp
    engines/cruise/cruise_main.cpp
    engines/cruise/detection.cpp
    engines/cruise/gfxModule.cpp
    engines/cruise/mainDraw.cpp
    engines/cruise/overlay.cpp
    engines/cruise/saveload.cpp
    engines/cruise/volume.cpp
    engines/draci/detection.cpp
    engines/draci/draci.cpp
    engines/draci/saveload.cpp
    engines/drascula/converse.cpp
    engines/drascula/detection.cpp
    engines/drascula/drascula.cpp
    engines/drascula/graphics.cpp
    engines/drascula/interface.cpp
    engines/drascula/saveload.cpp
    engines/drascula/sound.cpp
    engines/drascula/talk.cpp
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/detection.cpp
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamgen.cpp
    engines/dreamweb/dreamgen.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/module.mk
    engines/dreamweb/pathfind.cpp
    engines/dreamweb/print.cpp
    engines/dreamweb/runtime.h
    engines/dreamweb/saveload.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp
    engines/dreamweb/stubs.h
    engines/dreamweb/use.cpp
    engines/dreamweb/vgagrafx.cpp
    engines/engine.cpp
    engines/engine.h
    engines/engines.mk
    engines/game.cpp
    engines/game.h
    engines/gob/detection.cpp
    engines/gob/detection_tables.h
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/iniconfig.cpp
    engines/gob/inter_playtoons.cpp
    engines/gob/inter_v1.cpp
    engines/gob/inter_v2.cpp
    engines/gob/inter_v7.cpp
    engines/gob/map.cpp
    engines/groovie/detection.cpp
    engines/groovie/roq.cpp
    engines/groovie/script.cpp
    engines/hugo/detection.cpp
    engines/hugo/game.h
    engines/hugo/object_v1d.cpp
    engines/hugo/object_v1w.cpp
    engines/hugo/object_v2d.cpp
    engines/hugo/object_v3d.cpp
    engines/hugo/parser.cpp
    engines/hugo/route.cpp
    engines/hugo/schedule.cpp
    engines/kyra/debugger.cpp
    engines/kyra/debugger.h
    engines/kyra/detection_tables.h
    engines/kyra/gui.cpp
    engines/kyra/gui.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_lol.h
    engines/kyra/items_lol.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_lok.h
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/scene_lok.cpp
    engines/kyra/scene_mr.cpp
    engines/kyra/scene_v1.cpp
    engines/kyra/script_hof.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_mr.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound.h
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_adlib.h
    engines/kyra/sound_lol.cpp
    engines/lastexpress/data/scene.h
    engines/lastexpress/data/snd.cpp
    engines/lastexpress/detection.cpp
    engines/lastexpress/entities/abbot.cpp
    engines/lastexpress/entities/august.cpp
    engines/lastexpress/entities/francois.cpp
    engines/lastexpress/entities/mertens.cpp
    engines/lastexpress/game/action.cpp
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/game/savegame.cpp
    engines/lure/decode.cpp
    engines/lure/detection.cpp
    engines/lure/hotspots.cpp
    engines/lure/res.cpp
    engines/lure/room.cpp
    engines/lure/scripts.cpp
    engines/lure/sound.cpp
    engines/made/database.cpp
    engines/made/database.h
    engines/made/detection.cpp
    engines/made/graphics.cpp
    engines/made/graphics.h
    engines/made/made.cpp
    engines/made/made.h
    engines/made/music.cpp
    engines/made/music.h
    engines/made/pmvplayer.cpp
    engines/made/pmvplayer.h
    engines/made/redreader.cpp
    engines/made/redreader.h
    engines/made/resource.cpp
    engines/made/resource.h
    engines/made/screen.cpp
    engines/made/screen.h
    engines/made/screenfx.cpp
    engines/made/screenfx.h
    engines/made/script.cpp
    engines/made/script.h
    engines/made/scriptfuncs.cpp
    engines/made/scriptfuncs.h
    engines/made/sound.cpp
    engines/made/sound.h
    engines/mohawk/bitmap.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/graphics.cpp
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/livingbooks_code.h
    engines/mohawk/module.mk
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/stoneship.cpp
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/parallaction/detection.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/parallaction_br.cpp
    engines/parallaction/saveload.cpp
    engines/pegasus/detection.cpp
    engines/queen/queen.cpp
    engines/queen/talk.cpp
    engines/saga/detection.cpp
    engines/saga/detection_tables.h
    engines/saga/gfx.cpp
    engines/saga/isomap.cpp
    engines/saga/saveload.cpp
    engines/saga/scene.cpp
    engines/sci/console.cpp
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmovement.cpp
    engines/sci/engine/ksound.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/segment.cpp
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h
    engines/sci/engine/state.cpp
    engines/sci/engine/static_selectors.cpp
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/vm_types.h
    engines/sci/engine/workarounds.cpp
    engines/sci/event.cpp
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/cache.cpp
    engines/sci/graphics/cache.h
    engines/sci/graphics/compare.cpp
    engines/sci/graphics/compare.h
    engines/sci/graphics/coordadjuster.cpp
    engines/sci/graphics/coordadjuster.h
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/paint.h
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/paint16.h
    engines/sci/graphics/paint32.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h
    engines/sci/graphics/picture.cpp
    engines/sci/graphics/picture.h
    engines/sci/graphics/text32.cpp
    engines/sci/graphics/text32.h
    engines/sci/graphics/view.cpp
    engines/sci/graphics/view.h
    engines/sci/module.mk
    engines/sci/resource.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp
    engines/sci/sci.cpp
    engines/sci/sci.h
    engines/sci/sound/drivers/adlib.cpp
    engines/sci/sound/drivers/amigamac.cpp
    engines/sci/sound/drivers/mididriver.h
    engines/sci/sound/midiparser_sci.cpp
    engines/sci/sound/music.cpp
    engines/sci/sound/music.h
    engines/sci/sound/soundcmd.cpp
    engines/scumm/debugger.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection.h
    engines/scumm/detection_tables.h
    engines/scumm/he/script_v80he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/he/sound_he.cpp
    engines/scumm/he/sprite_he.cpp
    engines/scumm/imuse/imuse_player.cpp
    engines/scumm/input.cpp
    engines/scumm/object.cpp
    engines/scumm/palette.cpp
    engines/scumm/player_towns.cpp
    engines/scumm/player_v2a.cpp
    engines/scumm/player_v2a.h
    engines/scumm/saveload.cpp
    engines/scumm/saveload.h
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/smush/channel.cpp
    engines/scumm/sound.cpp
    engines/scumm/sound.h
    engines/sky/detection.cpp
    engines/sky/music/adlibmusic.cpp
    engines/sky/music/adlibmusic.h
    engines/sky/music/gmmusic.cpp
    engines/sky/music/gmmusic.h
    engines/sky/music/mt32music.cpp
    engines/sky/music/mt32music.h
    engines/sky/music/musicbase.cpp
    engines/sky/music/musicbase.h
    engines/sky/sky.cpp
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword1/detection.cpp
    engines/sword1/logic.cpp
    engines/sword1/sound.cpp
    engines/sword1/sound.h
    engines/sword1/staticres.cpp
    engines/sword1/sword1.h
    engines/sword1/swordres.h
    engines/sword2/console.cpp
    engines/sword2/sword2.cpp
    engines/sword25/detection.cpp
    engines/sword25/detection_tables.h
    engines/sword25/gfx/image/renderedimage.cpp
    engines/sword25/gfx/renderobject.h
    engines/teenagent/actor.cpp
    engines/teenagent/animation.h
    engines/teenagent/callbacks.cpp
    engines/teenagent/console.cpp
    engines/teenagent/console.h
    engines/teenagent/detection.cpp
    engines/teenagent/inventory.cpp
    engines/teenagent/music.cpp
    engines/teenagent/music.h
    engines/teenagent/objects.cpp
    engines/teenagent/objects.h
    engines/teenagent/pack.cpp
    engines/teenagent/pack.h
    engines/teenagent/scene.cpp
    engines/teenagent/scene.h
    engines/teenagent/surface.cpp
    engines/teenagent/surface.h
    engines/teenagent/surface_list.cpp
    engines/teenagent/surface_list.h
    engines/teenagent/teenagent.cpp
    engines/teenagent/teenagent.h
    engines/testbed/detection.cpp
    engines/tinsel/actors.cpp
    engines/tinsel/actors.h
    engines/tinsel/config.cpp
    engines/tinsel/detection_tables.h
    engines/tinsel/graphics.cpp
    engines/tinsel/music.cpp
    engines/tinsel/pcode.cpp
    engines/tinsel/pcode.h
    engines/tinsel/saveload.cpp
    engines/tinsel/savescn.cpp
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/audio.cpp
    engines/toon/audio.h
    engines/toon/character.cpp
    engines/toon/character.h
    engines/toon/detection.cpp
    engines/toon/font.cpp
    engines/toon/font.h
    engines/toon/hotspot.cpp
    engines/toon/hotspot.h
    engines/toon/movie.cpp
    engines/toon/movie.h
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/resource.cpp
    engines/toon/resource.h
    engines/toon/text.cpp
    engines/toon/text.h
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/detection.cpp
    engines/touche/resource.cpp
    engines/tsage/blue_force/blueforce_dialogs.cpp
    engines/tsage/blue_force/blueforce_dialogs.h
    engines/tsage/blue_force/blueforce_logic.cpp
    engines/tsage/blue_force/blueforce_logic.h
    engines/tsage/blue_force/blueforce_scenes0.cpp
    engines/tsage/blue_force/blueforce_scenes0.h
    engines/tsage/blue_force/blueforce_scenes1.cpp
    engines/tsage/blue_force/blueforce_scenes1.h
    engines/tsage/blue_force/blueforce_scenes2.cpp
    engines/tsage/blue_force/blueforce_scenes2.h
    engines/tsage/blue_force/blueforce_scenes3.cpp
    engines/tsage/blue_force/blueforce_scenes3.h
    engines/tsage/blue_force/blueforce_scenes4.cpp
    engines/tsage/blue_force/blueforce_scenes4.h
    engines/tsage/blue_force/blueforce_scenes5.cpp
    engines/tsage/blue_force/blueforce_scenes5.h
    engines/tsage/blue_force/blueforce_scenes6.cpp
    engines/tsage/blue_force/blueforce_scenes6.h
    engines/tsage/blue_force/blueforce_scenes7.cpp
    engines/tsage/blue_force/blueforce_scenes7.h
    engines/tsage/blue_force/blueforce_scenes8.cpp
    engines/tsage/blue_force/blueforce_scenes8.h
    engines/tsage/blue_force/blueforce_scenes9.cpp
    engines/tsage/blue_force/blueforce_scenes9.h
    engines/tsage/blue_force/blueforce_speakers.cpp
    engines/tsage/blue_force/blueforce_speakers.h
    engines/tsage/converse.cpp
    engines/tsage/converse.h
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/debugger.h
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/dialogs.h
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/module.mk
    engines/tsage/resources.cpp
    engines/tsage/resources.h
    engines/tsage/ringworld/ringworld_demo.cpp
    engines/tsage/ringworld/ringworld_demo.h
    engines/tsage/ringworld/ringworld_dialogs.cpp
    engines/tsage/ringworld/ringworld_dialogs.h
    engines/tsage/ringworld/ringworld_logic.cpp
    engines/tsage/ringworld/ringworld_logic.h
    engines/tsage/ringworld/ringworld_scenes1.cpp
    engines/tsage/ringworld/ringworld_scenes10.cpp
    engines/tsage/ringworld/ringworld_scenes10.h
    engines/tsage/ringworld/ringworld_scenes3.cpp
    engines/tsage/ringworld/ringworld_scenes5.cpp
    engines/tsage/ringworld/ringworld_scenes5.h
    engines/tsage/ringworld/ringworld_scenes6.cpp
    engines/tsage/ringworld/ringworld_scenes8.cpp
    engines/tsage/ringworld/ringworld_scenes8.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/scenes.h
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h
    engines/tsage/tsage.cpp
    engines/tsage/tsage.h
    engines/tucker/detection.cpp
    engines/tucker/locations.cpp
    graphics/VectorRenderer.cpp
    graphics/VectorRenderer.h
    graphics/VectorRendererSpec.cpp
    graphics/VectorRendererSpec.h
    graphics/pict.cpp
    graphics/png.cpp
    graphics/png.h
    graphics/scaler/scale2x.h
    graphics/scaler/scale3x.h
    graphics/scaler/scalebit.h
    graphics/surface.cpp
    graphics/yuv_to_rgb.h
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeParser.cpp
    gui/ThemeParser.h
    gui/console.cpp
    gui/credits.h
    gui/debugger.cpp
    gui/dialog.cpp
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/launcher.cpp
    gui/launcher.h
    gui/options.cpp
    gui/options.h
    gui/saveload.cpp
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/classic_gfx.stx
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/scummmodern/search.bmp
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    gui/widgets/edittext.cpp
    gui/widgets/list.cpp
    gui/widgets/scrollbar.cpp
    gui/widgets/scrollbar.h
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    test/audio/helper.h
    test/audio/raw.h
    test/common/array.h
    video/avi_decoder.h
    video/bink_decoder.cpp
    video/codecs/cinepak.h
    video/codecs/mjpeg.h
    video/coktel_decoder.cpp
    video/coktel_decoder.h
    video/dxa_decoder.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp



diff --cc engines/pegasus/detection.cpp
index 76455e9,0000000..64e7d32
mode 100644,000000..100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@@ -1,157 -1,0 +1,157 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "base/plugins.h"
 +
 +#include "engines/advancedDetector.h"
 +#include "common/config-manager.h"
 +#include "common/file.h"
 +#include "common/savefile.h"
 +
 +#include "pegasus/pegasus.h"
 +
 +namespace Pegasus {
 +
 +struct PegasusGameDescription {
 +	ADGameDescription desc;
 +};
 +
 +bool PegasusEngine::hasFeature(EngineFeature f) const {
 +	return
 +		(f == kSupportsRTL)
 +		|| (f == kSupportsLoadingDuringRuntime)
 +		|| (f == kSupportsSavingDuringRuntime);
 +}
 +
 +bool PegasusEngine::isDemo() const {
 +	return (_gameDescription->desc.flags & ADGF_DEMO) != 0;
 +}
 +
 +} // End of namespace Pegasus
 +
 +static const PlainGameDescriptor pegasusGames[] = {
 +	{"pegasus", "The Journeyman Project: Pegasus Prime"},
 +	{0, 0}
 +};
 +
 +
 +namespace Pegasus {
 +
 +static const PegasusGameDescription gameDescriptions[] = {
 +	{
 +		{
 +			"pegasus",
 +			"",
 +			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 2009943),
 +			Common::EN_ANY,
 +			Common::kPlatformMacintosh,
 +			ADGF_MACRESFORK,
- 			Common::GUIO_NONE
++			GUIO0()
 +		},
 +	},
 +
 +	{
 +		{
 +			"pegasus",
 +			"",
 +			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 360129),
 +			Common::EN_ANY,
 +			Common::kPlatformMacintosh,
 +			ADGF_MACRESFORK|ADGF_DEMO,
- 			Common::GUIO_NOLAUNCHLOAD
++			GUIO1(GUIO_NOLAUNCHLOAD)
 +		},
 +	},
 +
 +	{ AD_TABLE_END_MARKER }
 +};
 +
 +} // End of namespace Pegasus
 +
 +
 +class PegasusMetaEngine : public AdvancedMetaEngine {
 +public:
 +	PegasusMetaEngine() : AdvancedMetaEngine(Pegasus::gameDescriptions, sizeof(Pegasus::PegasusGameDescription), pegasusGames) {
 +		_singleid = "pegasus";
 +	}
 +
 +	virtual const char *getName() const {
 +		return "The Journeyman Project: Pegasus Prime";
 +	}
 +
 +	virtual const char *getOriginalCopyright() const {
 +		return "The Journeyman Project: Pegasus Prime (C) Presto Studios";
 +	}
 +
 +	virtual bool hasFeature(MetaEngineFeature f) const;
 +	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
 +	virtual SaveStateList listSaves(const char *target) const;
 +	virtual int getMaximumSaveSlot() const { return 999; }
 +	virtual void removeSaveState(const char *target, int slot) const;
 +};
 +
 +bool PegasusMetaEngine::hasFeature(MetaEngineFeature f) const {
 +	return
 +		(f == kSupportsListSaves)
 +		|| (f == kSupportsLoadingDuringStartup)
 +		|| (f == kSupportsDeleteSave);
 +}
 +
 +SaveStateList PegasusMetaEngine::listSaves(const char *target) const {
 +	// The original had no pattern, so the user must rename theirs
 +	// Note that we ignore the target because saves are compatible between
 +	// all versions
 +	Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav");
 +
 +	SaveStateList saveList;
 +	for (uint32 i = 0; i < filenames.size(); i++) {
 +		// Isolate the description from the file name
 +		Common::String desc = filenames[i].c_str() + 8;
 +		for (int j = 0; j < 4; j++)
 +			desc.deleteLastChar();
 +		
 +		saveList.push_back(SaveStateDescriptor(i, desc));
 +	}
 +
 +	return saveList;
 +}
 +
 +void PegasusMetaEngine::removeSaveState(const char *target, int slot) const {
 +	// See listSaves() for info on the pattern
 +	Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("pegasus-*.sav");
 +	g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str());
 +}
 +
 +bool PegasusMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 +	const Pegasus::PegasusGameDescription *gd = (const Pegasus::PegasusGameDescription *)desc;
 +
 +	if (gd)
 +		*engine = new Pegasus::PegasusEngine(syst, gd);
 +
 +	return (gd != 0);
 +}
 +
 +#if PLUGIN_ENABLED_DYNAMIC(PEGASUS)
 +	REGISTER_PLUGIN_DYNAMIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
 +#else
 +	REGISTER_PLUGIN_STATIC(PEGASUS, PLUGIN_TYPE_ENGINE, PegasusMetaEngine);
 +#endif
 +


Commit: 9c1fbbd1c2b63e4a610f39dac57366c227161908
    https://github.com/scummvm/scummvm/commit/9c1fbbd1c2b63e4a610f39dac57366c227161908
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-12T12:27:48-08:00

Commit Message:
PEGASUS: Implement shooting Sinclair

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.h



diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 9e8717b..3b6fe02 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -157,7 +157,16 @@ void sinclairTimerExpiredFunction(FunctionPtr *, void *caldoria) {
 	((Caldoria *)caldoria)->sinclairTimerExpired();
 }
 
-Caldoria::Caldoria(InputHandler* nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Caldoria", kCaldoriaID) {
+SinclairCallBack::SinclairCallBack(Caldoria *caldoria) {
+	_caldoria = caldoria;
+}
+
+void SinclairCallBack::callBack() {
+	_caldoria->checkInterruptSinclair();
+}
+
+Caldoria::Caldoria(InputHandler* nextHandler, PegasusEngine *owner)
+		: Neighborhood(nextHandler, owner, "Caldoria", kCaldoriaID), _sinclairInterrupt(this) {
 	setIsItemTaken(kKeyCard);
 	setIsItemTaken(kOrangeJuiceGlassEmpty);
 	GameState.setTakenItemID(kOrangeJuiceGlassFull, GameState.isTakenItemID(kOrangeJuiceGlassEmpty));
@@ -166,6 +175,7 @@ Caldoria::Caldoria(InputHandler* nextHandler, PegasusEngine *owner) : Neighborho
 }
 
 Caldoria::~Caldoria() {
+	_sinclairInterrupt.releaseCallBack();
 }
 
 void Caldoria::init() {
@@ -174,6 +184,8 @@ void Caldoria::init() {
 	//	We need this notification flag as well.
 	_neighborhoodNotification.notifyMe(this, kSinclairLoopDoneFlag, kSinclairLoopDoneFlag);
 
+	_sinclairInterrupt.initCallBack(&_navMovie, kCallBackAtTime);
+
 	forceStridingStop(kCaldoria55, kSouth, kAltCaldoriaSinclairDown);
 	forceStridingStop(kCaldoria50, kNorth, kAltCaldoriaSinclairDown);
 }
@@ -1072,8 +1084,15 @@ void Caldoria::setUpSinclairLoops() {
 	_navMovie.start();
 }
 
-void Caldoria::zoomToSinclair() {
-	// TODO
+void Caldoria::zoomToSinclair() {	
+	_utilityFuse.stopFuse();
+	_privateFlags.setFlag(kCaldoriaPrivateReadyToShootFlag, true);
+	setCurrentActivation(kActivateZoomedOnSinclair);
+
+	ExtraTable::Entry entry;
+	getExtraEntry(kCa53EastZoomToSinclair, entry);
+	_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime1, _navMovie.getScale());
+	startExtraSequence(kCa53EastZoomToSinclair, kExtraCompletedFlag, kFilterAllInput);
 }
 
 void Caldoria::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
@@ -1794,7 +1813,20 @@ void Caldoria::checkInterruptSinclair() {
 		_neighborhoodNotification.setNotificationFlags(kExtraCompletedFlag, kExtraCompletedFlag);
 		g_AIArea->unlockAI();
 	} else {
-		// TODO
+		uint32 currentTime = _navMovie.getTime();
+
+		ExtraTable::Entry entry;
+		getExtraEntry(kCa53EastZoomToSinclair, entry);
+
+		if (currentTime < entry.movieStart + kSinclairInterruptionTime2)
+			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime2,
+					_navMovie.getScale());
+		else if (currentTime < entry.movieStart + kSinclairInterruptionTime3)
+			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime3,
+					_navMovie.getScale());
+		else if (currentTime < entry.movieStart + kSinclairInterruptionTime4)
+			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime4,
+					_navMovie.getScale());
 	}
 }
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
index f2e3775..538eaaf 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -386,7 +386,21 @@ const tDisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
 const TimeValue kCaldoria4DBlankChoiceIn = 29730;
 const TimeValue kCaldoria4DBlankChoiceOut = 33910;
 
+class Caldoria;
+
+class SinclairCallBack : public TimeBaseCallBack {
+public:
+	SinclairCallBack(Caldoria *);
+	~SinclairCallBack() {}
+
+protected:
+	virtual void callBack();
+
+	Caldoria *_caldoria;
+};
+
 class Caldoria : public Neighborhood {
+friend class SinclairCallBack;
 friend void doorBombTimerExpiredFunction(FunctionPtr *, void *);
 friend void sinclairTimerExpiredFunction(FunctionPtr *, void *);
 
@@ -500,6 +514,8 @@ protected:
 
 	Sprite *_gunSprite;
 
+	SinclairCallBack _sinclairInterrupt;
+
 	Common::String getSoundSpotsName();
 	Common::String getNavMovieName();
 };


Commit: cd01d5dc1de3bdab4a0f784880a7dde1d0e7ef9a
    https://github.com/scummvm/scummvm/commit/cd01d5dc1de3bdab4a0f784880a7dde1d0e7ef9a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-12T14:16:15-08:00

Commit Message:
PEGASUS: Add the bomb active AI rule

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoria.cpp



diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 3b6fe02..adfa1ae 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -267,6 +267,19 @@ void Caldoria::flushGameState() {
 	GameState.setCaldoriaFuseTimeLimit(_utilityFuse.getTimeRemaining());
 }
 
+class AIBombActiveCondition : public AICondition {
+public:
+	AIBombActiveCondition() {}
+
+	bool fireCondition();
+};
+
+// Return true if player is on 53 east and Sinclair is shot.
+bool AIBombActiveCondition::fireCondition() {
+	return GameState.getCurrentRoom() == kCaldoria53 && GameState.getCurrentDirection() == kEast &&
+			GameState.getCaldoriaSinclairShot();
+}
+
 void Caldoria::setUpAIRules() {
 	Neighborhood::setUpAIRules();
 
@@ -278,13 +291,10 @@ void Caldoria::setUpAIRules() {
 			AIRule *rule = new AIRule(locCondition, messageAction);
 			g_AIArea->addAIRule(rule);
 
-#if 0
-			// TODO
 			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X56EH1", false);
-			AIBombActiveCondition *activeCondition = new AIBombActiveCondition;
+			AIBombActiveCondition *activeCondition = new AIBombActiveCondition();
 			rule = new AIRule(activeCondition, messageAction);
 			g_AIArea->addAIRule(rule);
-#endif
 		} else {
 			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XAB2", false);
 			AITimerCondition *timerCondition = new AITimerCondition(kLateWarning3TimeLimit, 1, true);


Commit: 5f276bf4ac140d05511963a255fb329274d3ba85
    https://github.com/scummvm/scummvm/commit/5f276bf4ac140d05511963a255fb329274d3ba85
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-13T08:33:11-08:00

Commit Message:
PEGASUS: Add a tickCount() function

Changed paths:
    engines/pegasus/util.cpp
    engines/pegasus/util.h



diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
index 9f4ad57..f0d80f5 100755
--- a/engines/pegasus/util.cpp
+++ b/engines/pegasus/util.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "common/random.h"
+#include "common/system.h"
 #include "common/util.h"
 
 #include "pegasus/util.h"
@@ -87,4 +88,8 @@ int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1,
 		return start2 + pegasusRound((current1 - start1) * (stop2 - start2), (stop1 - start1));
 }
 
+uint32 tickCount() {
+	return g_system->getMillis() * 60 / 1000;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index de2deb7..6eb1580 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -128,6 +128,8 @@ int32 linearInterp(const int32 start1, const int32 stop1, const int32 current1,
 
 int32 pegasusRound(const int32 a, const int32 b);
 
+uint32 tickCount();
+
 } // End of namespace Pegasus
 
 #endif


Commit: bbabf27f6191a06b6f1eeb77aee1c7bc8376c981
    https://github.com/scummvm/scummvm/commit/bbabf27f6191a06b6f1eeb77aee1c7bc8376c981
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-13T08:33:47-08:00

Commit Message:
PEGASUS: Add the bomb detonation game

Changed paths:
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/caldoria/caldoria.cpp



diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index d4ea537..e19b45e 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -55,6 +55,7 @@ MODULE_OBJS = \
 	neighborhood/zoom.o \
 	neighborhood/caldoria/caldoria.o \
 	neighborhood/caldoria/caldoria4dsystem.o \
+	neighborhood/caldoria/caldoriabomb.o \
 	neighborhood/caldoria/caldoriamessages.o \
 	neighborhood/caldoria/caldoriamirror.o \
 	neighborhood/mars/energybeam.o \
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index adfa1ae..878b0c3 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -35,6 +35,7 @@
 #include "pegasus/items/biochips/biochipitem.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
+#include "pegasus/neighborhood/caldoria/caldoriabomb.h"
 #include "pegasus/neighborhood/caldoria/caldoriamessages.h"
 #include "pegasus/neighborhood/caldoria/caldoriamirror.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
@@ -1522,17 +1523,12 @@ GameInteraction *Caldoria::makeInteraction(const tInteractionID interactionID) {
 	switch (interactionID) {
 	case kCaldoria4DInteractionID:
 		return new Caldoria4DSystem(this);
-		break;
 	case kCaldoriaBombInteractionID:
-		// TODO
-		error("STUB: Bomb game");
-		break;
+		return new CaldoriaBomb(this, _vm);
 	case kCaldoriaMessagesInteractionID:
 		return new CaldoriaMessages(this, kCaldoriaMessagesNotificationID, _vm);
-		break;
 	case kCaldoriaMirrorInteractionID:
 		return new CaldoriaMirror(this);
-		break;
 	}
 
 	return 0;
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
new file mode 100755
index 0000000..43de5e7
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
@@ -0,0 +1,1433 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/caldoria/caldoria.h"
+#include "pegasus/neighborhood/caldoria/caldoriabomb.h"
+
+namespace Pegasus {
+
+// Bomb game PICTs:
+
+static const uint16 kYellowBombPICTBaseID = 700;
+static const uint16 kRedBombPICTBaseID = 709;
+static const uint16 kTimerLeftPICTID = 718;
+static const uint16 kTimerRightPICTID = 719;
+
+static const uint32 kFlashOnTime = 20;
+static const uint32 kFlashOffTime = 10;
+
+static const uint32 kOnTime1 = kFlashOnTime;
+static const uint32 kOffTime1 = kOnTime1 + kFlashOffTime;
+static const uint32 kOnTime2 = kOffTime1 + kFlashOnTime;
+static const uint32 kOffTime2 = kOnTime2 + kFlashOffTime;
+static const uint32 kOnTime3 = kOffTime2 + kFlashOnTime;
+static const uint32 kOffTime3 = kOnTime3 + kFlashOffTime;
+static const uint32 kOnTime4 = kOffTime3 + kFlashOnTime;
+
+static const tHotSpotID kVertextHotSpotBaseID = 10000;
+
+static const tCoordType kVertextHotSpotWidth = 24;
+static const tCoordType kVertextHotSpotHeight = 24;
+
+static const tNotificationFlags kBombTimerExpiredFlag = 1;
+
+static const VertexType kBombLevelOne[] = {
+	0, 1, 0, 1, 0,			// hot vertices first.
+	1, 1, 0, 1, 1,
+	1, 1, 0, 1, 0,
+	1, 1, 0, 1, 1,
+	0, 1, 0, 1, 0,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	9,						// 9 edges in this level
+	
+	kEdgeOneFourth,
+	3,
+	1, 2, 3,
+	0, 0,
+	
+	kEdgeOneFourth,
+	5,
+	5, 6, 7, 8, 9,
+	0, 0, 0, 0,
+	
+	kEdgeOneFourth,
+	4,
+	10, 11, 12, 13,
+	0, 0, 0,
+	
+	kEdgeOneFourth,
+	5,
+	15, 16, 17, 18, 19,
+	0, 0, 0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	21, 22, 23,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	5, 10, 15,
+	0, 0,
+	
+	kEdgeOneHalf,
+	5,
+	1, 6, 11, 16, 21,
+	0, 0, 0, 0,
+	
+	kEdgeOneHalf,
+	5,
+	3, 8, 13, 18, 23,
+	0, 0, 0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	9, 14, 19,
+	0, 0
+};
+
+static const VertexType kBombLevelTwo[] = {
+	0, 1, 0, 1, 0,
+	1, 1, 1, 0, 1,
+	0, 0, 0, 1, 0,
+	1, 1, 1, 0, 1,
+	0, 1, 0, 1, 0,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	15,
+	
+	kEdgeOneEighth,
+	2,
+	5, 1,
+	0,
+	
+	kEdgeOneEighth,
+	3,
+	17, 13, 9,
+	0, 0,
+	
+	kEdgeOneEighth,
+	2,
+	23, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	3, 9,
+	0,
+	
+	kEdgeThreeEighths,
+	3,
+	7, 13, 19,
+	0, 0,
+	
+	kEdgeThreeEighths,
+	2,
+	15, 21,
+	0,
+	
+	kEdgeOneFourth,
+	3,
+	1, 2, 3,
+	0, 0,
+	
+	kEdgeOneFourth,
+	4,
+	6, 7, 8, 9,
+	0, 0, 0,
+	
+	kEdgeOneFourth,
+	4,
+	16, 17, 18, 19,
+	0, 0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	21, 22, 23,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	5, 10, 15,
+	0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	1, 6,
+	0,
+	
+	kEdgeOneHalf,
+	3,
+	7, 12, 17,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	9, 14, 19,
+	0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	16, 21,
+	0
+};
+
+static const VertexType kBombLevelThree[] = {
+	0, 1, 0, 1, 0,
+	1, 1, 1, 1, 1,
+	0, 1, 1, 0, 0,
+	1, 1, 1, 1, 1,
+	0, 1, 0, 1, 0,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	22,
+	
+	kEdgeThreeSixteenths,
+	3,
+	15, 12, 9,
+	0, 0,
+	
+	kEdgeFiveSixteenths,
+	3,
+	5, 12, 19,
+	0, 0,
+	
+	kEdgeOneEighth,
+	2,
+	5, 1,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	7, 3,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	15, 11,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	21, 17,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	23, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	1, 7,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	3, 9,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	5, 11,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	15, 21,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	17, 23,
+	0,
+	
+	kEdgeOneFourth,
+	3,
+	1, 2, 3,
+	0, 0,
+	
+	kEdgeOneFourth,
+	2,
+	5, 6,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	8, 9,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	15, 16,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	18, 19,
+	0,
+	
+	kEdgeOneFourth,
+	3,
+	21, 22, 23,
+	0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	1, 6,
+	0,
+	
+	kEdgeOneHalf,
+	2,
+	3, 8,
+	0,
+	
+	kEdgeOneHalf,
+	2,
+	16, 21,
+	0,
+	
+	kEdgeOneHalf,
+	2,
+	18, 23,
+	0
+};
+
+static const VertexType kBombLevelFour[] = {
+	1, 1, 1, 1, 0,
+	1, 1, 0, 1, 1,
+	1, 0, 1, 0, 1,
+	1, 1, 0, 1, 1,
+	0, 1, 1, 1, 1,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	19,
+	
+	kEdgeOneEighth,
+	2,
+	5, 1,
+	0,
+	
+	kEdgeOneEighth,
+	3,
+	10, 6, 2,
+	0, 0,
+	
+	kEdgeOneEighth,
+	3,
+	16, 12, 8,
+	0, 0,
+	
+	kEdgeOneEighth,
+	3,
+	22, 18, 14,
+	0, 0,
+	
+	kEdgeOneEighth,
+	2,
+	23, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	3,
+	2, 8, 14,
+	0, 0,
+	
+	kEdgeThreeEighths,
+	3,
+	10, 16, 22,
+	0, 0,
+	
+	kEdgeOneFourth,
+	4,
+	0, 1, 2, 3,
+	0, 0, 0,
+	
+	kEdgeOneFourth,
+	2,
+	5, 6,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	8, 9,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	15, 16,
+	0,
+	
+	kEdgeOneFourth,
+	2,
+	18, 19,
+	0,
+	
+	kEdgeOneFourth,
+	4,
+	21, 22, 23, 24,
+	0, 0, 0,
+	
+	kEdgeOneHalf,
+	4,
+	0, 5, 10, 15,
+	0, 0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	1, 6,
+	0,
+	
+	kEdgeOneHalf,
+	2,
+	3, 8,
+	0,
+	
+	kEdgeOneHalf,
+	4,
+	9, 14, 19, 24,
+	0, 0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	16, 21,
+	0,
+	
+	kEdgeOneHalf,
+	2,
+	18, 23,
+	0
+};
+
+static const VertexType kBombLevelFive[] = {
+	0, 1, 0, 1, 0,
+	1, 1, 1, 1, 1,
+	0, 1, 1, 1, 0,
+	1, 1, 1, 1, 1,
+	0, 1, 0, 1, 0,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	19,
+	
+	kEdgeOneEighth,
+	2,
+	5, 1,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	7, 3,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	13, 9,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	15, 11,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	21, 17,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	23, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	1, 7,
+	0,
+	
+	kEdgeThreeEighths,
+	4,
+	5, 11, 17, 23,
+	0, 0, 0,
+	
+	kEdgeThreeEighths,
+	3,
+	6, 12, 18,
+	0, 0,
+	
+	kEdgeThreeEighths,
+	2,
+	13, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	15, 21,
+	0,
+	
+	kEdgeOneFourth,
+	5,
+	5, 6, 7, 8, 9,
+	0, 0, 0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	15, 16, 17,
+	0, 0,
+	
+	kEdgeOneFourth,
+	2,
+	18, 19,
+	0,
+	
+	kEdgeOneFourth,
+	3,
+	21, 22, 23,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	5, 10, 15,
+	0, 0,
+	
+	kEdgeOneHalf,
+	2,
+	1, 6,
+	0,
+	
+	kEdgeOneHalf,
+	3,
+	11, 16, 21,
+	0, 0,
+	
+	kEdgeOneHalf,
+	5,
+	3, 8, 13, 18, 23,
+	0, 0, 0, 0
+};
+
+static const VertexType kBombLevelSix[] = {
+	0, 1, 1, 1, 0,
+	1, 1, 1, 1, 1,
+	1, 0, 0, 0, 1,
+	1, 1, 1, 1, 1,
+	0, 1, 1, 1, 0,
+	
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	0, 0, 0, 0, 0,
+	
+	25,
+	
+	kEdgeOneSixteenth,
+	2,
+	10, 1,
+	0,
+	
+	kEdgeOneSixteenth,
+	2,
+	23, 14,
+	0,
+	
+	kEdgeSevenSixteenths,
+	2,
+	3, 14,
+	0,
+	
+	kEdgeSevenSixteenths,
+	2,
+	10, 21,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	5, 1,
+	0,
+	
+	kEdgeOneEighth,
+	3,
+	10, 6, 2,
+	0, 0,
+	
+	kEdgeOneEighth,
+	2,
+	7, 3,
+	0,
+	
+	kEdgeOneEighth,
+	2,
+	21, 17,
+	0,
+	
+	kEdgeOneEighth,
+	3,
+	22, 18, 14,
+	0, 0,
+	
+	kEdgeOneEighth,
+	2,
+	23, 19,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	1, 7,
+	0,
+	
+	kEdgeThreeEighths,
+	3,
+	2, 8, 14,
+	0, 0,
+	
+	kEdgeThreeEighths,
+	2,
+	3, 9,
+	0,
+	
+	kEdgeThreeEighths,
+	3,
+	10, 16, 22,
+	0, 0,
+	
+	kEdgeThreeEighths,
+	2,
+	15, 21,
+	0,
+	
+	kEdgeThreeEighths,
+	2,
+	17, 23,
+	0,
+	
+	kEdgeOneFourth,
+	3,
+	1, 2, 3,
+	0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	6, 7, 8,
+	0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	16, 17, 18,
+	0, 0,
+	
+	kEdgeOneFourth,
+	3,
+	21, 22, 23,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	5, 10, 15,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	6, 11, 16,
+	0, 0,
+	
+	kEdgeOneHalf,
+	5,
+	2, 7, 12, 17, 22,
+	0, 0, 0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	8, 13, 18,
+	0, 0,
+	
+	kEdgeOneHalf,
+	3,
+	9, 14, 19,
+	0, 0
+};
+
+static const tCoordType kBombGridWidth = 140;
+static const tCoordType kBombGridHeight = 140;
+
+static const tCoordType kDotOriginX = 0;
+static const tCoordType kDotOriginY = 0;
+
+static const tCoordType kVertOriginX = 2;
+static const tCoordType kVertOriginY = 6;
+
+static const tCoordType kHorizOriginX = 6;
+static const tCoordType kHorizOriginY = 2;
+
+static const tCoordType kDiagOriginX = 6;
+static const tCoordType kDiagOriginY = 6;
+
+static const int g_originsX[] = {
+	kDiagOriginX,
+	kDiagOriginX,
+	kDiagOriginX,
+	kHorizOriginX,
+	kDiagOriginX,
+	kDiagOriginX,
+	kDiagOriginX,
+	kVertOriginX
+};
+
+static const int g_originsY[] = {
+	kDiagOriginY - 64,
+	kDiagOriginY - 32,
+	kDiagOriginY - 32,
+	kHorizOriginY,
+	kDiagOriginY,
+	kDiagOriginY,
+	kDiagOriginY,
+	kVertOriginY
+};
+
+struct HotVerticesList {
+	int numHotVerts;
+	VertexType hotVerts[25];
+};
+
+tCoordType vertToX(VertexType vertex) {
+	return (vertex % 5) * 32;
+}
+
+tCoordType vertToY(VertexType vertex) {
+	return (vertex / 5) * 32;
+}
+
+// This function returns the number of edges in the bomb edge list.
+VertexType getNumEdges(BombEdgeList edges) {
+	return edges[50];
+}
+
+// These four functions return pointers into the given edge list.
+
+// getFirstEdge and getNextEdge can be used to iterate across all edges
+// in an edge list. These functions can be used to walk all the edges
+// in a bomb edge list for drawing.
+VertexType *getFirstEdge(BombEdgeList edges) {
+	return &edges[51];
+}
+
+VertexType *getNextEdge(VertexType *anEdge) {
+	return anEdge + *(anEdge + 1) * 2 + 1;
+}
+
+// getVertices returns a pointer to all of the vertices that should are
+// hot. These vertices indicate all the vertices that should be drawn in
+// the game.
+VertexType *getVertices(BombEdgeList edges) {
+	return &edges[0];
+}
+
+// getUsedVertices returns a pointer to the "used" vertices area: the
+// area that keeps track of which vertices have been set by the
+// setVertexUsed used function.
+VertexType *getUsedVertices(BombEdgeList edges) {
+	return &edges[25];
+}
+
+// Useful for saving. Saving the state of the bomb game is as simple as writing
+// out the edge list.
+int getEdgeListSize(BombEdgeList edges) {	
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+
+	while (numEdges--)
+		anEdge = getNextEdge(anEdge);
+
+	return anEdge - edges + 4;
+}
+
+// Returns true if the given vertex lies on the given edge.
+bool vertexOnEdge(VertexType *anEdge, VertexType whichVertex) {	
+	VertexType numVerts = *++anEdge;
+
+	while (numVerts--)
+		if (*++anEdge == whichVertex)
+			return true;
+
+	return false;
+}
+
+// Given an edge list and a from vertex, this function constructs a list
+// of all vertices that may be clicked on.
+// if fromVertex == -1, all vertices are eligible.
+// otherwise, only vertices on a line from fromVertex are eligible.
+void makeHotVertexList(BombEdgeList edges, VertexType fromVertex, HotVerticesList &hotVertices) {	
+	hotVertices.numHotVerts = 0;
+
+	if (fromVertex == -1) {
+		for (VertexType i = 0; i < 25; i++)
+			if (edges[i])
+				hotVertices.hotVerts[hotVertices.numHotVerts++] = i;
+	} else {
+		VertexType numEdges = getNumEdges(edges);
+		VertexType *anEdge = getFirstEdge(edges);
+		hotVertices.hotVerts[hotVertices.numHotVerts++] = fromVertex;
+
+		while (numEdges--) {
+			if (vertexOnEdge(anEdge, fromVertex)) {
+				VertexType *p = anEdge + 1;
+				VertexType numVerts = *p;
+
+				while (numVerts--)
+					if (*++p != fromVertex)
+						hotVertices.hotVerts[hotVertices.numHotVerts++] = *p;
+			}
+
+			anEdge = getNextEdge(anEdge);
+		}
+	}
+}
+
+// Set all edges in the edge list to the value passed in "edgeVal".
+// For drawing purposes, 0 can mean don't draw, and 1 and higher can
+// represent different colors.
+void setAllEdgesUsed(BombEdgeList edges, VertexType used) {	
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+
+	while (numEdges--) {
+		VertexType *p1 = anEdge + 1;
+		VertexType numVerts = *p1;
+		p1 += numVerts + 1;
+
+		while (--numVerts)
+			*p1++ = used;
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	VertexType *p1 = edges;
+	VertexType *p2 = getUsedVertices(edges);
+
+	for (VertexType i = 0; i < 25; i++, p1++, p2++)
+		if (*p1)
+			*p2 = used;
+}
+
+// Same as setAllEdgesUsed, but only affects edges that are already set
+// to a non-zero value.
+void setAllUsedEdgesUsed(BombEdgeList edges, VertexType used) {
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+
+	while (numEdges--) {
+		VertexType *p = anEdge + 1;
+		VertexType numVerts = *p;
+		p += numVerts + 1;
+
+		while (--numVerts) {
+			if (*p)
+				*p = used;
+			++p;
+		}
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	VertexType *p = getUsedVertices(edges);
+	for (VertexType i = 0; i < 25; i++, p++)
+		if (*p)
+			*p = used;
+}
+
+// Replace all edges with value "value" with the new value "used".
+void replaceUsedEdges(BombEdgeList edges, VertexType value, VertexType used) {	
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+
+	while (numEdges--) {
+		VertexType *p = anEdge + 1;
+		VertexType numVerts = *p;
+		p += numVerts + 1;
+
+		while (--numVerts) {
+			if (*p == value)
+				*p = used;
+
+			p++;
+		}
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	VertexType *p = getUsedVertices(edges);
+	for (VertexType i = 0; i < 25; i++, p++)
+		if (*p == value)
+			*p = used;
+}
+
+// Set a vertex's value to "used".
+void setVertexUsed(BombEdgeList edges, VertexType whichVertex, VertexType value) {
+	*(getUsedVertices(edges) + whichVertex) = value;
+}
+
+// Mark an edge in the given list between the two vertices as "used". This marks
+// all inbetween vertices as well, even if the vertex is not marked as a "hot"
+// vertex in the hot vertex section. Returns true if doing this operation
+// crosses an already marked edge.
+bool setEdgeUsed(BombEdgeList edges, VertexType fromVertex, VertexType toVertex) {
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+	bool crossed = false;
+
+	while (numEdges--) {
+		VertexType *p = anEdge;
+		VertexType numVerts = *++p;
+		VertexType *fromPtr = 0;
+		VertexType *toPtr = 0;
+		VertexType i = numVerts;
+		p++;
+
+		while (i--) {
+			if (*p == fromVertex)
+				fromPtr = p;
+			else if (*p == toVertex)
+				toPtr = p;
+
+			if (fromPtr && toPtr) {
+				// Found the edge...
+				if (fromPtr > toPtr) {
+					p = fromPtr;
+					fromPtr = toPtr;
+					toPtr = p;
+				}
+
+				p = fromPtr + numVerts;
+
+				for (i = toPtr - fromPtr; i > 0; i--, p++) {
+					++(*p);
+
+					if (*p == 2)
+						crossed = true;
+				}
+
+				VertexType *verts = getVertices(edges);
+				VertexType *usedVerts = getUsedVertices(edges);
+				*(usedVerts + *fromPtr) = 1;
+
+				for (p = fromPtr + 1; p != toPtr; p++)
+					if (*(verts + *p))
+						*(usedVerts + *p) = 1;
+
+				*(usedVerts + *toPtr) = 1;
+				return crossed;
+			}
+
+			p++;
+		}
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	return false;
+}
+
+// Return true if all edges are used. Can be used to determine when the bomb
+// game is over.
+bool allEdgesUsed(BombEdgeList edges) {	
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+
+	while (numEdges--) {
+		VertexType *p = anEdge + 1;
+		VertexType numVerts = *p;
+		p += numVerts + 1;
+
+		while (--numVerts) {
+			if (!*p)
+				return false;
+
+			++p;
+		}
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	return true;
+}
+
+BombGrid::BombGrid(const tDisplayElementID id) : Picture(id) {
+	Common::Rect bounds(0, 0, kBombGridWidth, kBombGridHeight);
+
+	allocateSurface(bounds);
+	setBounds(bounds);
+	_surface->fillRect(bounds, g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff));
+
+	_transparent = true;
+
+	_yellowDot.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID, true);
+	_yellowOneSixteenth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 1, true);
+	_yellowOneEighth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 2, true);
+	_yellowThreeSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 3, true);
+	_yellowOneFourth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 4, true);
+	_yellowFiveSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 5, true);
+	_yellowThreeEighths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 6, true);
+	_yellowSevenSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 7, true);
+	_yellowOneHalf.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kYellowBombPICTBaseID + 8, true);
+	
+	_redDot.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID, true);
+	_redOneSixteenth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 1, true);
+	_redOneEighth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 2, true);
+	_redThreeSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 3, true);
+	_redOneFourth.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 4, true);
+	_redFiveSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 5, true);
+	_redThreeEighths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 6, true);
+	_redSevenSixteenths.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 7, true);
+	_redOneHalf.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kRedBombPICTBaseID + 8, true);
+}
+
+void BombGrid::drawEdges(BombEdgeList edges) {
+	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
+	gfx->setCurSurface(_surface);
+
+	_surface->fillRect(Common::Rect(0, 0, kBombGridWidth, kBombGridHeight), g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff));
+
+	Frame *yellowStuff = &_yellowDot;
+	Frame *redStuff = &_redDot;
+	VertexType numEdges = getNumEdges(edges);
+	VertexType *anEdge = getFirstEdge(edges);
+	VertexType i, *p;
+
+	Common::Rect bounds;
+	getSurfaceBounds(bounds);
+
+	while (numEdges--) {
+		p = anEdge;
+		VertexType edgeDirection = *p++;
+		VertexType numVerts = *p++;
+		VertexType numSegs = numVerts - 1;
+
+		for (i = 0; i < numSegs; i++, p++) {
+			if (*(p + numVerts) > 0 && *(p + numVerts) < 4) {
+				Frame *drawStuff;
+
+				if (*(p + numVerts) == 2)
+					drawStuff = redStuff;
+				else
+					drawStuff = yellowStuff;
+
+				int x = vertToX(*p) + g_originsX[edgeDirection];
+				int y = vertToY(*p) + g_originsY[edgeDirection];
+
+				Common::Rect r1;
+				drawStuff[edgeDirection + 1].getSurfaceBounds(r1);
+				Common::Rect r2 = r1;
+				r2.moveTo(x, y);
+				drawStuff[edgeDirection + 1].drawImage(r1, r2);
+			}
+		}
+
+		anEdge = getNextEdge(anEdge);
+	}
+
+	for (i = 0, p = getUsedVertices(edges); i < 25; i++, p++) {
+		if (*p > 0 && *p < 4) {
+			Frame *drawStuff;
+
+			if (*p == 2)
+				drawStuff = redStuff;
+			else
+				drawStuff = yellowStuff;
+
+			int x = vertToX(i) + kDotOriginX;
+			int y = vertToY(i) + kDotOriginY;
+
+			Common::Rect r1;
+			drawStuff->getSurfaceBounds(r1);
+			Common::Rect r2 = r1;
+			r2.moveTo(x, y);
+			drawStuff->drawImage(r1, r2);
+		}
+	}
+
+	triggerRedraw();
+	gfx->setCurSurface(gfx->getWorkArea());
+}
+
+BombTimer::BombTimer(const tDisplayElementID id) : IdlerAnimation(id) {	
+	_middle = -1;
+	_leftImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTimerLeftPICTID);
+	_rightImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTimerRightPICTID);
+
+	Common::Rect r;
+	_leftImage.getSurfaceBounds(r);
+	setBounds(r);
+}
+
+void BombTimer::draw(const Common::Rect &updateRect) {
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	Common::Rect r1 = bounds;
+	r1.right = _middle;
+	r1 = r1.findIntersectingRect(updateRect);
+
+	if (!r1.isEmpty()) {
+		Common::Rect r2 = r1;
+		r2.moveTo(r1.left - bounds.left, r1.top - bounds.top);
+		_leftImage.copyToCurrentPort(r2, r1);
+	}
+
+	r1 = bounds;
+	r1.left = _middle;
+	r1 = r1.findIntersectingRect(updateRect);
+
+	if (!r1.isEmpty()) {
+		Common::Rect r2 = r1;
+		r2.moveTo(r1.left - bounds.left, r1.top - bounds.top);
+		_rightImage.copyToCurrentPort(r2, r1);
+	}
+}
+
+void BombTimer::timeChanged(const TimeValue newTime) {	
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	int newMiddle = bounds.right - bounds.width() * newTime / getDuration();
+	if (newMiddle != _middle) {
+		_middle = newMiddle;
+		triggerRedraw();
+	}
+}
+
+#define CREATE_BOMB_LEVEL(num, data) \
+	_bombLevel[num] = new VertexType[sizeof(data)]; \
+	memcpy(_bombLevel[num], data, sizeof(data))
+
+CaldoriaBomb::CaldoriaBomb(Neighborhood *owner, NotificationManager *manager) :
+		GameInteraction(kCaldoriaBombInteractionID, owner), _grid(kCaldoriaBombGridID),
+		_timer(kCaldoriaBombTimerID), _timerNotification(kCaldoriaBombTimerNotificationID, manager) {
+	CREATE_BOMB_LEVEL(0, kBombLevelOne);
+	CREATE_BOMB_LEVEL(1, kBombLevelTwo);
+	CREATE_BOMB_LEVEL(2, kBombLevelThree);
+	CREATE_BOMB_LEVEL(3, kBombLevelFour);
+	CREATE_BOMB_LEVEL(4, kBombLevelFive);
+	CREATE_BOMB_LEVEL(5, kBombLevelSix);
+	_currentLevel = 0;
+}
+
+#undef CREATE_BOMB_LEVEL
+
+CaldoriaBomb::~CaldoriaBomb() {
+	for (int i = 0; i < 6; i++)
+		delete[] _bombLevel[i];
+}
+
+void CaldoriaBomb::openInteraction() {	
+	_grid.moveElementTo(kCaldoriaBombGridLeft, kCaldoriaBombGridTop);
+	_grid.setDisplayOrder(kCaldoriaBombGridOrder);
+	_grid.startDisplaying();
+
+	_timer.moveElementTo(kCaldoriaBombTimerLeft, kCaldoriaBombTimerTop);
+	_timer.setDisplayOrder(kCaldoriaBombTimerOrder);
+	_timer.startDisplaying();
+	_timer.setSegment(0, kTenMinutesPerFifteenTicks, kFifteenTicksPerSecond);
+	_timer.setTime(0);
+	
+	_timerNotification.notifyMe(this, kBombTimerExpiredFlag, kBombTimerExpiredFlag);
+	_timerCallBack.setNotification(&_timerNotification);
+	_timerCallBack.initCallBack(&_timer, kCallBackAtExtremes);
+	_timerCallBack.setCallBackFlag(kBombTimerExpiredFlag);
+	
+	Common::Rect r(0, 0, kVertextHotSpotWidth, kVertextHotSpotHeight);
+
+	for (VertexType i = 0; i < 25; i++) {
+		_vertexHotspot[i] = new Hotspot(i + kVertextHotSpotBaseID);
+		r.moveTo(vertToX(i) + kCaldoriaBombGridLeft - kVertextHotSpotWidth / 2 + 6,
+				vertToY(i) + kCaldoriaBombGridTop - kVertextHotSpotHeight / 2 + 6);
+		_vertexHotspot[i]->setArea(r);
+		_vertexHotspot[i]->setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
+		g_allHotspots.push_back(_vertexHotspot[i]);
+	}
+	
+	_neighborhoodNotification = _owner->getNeighborhoodNotification();
+	_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag, kExtraCompletedFlag);
+}
+
+void CaldoriaBomb::initInteraction() {
+	_owner->loadLoopSound1("");
+	_owner->startExtraSequence(kCaldoria56BombStage1, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void CaldoriaBomb::closeInteraction() {
+	_timer.stop();
+	_timer.hide();
+	_timer.stopDisplaying();
+	_grid.hide();
+	_grid.stopDisplaying();
+}
+
+void CaldoriaBomb::startBombAmbient(Common::String ambient) {
+	_owner->loadLoopSound1(ambient);
+}
+
+void CaldoriaBomb::receiveNotification(Notification *notification, const tNotificationFlags) {	
+	if (notification == _neighborhoodNotification) {
+		switch (_owner->getLastExtra()) {
+		case kCaldoria56BombStage1:
+			_grid.show();
+			_timer.show();
+			_timerCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+			_timer.start();
+			_currentLevel = 0;
+			_lastVertex = -1;
+			startBombAmbient("Sounds/Caldoria/BmbLoop1.22K.AIFF");
+			break;
+		case kCaldoria56BombStage2:
+		case kCaldoria56BombStage3:
+		case kCaldoria56BombStage4:
+		case kCaldoria56BombStage5:
+		case kCaldoria56BombStage6:
+			_grid.show();
+			_currentLevel++;
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -1;
+			startBombAmbient(Common::String::format("Sounds/Caldoria/BmbLoop%d.22K.AIFF", _owner->getLastExtra() - kCaldoria56BombStage1 + 1));
+			break;
+		case kCaldoria56BombStage7:
+			_owner->requestDeleteCurrentInteraction();
+			GameState.setCaldoriaBombDisarmed(true);
+			GameState.setScoringDisarmedNuke(true);
+			_owner->loadAmbientLoops();
+			break;
+		}
+	} else if (notification == &_timerNotification) {
+		_grid.hide();
+		_timer.stop();
+		_timer.hide();
+		_owner->loadLoopSound1("");
+		_owner->playDeathExtra(kCaldoria56BombExplodes, kDeathNuclearExplosion);
+	}
+}
+
+void CaldoriaBomb::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	if (_currentLevel != -1 && _lastVertex >= -1) {
+		HotVerticesList hotVertices;
+		makeHotVertexList(_bombLevel[_currentLevel], _lastVertex, hotVertices);
+
+		for (VertexType i = 0; i < hotVertices.numHotVerts; i++)
+			g_allHotspots.activateOneHotspot(hotVertices.hotVerts[i] + kVertextHotSpotBaseID);
+	}
+}
+
+void CaldoriaBomb::clickInHotspot(const Input &input, const Hotspot *hotspot) {
+	int clickedVertex = (int)hotspot->getObjectID() - (int)kVertextHotSpotBaseID;
+
+	if (clickedVertex >= 0 && clickedVertex < 25) {
+		if (_lastVertex != -1 && setEdgeUsed(_bombLevel[_currentLevel], _lastVertex, clickedVertex)) {
+			clickedVertex = -2;
+			_flashTime = tickCount();
+		} else if (allEdgesUsed(_bombLevel[_currentLevel])) {
+			setVertexUsed(_bombLevel[_currentLevel], clickedVertex, 1);
+			clickedVertex = -20;
+			_flashTime = tickCount();
+		} else {
+			setVertexUsed(_bombLevel[_currentLevel], clickedVertex, 2);
+		}
+
+		_grid.drawEdges(_bombLevel[_currentLevel]);
+		_lastVertex = clickedVertex;
+	} else {
+		GameInteraction::clickInHotspot(input, hotspot);
+	}
+}
+
+tInputBits CaldoriaBomb::getInputFilter() {
+	// Disallow arrow buttons.
+	return GameInteraction::getInputFilter() & kFilterAllButtons;
+}
+
+void CaldoriaBomb::handleInput(const Input &input, const Hotspot *hotspot) {
+	GameInteraction::handleInput(input, hotspot);
+
+	switch (_lastVertex) {
+	case -2:			// Flash back to yellow.
+		if (tickCount() > _flashTime + kOnTime1) {
+			replaceUsedEdges(_bombLevel[_currentLevel], 2, 3);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -3;
+		}
+		break;
+	case -3:			// Flash back to red.
+		if (tickCount() > _flashTime + kOffTime1) {
+			replaceUsedEdges(_bombLevel[_currentLevel], 3, 2);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -4;
+		}
+		break;
+	case -4:			// Flash all to yellow.
+		if (tickCount() > _flashTime + kOnTime2) {
+			setAllUsedEdgesUsed(_bombLevel[_currentLevel], 1);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -5;
+		}
+		break;
+	case -5:			// Flash all to red.
+		if (tickCount() > _flashTime + kOffTime2) {
+			setAllUsedEdgesUsed(_bombLevel[_currentLevel], 2);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -6;
+		}
+		break;
+	case -6:			// Flash all to yellow.
+		if (tickCount() > _flashTime + kOnTime3) {
+			setAllUsedEdgesUsed(_bombLevel[_currentLevel], 1);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -7;
+		}
+		break;
+	case -7:			// Flash all to red.
+		if (tickCount() > _flashTime + kOffTime3) {
+			setAllUsedEdgesUsed(_bombLevel[_currentLevel], 2);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -8;
+		}
+		break;
+	case -8:			// Restore to normal.
+		if (tickCount() > _flashTime + kOnTime4) {
+			setAllEdgesUsed(_bombLevel[_currentLevel], 0);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -1;
+		}
+		break;
+
+	// Flash grid after success.
+	case -20:			// Flash off.
+		if (tickCount() > _flashTime + kOnTime1) {
+			setAllEdgesUsed(_bombLevel[_currentLevel], 4);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -21;
+		}
+		break;
+	case -21:			// Flash on.
+		if (tickCount() > _flashTime + kOffTime1) {
+			setAllEdgesUsed(_bombLevel[_currentLevel], 1);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -22;
+		}
+		break;
+	case -22:			// Flash off.
+		if (tickCount() > _flashTime + kOnTime2) {
+			setAllEdgesUsed(_bombLevel[_currentLevel], 4);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -23;
+		}
+		break;
+	case -23:			// Flash on.
+		if (tickCount() > _flashTime + kOffTime2) {
+			setAllEdgesUsed(_bombLevel[_currentLevel], 1);
+			_grid.drawEdges(_bombLevel[_currentLevel]);
+			_lastVertex = -24;
+		}
+		break;
+	case -24:
+		if (tickCount() > _flashTime + kOnTime3) {
+			_grid.hide();
+			_lastVertex = -1;
+			_owner->loadLoopSound1("");
+
+			switch (_currentLevel) {
+			case 0:
+				_owner->startExtraSequence(kCaldoria56BombStage2, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 1:
+				_owner->startExtraSequence(kCaldoria56BombStage3, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 2:
+				_owner->startExtraSequence(kCaldoria56BombStage4, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 3:
+				_owner->startExtraSequence(kCaldoria56BombStage5, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 4:
+				_owner->startExtraSequence(kCaldoria56BombStage6, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			case 5:
+				_timer.stop();
+				_grid.hide();
+				_timer.hide();
+				_owner->startExtraSequence(kCaldoria56BombStage7, kExtraCompletedFlag, kFilterNoInput);
+				break;
+			}
+		}
+		break;
+	}
+}
+
+long CaldoriaBomb::getNumHints() {
+	return 2;
+}
+
+Common::String CaldoriaBomb::getHintMovie(uint hintNum) {
+	return (hintNum == 1) ? "Images/AI/Caldoria/X56EH2" : "Images/AI/Caldoria/X56EH3";
+}
+
+bool CaldoriaBomb::canSolve() {
+	return true;
+}
+
+void CaldoriaBomb::doSolve() {
+	_timer.stop();
+	_grid.hide();
+	_timer.hide();
+	_owner->loadLoopSound1("");
+	_owner->startExtraSequence(kCaldoria56BombStage7, kExtraCompletedFlag, kFilterNoInput);
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
new file mode 100755
index 0000000..fc48231
--- /dev/null
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
@@ -0,0 +1,156 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIABOMB_H
+#define PEGASUS_NEIGHBORHOOD_CALDORIA_CALDORIABOMB_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/notification.h"
+#include "pegasus/surface.h"
+
+namespace Pegasus {
+
+/*
+	Edge list is arranged as follows:
+	
+	all values in the edge list are bytes.
+	
+	all vertices are numbers between 0 and 24. x coordinate of vertex is vertex % 5,
+	and y coordinate is vertex / 5.
+	
+	an edge is
+		a direction code
+		a number of vertices in the edge
+		an array of vertices -- all vertices along the edge, whether or not they're
+			clickable.
+		an array of bools (bytes) indicating that a portion of the edge is
+			traversed (and should be drawn). the number of bools is one less than
+			the number of vertices.
+	
+	an edge list is
+		an array of 25 bools indicating which vertex is clickable.
+		an array of 25 bools indicating which vertex is used (drawn).
+		a number of edges
+		an array of edges.
+	
+	a hot vertex list is
+		a number of vertices
+		an array of 25 vertices
+
+*/
+
+typedef int8 VertexType;
+typedef VertexType *BombEdgeList;
+
+static const VertexType kEdgeOneSixteenth = 0;
+static const VertexType kEdgeOneEighth = 1;
+static const VertexType kEdgeThreeSixteenths = 2;
+static const VertexType kEdgeOneFourth = 3;
+static const VertexType kEdgeFiveSixteenths = 4;
+static const VertexType kEdgeThreeEighths = 5;
+static const VertexType kEdgeSevenSixteenths = 6;
+static const VertexType kEdgeOneHalf = 7;
+
+class BombTimer : public IdlerAnimation {
+public:
+	BombTimer(const tDisplayElementID);
+	virtual ~BombTimer() {}
+
+	void draw(const Common::Rect &);
+
+protected:
+	void timeChanged(const TimeValue);
+
+	int _middle;
+	Surface _leftImage, _rightImage;
+};
+
+class BombGrid : public Picture {
+public:
+	BombGrid(const tDisplayElementID);
+	virtual ~BombGrid() {}
+
+	void drawEdges(BombEdgeList);
+
+protected:
+	Frame _yellowDot;
+	Frame _yellowOneSixteenth;
+	Frame _yellowOneEighth;
+	Frame _yellowThreeSixteenths;
+	Frame _yellowOneFourth;
+	Frame _yellowFiveSixteenths;
+	Frame _yellowThreeEighths;
+	Frame _yellowSevenSixteenths;
+	Frame _yellowOneHalf;
+	Frame _redDot;
+	Frame _redOneSixteenth;
+	Frame _redOneEighth;
+	Frame _redThreeSixteenths;
+	Frame _redOneFourth;
+	Frame _redFiveSixteenths;
+	Frame _redThreeEighths;
+	Frame _redSevenSixteenths;
+	Frame _redOneHalf;
+};
+
+class Hotspot;
+
+class CaldoriaBomb : public GameInteraction, public NotificationReceiver {
+public:
+	CaldoriaBomb(Neighborhood *, NotificationManager *);
+	virtual ~CaldoriaBomb();
+
+	long getNumHints();
+	Common::String getHintMovie(uint);
+	void doSolve();
+	bool canSolve();
+
+protected:
+	void openInteraction();
+	void initInteraction();
+	void closeInteraction();
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	void handleInput(const Input &, const Hotspot *);
+	tInputBits getInputFilter();
+	void startBombAmbient(Common::String);
+	
+	Notification *_neighborhoodNotification;
+	BombGrid _grid;
+	BombTimer _timer;
+	BombEdgeList _bombLevel[6];
+	int _currentLevel, _flashTime;
+	Hotspot *_vertexHotspot[25];
+	VertexType _lastVertex;
+	Notification _timerNotification;
+	NotificationCallBack _timerCallBack;
+
+	TimeValue _readTime;
+};
+
+} // End of namespace Pegasus
+
+#endif


Commit: d55aeeec0b386966a194776f22434ad0bb81da4c
    https://github.com/scummvm/scummvm/commit/d55aeeec0b386966a194776f22434ad0bb81da4c
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-13T08:58:20-08:00

Commit Message:
PEGASUS: Fix displaying the end message

Changed paths:
    engines/pegasus/items/inventorypicture.cpp



diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 5eef7ef..04bac44 100755
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -319,6 +319,8 @@ void InventoryItemsPicture::deactivateInventoryPicture() {
 }
 
 void InventoryItemsPicture::playEndMessage(DisplayElement *pushElement) {
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
 	Movie endMessage(0);
 
 	_shouldDrawHighlight = false;
@@ -329,7 +331,8 @@ void InventoryItemsPicture::playEndMessage(DisplayElement *pushElement) {
 	endMessage.start();
 
 	while (endMessage.isRunning()) {
-		((PegasusEngine *)g_engine)->refreshDisplay();
+		vm->checkCallBacks();
+		vm->refreshDisplay();
 		g_system->delayMillis(10);
 	}
 


Commit: a328f32fed85743f85b26876b9ade388d4eb0bbd
    https://github.com/scummvm/scummvm/commit/a328f32fed85743f85b26876b9ade388d4eb0bbd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-13T18:02:28-08:00

Commit Message:
PEGASUS: Fix going from bomb game to the end game

The game is now completable from after completing from a save that has Norad complete.

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp



diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
index 43de5e7..9ec3124 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
@@ -1209,6 +1209,15 @@ void CaldoriaBomb::closeInteraction() {
 	_timer.stopDisplaying();
 	_grid.hide();
 	_grid.stopDisplaying();
+
+	// The original did not do this, but we need it here
+	// Not sure why the original worked without this; probably
+	// related to the way the List code worked in CodeWarrior.
+	// If this is not here, the notifications will later attempt
+	// to remove itself from this receiver causing a very nasty
+	// crash.
+	_timerNotification.cancelNotification(this);
+	_neighborhoodNotification->cancelNotification(this);
 }
 
 void CaldoriaBomb::startBombAmbient(Common::String ambient) {


Commit: 4b93bc6456aae0912c909d4349845544e1c9d23f
    https://github.com/scummvm/scummvm/commit/4b93bc6456aae0912c909d4349845544e1c9d23f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-14T21:02:10-08:00

Commit Message:
PEGASUS: Add Norad Delta

And with that, ladies and gentlemen, Pegasus Prime is officially completable in ScummVM.

Changed paths:
  A engines/pegasus/neighborhood/norad/constants.h
  A engines/pegasus/neighborhood/norad/delta/globegame.cpp
  A engines/pegasus/neighborhood/norad/delta/globegame.h
  A engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
  A engines/pegasus/neighborhood/norad/delta/noraddelta.h
    engines/pegasus/constants.h
    engines/pegasus/module.mk
    engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
    engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
    engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
    engines/pegasus/neighborhood/norad/alpha/noradalpha.h
    engines/pegasus/neighborhood/norad/norad.cpp
    engines/pegasus/neighborhood/norad/norad.h
    engines/pegasus/neighborhood/norad/noradelevator.cpp
    engines/pegasus/neighborhood/norad/pressuredoor.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp
    engines/pegasus/neighborhood/norad/subplatform.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index cc096dd..c6d4e45 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -736,9 +736,6 @@ static const tGameMode kModeInventoryPick = kLastGameShellMode + 1;
 static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
 static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
 
-// TODO: Remove me
-static const tRoomID kNorad41 = 0;
-
 } // End of namespace Pegasus
 
 #endif
diff --git a/engines/pegasus/module.mk b/engines/pegasus/module.mk
index e19b45e..cb44a04 100644
--- a/engines/pegasus/module.mk
+++ b/engines/pegasus/module.mk
@@ -82,6 +82,8 @@ MODULE_OBJS = \
 	neighborhood/norad/alpha/noradalpha.o \
 	neighborhood/norad/alpha/panorama.o \
 	neighborhood/norad/alpha/panoramascroll.o \
+	neighborhood/norad/delta/globegame.o \
+	neighborhood/norad/delta/noraddelta.o \
 	neighborhood/prehistoric/prehistoric.o \
 	neighborhood/tsa/fulltsa.o \
 	neighborhood/tsa/tinytsa.o \
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
index 1dc770a..2af4335 100755
--- a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/alpha/ecrmonitor.h"
 
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
index a858e75..c115f90 100755
--- a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
@@ -26,6 +26,7 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/alpha/fillingstation.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index 46bebf6..3bab3b8 100755
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -28,6 +28,7 @@
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/subcontrolroom.h"
 #include "pegasus/neighborhood/norad/alpha/ecrmonitor.h"
 #include "pegasus/neighborhood/norad/alpha/fillingstation.h"
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
index 72a7ac6..9b96d13 100755
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
@@ -30,33 +30,6 @@
 
 namespace Pegasus {
 
-const TimeValue kAlphaBumpIntoWallIn = 0;
-const TimeValue kAlphaBumpIntoWallOut = 303;
-
-const TimeValue kAlphaAccessDeniedIn = 303;
-const TimeValue kAlphaAccessDeniedOut = 3045;
-
-const TimeValue kAlphaRegDoorCloseIn = 3045;
-const TimeValue kAlphaRegDoorCloseOut = 4476;
-
-const TimeValue kAlphaElevatorDoorCloseIn = 4476;
-const TimeValue kAlphaElevatorDoorCloseOut = 5071;
-
-const TimeValue kAlphaCantTransportIn = 5071;
-const TimeValue kAlphaCantTransportOut = 9348;
-
-const TimeValue kPressureDoorIntro1In = 9348;
-const TimeValue kPressureDoorIntro1Out = 11061;
-
-const TimeValue kPressureDoorIntro2In = 11061;
-const TimeValue kPressureDoorIntro2Out = 14098;
-
-const TimeValue kN22ReplyIn = 14098;
-const TimeValue kN22ReplyOut = 18442;
-
-const TimeValue kLoadClawIntroIn = 18442;
-const TimeValue kLoadClawIntroOut = 20698;
-
 class Item;
 
 class NoradAlpha : public Norad {
diff --git a/engines/pegasus/neighborhood/norad/constants.h b/engines/pegasus/neighborhood/norad/constants.h
new file mode 100755
index 0000000..8d5eff4
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/constants.h
@@ -0,0 +1,755 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_CONSTANTS_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_CONSTANTS_H
+
+#include "pegasus/constants.h"
+
+namespace Pegasus {
+
+// Norad Alpha spot constants
+
+const TimeValue kAlphaBumpIntoWallIn = 0;
+const TimeValue kAlphaBumpIntoWallOut = 303;
+
+const TimeValue kAlphaAccessDeniedIn = 303;
+const TimeValue kAlphaAccessDeniedOut = 3045;
+
+const TimeValue kAlphaRegDoorCloseIn = 3045;
+const TimeValue kAlphaRegDoorCloseOut = 4476;
+
+const TimeValue kAlphaElevatorDoorCloseIn = 4476;
+const TimeValue kAlphaElevatorDoorCloseOut = 5071;
+
+const TimeValue kAlphaCantTransportIn = 5071;
+const TimeValue kAlphaCantTransportOut = 9348;
+
+const TimeValue kAlphaPressureDoorIntro1In = 9348;
+const TimeValue kAlphaPressureDoorIntro1Out = 11061;
+
+const TimeValue kAlphaPressureDoorIntro2In = 11061;
+const TimeValue kAlphaPressureDoorIntro2Out = 14098;
+
+const TimeValue kN22ReplyIn = 14098;
+const TimeValue kN22ReplyOut = 18442;
+
+const TimeValue kAlphaLoadClawIntroIn = 18442;
+const TimeValue kAlphaLoadClawIntroOut = 20698;
+
+// Norad Delta spot constants
+
+const TimeValue kDeltaBumpIntoWallIn = 0;
+const TimeValue kDeltaBumpIntoWallOut = 303;
+
+const TimeValue kDeltaAccessDeniedIn = 303;
+const TimeValue kDeltaAccessDeniedOut = 3045;
+
+const TimeValue kDeltaRegDoorCloseIn = 3045;
+const TimeValue kDeltaRegDoorCloseOut = 4476;
+
+const TimeValue kDeltaElevatorDoorCloseIn = 4476;
+const TimeValue kDeltaElevatorDoorCloseOut = 5071;
+
+const TimeValue kPressureDoorIntro1In = 5071;
+const TimeValue kPressureDoorIntro1Out = 6784;
+
+const TimeValue kPressureDoorIntro2In = 6784;
+const TimeValue kPressureDoorIntro2Out = 9821;
+
+const TimeValue kLoadClawIntroIn = 9821;
+const TimeValue kLoadClawIntroOut = 12077;
+
+const TimeValue kHoldForRetinalIn = 12077;
+const TimeValue kHoldForRetinalOut = 14104;
+
+const TimeValue kRetinalScanFailedIn = 14104;
+const TimeValue kRetinalScanFailedOut = 17538;
+
+const TimeValue kAddisAbabaIn = 17538;
+const TimeValue kAddisAbabaOut = 19263;
+
+const TimeValue kBangkokIn = 19263;
+const TimeValue kBangkokOut = 20201;
+
+const TimeValue kBonnIn = 20201;
+const TimeValue kBonnOut = 20915;
+
+const TimeValue kDublinIn = 20915;
+const TimeValue kDublinOut = 21660;
+
+const TimeValue kHonoluluIn = 21660;
+const TimeValue kHonoluluOut = 22498;
+
+const TimeValue kMadridIn = 22498;
+const TimeValue kMadridOut = 23474;
+
+const TimeValue kReykjavikIn = 23474;
+const TimeValue kReykjavikOut = 24488;
+
+const TimeValue kSanAntonioIn = 24488;
+const TimeValue kSanAntonioOut = 25561;
+
+const TimeValue kSeoulIn = 25561;
+const TimeValue kSeoulOut = 26461;
+
+const TimeValue kSvortalskIn = 26461;
+const TimeValue kSvortalskOut = 27582;
+
+const TimeValue kSiloBeepIn = 27582;
+const TimeValue kSiloBeepOut = 27721;
+
+const TimeValue kAllSilosDeactivatedIn = 27721;
+const TimeValue kAllSilosDeactivatedOut = 28928;
+
+const TimeValue kGlobalLaunchOverrideIn = 28928;
+const TimeValue kGlobalLaunchOverrideOut = 30736;
+
+const TimeValue kLaunchSiloSelectedIn = 30736;
+const TimeValue kLaunchSiloSelectedOut = 31660;
+
+const TimeValue kLaunchToProceedIn = 31660;
+const TimeValue kLaunchToProceedOut = 32536;
+
+const TimeValue kMaximumDeactivationIn = 32536;
+const TimeValue kMaximumDeactivationOut = 34337;
+
+const TimeValue kMissileLaunchedIn = 34337;
+const TimeValue kMissileLaunchedOut = 35082;
+
+const TimeValue kNewLaunchSiloIn = 35082;
+const TimeValue kNewLaunchSiloOut = 36320;
+
+const TimeValue kStrikeAuthorizedIn = 36320;
+const TimeValue kStrikeAuthorizedOut = 37393;
+
+const TimeValue kPrimaryTargetIn = 37393;
+const TimeValue kPrimaryTargetOut = 38628;
+
+const TimeValue kSiloDeactivatedIn = 38628;
+const TimeValue kSiloDeactivatedOut = 39566;
+
+const TimeValue kStrikeCodeRejectedIn = 39566;
+const TimeValue kStrikeCodeRejectedOut = 41056;
+
+const TimeValue kToDeactivateIn = 41056;
+const TimeValue kToDeactivateOut = 46494;
+
+const TimeValue kTwoMinutesIn = 46494;
+const TimeValue kTwoMinutesOut = 47166;
+
+const TimeValue kOneMinuteIn = 47166;
+const TimeValue kOneMinuteOut = 47856;
+
+const TimeValue kFiftySecondsIn = 47856;
+const TimeValue kFiftySecondsOut = 48691;
+
+const TimeValue kFortySecondsIn = 48691;
+const TimeValue kFortySecondsOut = 49500;
+
+const TimeValue kThirtySecondsIn = 49500;
+const TimeValue kThirtySecondsOut = 50362;
+
+const TimeValue kTwentySecondsIn = 50362;
+const TimeValue kTwentySecondsOut = 51245;
+
+const TimeValue kTenSecondsIn = 51245;
+const TimeValue kTenSecondsOut = 52069;
+
+const TimeValue kGiveUpHumanIn = 52069;
+const TimeValue kGiveUpHumanOut = 55023;
+
+const TimeValue kIJustBrokeIn = 55023;
+const TimeValue kIJustBrokeOut = 59191;
+
+const TimeValue kTheOnlyGoodHumanIn = 59191;
+const TimeValue kTheOnlyGoodHumanOut = 62379;
+
+const TimeValue kYouAreRunningIn = 62379;
+const TimeValue kYouAreRunningOut = 64201;
+
+const TimeValue kYouCannotPossiblyIn = 64201;
+const TimeValue kYouCannotPossiblyOut = 65740;
+
+const TimeValue kYouWillFailIn = 65740;
+const TimeValue kYouWillFailOut = 67217;
+
+const tCanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
+
+const tNotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
+
+const uint16 kNoradWarningVolume = 0x100 / 3;
+const uint16 kNoradSuckWindVolume = 0x100 / 2;
+
+const int16 kElevatorCompassAngle = -40;
+const int16 kSubPlatformCompassAngle = 45;
+const int16 kSubControlCompassAngle = -10;
+
+//	Norad interactions.
+
+const tInteractionID kNoradGlobeGameInteractionID = 0;
+const tInteractionID kNoradECRMonitorInteractionID = 1;
+const tInteractionID kNoradFillingStationInteractionID = 2;
+const tInteractionID kNoradElevatorInteractionID = 3;
+const tInteractionID kNoradPressureDoorInteractionID = 4;
+const tInteractionID kNoradSubControlRoomInteractionID = 5;
+const tInteractionID kNoradSubPlatformInteractionID = 6;
+
+/////////////////////////////////////////////
+//
+//	Norad Alpha
+
+const tCoordType kECRSlideShowLeft = kNavAreaLeft + 78;
+const tCoordType kECRSlideShowTop = kNavAreaTop + 1;
+
+const tCoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
+const tCoordType kECRPanTop = kNavAreaTop + 1 + 4;
+const tCoordType kECRPanRight = kECRPanLeft + 213;
+const tCoordType kECRPanBottom = kECRPanTop + 241;
+
+const tCoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
+const tCoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
+
+const tCoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
+const tCoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
+
+const tCoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
+const tCoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
+
+const tCoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
+const tCoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
+
+const tCoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
+const tCoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
+
+const tCoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
+const tCoordType kNoradUpperUpTop = kNavAreaTop + 32;
+
+const tCoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
+const tCoordType kNoradUpperDownTop = kNavAreaTop + 66;
+
+const tCoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
+const tCoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
+
+const tCoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
+const tCoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
+
+const tCoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
+const tCoordType kNoradLowerUpTop = kNavAreaTop + 164;
+
+const tCoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
+const tCoordType kNoradLowerDownTop = kNavAreaTop + 212;
+
+const tCoordType kNoradPlatformLeft = kNavAreaLeft + 36;
+const tCoordType kNoradPlatformTop = kNavAreaTop + 87;
+
+const tCoordType kNoradSubControlLeft = kNavAreaLeft + 0;
+const tCoordType kNoradSubControlTop = kNavAreaTop + 84;
+
+const tCoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
+const tCoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
+
+const tCoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
+const tCoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
+
+const tCoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
+const tCoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
+
+const tCoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
+const tCoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
+
+const tCoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
+const tCoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
+
+const tCoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
+const tCoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
+
+const tCoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
+const tCoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
+
+const tCoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
+const tCoordType kNoradClawMonitorTop = kNavAreaTop + 97;
+
+const tCoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
+const tCoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
+
+const tCoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
+const tCoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
+
+const tCoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
+const tCoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
+
+const tCoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
+const tCoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
+
+/////////////////////////////////////////////
+//
+//	Norad Delta
+
+const tCoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
+const tCoordType kGlobeMonitorTop = kNavAreaTop + 144;
+
+const tCoordType kGlobeLeft = kNavAreaLeft + 172;
+const tCoordType kGlobeTop = kNavAreaTop;
+
+const tCoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
+const tCoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
+
+const tCoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
+const tCoordType kGlobeCircleRightTop = kNavAreaTop + 41;
+
+const tCoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
+const tCoordType kGlobeCircleUpTop = kNavAreaTop + 7;
+
+const tCoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
+const tCoordType kGlobeCircleDownTop = kNavAreaTop + 142;
+
+const tCoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
+const tCoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
+
+const tCoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
+const tCoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
+
+const tCoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
+const tCoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
+
+const tCoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
+const tCoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
+
+const tCoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
+const tCoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
+
+const tCoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
+const tCoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
+
+const tCoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
+const tCoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
+
+const tCoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
+const tCoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
+
+const tCoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
+const tCoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
+
+const tCoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
+const tCoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
+
+const tCoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
+const tCoordType kGlobeCountdownTop = kNavAreaTop + 164;
+
+//	Norad Alpha display IDs.
+
+const tDisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
+const tDisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
+const tDisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
+const tDisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
+const tDisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
+const tDisplayElementID kN01RightSideID = kN01LeftSideID + 1;
+const tDisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
+const tDisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
+const tDisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
+const tDisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
+const tDisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
+const tDisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
+const tDisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
+const tDisplayElementID kSubControlPinchID = kClawMonitorID + 1;
+const tDisplayElementID kSubControlDownID = kSubControlPinchID + 1;
+const tDisplayElementID kSubControlRightID = kSubControlDownID + 1;
+const tDisplayElementID kSubControlLeftID = kSubControlRightID + 1;
+const tDisplayElementID kSubControlUpID = kSubControlLeftID + 1;
+const tDisplayElementID kSubControlCCWID = kSubControlUpID + 1;
+const tDisplayElementID kSubControlCWID = kSubControlCCWID + 1;
+const tDisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
+
+//	Norad Delta display IDs.
+
+const tDisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
+const tDisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
+const tDisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
+const tDisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
+const tDisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
+const tDisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
+const tDisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
+const tDisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
+const tDisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
+const tDisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
+const tDisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
+const tDisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
+const tDisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
+const tDisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
+const tDisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
+const tDisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
+const tDisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
+
+//	Norad Alpha:
+
+const tDisplayOrder kECRMonitorOrder = kMonitorLayer;
+const tDisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
+
+const tDisplayOrder kN01LeftSideOrder = kMonitorLayer;
+const tDisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
+
+const tDisplayOrder kElevatorControlsOrder = kMonitorLayer;
+
+const tDisplayOrder kPressureLevelsOrder = kMonitorLayer;
+const tDisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
+const tDisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
+const tDisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
+
+const tDisplayOrder kPlatformOrder = kMonitorLayer;
+
+const tDisplayOrder kSubControlOrder = kMonitorLayer;
+const tDisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
+const tDisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
+const tDisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
+const tDisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
+const tDisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
+const tDisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
+const tDisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
+const tDisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
+const tDisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
+
+//	Norad Delta:
+
+const tDisplayOrder kGlobeMonitorLayer = kMonitorLayer;
+const tDisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
+const tDisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
+const tDisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
+const tDisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
+const tDisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
+const tDisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
+
+//	Norad Alpha Tables
+
+const TimeScale kNoradAlphaMovieScale = 600;
+const TimeScale kNoradAlphaFramesPerSecond = 15;
+const TimeScale kNoradAlphaFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltNoradAlphaNormal = 0;
+
+//	Room IDs.
+
+const tRoomID kNorad01 = 0;
+const tRoomID kNorad01East = 1;
+const tRoomID kNorad01West = 2;
+const tRoomID kNorad02 = 3;
+const tRoomID kNorad03 = 4;
+const tRoomID kNorad04 = 5;
+const tRoomID kNorad05 = 6;
+const tRoomID kNorad06 = 7;
+const tRoomID kNorad07 = 8;
+const tRoomID kNorad07North = 9;
+const tRoomID kNorad08 = 10;
+const tRoomID kNorad09 = 11;
+const tRoomID kNorad10 = 12;
+const tRoomID kNorad10East = 13;
+const tRoomID kNorad11 = 14;
+const tRoomID kNorad11South = 15;
+const tRoomID kNorad12 = 16;
+const tRoomID kNorad12South = 17;
+const tRoomID kNorad13 = 18;
+const tRoomID kNorad14 = 19;
+const tRoomID kNorad15 = 20;
+const tRoomID kNorad16 = 21;
+const tRoomID kNorad17 = 22;
+const tRoomID kNorad18 = 23;
+const tRoomID kNorad19 = 24;
+const tRoomID kNorad19West = 25;
+const tRoomID kNorad21 = 26;
+const tRoomID kNorad21West = 27;
+const tRoomID kNorad22 = 28;
+const tRoomID kNorad22West = 29;
+
+//	Hot Spot Activation IDs.
+
+
+//	Hot Spot IDs.
+
+const tHotSpotID kNorad01ECRSpotID = 5000;
+const tHotSpotID kNorad01GasSpotID = 5001;
+const tHotSpotID kNorad01ECROutSpotID = 5002;
+const tHotSpotID kNorad01GasOutSpotID = 5003;
+const tHotSpotID kNorad01MonitorSpotID = 5004;
+const tHotSpotID kNorad01IntakeSpotID = 5005;
+const tHotSpotID kNorad01DispenseSpotID = 5006;
+const tHotSpotID kNorad01ArSpotID = 5007;
+const tHotSpotID kNorad01CO2SpotID = 5008;
+const tHotSpotID kNorad01HeSpotID = 5009;
+const tHotSpotID kNorad01OSpotID = 5010;
+const tHotSpotID kNorad01NSpotID = 5011;
+const tHotSpotID kN01GasCanisterSpotID = 5012;
+const tHotSpotID kN01ArgonCanisterSpotID = 5013;
+const tHotSpotID kN01AirMaskSpotID = 5014;
+const tHotSpotID kN01NitrogenCanisterSpotID = 5015;
+const tHotSpotID kN01GasOutletSpotID = 5016;
+const tHotSpotID kNorad07DoorSpotID = 5017;
+const tHotSpotID kNorad07DoorOutSpotID = 5018;
+const tHotSpotID kNorad10DoorSpotID = 5019;
+const tHotSpotID kNorad10EastOutSpotID = 5020;
+const tHotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
+const tHotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
+const tHotSpotID kNorad11ElevatorSpotID = 5023;
+const tHotSpotID kNorad11ElevatorOutSpotID = 5024;
+const tHotSpotID kNorad11ElevatorDownSpotID = 5025;
+const tHotSpotID kNorad12ElevatorSpotID = 5026;
+const tHotSpotID kNorad12ElevatorOutSpotID = 5027;
+const tHotSpotID kNorad12ElevatorUpSpotID = 5028;
+const tHotSpotID kNorad19MonitorSpotID = 5029;
+const tHotSpotID kNorad19MonitorOutSpotID = 5030;
+const tHotSpotID kNorad19ActivateMonitorSpotID = 5031;
+const tHotSpotID kNorad21WestSpotID = 5032;
+const tHotSpotID kNorad21WestOutSpotID = 5033;
+const tHotSpotID kAlphaLowerPressureDoorUpSpotID = 5034;
+const tHotSpotID kAlphaLowerPressureDoorDownSpotID = 5035;
+const tHotSpotID kNorad22MonitorSpotID = 5036;
+const tHotSpotID kNorad22MonitorOutSpotID = 5037;
+const tHotSpotID kNorad22LaunchPrepSpotID = 5038;
+const tHotSpotID kNorad22ClawControlSpotID = 5039;
+const tHotSpotID kNorad22ClawPinchSpotID = 5040;
+const tHotSpotID kNorad22ClawDownSpotID = 5041;
+const tHotSpotID kNorad22ClawRightSpotID = 5042;
+const tHotSpotID kNorad22ClawLeftSpotID = 5043;
+const tHotSpotID kNorad22ClawUpSpotID = 5044;
+const tHotSpotID kNorad22ClawCCWSpotID = 5045;
+const tHotSpotID kNorad22ClawCWSpotID = 5046;
+
+//	Extra sequence IDs.
+
+const tExtraID kNoradArriveFromTSA = 0;
+const tExtraID kNorad01RobotTaunt = 1;
+const tExtraID kNorad01ZoomInWithGasCanister = 2;
+const tExtraID kN01WGasCanister = 3;
+const tExtraID kNorad01ZoomOutWithGasCanister = 4;
+const tExtraID kN01WZEmptyLit = 5;
+const tExtraID kN01WZGasCanisterDim = 6;
+const tExtraID kN01WZGasCanisterLit = 7;
+const tExtraID kN01WZArgonCanisterDim = 8;
+const tExtraID kN01WZArgonCanisterLit = 9;
+const tExtraID kN01WZAirMaskDim = 10;
+const tExtraID kN01WZAirMaskLit = 11;
+const tExtraID kN01WZNitrogenCanisterDim = 12;
+const tExtraID kN01WZNitrogenCanisterLit = 13;
+const tExtraID kNorad04EastDeath = 14;
+const tExtraID kNorad19PrepSub = 15;
+const tExtraID kNorad19ExitToSub = 16;
+const tExtraID kNorad22SouthIntro = 17;
+const tExtraID kNorad22SouthReply = 18;
+const tExtraID kNorad22SouthFinish = 19;
+const tExtraID kN22ClawFromAToB = 20;
+const tExtraID kN22ClawALoop = 21;
+const tExtraID kN22ClawAPinch = 22;
+const tExtraID kN22ClawACounterclockwise = 23;
+const tExtraID kN22ClawAClockwise = 24;
+const tExtraID kN22ClawFromBToA = 25;
+const tExtraID kN22ClawFromBToC = 26;
+const tExtraID kN22ClawFromBToD = 27;
+const tExtraID kN22ClawBLoop = 28;
+const tExtraID kN22ClawBPinch = 29;
+const tExtraID kN22ClawBCounterclockwise = 30;
+const tExtraID kN22ClawBClockwise = 31;
+const tExtraID kN22ClawFromCToB = 32;
+const tExtraID kN22ClawCLoop = 33;
+const tExtraID kN22ClawCPinch = 34;
+const tExtraID kN22ClawCCounterclockwise = 35;
+const tExtraID kN22ClawCClockwise = 36;
+const tExtraID kN22ClawFromDToB = 37;
+const tExtraID kN22ClawDLoop = 38;
+const tExtraID kN22ClawDPinch = 39;
+const tExtraID kN22ClawDCounterclockwise = 40;
+const tExtraID kN22ClawDClockwise = 41;
+
+
+//	Norad Delta Extra sequence IDs.
+
+const tExtraID kArriveFromSubChase = 0;
+const tExtraID kN59ZoomWithRobot = 1;
+const tExtraID kN59RobotApproaches = 2;
+const tExtraID kN59RobotPunchLoop = 3;
+const tExtraID kN59PlayerWins1 = 4;
+const tExtraID kN59PlayerWins2 = 5;
+const tExtraID kN59RobotWins = 6;
+const tExtraID kN59RobotHeadOpens = 7;
+const tExtraID kN59Biochips111 = 8;
+const tExtraID kN59Biochips011 = 9;
+const tExtraID kN59Biochips101 = 10;
+const tExtraID kN59Biochips001 = 11;
+const tExtraID kN59Biochips110 = 12;
+const tExtraID kN59Biochips010 = 13;
+const tExtraID kN59Biochips100 = 14;
+const tExtraID kN59Biochips000 = 15;
+const tExtraID kN59RobotDisappears = 16;
+const tExtraID kN60ClawFromAToB = 17;
+const tExtraID kN60ClawALoop = 18;
+const tExtraID kN60ClawAPinch = 19;
+const tExtraID kN60ClawACounterclockwise = 20;
+const tExtraID kN60ClawAClockwise = 21;
+const tExtraID kN60ClawFromBToA = 22;
+const tExtraID kN60ClawFromBToC = 23;
+const tExtraID kN60ClawFromBToD = 24;
+const tExtraID kN60ClawBLoop = 25;
+const tExtraID kN60ClawBPinch = 26;
+const tExtraID kN60ClawBCounterclockwise = 27;
+const tExtraID kN60ClawBClockwise = 28;
+const tExtraID kN60ClawFromCToB = 29;
+const tExtraID kN60ClawCLoop = 30;
+const tExtraID kN60ClawCPinch = 31;
+const tExtraID kN60ClawCCounterclockwise = 32;
+const tExtraID kN60ClawCClockwise = 33;
+const tExtraID kN60ClawFromDToB = 34;
+const tExtraID kN60ClawDLoop = 35;
+const tExtraID kN60ClawDPinch = 36;
+const tExtraID kN60ClawDCounterclockwise = 37;
+const tExtraID kN60ClawDClockwise = 38;
+const tExtraID kN60RobotApproaches = 39;
+const tExtraID kN60FirstMistake = 40;
+const tExtraID kN60ArmActivated = 41;
+const tExtraID kN60SecondMistake = 42;
+const tExtraID kN60ArmToPositionB = 43;
+const tExtraID kN60ThirdMistake = 44;
+const tExtraID kN60ArmGrabsRobot = 45;
+const tExtraID kN60FourthMistake = 46;
+const tExtraID kN60ArmCarriesRobotToPositionA = 47;
+const tExtraID kN60PlayerFollowsRobotToDoor = 48;
+const tExtraID kN60RobotHeadOpens = 49;
+const tExtraID kN60Biochips111 = 50;
+const tExtraID kN60Biochips011 = 51;
+const tExtraID kN60Biochips101 = 52;
+const tExtraID kN60Biochips001 = 53;
+const tExtraID kN60Biochips110 = 54;
+const tExtraID kN60Biochips010 = 55;
+const tExtraID kN60Biochips100 = 56;
+const tExtraID kN60Biochips000 = 57;
+const tExtraID kN60RobotDisappears = 58;
+const tExtraID kNoradDeltaRetinalScanBad = 59;
+const tExtraID kNoradDeltaRetinalScanGood = 60;
+const tExtraID kN79BrightView = 61;
+
+// Norad Delta Tables
+
+const TimeScale kNoradDeltaMovieScale = 600;
+const TimeScale kNoradDeltaFramesPerSecond = 15;
+const TimeScale kNoradDeltaFrameDuration = 40;
+
+//	Alternate IDs.
+
+const tAlternateID kAltNoradDeltaNormal = 0;
+
+//	Room IDs.
+
+const tRoomID kNorad41 = 0;
+const tRoomID kNorad42 = 1;
+const tRoomID kNorad43 = 2;
+const tRoomID kNorad44 = 3;
+const tRoomID kNorad45 = 4;
+const tRoomID kNorad46 = 5;
+const tRoomID kNorad47 = 6;
+const tRoomID kNorad48 = 7;
+const tRoomID kNorad48South = 8;
+const tRoomID kNorad49 = 9;
+const tRoomID kNorad49South = 10;
+const tRoomID kNorad50 = 11;
+const tRoomID kNorad50East = 12;
+const tRoomID kNorad51 = 13;
+const tRoomID kNorad52 = 14;
+const tRoomID kNorad53 = 15;
+const tRoomID kNorad54 = 16;
+const tRoomID kNorad54North = 17;
+const tRoomID kNorad55 = 18;
+const tRoomID kNorad56 = 19;
+const tRoomID kNorad57 = 20;
+const tRoomID kNorad58 = 21;
+const tRoomID kNorad59 = 22;
+const tRoomID kNorad59West = 23;
+const tRoomID kNorad60 = 24;
+const tRoomID kNorad60West = 25;
+const tRoomID kNorad61 = 26;
+const tRoomID kNorad62 = 27;
+const tRoomID kNorad63 = 28;
+const tRoomID kNorad64 = 29;
+const tRoomID kNorad65 = 30;
+const tRoomID kNorad66 = 31;
+const tRoomID kNorad67 = 32;
+const tRoomID kNorad68 = 33;
+const tRoomID kNorad68West = 34;
+const tRoomID kNorad69 = 35;
+const tRoomID kNorad78 = 36;
+const tRoomID kNorad79 = 37;
+const tRoomID kNorad79West = 38;
+
+//	Hot Spot Activation IDs.
+
+
+//	Hot Spot IDs.
+
+const tHotSpotID kNorad48ElevatorSpotID = 5000;
+const tHotSpotID kNorad48ElevatorOutSpotID = 5001;
+const tHotSpotID kNorad48ElevatorUpSpotID = 5002;
+const tHotSpotID kNorad49ElevatorSpotID = 5003;
+const tHotSpotID kNorad49ElevatorOutSpotID = 5004;
+const tHotSpotID kNorad49ElevatorDownSpotID = 5005;
+const tHotSpotID kNorad50DoorSpotID = 5006;
+const tHotSpotID kNorad50DoorOutSpotID = 5007;
+const tHotSpotID kDeltaUpperPressureDoorUpSpotID = 5008;
+const tHotSpotID kDeltaUpperPressureDoorDownSpotID = 5009;
+const tHotSpotID kNorad54DoorSpotID = 5010;
+const tHotSpotID kNorad54DoorOutSpotID = 5011;
+const tHotSpotID kNorad59WestSpotID = 5012;
+const tHotSpotID kNorad59WestOutSpotID = 5013;
+const tHotSpotID kDeltaLowerPressureDoorUpSpotID = 5014;
+const tHotSpotID kDeltaLowerPressureDoorDownSpotID = 5015;
+const tHotSpotID kDelta59RobotHeadSpotID = 5016;
+const tHotSpotID kDelta59RobotShieldBiochipSpotID = 5017;
+const tHotSpotID kDelta59RobotOpMemBiochipSpotID = 5018;
+const tHotSpotID kDelta59RobotRetinalBiochipSpotID = 5019;
+const tHotSpotID kNorad60MonitorSpotID = 5020;
+const tHotSpotID kNorad60MonitorOutSpotID = 5021;
+const tHotSpotID kNorad60LaunchPrepSpotID = 5022;
+const tHotSpotID kNorad60ClawControlSpotID = 5023;
+const tHotSpotID kNorad60ClawPinchSpotID = 5024;
+const tHotSpotID kNorad60ClawDownSpotID = 5025;
+const tHotSpotID kNorad60ClawRightSpotID = 5026;
+const tHotSpotID kNorad60ClawLeftSpotID = 5027;
+const tHotSpotID kNorad60ClawUpSpotID = 5028;
+const tHotSpotID kNorad60ClawCCWSpotID = 5029;
+const tHotSpotID kNorad60ClawCWSpotID = 5030;
+const tHotSpotID kDelta60RobotHeadSpotID = 5031;
+const tHotSpotID kDelta60RobotShieldBiochipSpotID = 5032;
+const tHotSpotID kDelta60RobotOpMemBiochipSpotID = 5033;
+const tHotSpotID kDelta60RobotRetinalBiochipSpotID = 5034;
+const tHotSpotID kNorad68WestSpotID = 5035;
+const tHotSpotID kNorad68WestOutSpotID = 5036;
+const tHotSpotID kNorad79WestSpotID = 5037;
+const tHotSpotID kNorad79WestOutSpotID = 5038;
+const tHotSpotID kNorad79SpinLeftSpotID = 5039;
+const tHotSpotID kNorad79SpinRightSpotID = 5040;
+const tHotSpotID kNorad79SpinUpSpotID = 5041;
+const tHotSpotID kNorad79SpinDownSpotID = 5042;
+const tHotSpotID kNorad79SiloAreaSpotID = 5043;
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.cpp b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
new file mode 100755
index 0000000..39cccc6
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
@@ -0,0 +1,1064 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/cursor.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/constants.h"
+#include "pegasus/neighborhood/norad/delta/globegame.h"
+#include "pegasus/neighborhood/norad/delta/noraddelta.h"
+
+namespace Pegasus {
+
+static const TimeValue kDurationPerFrame = 600 / 15;
+static const TimeValue kDurationPerRow = kNumLongSlices * kDurationPerFrame;
+static const short kVerticalDuration = 16;
+
+GlobeTracker::GlobeTracker(Movie *globeMovie, Picture *leftHighlight, Picture *rightHighlight,
+		Picture *upHighlight, Picture *downHighlight) {
+	_globeMovie = globeMovie;
+	_leftHighlight = leftHighlight;
+	_rightHighlight = rightHighlight;
+	_upHighlight = upHighlight;
+	_downHighlight = downHighlight;
+}
+
+void GlobeTracker::setTrackParameters(const Hotspot *trackSpot, GlobeTrackDirection direction) {
+	_trackSpot = trackSpot;
+	_trackDirection = direction;
+
+	TimeValue time, newTime, start;
+
+	switch (_trackDirection) {
+	case kTrackLeft:
+		time = _globeMovie->getTime();
+
+		if (((time / kDurationPerRow) & 1) == 0) {
+			start = (time / kDurationPerRow + 1) * kDurationPerRow;
+			newTime = start + kDurationPerRow - time % kDurationPerRow;
+		} else {
+			start = (time / kDurationPerRow) * kDurationPerRow;
+			newTime = time;
+		}
+
+		_globeMovie->setSegment(start, start + kDurationPerRow);
+
+		if (newTime != time) {
+			_globeMovie->setTime(newTime);
+			_globeMovie->redrawMovieWorld();
+		}
+
+		_globeMovie->setFlags(kLoopTimeBase);
+		break;
+	case kTrackRight:
+		time = _globeMovie->getTime();
+
+		if (((time / kDurationPerRow) & 1) == 0) {
+			start = (time / kDurationPerRow) * kDurationPerRow;
+			newTime = time;
+		} else {
+			start = (time / kDurationPerRow - 1) * kDurationPerRow;
+			newTime = start + kDurationPerRow - time % kDurationPerRow;
+		}
+
+		_globeMovie->setSegment(start, start + kDurationPerRow);
+
+		if (newTime != time) {
+			_globeMovie->setTime(newTime);
+			_globeMovie->redrawMovieWorld();
+		}
+
+		_globeMovie->setFlags(kLoopTimeBase);
+		break;
+	case kTrackUp:
+	case kTrackDown:
+		_globeMovie->setSegment(0, _globeMovie->getDuration());
+		_globeMovie->setFlags(0);
+		break;
+	}
+}
+
+void GlobeTracker::activateHotspots() {
+	Tracker::activateHotspots();
+
+	if (_trackSpot)
+		g_allHotspots.activateOneHotspot(_trackSpot->getObjectID());
+}
+
+bool GlobeTracker::stopTrackingInput(const Input &input) {
+	return !JMPPPInput::isPressingInput(input);
+}
+
+void GlobeTracker::continueTracking(const Input &input) {
+	Common::Point where;
+	input.getInputLocation(where);
+
+	if (g_allHotspots.findHotspot(where) == _trackSpot)
+		trackGlobeMovie();
+	else
+		stopGlobeMovie();
+}
+
+void GlobeTracker::startTracking(const Input &input) {
+	Tracker::startTracking(input);
+	trackGlobeMovie();
+}
+
+void GlobeTracker::stopTracking(const Input &input) {
+	Tracker::stopTracking(input);
+	stopGlobeMovie();
+}
+
+void GlobeTracker::trackGlobeMovie() {
+	TimeValue time;
+
+	switch (_trackDirection) {
+	case kTrackLeft:
+		if (!_globeMovie->isRunning())
+			_globeMovie->start();
+
+		_leftHighlight->show();
+		break;
+	case kTrackRight:
+		if (!_globeMovie->isRunning())
+			_globeMovie->start();
+
+		_rightHighlight->show();
+		break;
+	case kTrackUp:
+		time = _globeMovie->getTime();
+
+		if (_trackTime == 0) {
+			_trackTime = tickCount();
+		} else if ((int)time - (int)kDurationPerRow * 2 >= 0 && (int)tickCount() >= _trackTime + kVerticalDuration) {
+			_trackTime = tickCount();
+			_globeMovie->setTime(time - kDurationPerRow * 2);
+			_globeMovie->redrawMovieWorld();
+		}
+
+		_upHighlight->show();
+		break;
+	case kTrackDown:
+		time = _globeMovie->getTime();
+
+		if (_trackTime == 0) {
+			_trackTime = tickCount();
+		} else if (time + kDurationPerRow * 2 < _globeMovie->getDuration() && (int)tickCount() >= _trackTime + kVerticalDuration) {
+			_trackTime = tickCount();
+			_globeMovie->setTime(time + kDurationPerRow * 2);
+			_globeMovie->redrawMovieWorld();
+		}
+
+		_downHighlight->show();
+		break;
+	}
+}
+
+void GlobeTracker::stopGlobeMovie() {
+	switch (_trackDirection) {
+	case kTrackLeft:
+		_leftHighlight->hide();
+		_globeMovie->stop();
+		break;
+	case kTrackRight:
+		_rightHighlight->hide();
+		_globeMovie->stop();
+		break;
+	case kTrackUp:
+		_upHighlight->hide();
+		_trackTime = tickCount() - kVerticalDuration;
+		break;
+	case kTrackDown:
+		_downHighlight->hide();
+		_trackTime = tickCount() - kVerticalDuration;
+		break;
+	}
+}
+
+//	Globe game PICTs:
+
+static const tResIDType kGlobeCircleLeftPICTID = 300;
+static const tResIDType kGlobeCircleRightPICTID = 301;
+static const tResIDType kGlobeCircleUpPICTID = 302;
+static const tResIDType kGlobeCircleDownPICTID = 303;
+static const tResIDType kTargetUpperLeftPICTID = 304;
+static const tResIDType kTargetUpperRightPICTID = 305;
+static const tResIDType kTargetLowerLeftPICTID = 306;
+static const tResIDType kTargetLowerRightPICTID = 307;
+static const tResIDType kMotionHiliteLeftPICTID = 308;
+static const tResIDType kMotionHiliteRightPICTID = 309;
+static const tResIDType kMotionHiliteUpPICTID = 310;
+static const tResIDType kMotionHiliteDownPICTID = 311;
+
+const tResIDType kGlobeCountdownDigitsID = 350;
+
+static const int kGlobeCountdownWidth = 28;
+static const int kGlobeCountdownHeight = 12;
+static const int kGlobeCountdownOffset1 = 12;
+static const int kGlobeCountdownOffset2 = 20;
+
+GlobeCountdown::GlobeCountdown(const tDisplayElementID id) : IdlerAnimation(id) {	
+	_digits.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kGlobeCountdownDigitsID);
+
+	Common::Rect r;
+	_digits.getSurfaceBounds(r);
+	_digitOffset = r.width() / 10;
+	setScale(1);
+	sizeElement(kGlobeCountdownWidth, kGlobeCountdownHeight);
+}
+
+void GlobeCountdown::setDisplayOrder(const tDisplayOrder order) {
+	IdlerAnimation::setDisplayOrder(order);
+}
+
+void GlobeCountdown::show() {
+	IdlerAnimation::show();
+}
+
+void GlobeCountdown::hide() {
+	IdlerAnimation::hide();
+}
+
+void GlobeCountdown::moveElementTo(const tCoordType x, const tCoordType y) {
+	IdlerAnimation::moveElementTo(x, y);
+}
+
+void GlobeCountdown::setCountdownTime(const int numSeconds) {
+	stop();
+	setSegment(0, numSeconds);
+	setTime(numSeconds);
+}
+
+void GlobeCountdown::startCountdown() {
+	setRate(-1);
+}
+
+void GlobeCountdown::stopCountdown() {
+	stop();
+}
+
+void GlobeCountdown::draw(const Common::Rect &) {
+	Common::Rect r1;
+	_digits.getSurfaceBounds(r1);
+	r1.right = r1.left + _digitOffset;
+	Common::Rect r2 = r1;
+	TimeValue time = getTime();
+
+	Common::Rect bounds;
+	getBounds(bounds);
+
+	if (time > 60 * 9 + 59) {
+		r2.moveTo(bounds.left, bounds.top);
+		r1.moveTo(9 * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+		
+		r2.moveTo(bounds.left + kGlobeCountdownOffset1, bounds.top);
+		r1.moveTo(5 * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+		
+		r2.moveTo(bounds.left + kGlobeCountdownOffset2, bounds.top);
+		r1.moveTo(9 * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+	} else {
+		r2.moveTo(bounds.left, bounds.top);
+		r1.moveTo((time / 60) * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+		
+		time %= 60;
+		r2.moveTo(bounds.left + kGlobeCountdownOffset1, bounds.top);
+		r1.moveTo((time / 10) * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+		
+		r2.moveTo(bounds.left + kGlobeCountdownOffset2, bounds.top);
+		r1.moveTo((time % 10) * _digitOffset, 0);
+		_digits.copyToCurrentPort(r1, r2);
+	}
+}
+
+const int16 GlobeGame::_siloCoords[kNumAllSilos][2] = {
+	{ 60, -151 }, // Anchorage, Alaska
+	{ 6, 39 },    // Addis Ababa, Ethiopia
+	{ -22, 44 },  // Antaro, Madagascar
+	{ 30, -83 },  // Atlanta, Georgia
+	{ -41, 173 }, // Auckland, New Zealand
+	{ 39, -78 },  // Baltimore, Maryland
+	{ 11, 101 },  // Bangkok, Thailand
+	{ 2, -75 },   // Bogota, Colombia
+	{ 46, 4 },    // Bonn, Germany
+	{ 51, -7 },   // Dublin, Ireland
+	{ 28, -1 },   // El Menia, Algeria
+	{ 67, -111 }, // Ellesmere, Canada
+	{ 43, -107 }, // Glasgow, Montana
+	{ 61, -48 },  // Godthab, Greenland
+	{ 19, -157 }, // Honolulu, Hawaii
+	{ 6, 5 },     // Ibadan, Nigeria
+	{ -29, 26 },  // Johannesburg, South Africa
+	{ 46, 92 },   // Kobdo, Mongolia
+	{ -15, -63 }, // La Paz, Bolivia
+	{ -35, -61 }, // La Plata, Argentina
+	{ -9, -76 },  // Lima, Peru
+	{ 38, -4 },   // Madrid, Spain
+	{ -8, -51 },  // Manaus, Brazil
+	{ 13, 120 },  // Manila, Phillipines
+	{ -35, 143 }, // Melbourne, Australia
+	{ 60, -161 }, // Nome, Alaska
+	{ -7, 142 },  // Papua, New Guinea
+	{ -32, 117 }, // Perth, West Australia
+	{ 34, -114 }, // Phoenix, Arizona
+	{ 18, -71 },  // Port-Au-Prince, Haiti
+	{ 42, -121 }, // Portland, Oregon
+	{ 61, -20 },  // Reykjavik, Iceland
+	{ -22, -46 }, // Rio de Janeiro
+	{ 27, -101 }, // San Antonio, Texas
+	{ 34, 126 },  // Seoul, Korea
+	{ 37, -87 },  // Saint Louis, Missouri
+	{ 60, 30 },   // Saint Petersberg, Russia
+	{ 56, 12 },   // Stockholm, Sweden
+	{ 51, 105 },  // Svortalsk, Siberia
+	{ 36, -96 }   // Tulsa, Oklahoma
+};
+
+const int16 GlobeGame::_targetSilo[kNumTargetSilos] = {
+	14, 9, 1, 33, 6, 8, 34, 31, 38, 21
+};
+
+const short GlobeGame::_timeLimit[kNumTargetSilos] = {
+	120, 110, 100, 90, 80, 70, 60, 50, 40, 30
+};
+
+const TimeValue GlobeGame::_siloName[kNumTargetSilos][2] = {
+	{ kHonoluluIn, kHonoluluOut },
+	{ kDublinIn, kDublinOut },
+	{ kAddisAbabaIn, kAddisAbabaOut },
+	{ kSanAntonioIn, kSanAntonioOut },
+	{ kBangkokIn, kBangkokOut },
+	{ kBonnIn, kBonnOut },
+	{ kSeoulIn, kSeoulOut },
+	{ kReykjavikIn, kReykjavikOut },
+	{ kSvortalskIn, kSvortalskOut },
+	{ kMadridIn, kMadridOut }
+};
+
+// From globe room models
+
+static const GlobeGame::Point3D kCameraLocation = { 0.53f, 4.4f, -0.86f };
+static const GlobeGame::Point3D kGlobeCenter = { -31.5f, 8.0f, 0.0f };
+static const float kGlobeRadius = 8.25f;
+static const int16 kDegreesPerLongSlice = 360 / kNumLongSlices;
+static const int16 kDegreesPerLatSlice = 25;
+static const int16 kLongOrigin = -95;
+
+// Other constants.
+
+static const float kTanFieldOfView = 0.7082373180482f;
+static const float kPicturePlaneDistance = 10.0f; // Completely arbitrary.
+static const int16 kLatError = 2;
+static const int16 kLongError = 2;
+static const TimeValue kGlobeMovieStartTime = 2 * 2 * kNumLongSlices * 600 / 15;
+
+static const TimeValue kTimePerGlobeFrame = 40;
+
+static const tNotificationFlags kGlobeSplash1Finished = 1;
+static const tNotificationFlags kGlobeTimerExpired = kGlobeSplash1Finished << 1;
+static const tNotificationFlags kMaxDeactivatedFinished = kGlobeTimerExpired << 1;
+
+static const tNotificationFlags kGlobeNotificationFlags = kGlobeSplash1Finished |
+													kGlobeTimerExpired |
+													kMaxDeactivatedFinished;
+
+static const int16 kSplash1End = 4;
+static const int16 kSplash2End = 5;
+static const int16 kSplash3Start = 8;
+static const int16 kSplash3Stop = 9;
+static const int16 kSplash4Start = 9;
+static const int16 kSplash4Stop = 10;
+static const int16 kNewLaunchSiloTime = 10;
+static const int16 kSiloDeactivatedTime = 11;
+static const int16 kMissileLaunchedTime = 12;
+static const int16 kMaxDeactivatedStart = 13;
+static const int16 kMaxDeactivatedStop = 23;
+
+static const int16 kGamePlaying = 1;
+static const int16 kGameOver = 2;
+
+enum {
+	kGameIntro,
+	kPlayingRobotIntro,
+	kPlayingStrikeAuthorized,
+	kPlayingPrimaryTarget,
+	kPlayingNewSilo1,
+	kPlayingNewSilo2,
+	kPlayingNewSilo3,
+	kPlayingTime,
+	kPlayingInstructions,
+	kWaitingForPlayer,
+	kSiloDeactivated,
+	kRobotTaunting,
+	kDelayingPlayer,
+	kPlayerWon1,
+	kPlayerWon2,
+	kPlayerLost1
+};
+
+// TODO: Use ScummVM equivalent
+
+static const float kPI = 3.1415926535f;
+
+float degreesToRadians(float angle) {
+	return (angle * kPI) / 180;
+}
+
+float radiansToDegrees(float angle) {
+	return (angle * 180) / kPI;
+}
+
+GlobeGame::GlobeGame(Neighborhood* handler) : GameInteraction(kNoradGlobeGameInteractionID, handler),
+		_monitorMovie(kGlobeMonitorID), _globeMovie(kGlobeMovieID), _upperNamesMovie(kGlobeUpperNamesID),
+		_lowerNamesMovie(kGlobeLowerNamesID), _globeNotification(kNoradGlobeNotificationID, (PegasusEngine *)g_engine),
+		_globeCircleLeft(kGlobeCircleLeftID), _globeCircleRight(kGlobeCircleRightID),
+		_globeCircleUp(kGlobeCircleUpID), _globeCircleDown(kGlobeCircleDownID),
+		_motionHighlightLeft(kMotionHiliteLeftID), _motionHighlightRight(kMotionHiliteRightID),
+		_motionHighlightUp(kMotionHiliteUpID), _motionHighlightDown(kMotionHiliteDownID),
+		_targetHighlightUpperLeft(kTargetHiliteUpperLeftID), _targetHighlightUpperRight(kTargetHiliteUpperRightID),
+		_targetHighlightLowerLeft(kTargetHiliteLowerLeftID), _targetHighlightLowerRight(kTargetHiliteLowerRightID),
+		_globeTracker(&_globeMovie, &_motionHighlightLeft, &_motionHighlightRight, &_motionHighlightUp,
+				&_motionHighlightDown), _countdown(kGlobeCountdownID) {
+	_neighborhoodNotification = handler->getNeighborhoodNotification();
+}
+
+void GlobeGame::openInteraction() {
+	_monitorMovie.initFromMovieFile("Images/Norad Delta/N79 Left Monitor");
+	_monitorMovie.moveElementTo(kGlobeMonitorLeft, kGlobeMonitorTop);
+	_monitorMovie.setDisplayOrder(kGlobeMonitorLayer);
+	_monitorMovie.startDisplaying();
+	_monitorMovie.setSegment(0, kSplash1End * _monitorMovie.getScale());
+	_monitorMovie.show();
+	
+	_monitorCallBack.setNotification(&_globeNotification);
+	_monitorCallBack.initCallBack(&_monitorMovie, kCallBackAtExtremes);
+	_monitorCallBack.setCallBackFlag(kGlobeSplash1Finished);
+	_monitorCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+
+	_upperNamesMovie.initFromMovieFile("Images/Norad Delta/Upper Names");
+	_upperNamesMovie.moveElementTo(kGlobeUpperNamesLeft, kGlobeUpperNamesTop);
+	_upperNamesMovie.setDisplayOrder(kGlobeUpperNamesLayer);
+	_upperNamesMovie.startDisplaying();
+
+	_lowerNamesMovie.initFromMovieFile("Images/Norad Delta/Lower Names");
+	_lowerNamesMovie.moveElementTo(kGlobeLowerNamesLeft, kGlobeLowerNamesTop);
+	_lowerNamesMovie.setDisplayOrder(kGlobeLowerNamesLayer);
+	_lowerNamesMovie.startDisplaying();
+
+	_globeMovie.initFromMovieFile("Images/Norad Delta/Spinning Globe");
+	_globeMovie.moveElementTo(kGlobeLeft, kGlobeTop);
+	_globeMovie.setDisplayOrder(kGlobeMovieLayer);
+	_globeMovie.startDisplaying();
+	_globeMovie.setTime(kGlobeMovieStartTime);
+	_globeMovie.redrawMovieWorld();
+
+	_globeCircleLeft.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kGlobeCircleLeftPICTID, true);
+	_globeCircleLeft.moveElementTo(kGlobeCircleLeftLeft, kGlobeCircleLeftTop);
+	_globeCircleLeft.setDisplayOrder(kGlobeCircleLayer);
+	_globeCircleLeft.startDisplaying();
+
+	_globeCircleRight.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kGlobeCircleRightPICTID, true);
+	_globeCircleRight.moveElementTo(kGlobeCircleRightLeft, kGlobeCircleRightTop);
+	_globeCircleRight.setDisplayOrder(kGlobeCircleLayer);
+	_globeCircleRight.startDisplaying();
+
+	_globeCircleUp.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kGlobeCircleUpPICTID, true);
+	_globeCircleUp.moveElementTo(kGlobeCircleUpLeft, kGlobeCircleUpTop);
+	_globeCircleUp.setDisplayOrder(kGlobeCircleLayer);
+	_globeCircleUp.startDisplaying();
+
+	_globeCircleDown.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kGlobeCircleDownPICTID, true);
+	_globeCircleDown.moveElementTo(kGlobeCircleDownLeft, kGlobeCircleDownTop);
+	_globeCircleDown.setDisplayOrder(kGlobeCircleLayer);
+	_globeCircleDown.startDisplaying();
+
+	_motionHighlightLeft.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMotionHiliteLeftPICTID, true);
+	_motionHighlightLeft.moveElementTo(kGlobeLeftMotionHiliteLeft, kGlobeLeftMotionHiliteTop);
+	_motionHighlightLeft.setDisplayOrder(kGlobeHilitesLayer);
+	_motionHighlightLeft.startDisplaying();
+
+	_motionHighlightRight.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMotionHiliteRightPICTID, true);
+	_motionHighlightRight.moveElementTo(kGlobeRightMotionHiliteLeft, kGlobeRightMotionHiliteTop);
+	_motionHighlightRight.setDisplayOrder(kGlobeCircleLayer);
+	_motionHighlightRight.startDisplaying();
+
+	_motionHighlightUp.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMotionHiliteUpPICTID, true);
+	_motionHighlightUp.moveElementTo(kGlobeUpMotionHiliteLeft, kGlobeUpMotionHiliteTop);
+	_motionHighlightUp.setDisplayOrder(kGlobeHilitesLayer);
+	_motionHighlightUp.startDisplaying();
+
+	_motionHighlightDown.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kMotionHiliteDownPICTID, true);
+	_motionHighlightDown.moveElementTo(kGlobeDownMotionHiliteLeft, kGlobeDownMotionHiliteTop);
+	_motionHighlightDown.setDisplayOrder(kGlobeHilitesLayer);
+	_motionHighlightDown.startDisplaying();
+
+	_targetHighlightUpperLeft.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTargetUpperLeftPICTID, true);
+	_targetHighlightUpperLeft.moveElementTo(kGlobeUpperLeftHiliteLeft, kGlobeUpperLeftHiliteTop);
+	_targetHighlightUpperLeft.setDisplayOrder(kGlobeHilitesLayer);
+	_targetHighlightUpperLeft.startDisplaying();
+
+	_targetHighlightUpperRight.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTargetUpperRightPICTID, true);
+	_targetHighlightUpperRight.moveElementTo(kGlobeUpperRightHiliteLeft, kGlobeUpperRightHiliteTop);
+	_targetHighlightUpperRight.setDisplayOrder(kGlobeHilitesLayer);
+	_targetHighlightUpperRight.startDisplaying();
+
+	_targetHighlightLowerLeft.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTargetLowerLeftPICTID, true);
+	_targetHighlightLowerLeft.moveElementTo(kGlobeLowerLeftHiliteLeft, kGlobeLowerLeftHiliteTop);
+	_targetHighlightLowerLeft.setDisplayOrder(kGlobeHilitesLayer);
+	_targetHighlightLowerLeft.startDisplaying();
+
+	_targetHighlightLowerRight.initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTargetLowerRightPICTID, true);
+	_targetHighlightLowerRight.moveElementTo(kGlobeLowerRightHiliteLeft, kGlobeLowerRightHiliteTop);
+	_targetHighlightLowerRight.setDisplayOrder(kGlobeHilitesLayer);
+	_targetHighlightLowerRight.startDisplaying();
+
+	_countdown.setDisplayOrder(kGlobeCountdownLayer);
+	_countdown.moveElementTo(kGlobeCountdownLeft, kGlobeCountdownTop);
+	_countdown.startDisplaying();
+	_countdown.setCountdownTime(_timeLimit[0]);
+
+	_countdownCallBack.setNotification(&_globeNotification);
+	_countdownCallBack.initCallBack(&_countdown, kCallBackAtExtremes);
+	_countdownCallBack.setCallBackFlag(kGlobeTimerExpired);
+	_countdownCallBack.scheduleCallBack(kTriggerAtStart, 0, 0);
+
+	_globeNotification.notifyMe(this, kGlobeNotificationFlags, kGlobeNotificationFlags);
+
+	_gameState = kGameIntro;
+	_currentSiloIndex = 0;
+	_playedInstructions = false;
+
+	_neighborhoodNotification->notifyMe(this, kDelayCompletedFlag | kSpotSoundCompletedFlag, kDelayCompletedFlag | kSpotSoundCompletedFlag);
+}
+
+void GlobeGame::initInteraction() {
+	_monitorMovie.start();
+	_monitorMovie.redrawMovieWorld();
+}
+
+void GlobeGame::closeInteraction() {
+	_monitorMovie.stop();
+	_monitorMovie.stopDisplaying();
+	_monitorMovie.releaseMovie();
+	_monitorCallBack.releaseCallBack();
+
+	_globeMovie.stop();
+	_globeMovie.stopDisplaying();
+	_globeMovie.releaseMovie();
+	_globeNotification.cancelNotification(this);
+
+	_upperNamesMovie.stop();
+	_upperNamesMovie.stopDisplaying();
+	_upperNamesMovie.releaseMovie();
+
+	_lowerNamesMovie.stop();
+	_lowerNamesMovie.stopDisplaying();
+	_lowerNamesMovie.releaseMovie();
+
+	_countdown.hide();
+	_countdown.stopDisplaying();
+	_countdownCallBack.releaseCallBack();
+
+	_globeCircleLeft.stopDisplaying();
+	_globeCircleLeft.deallocateSurface();
+	_globeCircleRight.stopDisplaying();
+	_globeCircleRight.deallocateSurface();
+	_globeCircleUp.stopDisplaying();
+	_globeCircleUp.deallocateSurface();
+	_globeCircleDown.stopDisplaying();
+	_globeCircleDown.deallocateSurface();
+
+	_motionHighlightLeft.stopDisplaying();
+	_motionHighlightLeft.deallocateSurface();
+	_motionHighlightRight.stopDisplaying();
+	_motionHighlightRight.deallocateSurface();
+	_motionHighlightUp.stopDisplaying();
+	_motionHighlightUp.deallocateSurface();
+	_motionHighlightDown.stopDisplaying();
+	_motionHighlightDown.deallocateSurface();
+
+	_targetHighlightUpperLeft.stopDisplaying();
+	_targetHighlightUpperLeft.deallocateSurface();
+	_targetHighlightUpperRight.stopDisplaying();
+	_targetHighlightUpperRight.deallocateSurface();
+	_targetHighlightLowerLeft.stopDisplaying();
+	_targetHighlightLowerLeft.deallocateSurface();
+	_targetHighlightLowerRight.stopDisplaying();
+	_targetHighlightLowerRight.deallocateSurface();
+
+	_neighborhoodNotification->cancelNotification(this);
+}
+
+void GlobeGame::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+	TimeScale scale = _monitorMovie.getScale();
+
+	if (notification == _neighborhoodNotification) {
+		switch (_gameState) {
+		case kPlayingRobotIntro:
+			_monitorMovie.stop();
+			_monitorMovie.setSegment(0, _monitorMovie.getDuration());
+			_monitorMovie.setTime(kSplash2End * scale - 1);
+			_monitorMovie.setFlags(0);
+
+			_owner->requestDelay(1, 2, kFilterNoInput, 0);
+			_owner->requestSpotSound(kStrikeAuthorizedIn, kStrikeAuthorizedOut,
+					kFilterNoInput, kSpotSoundCompletedFlag);
+			_gameState = kPlayingStrikeAuthorized;
+			break;
+		case kPlayingStrikeAuthorized:
+			_monitorMovie.setSegment(kSplash3Start * scale, kSplash3Stop * scale);
+			_monitorMovie.setTime(kSplash3Start * scale);
+			_monitorMovie.redrawMovieWorld();
+
+			_owner->requestDelay(1, 3, kFilterNoInput, 0);
+			_owner->requestSpotSound(kPrimaryTargetIn, kPrimaryTargetOut, kFilterNoInput, 0);
+			_owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
+			_monitorMovie.start();
+			_gameState = kPlayingPrimaryTarget;
+			break;
+		case kPlayingPrimaryTarget:
+			_monitorMovie.stop();
+			_monitorMovie.setSegment(0, _monitorMovie.getDuration());
+			_monitorMovie.setTime(kNewLaunchSiloTime * scale);
+			_owner->requestSpotSound(kNewLaunchSiloIn, kNewLaunchSiloOut, kFilterNoInput,
+					kSpotSoundCompletedFlag);
+			_gameState = kPlayingNewSilo1;
+			break;
+		case kPlayingNewSilo1:
+			_monitorMovie.stop();
+			_monitorMovie.setSegment(0, _monitorMovie.getDuration());
+			_owner->requestDelay(1, 3, kFilterNoInput, kDelayCompletedFlag);
+			_gameState = kPlayingNewSilo2;
+			break;
+		case kPlayingNewSilo2:
+			_upperNamesMovie.show();
+			_upperNamesMovie.setTime(_currentSiloIndex * _upperNamesMovie.getScale());
+			_upperNamesMovie.redrawMovieWorld();
+			_monitorMovie.setTime(kSplash4Stop * scale - 1);
+			_monitorMovie.redrawMovieWorld();
+			_owner->requestSpotSound(_siloName[_currentSiloIndex][0], _siloName[_currentSiloIndex][1], kFilterNoInput, 0);
+			_owner->requestDelay(1, 3, kFilterNoInput, 0);
+			_owner->requestSpotSound(kLaunchToProceedIn, kLaunchToProceedOut, kFilterNoInput, 0);
+			_owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
+			_gameState = kPlayingNewSilo3;
+			break;
+		case kPlayingNewSilo3:
+			_countdown.stopCountdown();
+			_countdown.setCountdownTime(_timeLimit[_currentSiloIndex]);
+			_countdown.show();
+			_gameState = kPlayingTime;
+
+			if (_timeLimit[_currentSiloIndex] >= 120)
+				_owner->requestSpotSound(kTwoMinutesIn, kTwoMinutesOut, kFilterNoInput, 0);
+			else if (_timeLimit[_currentSiloIndex] >= 60)
+				_owner->requestSpotSound(kOneMinuteIn, kOneMinuteOut, kFilterNoInput, 0);
+
+			switch (_timeLimit[_currentSiloIndex] % 60) {
+			case 0:
+				_owner->requestDelay(1, 5, kFilterNoInput, kDelayCompletedFlag);
+				break;
+			case 10:
+				_owner->requestDelay(1, 5, kFilterNoInput, 0);
+				_owner->requestSpotSound(kTenSecondsIn, kTenSecondsOut, kFilterNoInput,
+						kSpotSoundCompletedFlag);
+				break;
+			case 20:
+				_owner->requestDelay(1, 5, kFilterNoInput, 0);
+				_owner->requestSpotSound(kTwentySecondsIn, kTwentySecondsOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			case 30:
+				_owner->requestDelay(1, 5, kFilterNoInput, 0);
+				_owner->requestSpotSound(kThirtySecondsIn, kThirtySecondsOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			case 40:
+				_owner->requestDelay(1, 5, kFilterNoInput, 0);
+				_owner->requestSpotSound(kFortySecondsIn, kFortySecondsOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			case 50:
+				_owner->requestDelay(1, 5, kFilterNoInput, 0);
+				_owner->requestSpotSound(kFiftySecondsIn, kFiftySecondsOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			}
+		case kPlayingTime:
+			_gameState = kPlayingInstructions;
+			_globeMovie.show();
+			_globeCircleLeft.show();
+			_globeCircleRight.show();
+			_globeCircleUp.show();
+			_globeCircleDown.show();
+
+			if (_playedInstructions) {
+				receiveNotification(notification, flags);
+			} else {
+				_owner->requestSpotSound(kToDeactivateIn, kToDeactivateOut, kFilterNoInput,
+						kSpotSoundCompletedFlag);
+				_playedInstructions = true;
+			}
+			break;
+		case kPlayingInstructions:
+			_gameState = kWaitingForPlayer;
+			_countdown.startCountdown();
+			break;
+		case kSiloDeactivated:
+			_gameState = kRobotTaunting;
+
+			switch (_currentSiloIndex) {
+			case 3:
+				_owner->requestSpotSound(kYouCannotPossiblyIn, kYouCannotPossiblyOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			case 5:
+				_owner->requestSpotSound(kYouWillFailIn, kYouWillFailOut, kFilterNoInput,
+						kSpotSoundCompletedFlag);
+				break;
+			case 7:
+				_owner->requestSpotSound(kGiveUpHumanIn, kGiveUpHumanOut, kFilterNoInput,
+						kSpotSoundCompletedFlag);
+				break;
+			case 9:
+				_owner->requestSpotSound(kYouAreRunningIn, kYouAreRunningOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				break;
+			default:
+				_owner->requestSpotSound(kNewLaunchSiloIn, kNewLaunchSiloOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				_monitorMovie.setTime(kNewLaunchSiloTime * scale);
+				_monitorMovie.redrawMovieWorld();
+				_gameState = kPlayingNewSilo1;
+				break;
+			}
+			break;
+		case kRobotTaunting:
+			_owner->requestDelay(1, 1, kFilterNoInput, 0);
+			_owner->requestSpotSound(kNewLaunchSiloIn, kNewLaunchSiloOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			_monitorMovie.setTime(kNewLaunchSiloTime * scale);
+			_monitorMovie.redrawMovieWorld();
+			_gameState = kPlayingNewSilo1;
+			break;
+		case kDelayingPlayer:
+			_gameState = kWaitingForPlayer;
+			break;
+		case kPlayerLost1:
+			_owner->recallToTSAFailure();
+			break;
+		case kPlayerWon2:
+			((NoradDelta *)_owner)->finishedGlobeGame();
+			_owner->requestDeleteCurrentInteraction();
+			break;
+		default:
+			break;
+		}
+	} else if (notification == &_globeNotification) {
+		ExtraTable::Entry entry;
+
+		switch (flags) {
+		case kGlobeSplash1Finished:
+			_owner->getExtraEntry(kN79BrightView, entry);
+			_monitorMovie.stop();
+			_monitorMovie.setSegment(kSplash1End * scale, kSplash2End * scale);
+			_monitorMovie.setFlags(kLoopTimeBase);
+			_monitorMovie.start();
+			_owner->showViewFrame(entry.movieStart);
+			_owner->requestSpotSound(kIJustBrokeIn, kIJustBrokeOut, kFilterNoInput, 0);
+			_owner->requestDelay(1, 2, kFilterNoInput, kDelayCompletedFlag);
+			_gameState = kPlayingRobotIntro;
+			break;
+		case kGlobeTimerExpired:
+			// Missile launched, player loses.
+			_owner->requestSpotSound(kMissileLaunchedIn, kMissileLaunchedOut, kFilterNoInput, kSpotSoundCompletedFlag);
+			_gameState = kPlayerLost1;
+			break;
+		case kMaxDeactivatedFinished:
+			_monitorMovie.stop();
+			_monitorMovie.setSegment(0, _monitorMovie.getDuration());
+			_owner->requestDelay(1, 2, kFilterNoInput, 0);
+			_owner->requestSpotSound(kTheOnlyGoodHumanIn, kTheOnlyGoodHumanOut, kFilterNoInput, 0);
+			_owner->requestDelay(1, 2, kFilterNoInput, kDelayCompletedFlag);
+			_gameState = kPlayerWon2;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+// Prevent the player from getting up until the game is over.
+
+void GlobeGame::handleInput(const Input &input, const Hotspot *cursorSpot) {
+	Common::Point where;
+	input.getInputLocation(where);
+	Hotspot *spot = g_allHotspots.findHotspot(where);
+
+	if (((PegasusEngine *)g_engine)->_cursor->isVisible() && spot != 0 &&
+			spot->getObjectID() == kNorad79SiloAreaSpotID && findClickedSilo(input) != -1) {
+		_targetHighlightUpperLeft.show();
+		_targetHighlightUpperRight.show();
+		_targetHighlightLowerLeft.show();
+		_targetHighlightLowerRight.show();
+	} else {
+		_targetHighlightUpperLeft.hide();
+		_targetHighlightUpperRight.hide();
+		_targetHighlightLowerLeft.hide();
+		_targetHighlightLowerRight.hide();
+	}
+
+	// Interrupt certain inputs to prevent player from switching modes.
+	InputHandler::handleInput(input, cursorSpot);
+}
+
+int16 GlobeGame::findClickedSilo(const Input &input) {
+	Common::Point screenPoint;
+	input.getInputLocation(screenPoint);
+	screenPoint.x -= kNavAreaLeft;
+	screenPoint.y -= kNavAreaTop;
+
+	Line3D ray;
+	screenPointTo3DPoint(screenPoint.x, screenPoint.y, ray.pt2);
+	ray.pt1 = kCameraLocation;
+
+	Point3D globePoint;
+	if (lineHitsGlobe(ray, globePoint)) {
+		int16 latOrigin, longOrigin, latitude, longitude;
+		globeMovieFrameToOrigin(_globeMovie.getTime() / kTimePerGlobeFrame, latOrigin, longOrigin);
+		globePointToLatLong(globePoint, latOrigin, longOrigin, latitude, longitude);
+
+		for (int16 i = 0; i < kNumAllSilos; i++)
+			if (_siloCoords[i][0] >= latitude - kLatError && _siloCoords[i][0] <= latitude + kLatError &&
+					_siloCoords[i][1] >= longitude - kLongError && _siloCoords[i][1] <= longitude + kLongError)
+				return i;
+	}
+
+	return -1;
+}
+
+void GlobeGame::spinGlobe(const Input &input, const Hotspot *spot, GlobeTrackDirection trackDirection) {
+	_globeTracker.setTrackParameters(spot, trackDirection);
+	_globeTracker.startTracking(input);
+}
+
+void GlobeGame::clickGlobe(const Input &input) {	
+	int16 newSilo = findClickedSilo(input);
+
+	if (newSilo != -1) {
+		_targetHighlightUpperLeft.hide();
+		_targetHighlightUpperRight.hide();
+		_targetHighlightLowerLeft.hide();
+		_targetHighlightLowerRight.hide();
+		_lowerNamesMovie.show();
+		_lowerNamesMovie.setTime(newSilo * _lowerNamesMovie.getScale());
+		_lowerNamesMovie.redrawMovieWorld();
+		_owner->requestSpotSound(kSiloBeepIn, kSiloBeepOut, kFilterNoInput, 0);
+
+		if (newSilo == _targetSilo[_currentSiloIndex]) {
+			_currentSiloIndex++;
+			_countdown.stopCountdown();
+			_owner->requestSpotSound(kSiloDeactivatedIn, kSiloDeactivatedOut, kFilterNoInput, 0);
+
+			if (_currentSiloIndex == kNumTargetSilos) {
+				// Player won.
+				_owner->requestDelay(1, 2, kFilterNoInput, 0);
+				_upperNamesMovie.hide();
+				_lowerNamesMovie.hide();
+				_countdown.hide();
+				_monitorMovie.setSegment(kMaxDeactivatedStart * _monitorMovie.getScale(),
+						kMaxDeactivatedStop * _monitorMovie.getScale());
+				_monitorMovie.setTime(kMaxDeactivatedStart * _monitorMovie.getScale());
+				_monitorCallBack.setCallBackFlag(kMaxDeactivatedFinished);
+				_monitorCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+				_monitorMovie.start();
+				_owner->requestSpotSound(kMaximumDeactivationIn, kMaximumDeactivationOut,
+						kFilterNoInput, kSpotSoundCompletedFlag);
+				_gameState = kPlayerWon1;
+			} else {
+				_owner->requestDelay(2, 1, kFilterNoInput, kDelayCompletedFlag);
+				_upperNamesMovie.hide();
+				_lowerNamesMovie.hide();
+				_countdown.hide();
+				_monitorMovie.setTime(kSiloDeactivatedTime * _monitorMovie.getScale());
+				_monitorMovie.redrawMovieWorld();
+				_gameState = kSiloDeactivated;
+			}
+		} else {
+			_owner->requestDelay(5, 1, kFilterNoInput, kDelayCompletedFlag);
+			_gameState = kDelayingPlayer;
+			// Play "incorrect" sound?
+		}
+	}
+}
+
+void GlobeGame::clickInHotspot(const Input &input, const Hotspot *spot) {
+	switch (spot->getObjectID()) {
+	case kNorad79SpinLeftSpotID:
+		spinGlobe(input, spot, kTrackLeft);
+		break;
+	case kNorad79SpinRightSpotID:
+		spinGlobe(input, spot, kTrackRight);
+		break;
+	case kNorad79SpinUpSpotID:
+		spinGlobe(input, spot, kTrackUp);
+		break;
+	case kNorad79SpinDownSpotID:
+		spinGlobe(input, spot, kTrackDown);
+		break;
+	case kNorad79SiloAreaSpotID:
+		clickGlobe(input);
+		break;
+	default:
+		GameInteraction::clickInHotspot(input, spot);
+		break;
+	}
+}
+
+void GlobeGame::activateHotspots() {
+	GameInteraction::activateHotspots();
+
+	switch (_gameState) {
+	case kWaitingForPlayer:
+		g_allHotspots.deactivateOneHotspot(kNorad79WestOutSpotID);
+		g_allHotspots.activateOneHotspot(kNorad79SpinLeftSpotID);
+		g_allHotspots.activateOneHotspot(kNorad79SpinRightSpotID);
+		g_allHotspots.activateOneHotspot(kNorad79SpinUpSpotID);
+		g_allHotspots.activateOneHotspot(kNorad79SpinDownSpotID);
+		g_allHotspots.activateOneHotspot(kNorad79SiloAreaSpotID);
+		break;
+	default:
+		g_allHotspots.deactivateOneHotspot(kNorad79WestOutSpotID);
+		break;
+	}
+}
+
+void GlobeGame::globeMovieFrameToOrigin(int16 frameNum, int16 &latOrigin, int16 &longOrigin) {
+	latOrigin = kDegreesPerLatSlice * 2 - (frameNum / (kNumLongSlices * 2)) * kDegreesPerLatSlice;
+	frameNum %= kNumLongSlices * 2;
+
+	if (frameNum >= kNumLongSlices)
+		longOrigin = kLongOrigin + (kNumLongSlices * 2 - 1 - frameNum) * kDegreesPerLongSlice;
+	else
+		longOrigin = kLongOrigin + frameNum * kDegreesPerLongSlice;
+
+	if (longOrigin > 180)
+		longOrigin -= 360;
+}
+
+void GlobeGame::globePointToLatLong(const GlobeGame::Point3D &pt, int16 latOrigin, int16 longOrigin,
+		int16 &latitude, int16 &longitude) {	
+	Point3D scratch = pt;
+	
+	// Translate globe center to origin.
+	scratch.x -= kGlobeCenter.x;
+	scratch.y -= kGlobeCenter.y;
+	scratch.z -= kGlobeCenter.z;
+
+	// Rotate around z axis latOrigin degrees to bring equator parallel with XZ plane
+	float theta = degreesToRadians(latOrigin);
+	float s = sin(theta);
+	float c = cos(theta);
+	float x = scratch.x * c - scratch.y * s;
+	float y = scratch.y * c + scratch.x * s;
+	scratch.x = x;
+	scratch.y = y;
+	
+	// Calculate latitude
+	latitude = (int16)radiansToDegrees(asin(scratch.y / kGlobeRadius));
+
+	// Rotate around y axis longOrigin degrees to bring longitude 0 to positive X axis
+	theta = degreesToRadians(longOrigin);
+	s = sin(theta);
+	c = cos(theta);
+	x = scratch.x * c - scratch.z * s;
+	float z = scratch.z * c + scratch.x * s;
+	scratch.x = x;
+	scratch.z = z;
+	
+	// Calculate longitude
+	longitude = (int16)radiansToDegrees(acos(scratch.x / sqrt(scratch.x * scratch.x + scratch.z * scratch.z)));
+
+	if (scratch.z < 0)
+		longitude = -longitude;
+}
+
+// h, v in [0, 511][0, 255]
+// Looking down negative x axis.
+void GlobeGame::screenPointTo3DPoint(int16 h, int16 v, GlobeGame::Point3D &pt) {
+	pt.x = kCameraLocation.x - kPicturePlaneDistance;
+	pt.y = kCameraLocation.y + (128 - v) * kPicturePlaneDistance * kTanFieldOfView / 256;
+	pt.z = kCameraLocation.z + (h - 256) * kPicturePlaneDistance * kTanFieldOfView / 256;
+}
+
+// Fundamentals of Three-Dimensional Graphics, by Alan Watt
+// pp. 163-164
+bool GlobeGame::lineHitsGlobe(const GlobeGame::Line3D &line, GlobeGame::Point3D &pt) {	
+	float i = line.pt2.x - line.pt1.x;
+	float j = line.pt2.y - line.pt1.y;
+	float k = line.pt2.z - line.pt1.z;
+	float a = i * i + j * j + k * k;
+	float b = 2 * i * (line.pt1.x - kGlobeCenter.x) + 2 * j * (line.pt1.y - kGlobeCenter.y) +
+			2 * k * (line.pt1.z - kGlobeCenter.z);
+	float c = kGlobeCenter.x * kGlobeCenter.x + kGlobeCenter.y * kGlobeCenter.y +
+			kGlobeCenter.z * kGlobeCenter.z + line.pt1.x * line.pt1.x + line.pt1.y * line.pt1.y +
+			line.pt1.z * line.pt1.z + -2 * (kGlobeCenter.x * line.pt1.x + kGlobeCenter.y * line.pt1.y +
+			kGlobeCenter.z * line.pt1.z) - kGlobeRadius * kGlobeRadius;
+
+	// Solve quadratic equation of a, b, c.
+	float t = b * b - 4 * a * c;
+
+	if (t >= 0.0f) {
+		// Return smaller root, which corresponds to closest intersection point.
+		t = (-b - sqrt(t)) / (2 * a);
+		pt.x = i * t + line.pt1.x;
+		pt.y = j * t + line.pt1.y;
+		pt.z = k * t + line.pt1.z;
+		return true;
+	}
+
+	return false;
+}
+
+bool GlobeGame::canSolve() {
+	return	_gameState != kPlayerWon1 && _gameState != kPlayerWon2 && _gameState != kPlayerLost1;
+}
+
+void GlobeGame::doSolve() {
+	_owner->requestDelay(1, 2, kFilterNoInput, 0);
+	_upperNamesMovie.hide();
+	_lowerNamesMovie.hide();
+	_countdown.hide();
+	_monitorMovie.setSegment(kMaxDeactivatedStart * _monitorMovie.getScale(), kMaxDeactivatedStop * _monitorMovie.getScale());
+	_monitorMovie.setTime(kMaxDeactivatedStart * _monitorMovie.getScale());
+	_monitorCallBack.setCallBackFlag(kMaxDeactivatedFinished);
+	_monitorCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
+	_monitorMovie.start();
+	_owner->requestSpotSound(kMaximumDeactivationIn, kMaximumDeactivationOut, kFilterNoInput, kSpotSoundCompletedFlag);
+	_gameState = kPlayerWon1;
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.h b/engines/pegasus/neighborhood/norad/delta/globegame.h
new file mode 100755
index 0000000..e2fe318
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/delta/globegame.h
@@ -0,0 +1,169 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_DELTA_GLOBEGAME_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_DELTA_GLOBEGAME_H
+
+#include "pegasus/interaction.h"
+#include "pegasus/movie.h"
+#include "pegasus/notification.h"
+
+namespace Pegasus {
+
+enum GlobeTrackDirection {
+	kTrackLeft,
+	kTrackRight,
+	kTrackUp,
+	kTrackDown
+};
+
+// This class assumes that the globe movie is built at 15 frames per second with a
+// time scale of 600, yielding 40 time unit per frame.
+
+class GlobeTracker : public Tracker {
+public:
+	GlobeTracker(Movie *, Picture *, Picture *, Picture *, Picture *);
+	virtual ~GlobeTracker() {}
+
+	void setTrackParameters(const Hotspot *, GlobeTrackDirection);
+	void continueTracking(const Input &);
+	void startTracking(const Input &);
+	void stopTracking(const Input &);
+	void activateHotspots();
+	bool stopTrackingInput(const Input &);
+
+protected:
+	void trackGlobeMovie();
+	void stopGlobeMovie();
+
+	Movie *_globeMovie;
+	Picture *_leftHighlight;
+	Picture *_rightHighlight;
+	Picture *_upHighlight;
+	Picture *_downHighlight;
+	const Hotspot *_trackSpot;
+	int _trackTime;
+	GlobeTrackDirection _trackDirection;
+};
+
+class GlobeCountdown : public IdlerAnimation {
+public:
+	GlobeCountdown(const tDisplayElementID);
+	virtual ~GlobeCountdown() {}
+
+	void setCountdownTime(const int);
+	void startCountdown();
+	void stopCountdown();
+
+	void setDisplayOrder(const tDisplayOrder);
+	void show();
+	void hide();
+	void moveElementTo(const tCoordType, const tCoordType);
+
+	void draw(const Common::Rect &);
+
+protected:
+	Surface _digits;
+	int16 _digitOffset;
+};
+
+static const int16 kNumAllSilos = 40;
+static const int16 kNumTargetSilos = 10;
+static const int16 kNumLongSlices = 72;
+
+class GlobeGame : public GameInteraction, public NotificationReceiver {
+public:
+	GlobeGame(Neighborhood *);
+	virtual ~GlobeGame() {}
+
+	void handleInput(const Input &, const Hotspot *);
+	void clickInHotspot(const Input &, const Hotspot *);
+	void activateHotspots();
+	
+	bool canSolve();
+	void doSolve();
+
+	struct Point3D {
+		float x, y, z;
+	};
+
+	struct Line3D {
+		Point3D	pt1, pt2;
+	};
+
+protected:
+	// Latitude (-90 - 90) and longitude (-180 - 180)
+	static const int16 _siloCoords[kNumAllSilos][2];
+
+	static const int16 _targetSilo[kNumTargetSilos];
+	static const int16 _timeLimit[kNumTargetSilos];
+	static const TimeValue _siloName[kNumTargetSilos][2];
+
+	void openInteraction();
+	void initInteraction();
+	void closeInteraction();
+
+	void receiveNotification(Notification *, const tNotificationFlags);
+
+	void spinGlobe(const Input &, const Hotspot *, GlobeTrackDirection);
+	void clickGlobe(const Input &);
+
+	int16 findClickedSilo(const Input &);
+
+	void globeMovieFrameToOrigin(int16, int16 &, int16 &);
+	void globePointToLatLong(const Point3D &, int16, int16, int16 &, int16 &);
+	void screenPointTo3DPoint(int16, int16, Point3D &);
+	bool lineHitsGlobe(const Line3D &, Point3D &);
+
+	Movie _monitorMovie;
+	Movie _globeMovie;
+	Movie _upperNamesMovie;
+	Movie _lowerNamesMovie;
+	Notification _globeNotification;
+	NotificationCallBack _monitorCallBack;
+	GlobeTracker _globeTracker;
+	Picture _globeCircleLeft;
+	Picture _globeCircleRight;
+	Picture _globeCircleUp;
+	Picture _globeCircleDown;
+	Picture _motionHighlightLeft;
+	Picture _motionHighlightRight;
+	Picture _motionHighlightUp;
+	Picture _motionHighlightDown;
+	Picture _targetHighlightUpperLeft;
+	Picture _targetHighlightUpperRight;
+	Picture _targetHighlightLowerLeft;
+	Picture _targetHighlightLowerRight;
+	GlobeCountdown _countdown;
+	NotificationCallBack _countdownCallBack;
+	int16 _gameState;
+	int16 _currentSiloIndex;
+	Notification *_neighborhoodNotification;
+	bool _playedInstructions;
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
new file mode 100755
index 0000000..8f4df72
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
@@ -0,0 +1,869 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "pegasus/energymonitor.h"
+#include "pegasus/gamestate.h"
+#include "pegasus/interface.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/ai/ai_area.h"
+#include "pegasus/items/biochips/opticalchip.h"
+#include "pegasus/items/biochips/retscanchip.h"
+#include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/constants.h"
+#include "pegasus/neighborhood/norad/subcontrolroom.h"
+#include "pegasus/neighborhood/norad/delta/globegame.h"
+#include "pegasus/neighborhood/norad/delta/noraddelta.h"
+
+namespace Pegasus {
+
+const uint32 NoradDelta::_noradDeltaClawExtras[22] = {
+	kN60ClawFromAToB,
+	kN60ClawALoop,
+	kN60ClawAPinch,
+	kN60ClawACounterclockwise,
+	kN60ClawAClockwise,
+	kN60ClawFromBToA,
+	kN60ClawFromBToC,
+	kN60ClawFromBToD,
+	kN60ClawBLoop,
+	kN60ClawBPinch,
+	kN60ClawBCounterclockwise,
+	kN60ClawBClockwise,
+	kN60ClawFromCToB,
+	kN60ClawCLoop,
+	kN60ClawCPinch,
+	kN60ClawCCounterclockwise,
+	kN60ClawCClockwise,
+	kN60ClawFromDToB,
+	kN60ClawDLoop,
+	kN60ClawDPinch,
+	kN60ClawDCounterclockwise,
+	kN60ClawDClockwise
+};
+	
+NoradDelta::NoradDelta(InputHandler *nextHandler, PegasusEngine *owner) : Norad(nextHandler, owner, "Norad Delta", kNoradDeltaID) {	
+	_elevatorUpRoomID = kNorad49South;
+	_elevatorDownRoomID = kNorad48South;
+	_elevatorUpSpotID = kNorad48ElevatorUpSpotID;
+	_elevatorDownSpotID = kNorad49ElevatorDownSpotID;
+
+	// Pressure door stuff.
+
+	_subRoomEntryRoom1 = kNorad50;
+	_subRoomEntryDir1 = kEast;
+	_subRoomEntryRoom2 = kNorad59;
+	_subRoomEntryDir2 = kWest;
+	_upperPressureDoorRoom = kNorad50East;
+	_lowerPressureDoorRoom = kNorad59West;
+
+	_upperPressureDoorUpSpotID = kDeltaUpperPressureDoorUpSpotID;
+	_upperPressureDoorDownSpotID = kDeltaUpperPressureDoorDownSpotID;
+	_upperPressureDoorAbortSpotID = kNorad50DoorOutSpotID;
+
+	_lowerPressureDoorUpSpotID = kDeltaLowerPressureDoorUpSpotID;
+	_lowerPressureDoorDownSpotID = kDeltaLowerPressureDoorDownSpotID;
+	_lowerPressureDoorAbortSpotID = kNorad59WestOutSpotID;
+
+	_pressureSoundIn = kPressureDoorIntro1In;
+	_pressureSoundOut = kPressureDoorIntro1Out;
+	_equalizeSoundIn = kPressureDoorIntro2In;
+	_equalizeSoundOut = kPressureDoorIntro2Out;
+	_accessDeniedIn = kDeltaAccessDeniedIn;
+	_accessDeniedOut = kDeltaAccessDeniedOut;
+
+	GameState.setNoradSubPrepState(kSubDamaged);
+
+	_subControlRoom = kNorad60West;
+}
+
+void NoradDelta::init() {	
+	Norad::init();
+
+	// Little fix for the retinal scan zoom in spot...
+	Hotspot *hotspot = g_allHotspots.findHotspotByID(kNorad68WestSpotID);
+	hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag);
+	
+	hotspot = g_allHotspots.findHotspotByID(kNorad79WestSpotID);
+	hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag);
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotShieldBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kDelta59RobotShieldBiochipSpotID);
+	hotspotEntry->hotspotItem = kShieldBiochip;
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotOpMemBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	hotspotEntry = findHotspotEntry(kDelta59RobotOpMemBiochipSpotID);
+	hotspotEntry->hotspotItem = kOpticalBiochip;
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotRetinalBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	hotspotEntry = findHotspotEntry(kDelta59RobotRetinalBiochipSpotID);
+	hotspotEntry->hotspotItem = kRetinalScanBiochip;
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotShieldBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	hotspotEntry = findHotspotEntry(kDelta60RobotShieldBiochipSpotID);
+	hotspotEntry->hotspotItem = kShieldBiochip;
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotOpMemBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	hotspotEntry = findHotspotEntry(kDelta60RobotOpMemBiochipSpotID);
+	hotspotEntry->hotspotItem = kOpticalBiochip;
+	
+	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotRetinalBiochipSpotID);
+	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
+	hotspotEntry = findHotspotEntry(kDelta60RobotRetinalBiochipSpotID);
+	hotspotEntry->hotspotItem = kRetinalScanBiochip;
+}
+
+void NoradDelta::start() {
+	if (g_energyMonitor) {
+		g_energyMonitor->stopEnergyDraining();
+		g_energyMonitor->restoreLastEnergyValue();
+		_vm->resetEnergyDeathReason();
+		g_energyMonitor->startEnergyDraining();
+	}
+
+	Norad::start();
+}
+
+void NoradDelta::setUpAIRules() {	
+	Neighborhood::setUpAIRules();
+
+	if (g_AIArea) {
+		AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Norad/XN07NE", false);
+		AILocationCondition *locCondition = new AILocationCondition(1);
+		locCondition->addLocation(MakeRoomView(kNorad68, kWest));
+		AIRule *rule = new AIRule(locCondition, messageAction);
+		g_AIArea->addAIRule(rule);
+	}
+}
+
+void NoradDelta::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
+	switch (entry.extra) {
+	case kArriveFromSubChase:
+		compassMove.makeTwoKnotFaderSpec(kNoradDeltaMovieScale, entry.movieStart, 20, entry.movieEnd, 90);
+		compassMove.insertFaderKnot(entry.movieStart + 25 * kNoradDeltaFrameDuration, 20);
+		compassMove.insertFaderKnot(entry.movieStart + 94 * kNoradDeltaFrameDuration, 45);
+		compassMove.insertFaderKnot(entry.movieStart + 101 * kNoradDeltaFrameDuration, 45);
+		compassMove.insertFaderKnot(entry.movieStart + 146 * kNoradDeltaFrameDuration, 90 + 15);
+		compassMove.insertFaderKnot(entry.movieStart + 189 * kNoradDeltaFrameDuration, 90 + 15);
+		compassMove.insertFaderKnot(entry.movieStart + 204 * kNoradDeltaFrameDuration, 90 + 30);
+		compassMove.insertFaderKnot(entry.movieStart + 214 * kNoradDeltaFrameDuration, 90 + 20);
+		compassMove.insertFaderKnot(entry.movieStart + 222 * kNoradDeltaFrameDuration, 90 + 20);
+		compassMove.insertFaderKnot(entry.movieStart + 228 * kNoradDeltaFrameDuration, 90 + 10);
+		compassMove.insertFaderKnot(entry.movieStart + 245 * kNoradDeltaFrameDuration, 90 + 85);
+		compassMove.insertFaderKnot(entry.movieStart + 262 * kNoradDeltaFrameDuration, 90 + 70);
+		compassMove.insertFaderKnot(entry.movieStart + 273 * kNoradDeltaFrameDuration, 90 + 80);
+		compassMove.insertFaderKnot(entry.movieStart + 287 * kNoradDeltaFrameDuration, 90);
+		break;
+	case kN60PlayerFollowsRobotToDoor:
+		compassMove.makeTwoKnotFaderSpec(kNoradDeltaMovieScale, entry.movieStart, 270 + kSubControlCompassAngle,
+				entry.movieEnd, 270 - 15);
+		compassMove.insertFaderKnot(entry.movieStart + 280, 270 + kSubControlCompassAngle);
+		compassMove.insertFaderKnot(entry.movieStart + 920, 360);
+		compassMove.insertFaderKnot(entry.movieStart + 1840, 360);
+		compassMove.insertFaderKnot(entry.movieStart + 2520, 270);
+		compassMove.insertFaderKnot(entry.movieStart + 3760, 270);
+		compassMove.insertFaderKnot(entry.movieStart + 4640, 270 + kSubControlCompassAngle);
+		break;
+	case kN59PlayerWins2:
+		compassMove.makeTwoKnotFaderSpec(kNoradDeltaMovieScale, entry.movieStart, 270, entry.movieEnd, 280);
+		compassMove.insertFaderKnot(entry.movieEnd - 1000, 270);
+	default:
+		Norad::getExtraCompassMove(entry, compassMove);
+		break;
+	}
+}
+
+GameInteraction *NoradDelta::makeInteraction(const tInteractionID interactionID) {
+	if (interactionID == kNoradGlobeGameInteractionID)
+		return new GlobeGame(this);
+
+	return Norad::makeInteraction(interactionID);
+}
+
+void NoradDelta::playClawMonitorIntro() {
+	playSpotSoundSync(kLoadClawIntroIn, kLoadClawIntroOut);
+}
+
+void NoradDelta::getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry) {
+	Norad::getExitEntry(room, direction, entry);
+
+	if (room == kNorad61 && direction == kSouth)
+		entry.movieStart += kNoradDeltaFrameDuration;
+}
+
+void NoradDelta::getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry) {
+	Norad::getZoomEntry(id, zoomEntry);
+
+	if (id == kNorad59WestSpotID && GameState.getNoradPlayedGlobeGame()) {
+		ExtraTable::Entry extraEntry;
+		getExtraEntry(kN59ZoomWithRobot, extraEntry);
+		zoomEntry.movieStart = extraEntry.movieStart;
+		zoomEntry.movieEnd = extraEntry.movieEnd;
+	}
+}
+
+void NoradDelta::loadAmbientLoops() {	
+/*
+	Logic:
+	
+	loop sound 1:
+		if room == kNorad79West
+			if player globe game
+				play kNoradGlobeLoop2SoundNum
+			else
+				play kNoradRedAlertLoopSoundNum
+		else if room >= kNorad78 && room <= kNorad79
+			play kNoradGlobeLoop2SoundNum
+		else if gassed,
+			if room >= kNorad41 && room <= kNorad49South
+				play kNoradNewSubLoopSoundNum, kNoradWarningVolume
+			else if room >= kNorad59 && room <= kNorad60West
+				play kNoradSubControlLoopSoundNum, kNoradWarningVolume
+			else
+				play kNoradWarningLoopSoundNum, kNoradWarningVolume
+		else
+			play nothing
+	loop sound 2:
+		if gassed and not wearing air mask
+			if room == kNorad54North
+				play breathing unmanned loop
+			else
+				play breathing
+		else
+			if room == kNorad54North
+				play unmanned loop
+			else
+				play nothing
+*/
+	
+	if (GameState.getNoradArrivedFromSub()) {
+		tRoomID room = GameState.getCurrentRoom();
+
+		if (room == kNorad79West) {
+			if (_privateFlags.getFlag(kNoradPrivateFinishedGlobeGameFlag))
+				loadLoopSound1("Sounds/Norad/GlobAmb2.22K.AIFF");
+			else
+				loadLoopSound1("Sounds/Norad/RedAlert.22K.AIFF");
+		} else if (room >= kNorad78 && room <= kNorad79) {
+			// clone2727 says: This looks like it should be loadLoopSound1...
+			loadLoopSound2("Sounds/Norad/RedAlert.22K.AIFF");
+		} else if (GameState.getNoradGassed()) {
+			if (room >= kNorad41 && room <= kNorad49South)
+				loadLoopSound1("Sounds/Norad/NEW SUB AMB.22K.AIFF", kNoradWarningVolume * 3);
+			else if (room >= kNorad59 && room <= kNorad60West)
+				loadLoopSound1("Sounds/Norad/SUB CONTRL LOOP.22K.AIFF", kNoradWarningVolume * 3);
+			else
+				loadLoopSound1("Sounds/Norad/WARNING LOOP.22K.AIFF", kNoradWarningVolume);
+		} else {
+			loadLoopSound1("");
+		}
+
+		if (GameState.getNoradGassed() && !g_airMask->isAirFilterOn()) {
+			if (room == kNorad54North)
+				loadLoopSound2("Sounds/Norad/Breathing Typing.22K.AIFF", 0x100 / 2);
+			else
+				loadLoopSound2("Sounds/Norad/SUCKING WIND.22K.AIFF", kNoradSuckWindVolume, 0, 0);
+		} else {
+			if (room == kNorad54North)
+				loadLoopSound2("Sounds/Norad/N54NAS.22K.AIFF", 0x100 / 2);
+			else
+				loadLoopSound2("");
+		}
+	} else {
+		// Start them off at zero...
+		if (GameState.getNoradGassed())
+			loadLoopSound1("Sounds/Norad/NEW SUB AMB.22K.AIFF", 0, 0, 0);
+		if (!g_airMask->isAirFilterOn())
+			loadLoopSound2("Sounds/Norad/SUCKING WIND.22K.AIFF", 0, 0, 0);
+	}
+}
+
+void NoradDelta::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+	switch (MakeRoomView(room, direction)) {
+	case MakeRoomView(kNorad41, kEast):
+	case MakeRoomView(kNorad49, kEast):
+	case MakeRoomView(kNorad49, kWest):
+	case MakeRoomView(kNorad61, kSouth):
+	case MakeRoomView(kNorad68, kEast):
+	case MakeRoomView(kNorad79, kWest):
+		makeContinuePoint();
+		break;
+	}
+}
+
+void NoradDelta::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+	if (room != kNorad68)
+		GameState.setNoradRetScanGood(false);
+
+	Norad::arriveAt(room, direction);
+
+	FaderMoveSpec loop1Spec, loop2Spec;
+	ExtraTable::Entry entry;
+
+	switch (room) {
+	case kNorad41:
+		if (direction == kEast && !GameState.getNoradArrivedFromSub()) {
+			GameState.setNoradPlayedGlobeGame(false);
+
+			GameState.setNoradBeatRobotWithClaw(false);
+			GameState.setNoradBeatRobotWithDoor(false);
+			GameState.setNoradRetScanGood(false);
+
+			GameState.setScoringExitedSub(true);
+
+			getExtraEntry(kArriveFromSubChase, entry);
+
+			loop1Spec.makeTwoKnotFaderSpec(kNoradDeltaMovieScale, 0, 0, entry.movieEnd -
+					entry.movieStart, kNoradWarningVolume);
+			loop1Spec.insertFaderKnot(7320, 0);
+			loop1Spec.insertFaderKnot(7880, kNoradWarningVolume);
+
+			loop2Spec.makeTwoKnotFaderSpec(kNoradDeltaMovieScale, 0, 0, entry.movieEnd -
+					entry.movieStart, kNoradSuckWindVolume);
+			loop1Spec.insertFaderKnot(7320, 0);
+			loop1Spec.insertFaderKnot(7880, kNoradSuckWindVolume);
+
+			startExtraSequence(kArriveFromSubChase, kExtraCompletedFlag, kFilterNoInput);
+
+			startLoop1Fader(loop1Spec);
+			startLoop2Fader(loop2Spec);
+		}
+		break;
+	case kNorad54North:
+		GameState.setScoringSawRobotAt54North(true);
+		break;
+	case kNorad68:
+		if (GameState.getNoradRetScanGood())
+			openDoor();
+		break;
+	case kNorad68West:
+		arriveAtNorad68West();
+		break;
+	case kNorad79West:
+		arriveAtNorad79West();
+		break;
+	default:
+		break;
+	}
+}
+
+void NoradDelta::doorOpened() {
+	Norad::doorOpened();
+	GameState.setNoradRetScanGood(false);
+}
+
+void NoradDelta::arriveAtNorad68West() {
+	playSpotSoundSync(kHoldForRetinalIn, kHoldForRetinalOut);
+
+	BiochipItem *retScan = _vm->getCurrentBiochip();
+
+	if (retScan != 0 && retScan->getObjectID() == kRetinalScanBiochip) {
+		((RetScanChip *)retScan)->searchForLaser();
+		succeedRetinalScan();
+	} else {
+		failRetinalScan();
+	}
+}
+
+void NoradDelta::arriveAtNorad79West() {	
+	if (!GameState.getNoradPlayedGlobeGame())
+		newInteraction(kNoradGlobeGameInteractionID);
+}
+
+void NoradDelta::bumpIntoWall() {
+	requestSpotSound(kDeltaBumpIntoWallIn, kDeltaBumpIntoWallOut, kFilterNoInput, 0);
+	Neighborhood::bumpIntoWall();
+}
+
+void NoradDelta::failRetinalScan() {
+	startExtraSequence(kNoradDeltaRetinalScanBad, kExtraCompletedFlag, kFilterNoInput);
+}
+
+void NoradDelta::succeedRetinalScan() {
+	startExtraSequence(kNoradDeltaRetinalScanGood, kExtraCompletedFlag, kFilterNoInput);
+	GameState.setNoradRetScanGood(true);
+	GameState.setScoringUsedRetinalChip(true);
+}
+
+void NoradDelta::getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &entry) {
+	Norad::getDoorEntry(room, direction, entry);
+
+	if (room == kNorad68 && direction == kWest && !GameState.getNoradRetScanGood())
+		entry.flags = kDoorPresentMask | kDoorLockedMask;
+}
+
+void NoradDelta::finishedGlobeGame() {
+	GameState.setNoradPlayedGlobeGame(true);
+	_privateFlags.setFlag(kNoradPrivateFinishedGlobeGameFlag, true);
+	GameState.setScoringFinishedGlobeGame(true);
+	loadAmbientLoops();
+	g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Norad/XN60WD1", false, kWarningInterruption);
+}
+
+bool NoradDelta::playingAgainstRobot() {
+	return GameState.getNoradPlayedGlobeGame();
+}
+
+void NoradDelta::getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID, tHotSpotID &pinchClawSpotID,
+		tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID, tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID,
+		tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &clawPosition, const uint32 *&clawExtraIDs) {
+	outSpotID = kNorad60MonitorOutSpotID;
+	prepSpotID = kNorad60LaunchPrepSpotID;
+	clawControlSpotID = kNorad60ClawControlSpotID;
+	pinchClawSpotID = kNorad60ClawPinchSpotID;
+	moveClawDownSpotID = kNorad60ClawDownSpotID;
+	moveClawRightSpotID = kNorad60ClawRightSpotID;
+	moveClawLeftSpotID = kNorad60ClawLeftSpotID;
+	moveClawUpSpotID = kNorad60ClawUpSpotID;
+	clawCCWSpotID = kNorad60ClawCCWSpotID;
+	clawCWSpotID = kNorad60ClawCWSpotID;
+	clawPosition = kClawAtC;
+	clawExtraIDs = _noradDeltaClawExtras;
+}
+
+void NoradDelta::playerBeatRobotWithDoor() {
+	GameState.setNoradBeatRobotWithDoor(true);
+	updateViewFrame();
+	GameState.setScoringStoppedNoradRobot(true);
+	g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Norad/XN59WD", false, kWarningInterruption);
+}
+
+void NoradDelta::playerBeatRobotWithClaw() {
+	GameState.setNoradBeatRobotWithClaw(true);
+	updateViewFrame();
+	GameState.setScoringStoppedNoradRobot(true);
+	GameState.setScoringNoradGandhi(true);
+	g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Norad/XN59WD", false, kWarningInterruption);
+}
+
+TimeValue NoradDelta::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+	ExtraTable::Entry entry;
+	
+	if (room == kNorad41 && direction == kSouth && !GameState.getNoradArrivedFromSub()) {
+		getExtraEntry(kArriveFromSubChase, entry);
+		return entry.movieStart;
+	}
+
+	if (GameState.getNoradBeatRobotWithDoor()) {
+		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
+			uint32 extraID = kN59Biochips111;
+			if (_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
+				extraID += 1;
+			if (_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
+				extraID += 2;
+			if (_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
+				extraID += 4;
+			getExtraEntry(extraID, entry);
+			return entry.movieStart;
+		}
+
+		getExtraEntry(kN59RobotHeadOpens, entry);
+		return entry.movieStart;
+	} else if (GameState.getNoradBeatRobotWithClaw()) {
+		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
+			uint32 extraID = kN60Biochips111;
+			if (_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
+				extraID += 1;
+			if (_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
+				extraID += 2;
+			if (_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
+				extraID += 4;
+			getExtraEntry(extraID, entry);
+			return entry.movieStart;
+		}
+
+		getExtraEntry(kN60RobotHeadOpens, entry);
+		return entry.movieStart;
+	}
+
+	return Norad::getViewTime(room, direction);
+}
+
+void NoradDelta::openDoor() {	
+	if (GameState.getCurrentRoom() == kNorad59 && GameState.getCurrentDirection() == kWest && GameState.getNoradPlayedGlobeGame()) {
+		Input scratch;
+		InputHandler::_inputHandler->clickInHotspot(scratch, g_allHotspots.findHotspotByID(kNorad59WestSpotID));
+	} else {
+		Norad::openDoor();
+	}
+}
+
+void NoradDelta::activateHotspots() {
+	Norad::activateHotspots();
+
+	if (GameState.getCurrentRoom() == kNorad59West && GameState.getCurrentDirection() == kWest && GameState.getNoradBeatRobotWithDoor()) {
+		g_allHotspots.deactivateOneHotspot(kNorad59WestOutSpotID);
+
+		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
+			if (!_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta59RobotShieldBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta59RobotShieldBiochipSpotID);
+
+			if (!_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
+
+			if (!_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
+		} else
+			g_allHotspots.activateOneHotspot(kDelta59RobotHeadSpotID);
+	} else if (GameState.getCurrentRoom() == kNorad60West && GameState.getCurrentDirection() == kWest &&
+			GameState.getNoradBeatRobotWithClaw()) {
+		g_allHotspots.deactivateOneHotspot(kNorad60MonitorOutSpotID);
+
+		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
+			if (!_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta60RobotShieldBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta60RobotShieldBiochipSpotID);
+
+			if (!_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
+
+			if (!_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
+				g_allHotspots.activateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
+			else
+				g_allHotspots.deactivateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
+		} else {
+			g_allHotspots.activateOneHotspot(kDelta60RobotHeadSpotID);
+		}
+	} else if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad50, kEast)) {
+		if (GameState.isCurrentDoorOpen())
+			g_allHotspots.deactivateOneHotspot(kNorad50DoorSpotID);
+	} else if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad59, kWest)) {
+		if (GameState.isCurrentDoorOpen())
+			g_allHotspots.deactivateOneHotspot(kNorad59WestSpotID);
+	}
+}
+
+void NoradDelta::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
+	switch (clickedSpot->getObjectID()) {
+	case kDelta59RobotHeadSpotID:
+		startExtraSequence(kN59RobotHeadOpens, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	case kDelta60RobotHeadSpotID:
+		startExtraSequence(kN60RobotHeadOpens, kExtraCompletedFlag, kFilterNoInput);
+		break;
+	default:
+		Norad::clickInHotspot(input, clickedSpot);
+		break;
+	}
+}
+
+void NoradDelta::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+	Norad::receiveNotification(notification, flags);
+
+	if ((flags & kExtraCompletedFlag) != 0) {
+		RetScanChip *retScan;
+		Input dummy;
+
+		switch (_lastExtra) {
+		case kArriveFromSubChase:
+			GameState.setNoradArrivedFromSub(true);
+			GameState.setCurrentRoom(kNoRoomID);
+			GameState.setCurrentDirection(kNoDirection);
+			arriveAt(kNorad41, kEast);
+			break;
+		case kN59RobotHeadOpens:
+		case kN60RobotHeadOpens:
+			_privateFlags.setFlag(kNoradPrivateRobotHeadOpenFlag, true);
+			break;
+		case kNoradDeltaRetinalScanBad:
+			retScan = (RetScanChip *)_vm->getCurrentBiochip();
+			retScan->setItemState(kNormalItem);
+			playSpotSoundSync(kRetinalScanFailedIn, kRetinalScanFailedOut);
+			downButton(dummy);
+			break;
+		case kNoradDeltaRetinalScanGood:
+			retScan = (RetScanChip *)_vm->getCurrentBiochip();
+			retScan->setItemState(kNormalItem);
+			downButton(dummy);
+			break;
+		case kN59RobotDisappears:
+		case kN60RobotDisappears:
+			recallToTSASuccess();
+			break;
+		}
+
+		_interruptionFilter = kFilterAllInput;
+	}
+
+	g_AIArea->checkMiddleArea();
+}
+
+void NoradDelta::pickedUpItem(Item *item) {
+	switch (item->getObjectID()) {
+	case kShieldBiochip:
+		if (_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag) &&
+					_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag) &&
+					_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag)) {
+			GameState.setNoradFinished(true);
+
+			if (GameState.getCurrentRoom() == kNorad59West)
+				startExtraSequence(kN59RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kN60RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kRetinalScanBiochip:
+		if (_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag) &&
+				_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag) &&
+				_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag)) {
+			GameState.setNoradFinished(true);
+
+			if (GameState.getCurrentRoom() == kNorad59West)
+				startExtraSequence(kN59RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kN60RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	case kOpticalBiochip:
+		g_opticalChip->addPoseidon();
+		GameState.setScoringGotNoradOpMemChip();
+
+		if (_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag) &&
+				_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag) &&
+				_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag)) {
+			GameState.setNoradFinished(true);
+
+			if (GameState.getCurrentRoom() == kNorad59West)
+				startExtraSequence(kN59RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+			else
+				startExtraSequence(kN60RobotDisappears, kExtraCompletedFlag, kFilterNoInput);
+		}
+		break;
+	}
+
+	Norad::pickedUpItem(item);
+}
+
+void NoradDelta::takeItemFromRoom(Item *item) {
+	switch (item->getObjectID()) {
+	case kShieldBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotShieldChipFlag, true);
+		break;
+	case kRetinalScanBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotRetScanChipFlag, true);
+		break;
+	case kOpticalBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotOpticalChipFlag, true);
+		break;
+	}
+
+	Norad::takeItemFromRoom(item);
+}
+
+void NoradDelta::dropItemIntoRoom(Item *item, Hotspot *hotspot) {
+	switch (item->getObjectID()) {
+	case kShieldBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotShieldChipFlag, false);
+		break;
+	case kOpticalBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotOpticalChipFlag, false);
+		break;
+	case kRetinalScanBiochip:
+		_privateFlags.setFlag(kNoradPrivateGotRetScanChipFlag, false);
+		break;
+	}
+
+	Norad::dropItemIntoRoom(item, hotspot);
+}
+
+Hotspot *NoradDelta::getItemScreenSpot(Item *item, DisplayElement *element) {
+	tHotSpotID id = kNoHotSpotID;
+	
+	switch (item->getObjectID()) {
+	case kShieldBiochip:
+		if (GameState.getNoradBeatRobotWithDoor())
+			id = kDelta59RobotShieldBiochipSpotID;
+		else
+			id = kDelta60RobotShieldBiochipSpotID;
+		break;
+	case kOpticalBiochip:
+		if (GameState.getNoradBeatRobotWithDoor())
+			id = kDelta59RobotOpMemBiochipSpotID;
+		else
+			id = kDelta60RobotOpMemBiochipSpotID;
+		break;
+	case kRetinalScanBiochip:
+		if (GameState.getNoradBeatRobotWithDoor())
+			id = kDelta59RobotRetinalBiochipSpotID;
+		else
+			id = kDelta60RobotRetinalBiochipSpotID;
+		break;
+	}
+
+	if (id != kNoHotSpotID)
+		return g_allHotspots.findHotspotByID(id);
+
+	return Norad::getItemScreenSpot(item, element);
+}
+
+Common::String NoradDelta::getEnvScanMovie() {
+	return "Images/AI/Norad/XNE2";
+}
+
+uint NoradDelta::getNumHints() {	
+	uint numHints = Neighborhood::getNumHints();
+
+	if (numHints == 0) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kNorad60, kWest):
+			if (GameState.getNoradPlayedGlobeGame())
+				numHints = 2;
+			else
+				numHints = 1;
+			break;
+		case MakeRoomView(kNorad59, kNorth):
+		case MakeRoomView(kNorad59, kSouth):
+		case MakeRoomView(kNorad59, kEast):
+		case MakeRoomView(kNorad59, kWest):
+		case MakeRoomView(kNorad60, kNorth):
+		case MakeRoomView(kNorad60, kSouth):
+		case MakeRoomView(kNorad60, kEast):
+			if (GameState.getNoradPlayedGlobeGame())
+				numHints = 2;
+			break;
+		case MakeRoomView(kNorad68, kWest):
+			if (_vm->playerHasItemID(kRetinalScanBiochip)) {
+				BiochipItem *retScan = _vm->getCurrentBiochip();
+				if (retScan == 0 || retScan->getObjectID() != kRetinalScanBiochip)
+					numHints = 2;
+			} else if (!GameState.isCurrentDoorOpen()) {
+				numHints = 2;
+			}
+			break;
+		}
+	}
+
+	return numHints;
+}
+
+Common::String NoradDelta::getHintMovie(uint hintNum) {
+	Common::String movieName = Neighborhood::getHintMovie(hintNum);
+
+	if (movieName.empty()) {
+		switch (GameState.getCurrentRoomAndView()) {
+		case MakeRoomView(kNorad60, kWest):
+			if (GameState.getNoradPlayedGlobeGame()) {
+				if (hintNum == 1)
+					return "Images/AI/Norad/XN60WD2";
+
+				return "Images/AI/Norad/XN60WD3";
+			}
+
+			return "Images/AI/Globals/XGLOB1C";
+		case MakeRoomView(kNorad59, kNorth):
+		case MakeRoomView(kNorad59, kSouth):
+		case MakeRoomView(kNorad59, kEast):
+		case MakeRoomView(kNorad59, kWest):
+		case MakeRoomView(kNorad60, kNorth):
+		case MakeRoomView(kNorad60, kSouth):
+		case MakeRoomView(kNorad60, kEast):
+			if (hintNum == 1)
+				return "Images/AI/Norad/XN60WD2";
+
+			return "Images/AI/Norad/XN60WD3";
+		case MakeRoomView(kNorad68, kWest):
+			if (_vm->playerHasItemID(kRetinalScanBiochip)) {
+				if (hintNum == 1)
+					return "Images/AI/Globals/XGLOB1A";
+
+				return "Images/AI/Globals/XGLOB1C";
+			}
+
+			if (hintNum == 1)
+				return "Images/AI/Globals/XGLOB1B";
+
+			return "Images/AI/Globals/XGLOB3B";
+		}
+	}
+
+	return movieName;
+}
+
+void NoradDelta::closeDoorOffScreen(const tRoomID room, const tDirectionConstant) {
+	switch (room) {
+	case kNorad47:
+	case kNorad48:
+	case kNorad41:
+	case kNorad42:
+		playSpotSoundSync(kDeltaElevatorDoorCloseIn, kDeltaElevatorDoorCloseOut);
+		break;
+	default:
+		playSpotSoundSync(kDeltaRegDoorCloseIn, kDeltaRegDoorCloseOut);
+		break;
+	}
+}
+
+bool NoradDelta::canSolve() {
+	if (Norad::canSolve())
+		return true;
+
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad68, kWest)) {
+		BiochipItem *biochip = _vm->getCurrentBiochip();
+		if (biochip != 0 && biochip->getObjectID() != kRetinalScanBiochip)
+			return true;
+	}
+
+	return false;
+}
+
+void NoradDelta::doSolve() {
+	Norad::doSolve();
+
+	if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad68, kWest)) {
+		if (!_vm->playerHasItemID(kRetinalScanBiochip))
+			_vm->addItemToBiochips((BiochipItem *)g_allItems.findItemByID(kRetinalScanBiochip));
+
+		BiochipItem *biochip = _vm->getCurrentBiochip();
+		if (biochip != 0 && biochip->getObjectID() != kRetinalScanBiochip && g_interface)
+			g_interface->setCurrentBiochipID(kRetinalScanBiochip);
+
+		Hotspot *spot = g_allHotspots.findHotspotByID(kNorad68WestSpotID);
+		Input scratch;
+		InputHandler::_inputHandler->clickInHotspot(scratch, spot);
+	}
+}
+
+Common::String NoradDelta::getSoundSpotsName() {
+	return "Sounds/Norad/Norad Delta Spots";
+}
+
+Common::String NoradDelta::getNavMovieName() {
+	return "Images/Norad Delta/Norad Delta.movie";
+}
+
+} // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.h b/engines/pegasus/neighborhood/norad/delta/noraddelta.h
new file mode 100755
index 0000000..69798b5
--- /dev/null
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.h
@@ -0,0 +1,117 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * Additional copyright for this file:
+ * Copyright (C) 1995-1997 Presto Studios, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef PEGASUS_NEIGHBORHOOD_NORAD_DELTA_NORADDELTA_H
+#define PEGASUS_NEIGHBORHOOD_NORAD_DELTA_NORADDELTA_H
+
+#include "pegasus/neighborhood/norad/norad.h"
+
+namespace Pegasus {
+
+class NoradDelta : public Norad {
+public:
+	NoradDelta(InputHandler *, PegasusEngine *);
+	virtual ~NoradDelta() {}
+
+	void init();
+
+	void start();
+
+	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
+
+	void finishedGlobeGame();
+
+	virtual GameInteraction *makeInteraction(const tInteractionID);
+
+	void playClawMonitorIntro();
+
+	virtual void getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID,
+			tHotSpotID &pinchClawSpotID, tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID,
+			tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID, tHotSpotID &clawCCWSpotID,
+			tHotSpotID &clawCWSpotID, uint32 &, const uint32 *&);
+
+	void playerBeatRobotWithClaw();
+	void playerBeatRobotWithDoor();
+
+	void loadAmbientLoops();
+
+	void setUpAIRules();
+	Common::String getEnvScanMovie();
+	uint getNumHints();
+	Common::String getHintMovie(uint);
+	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+
+	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+
+	bool canSolve();
+	void doSolve();
+
+	void doorOpened();
+
+protected:
+	enum {
+		kNoradPrivateArrivedFromSubFlag,
+		kNoradPrivateFinishedGlobeGameFlag,
+		kNoradPrivateRobotHeadOpenFlag,
+		kNoradPrivateGotShieldChipFlag,
+		kNoradPrivateGotOpticalChipFlag,
+		kNoradPrivateGotRetScanChipFlag,
+		kNumNoradPrivateFlags
+	};
+
+	static const uint32 _noradDeltaClawExtras[22];
+
+	void getExitEntry(const tRoomID, const tDirectionConstant, ExitTable::Entry &);
+	void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
+	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	void arriveAtNorad68West();
+	void arriveAtNorad79West();
+	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	void openDoor();
+	void activateHotspots();
+	void clickInHotspot(const Input &, const Hotspot *);
+	void receiveNotification(Notification *, const tNotificationFlags);
+	void pickedUpItem(Item *item);
+	void takeItemFromRoom(Item *item);
+	void dropItemIntoRoom(Item *item, Hotspot *);
+	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
+
+	virtual bool playingAgainstRobot();
+
+	void failRetinalScan();
+	void succeedRetinalScan();
+	void getDoorEntry(const tRoomID, const tDirectionConstant, DoorTable::Entry &);
+
+	void bumpIntoWall();
+
+	FlagsArray<byte, kNumNoradPrivateFlags> _privateFlags;
+
+	Common::String getSoundSpotsName();
+	Common::String getNavMovieName();
+};
+
+} // End of namespace Pegasus
+
+#endif
diff --git a/engines/pegasus/neighborhood/norad/norad.cpp b/engines/pegasus/neighborhood/norad/norad.cpp
index 931d854..8e891f3 100755
--- a/engines/pegasus/neighborhood/norad/norad.cpp
+++ b/engines/pegasus/neighborhood/norad/norad.cpp
@@ -28,6 +28,7 @@
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/inventory/airmask.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/noradelevator.h"
 #include "pegasus/neighborhood/norad/pressuredoor.h"
diff --git a/engines/pegasus/neighborhood/norad/norad.h b/engines/pegasus/neighborhood/norad/norad.h
index 5e81890..eb4c480 100755
--- a/engines/pegasus/neighborhood/norad/norad.h
+++ b/engines/pegasus/neighborhood/norad/norad.h
@@ -30,462 +30,6 @@
 
 namespace Pegasus {
 
-const tCanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
-
-const tNotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
-
-const uint16 kNoradWarningVolume = 0x100 / 3;
-const uint16 kNoradSuckWindVolume = 0x100 / 2;
-
-const int16 kElevatorCompassAngle = -40;
-const int16 kSubPlatformCompassAngle = 45;
-const int16 kSubControlCompassAngle = -10;
-
-//	Norad interactions.
-
-const tInteractionID kNoradGlobeGameInteractionID = 0;
-const tInteractionID kNoradECRMonitorInteractionID = 1;
-const tInteractionID kNoradFillingStationInteractionID = 2;
-const tInteractionID kNoradElevatorInteractionID = 3;
-const tInteractionID kNoradPressureDoorInteractionID = 4;
-const tInteractionID kNoradSubControlRoomInteractionID = 5;
-const tInteractionID kNoradSubPlatformInteractionID = 6;
-
-/////////////////////////////////////////////
-//
-//	Norad Alpha
-
-const tCoordType kECRSlideShowLeft = kNavAreaLeft + 78;
-const tCoordType kECRSlideShowTop = kNavAreaTop + 1;
-
-const tCoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
-const tCoordType kECRPanTop = kNavAreaTop + 1 + 4;
-const tCoordType kECRPanRight = kECRPanLeft + 213;
-const tCoordType kECRPanBottom = kECRPanTop + 241;
-
-const tCoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
-const tCoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
-
-const tCoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
-const tCoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
-
-const tCoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
-const tCoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
-
-const tCoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
-const tCoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
-
-const tCoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
-const tCoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
-
-const tCoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
-const tCoordType kNoradUpperUpTop = kNavAreaTop + 32;
-
-const tCoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
-const tCoordType kNoradUpperDownTop = kNavAreaTop + 66;
-
-const tCoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
-const tCoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
-
-const tCoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
-const tCoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
-
-const tCoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
-const tCoordType kNoradLowerUpTop = kNavAreaTop + 164;
-
-const tCoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
-const tCoordType kNoradLowerDownTop = kNavAreaTop + 212;
-
-const tCoordType kNoradPlatformLeft = kNavAreaLeft + 36;
-const tCoordType kNoradPlatformTop = kNavAreaTop + 87;
-
-const tCoordType kNoradSubControlLeft = kNavAreaLeft + 0;
-const tCoordType kNoradSubControlTop = kNavAreaTop + 84;
-
-const tCoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
-const tCoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
-
-const tCoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
-const tCoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
-
-const tCoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
-const tCoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
-
-const tCoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
-const tCoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
-
-const tCoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
-const tCoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
-
-const tCoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
-const tCoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
-
-const tCoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
-const tCoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
-
-const tCoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
-const tCoordType kNoradClawMonitorTop = kNavAreaTop + 97;
-
-const tCoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
-const tCoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
-
-const tCoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
-const tCoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
-
-const tCoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
-const tCoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
-
-const tCoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
-const tCoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
-
-/////////////////////////////////////////////
-//
-//	Norad Delta
-
-const tCoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
-const tCoordType kGlobeMonitorTop = kNavAreaTop + 144;
-
-const tCoordType kGlobeLeft = kNavAreaLeft + 172;
-const tCoordType kGlobeTop = kNavAreaTop;
-
-const tCoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
-const tCoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
-
-const tCoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
-const tCoordType kGlobeCircleRightTop = kNavAreaTop + 41;
-
-const tCoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
-const tCoordType kGlobeCircleUpTop = kNavAreaTop + 7;
-
-const tCoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
-const tCoordType kGlobeCircleDownTop = kNavAreaTop + 142;
-
-const tCoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
-const tCoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
-
-const tCoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
-const tCoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
-
-const tCoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
-const tCoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
-
-const tCoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
-const tCoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
-
-const tCoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
-const tCoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
-
-const tCoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
-const tCoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
-
-const tCoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
-const tCoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
-
-const tCoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
-const tCoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
-
-const tCoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
-const tCoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
-
-const tCoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
-const tCoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
-
-const tCoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
-const tCoordType kGlobeCountdownTop = kNavAreaTop + 164;
-
-//	Norad Alpha display IDs.
-
-const tDisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
-const tDisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
-const tDisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
-const tDisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
-const tDisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
-const tDisplayElementID kN01RightSideID = kN01LeftSideID + 1;
-const tDisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
-const tDisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
-const tDisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
-const tDisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
-const tDisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
-const tDisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
-const tDisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
-const tDisplayElementID kSubControlPinchID = kClawMonitorID + 1;
-const tDisplayElementID kSubControlDownID = kSubControlPinchID + 1;
-const tDisplayElementID kSubControlRightID = kSubControlDownID + 1;
-const tDisplayElementID kSubControlLeftID = kSubControlRightID + 1;
-const tDisplayElementID kSubControlUpID = kSubControlLeftID + 1;
-const tDisplayElementID kSubControlCCWID = kSubControlUpID + 1;
-const tDisplayElementID kSubControlCWID = kSubControlCCWID + 1;
-const tDisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
-
-//	Norad Delta display IDs.
-
-const tDisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
-const tDisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
-const tDisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
-const tDisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
-const tDisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
-const tDisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
-const tDisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
-const tDisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
-const tDisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
-const tDisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
-const tDisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
-const tDisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
-const tDisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
-const tDisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
-const tDisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
-const tDisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
-const tDisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
-
-//	Norad Alpha:
-
-const tDisplayOrder kECRMonitorOrder = kMonitorLayer;
-const tDisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
-
-const tDisplayOrder kN01LeftSideOrder = kMonitorLayer;
-const tDisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
-
-const tDisplayOrder kElevatorControlsOrder = kMonitorLayer;
-
-const tDisplayOrder kPressureLevelsOrder = kMonitorLayer;
-const tDisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
-const tDisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
-const tDisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
-
-const tDisplayOrder kPlatformOrder = kMonitorLayer;
-
-const tDisplayOrder kSubControlOrder = kMonitorLayer;
-const tDisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
-const tDisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
-const tDisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
-const tDisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
-const tDisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
-const tDisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
-const tDisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
-const tDisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
-const tDisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
-
-//	Norad Delta:
-
-const tDisplayOrder kGlobeMonitorLayer = kMonitorLayer;
-const tDisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
-const tDisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
-const tDisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
-const tDisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
-const tDisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
-const tDisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
-
-
-//	Norad Alpha constants
-
-const TimeScale kNoradAlphaMovieScale = 600;
-const TimeScale kNoradAlphaFramesPerSecond = 15;
-const TimeScale kNoradAlphaFrameDuration = 40;
-
-//	Alternate IDs.
-
-const tAlternateID kAltNoradAlphaNormal = 0;
-
-//	Room IDs.
-
-const tRoomID kNorad01 = 0;
-const tRoomID kNorad01East = 1;
-const tRoomID kNorad01West = 2;
-const tRoomID kNorad02 = 3;
-const tRoomID kNorad03 = 4;
-const tRoomID kNorad04 = 5;
-const tRoomID kNorad05 = 6;
-const tRoomID kNorad06 = 7;
-const tRoomID kNorad07 = 8;
-const tRoomID kNorad07North = 9;
-const tRoomID kNorad08 = 10;
-const tRoomID kNorad09 = 11;
-const tRoomID kNorad10 = 12;
-const tRoomID kNorad10East = 13;
-const tRoomID kNorad11 = 14;
-const tRoomID kNorad11South = 15;
-const tRoomID kNorad12 = 16;
-const tRoomID kNorad12South = 17;
-const tRoomID kNorad13 = 18;
-const tRoomID kNorad14 = 19;
-const tRoomID kNorad15 = 20;
-const tRoomID kNorad16 = 21;
-const tRoomID kNorad17 = 22;
-const tRoomID kNorad18 = 23;
-const tRoomID kNorad19 = 24;
-const tRoomID kNorad19West = 25;
-const tRoomID kNorad21 = 26;
-const tRoomID kNorad21West = 27;
-const tRoomID kNorad22 = 28;
-const tRoomID kNorad22West = 29;
-
-//	Hot Spot Activation IDs.
-
-
-//	Hot Spot IDs.
-
-const tHotSpotID kNorad01ECRSpotID = 5000;
-const tHotSpotID kNorad01GasSpotID = 5001;
-const tHotSpotID kNorad01ECROutSpotID = 5002;
-const tHotSpotID kNorad01GasOutSpotID = 5003;
-const tHotSpotID kNorad01MonitorSpotID = 5004;
-const tHotSpotID kNorad01IntakeSpotID = 5005;
-const tHotSpotID kNorad01DispenseSpotID = 5006;
-const tHotSpotID kNorad01ArSpotID = 5007;
-const tHotSpotID kNorad01CO2SpotID = 5008;
-const tHotSpotID kNorad01HeSpotID = 5009;
-const tHotSpotID kNorad01OSpotID = 5010;
-const tHotSpotID kNorad01NSpotID = 5011;
-const tHotSpotID kN01GasCanisterSpotID = 5012;
-const tHotSpotID kN01ArgonCanisterSpotID = 5013;
-const tHotSpotID kN01AirMaskSpotID = 5014;
-const tHotSpotID kN01NitrogenCanisterSpotID = 5015;
-const tHotSpotID kN01GasOutletSpotID = 5016;
-const tHotSpotID kNorad07DoorSpotID = 5017;
-const tHotSpotID kNorad07DoorOutSpotID = 5018;
-const tHotSpotID kNorad10DoorSpotID = 5019;
-const tHotSpotID kNorad10EastOutSpotID = 5020;
-const tHotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
-const tHotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
-const tHotSpotID kNorad11ElevatorSpotID = 5023;
-const tHotSpotID kNorad11ElevatorOutSpotID = 5024;
-const tHotSpotID kNorad11ElevatorDownSpotID = 5025;
-const tHotSpotID kNorad12ElevatorSpotID = 5026;
-const tHotSpotID kNorad12ElevatorOutSpotID = 5027;
-const tHotSpotID kNorad12ElevatorUpSpotID = 5028;
-const tHotSpotID kNorad19MonitorSpotID = 5029;
-const tHotSpotID kNorad19MonitorOutSpotID = 5030;
-const tHotSpotID kNorad19ActivateMonitorSpotID = 5031;
-const tHotSpotID kNorad21WestSpotID = 5032;
-const tHotSpotID kNorad21WestOutSpotID = 5033;
-const tHotSpotID kAlphaLowerPressureDoorUpSpotID = 5034;
-const tHotSpotID kAlphaLowerPressureDoorDownSpotID = 5035;
-const tHotSpotID kNorad22MonitorSpotID = 5036;
-const tHotSpotID kNorad22MonitorOutSpotID = 5037;
-const tHotSpotID kNorad22LaunchPrepSpotID = 5038;
-const tHotSpotID kNorad22ClawControlSpotID = 5039;
-const tHotSpotID kNorad22ClawPinchSpotID = 5040;
-const tHotSpotID kNorad22ClawDownSpotID = 5041;
-const tHotSpotID kNorad22ClawRightSpotID = 5042;
-const tHotSpotID kNorad22ClawLeftSpotID = 5043;
-const tHotSpotID kNorad22ClawUpSpotID = 5044;
-const tHotSpotID kNorad22ClawCCWSpotID = 5045;
-const tHotSpotID kNorad22ClawCWSpotID = 5046;
-
-//	Extra sequence IDs.
-
-const tExtraID kNoradArriveFromTSA = 0;
-const tExtraID kNorad01RobotTaunt = 1;
-const tExtraID kNorad01ZoomInWithGasCanister = 2;
-const tExtraID kN01WGasCanister = 3;
-const tExtraID kNorad01ZoomOutWithGasCanister = 4;
-const tExtraID kN01WZEmptyLit = 5;
-const tExtraID kN01WZGasCanisterDim = 6;
-const tExtraID kN01WZGasCanisterLit = 7;
-const tExtraID kN01WZArgonCanisterDim = 8;
-const tExtraID kN01WZArgonCanisterLit = 9;
-const tExtraID kN01WZAirMaskDim = 10;
-const tExtraID kN01WZAirMaskLit = 11;
-const tExtraID kN01WZNitrogenCanisterDim = 12;
-const tExtraID kN01WZNitrogenCanisterLit = 13;
-const tExtraID kNorad04EastDeath = 14;
-const tExtraID kNorad19PrepSub = 15;
-const tExtraID kNorad19ExitToSub = 16;
-const tExtraID kNorad22SouthIntro = 17;
-const tExtraID kNorad22SouthReply = 18;
-const tExtraID kNorad22SouthFinish = 19;
-const tExtraID kN22ClawFromAToB = 20;
-const tExtraID kN22ClawALoop = 21;
-const tExtraID kN22ClawAPinch = 22;
-const tExtraID kN22ClawACounterclockwise = 23;
-const tExtraID kN22ClawAClockwise = 24;
-const tExtraID kN22ClawFromBToA = 25;
-const tExtraID kN22ClawFromBToC = 26;
-const tExtraID kN22ClawFromBToD = 27;
-const tExtraID kN22ClawBLoop = 28;
-const tExtraID kN22ClawBPinch = 29;
-const tExtraID kN22ClawBCounterclockwise = 30;
-const tExtraID kN22ClawBClockwise = 31;
-const tExtraID kN22ClawFromCToB = 32;
-const tExtraID kN22ClawCLoop = 33;
-const tExtraID kN22ClawCPinch = 34;
-const tExtraID kN22ClawCCounterclockwise = 35;
-const tExtraID kN22ClawCClockwise = 36;
-const tExtraID kN22ClawFromDToB = 37;
-const tExtraID kN22ClawDLoop = 38;
-const tExtraID kN22ClawDPinch = 39;
-const tExtraID kN22ClawDCounterclockwise = 40;
-const tExtraID kN22ClawDClockwise = 41;
-
-
-//	Norad Delta Extra sequence IDs.
-
-const tExtraID kArriveFromSubChase = 0;
-const tExtraID kN59ZoomWithRobot = 1;
-const tExtraID kN59RobotApproaches = 2;
-const tExtraID kN59RobotPunchLoop = 3;
-const tExtraID kN59PlayerWins1 = 4;
-const tExtraID kN59PlayerWins2 = 5;
-const tExtraID kN59RobotWins = 6;
-const tExtraID kN59RobotHeadOpens = 7;
-const tExtraID kN59Biochips111 = 8;
-const tExtraID kN59Biochips011 = 9;
-const tExtraID kN59Biochips101 = 10;
-const tExtraID kN59Biochips001 = 11;
-const tExtraID kN59Biochips110 = 12;
-const tExtraID kN59Biochips010 = 13;
-const tExtraID kN59Biochips100 = 14;
-const tExtraID kN59Biochips000 = 15;
-const tExtraID kN59RobotDisappears = 16;
-const tExtraID kN60ClawFromAToB = 17;
-const tExtraID kN60ClawALoop = 18;
-const tExtraID kN60ClawAPinch = 19;
-const tExtraID kN60ClawACounterclockwise = 20;
-const tExtraID kN60ClawAClockwise = 21;
-const tExtraID kN60ClawFromBToA = 22;
-const tExtraID kN60ClawFromBToC = 23;
-const tExtraID kN60ClawFromBToD = 24;
-const tExtraID kN60ClawBLoop = 25;
-const tExtraID kN60ClawBPinch = 26;
-const tExtraID kN60ClawBCounterclockwise = 27;
-const tExtraID kN60ClawBClockwise = 28;
-const tExtraID kN60ClawFromCToB = 29;
-const tExtraID kN60ClawCLoop = 30;
-const tExtraID kN60ClawCPinch = 31;
-const tExtraID kN60ClawCCounterclockwise = 32;
-const tExtraID kN60ClawCClockwise = 33;
-const tExtraID kN60ClawFromDToB = 34;
-const tExtraID kN60ClawDLoop = 35;
-const tExtraID kN60ClawDPinch = 36;
-const tExtraID kN60ClawDCounterclockwise = 37;
-const tExtraID kN60ClawDClockwise = 38;
-const tExtraID kN60RobotApproaches = 39;
-const tExtraID kN60FirstMistake = 40;
-const tExtraID kN60ArmActivated = 41;
-const tExtraID kN60SecondMistake = 42;
-const tExtraID kN60ArmToPositionB = 43;
-const tExtraID kN60ThirdMistake = 44;
-const tExtraID kN60ArmGrabsRobot = 45;
-const tExtraID kN60FourthMistake = 46;
-const tExtraID kN60ArmCarriesRobotToPositionA = 47;
-const tExtraID kN60PlayerFollowsRobotToDoor = 48;
-const tExtraID kN60RobotHeadOpens = 49;
-const tExtraID kN60Biochips111 = 50;
-const tExtraID kN60Biochips011 = 51;
-const tExtraID kN60Biochips101 = 52;
-const tExtraID kN60Biochips001 = 53;
-const tExtraID kN60Biochips110 = 54;
-const tExtraID kN60Biochips010 = 55;
-const tExtraID kN60Biochips100 = 56;
-const tExtraID kN60Biochips000 = 57;
-const tExtraID kN60RobotDisappears = 58;
-const tExtraID kNoradDeltaRetinalScanBad = 59;
-const tExtraID kNoradDeltaRetinalScanGood = 60;
-const tExtraID kN79BrightView = 61;
-
-const tRoomID kNorad59West = 23;
-const tRoomID kNorad60West = 25;
-
 // This is the code common to both Norad Alpha and Norad Delta
 
 class Norad : public Neighborhood {
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.cpp b/engines/pegasus/neighborhood/norad/noradelevator.cpp
index 98b3d29..0cdc818 100755
--- a/engines/pegasus/neighborhood/norad/noradelevator.cpp
+++ b/engines/pegasus/neighborhood/norad/noradelevator.cpp
@@ -25,6 +25,7 @@
 
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/noradelevator.h"
 
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
index 59adb09..7cb483f 100755
--- a/engines/pegasus/neighborhood/norad/pressuredoor.cpp
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
@@ -26,8 +26,10 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/pressuredoor.h"
+#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 
 namespace Pegasus {
 
@@ -338,8 +340,7 @@ void PressureDoor::receiveNotification(Notification *notification, const tNotifi
 				break;
 			case kRobotDead:
 				allowInput(true);
-				// TODO
-				//((NoradDelta *)owner)->playerBeatRobotWithDoor();
+				((NoradDelta *)owner)->playerBeatRobotWithDoor();
 				owner->requestDeleteCurrentInteraction();
 				break;
 			}
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index 9174a72..0515f96 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -25,8 +25,10 @@
 
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/subcontrolroom.h"
+#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 
 namespace Pegasus {
 
@@ -658,8 +660,7 @@ void SubControlRoom::receiveNotification(Notification *notification, const tNoti
 				owner->startExtraSequence(kN60PlayerFollowsRobotToDoor, kExtraCompletedFlag, kFilterAllInput);
 				break;
 			case kPlayerWon:
-				// TODO
-				//((NoradDelta *)owner)->playerBeatRobotWithClaw();
+				((NoradDelta *)owner)->playerBeatRobotWithClaw();
 				owner->requestDeleteCurrentInteraction();
 				break;
 			case kRobotWon:
diff --git a/engines/pegasus/neighborhood/norad/subplatform.cpp b/engines/pegasus/neighborhood/norad/subplatform.cpp
index 2665ab4..dd2058c 100755
--- a/engines/pegasus/neighborhood/norad/subplatform.cpp
+++ b/engines/pegasus/neighborhood/norad/subplatform.cpp
@@ -26,6 +26,7 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/norad.h"
 #include "pegasus/neighborhood/norad/subplatform.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 3d19cc3..3884f0f 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -31,7 +31,7 @@
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
-#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/mars/constants.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index a2e2ef8..da3a55c 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -30,7 +30,7 @@
 #include "pegasus/items/biochips/aichip.h"
 #include "pegasus/items/biochips/opticalchip.h"
 #include "pegasus/neighborhood/mars/constants.h"
-#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
 #include "pegasus/neighborhood/wsc/wsc.h"
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index de2e7f4..e5a1776 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -63,7 +63,9 @@
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/mars/mars.h"
+#include "pegasus/neighborhood/norad/constants.h"
 #include "pegasus/neighborhood/norad/alpha/noradalpha.h"
+#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 #include "pegasus/neighborhood/prehistoric/prehistoric.h"
 #include "pegasus/neighborhood/tsa/fulltsa.h"
 #include "pegasus/neighborhood/tsa/tinytsa.h"
@@ -1374,7 +1376,7 @@ void PegasusEngine::makeNeighborhood(tNeighborhoodID neighborhoodID, Neighborhoo
 		break;
 	case kNoradDeltaID:
 		createInterface();
-		error("TODO: Norad Delta");
+		neighborhood = new NoradDelta(g_AIArea, this);
 		break;
 	default:
 		error("Unknown neighborhood %d", neighborhoodID);


Commit: 693fcec6f5a43a3035c00ec8802795a00c3045ee
    https://github.com/scummvm/scummvm/commit/693fcec6f5a43a3035c00ec8802795a00c3045ee
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-15T16:18:29-08:00

Commit Message:
PEGASUS: Fix info screen weirdness

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index e5a1776..e2cb560 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1458,6 +1458,7 @@ void PegasusEngine::showInfoScreen() {
 		TimeValue startTime, stopTime;
 		g_AIArea->getSmallInfoSegment(startTime, stopTime);
 		_smallInfoMovie.setSegment(startTime, stopTime);
+		_smallInfoMovie.setTime(startTime);
 		_smallInfoMovie.setFlags(kLoopTimeBase);
 
 		_bigInfoMovie.initFromMovieFile("Images/Items/Info Left Movie");
@@ -1632,6 +1633,7 @@ void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot
 				TimeValue startTime, stopTime;
 				g_AIArea->getSmallInfoSegment(startTime, stopTime);
 				_smallInfoMovie.setSegment(startTime, stopTime);
+				_smallInfoMovie.setTime(startTime);
 				_smallInfoMovie.setFlags(kLoopTimeBase);
 
 				_bigInfoMovie.redrawMovieWorld();


Commit: b5565a43378014a037798f43bc382b2c30cdf8d9
    https://github.com/scummvm/scummvm/commit/b5565a43378014a037798f43bc382b2c30cdf8d9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-15T16:21:49-08:00

Commit Message:
PEGASUS: Fix compilation on Windows

Changed paths:
    engines/pegasus/notification.h



diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
index ded6647..70fcd82 100755
--- a/engines/pegasus/notification.h
+++ b/engines/pegasus/notification.h
@@ -41,8 +41,8 @@ struct tReceiverEntry {
 	tNotificationFlags mask;
 };
 
-int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
-int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry1);
+int operator==(const tReceiverEntry &entry1, const tReceiverEntry &entry2);
+int operator!=(const tReceiverEntry &entry1, const tReceiverEntry &entry2);
 
 typedef Common::List<tReceiverEntry> tReceiverList;
 


Commit: fdced472abc830c07d28474727db004c8018fcac
    https://github.com/scummvm/scummvm/commit/fdced472abc830c07d28474727db004c8018fcac
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-15T19:01:03-08:00

Commit Message:
PEGASUS: Begin cleaning up pegasus-defined types

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/types.h
    engines/pegasus/util.cpp
    engines/pegasus/util.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index c6d4e45..17466b0 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -99,15 +99,8 @@ const tNotificationFlags kNoNotificationFlags = 0;
 
 const tDisplayElementID kCurrentDragSpriteID = 1000;
 
-// TODO
-//const Fixed kFixed1 = 1 << 16;
-//const Fixed kFixedMinus1 = -1 << 16;
-
 const TimeScale kDefaultTimeScale = 600;
 
-// TODO
-//const RGBColor kWhiteRGB = {0xFFFF, 0xFFFF, 0xFFFF};
-
 //	Ticks per second.
 
 const TimeScale kOneTickPerSecond = 1;
@@ -355,10 +348,6 @@ const tCoordType kBiochipPushTop = 192;
 const tCoordType kBiochipLidLeft = 362;
 const tCoordType kBiochipLidTop = 316;
 
-// TODO: Remove global variable needs
-//const Common::Rect kInventoryHiliteBounds(334, 76, 430, 172);
-//const Common::Rect kBiochipHiliteBounds (334, 364, 430, 460);
-
 const tCoordType kInventoryDropLeft = 0;
 const tCoordType kInventoryDropTop = 320;
 const tCoordType kInventoryDropRight = 232;
@@ -521,10 +510,10 @@ const tHotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
 											kOpticalBiochipSpotFlag |
 											kAirMaskSpotFlag;
 
-const tMM32BitID kMainMenuID = 1;
-const tMM32BitID kPauseMenuID = 2;
-const tMM32BitID kCreditsMenuID = 3;
-const tMM32BitID kDeathMenuID = 4;
+const int32 kMainMenuID = 1;
+const int32 kPauseMenuID = 2;
+const int32 kCreditsMenuID = 3;
+const int32 kDeathMenuID = 4;
 
 /////////////////////////////////////////////
 //
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index c670c6b..db05e22 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -37,7 +37,7 @@ namespace Common {
 
 namespace Pegasus {
 
-typedef tMM8BitFlags tDoorFlags;
+typedef byte tDoorFlags;
 
 enum {
 	kDoorPresentBit,				//	Bit set if there is a door here.
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index 38cc81d..1d5d296 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -37,7 +37,7 @@ namespace Common {
 
 namespace Pegasus {
 
-typedef tMM8BitFlags tSpotFlags;
+typedef byte tSpotFlags;
 
 enum {
 	kSpotLoopsBit,			//	Loop or once only?
diff --git a/engines/pegasus/types.h b/engines/pegasus/types.h
index ed22784..d025737 100755
--- a/engines/pegasus/types.h
+++ b/engines/pegasus/types.h
@@ -30,53 +30,23 @@
 
 namespace Pegasus {
 
-// TODO: All of the "tMM"-prefixed defines should be replaced eventually
 // TODO: Probably all of these don't really need to be typedef'd...
-typedef int8 tMM8BitS;
-typedef uint8 tMM8BitU;
 
-typedef int16 tMM16BitS;
-typedef uint16 tMM16BitU;
+typedef int32 tDisplayElementID;
+typedef int32 tDisplayOrder;
 
-typedef int32 tMM32BitS;
-typedef uint32 tMM32BitU;
+typedef int16 tHotSpotID;
+typedef uint32 tHotSpotFlags;
 
-typedef tMM8BitS tMM8BitID;
-typedef tMM16BitS tMM16BitID;
-typedef tMM32BitS tMM32BitID;
+typedef byte tButtonState;
+typedef uint32 tInputBits;
 
-typedef tMM8BitU tMM8BitFlags;
-typedef tMM16BitU tMM16BitFlags;
-typedef tMM32BitU tMM32BitFlags;
+typedef int32 tNotificationID;
+typedef uint32 tNotificationFlags;
 
-typedef tMM32BitID tDisplayElementID;
-typedef tMM32BitS tDisplayOrder;
-
-typedef tMM16BitID tHotSpotID;
-typedef tMM32BitFlags tHotSpotFlags;
-
-typedef tMM8BitFlags tButtonState;
-typedef tMM32BitFlags tInputBits;
-
-typedef tMM8BitU tKeyMapType[16];
-typedef tMM8BitU tKeyType;
-typedef tMM8BitU tKeyMapIndexType;
-typedef tMM8BitU tKeyMapBitType;
-
-typedef tMM32BitID tNotificationID;
-typedef tMM32BitFlags tNotificationFlags;
-
-//	Mac types.
-typedef tMM16BitS tResIDType;
-typedef tMM16BitS tCoordType;
-typedef tMM16BitS tQDCopyMode;
-typedef tMM16BitS tResItemCountType;
-
-enum tCopyMode {
-	kNoMask,
-	kUseClipArea,
-	kUseTransparency
-};
+// Mac types.
+typedef int16 tResIDType;
+typedef int16 tCoordType;
 
 enum tSlideDirection {
 	kSlideLeftMask = 1,
@@ -96,40 +66,39 @@ enum tSlideDirection {
 // ScummVM QuickTime/QuickDraw replacement types
 typedef uint TimeValue;
 typedef uint TimeScale;
-// TODO: Fixed and RGBColor
 
-typedef tMM16BitID tGameID;
+typedef int16 tGameID;
 
 typedef tGameID tItemID;
 typedef tGameID tActorID;
 typedef tGameID tRoomID;
 typedef tGameID tNeighborhoodID;
-typedef tMM8BitU tAlternateID;
-typedef tMM8BitS tHotSpotActivationID;
+typedef byte tAlternateID;
+typedef int8 tHotSpotActivationID;
 
-typedef tMM16BitS tWeightType;
+typedef int16 tWeightType;
 
-typedef tMM8BitU tDirectionConstant;
-typedef tMM8BitU tTurnDirection;
+typedef byte tDirectionConstant;
+typedef byte tTurnDirection;
 
 // Meant to be room in low 16 bits and direction in high 16 bits.
-typedef tMM32BitU tRoomViewID;
+typedef uint32 tRoomViewID;
 
 #define MakeRoomView(room, direction) (((tRoomViewID) (room)) | (((tRoomViewID) (direction)) << 16))
 
-typedef tMM32BitU tExtraID;
+typedef uint32 tExtraID;
 
-typedef tMM16BitS tGameMode;
+typedef int16 tGameMode;
 
-typedef tMM16BitS tWeightType;
+typedef int16 tWeightType;
 
-typedef tMM16BitS tItemState;
+typedef int16 tItemState;
 
-typedef tMM8BitS tDeathReason;
+typedef int8 tDeathReason;
 
-typedef tMM32BitS tGameMenuCommand;
+typedef int32 tGameMenuCommand;
 
-typedef tMM32BitS tGameScoreType;
+typedef int32 tGameScoreType;
 
 typedef long tCanMoveForwardReason;
 
@@ -143,9 +112,9 @@ enum tInventoryResult {
 	kItemNotInInventory
 };
 
-typedef tMM32BitID tInteractionID;
+typedef int32 tInteractionID;
 
-typedef tMM32BitID tAIConditionID;
+typedef int32 tAIConditionID;
 
 enum tEnergyStage {
 	kStageNoStage,
diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
index f0d80f5..c38054d 100755
--- a/engines/pegasus/util.cpp
+++ b/engines/pegasus/util.cpp
@@ -31,14 +31,14 @@
 
 namespace Pegasus {
 
-IDObject::IDObject(const tMM32BitID id) {
+IDObject::IDObject(const int32 id) {
 	_objectID = id;
 }
 
 IDObject::~IDObject() {
 }
 
-tMM32BitID IDObject::getObjectID() const {
+int32 IDObject::getObjectID() const {
 	return _objectID;
 }
 
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index 6eb1580..8ca69da 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -38,13 +38,13 @@ namespace Pegasus {
 
 class IDObject {
 public:
-	IDObject(const tMM32BitID id);
+	IDObject(const int32 id);
 	~IDObject();
 	
-	tMM32BitID getObjectID() const;
+	int32 getObjectID() const;
 
 private:
-	tMM32BitID _objectID;
+	int32 _objectID;
 };
 
 class FunctionPtr;


Commit: 12efb47b536d2f663c9cde2739a1fd40599da669
    https://github.com/scummvm/scummvm/commit/12efb47b536d2f663c9cde2739a1fd40599da669
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-16T11:17:50-08:00

Commit Message:
PEGASUS: Remove t prefix from typedefs

Some other minor cleanup too

Changed paths:
    engines/pegasus/ai/ai_action.cpp
    engines/pegasus/ai/ai_action.h
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/ai/ai_area.h
    engines/pegasus/ai/ai_condition.cpp
    engines/pegasus/ai/ai_condition.h
    engines/pegasus/compass.cpp
    engines/pegasus/console.cpp
    engines/pegasus/constants.h
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h
    engines/pegasus/energymonitor.cpp
    engines/pegasus/energymonitor.h
    engines/pegasus/fader.h
    engines/pegasus/gamestate.cpp
    engines/pegasus/gamestate.h
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/hotspot.cpp
    engines/pegasus/hotspot.h
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/interaction.h
    engines/pegasus/interface.cpp
    engines/pegasus/interface.h
    engines/pegasus/items/biochips/aichip.cpp
    engines/pegasus/items/biochips/aichip.h
    engines/pegasus/items/biochips/biochipitem.cpp
    engines/pegasus/items/biochips/biochipitem.h
    engines/pegasus/items/biochips/mapchip.cpp
    engines/pegasus/items/biochips/mapchip.h
    engines/pegasus/items/biochips/mapimage.cpp
    engines/pegasus/items/biochips/mapimage.h
    engines/pegasus/items/biochips/opticalchip.cpp
    engines/pegasus/items/biochips/opticalchip.h
    engines/pegasus/items/biochips/pegasuschip.cpp
    engines/pegasus/items/biochips/pegasuschip.h
    engines/pegasus/items/biochips/retscanchip.cpp
    engines/pegasus/items/biochips/retscanchip.h
    engines/pegasus/items/biochips/shieldchip.cpp
    engines/pegasus/items/biochips/shieldchip.h
    engines/pegasus/items/inventory.cpp
    engines/pegasus/items/inventory.h
    engines/pegasus/items/inventory/airmask.cpp
    engines/pegasus/items/inventory/airmask.h
    engines/pegasus/items/inventory/gascanister.cpp
    engines/pegasus/items/inventory/gascanister.h
    engines/pegasus/items/inventory/inventoryitem.cpp
    engines/pegasus/items/inventory/inventoryitem.h
    engines/pegasus/items/inventory/keycard.cpp
    engines/pegasus/items/inventory/keycard.h
    engines/pegasus/items/inventorypicture.cpp
    engines/pegasus/items/inventorypicture.h
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h
    engines/pegasus/items/itemlist.cpp
    engines/pegasus/items/itemlist.h
    engines/pegasus/menu.cpp
    engines/pegasus/menu.h
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.h
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
    engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
    engines/pegasus/neighborhood/caldoria/caldoriabomb.h
    engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
    engines/pegasus/neighborhood/caldoria/caldoriamessages.h
    engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
    engines/pegasus/neighborhood/caldoria/caldoriamirror.h
    engines/pegasus/neighborhood/door.cpp
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/exit.cpp
    engines/pegasus/neighborhood/exit.h
    engines/pegasus/neighborhood/extra.cpp
    engines/pegasus/neighborhood/extra.h
    engines/pegasus/neighborhood/hotspotinfo.cpp
    engines/pegasus/neighborhood/hotspotinfo.h
    engines/pegasus/neighborhood/mars/constants.h
    engines/pegasus/neighborhood/mars/energybeam.cpp
    engines/pegasus/neighborhood/mars/gravitoncannon.cpp
    engines/pegasus/neighborhood/mars/hermite.cpp
    engines/pegasus/neighborhood/mars/hermite.h
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/mars.h
    engines/pegasus/neighborhood/mars/planetmover.cpp
    engines/pegasus/neighborhood/mars/planetmover.h
    engines/pegasus/neighborhood/mars/reactor.cpp
    engines/pegasus/neighborhood/mars/reactor.h
    engines/pegasus/neighborhood/mars/robotship.cpp
    engines/pegasus/neighborhood/mars/robotship.h
    engines/pegasus/neighborhood/mars/shuttlehud.cpp
    engines/pegasus/neighborhood/mars/shuttleweapon.cpp
    engines/pegasus/neighborhood/mars/shuttleweapon.h
    engines/pegasus/neighborhood/mars/spacejunk.cpp
    engines/pegasus/neighborhood/mars/spacejunk.h
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
    engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
    engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
    engines/pegasus/neighborhood/norad/alpha/fillingstation.h
    engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
    engines/pegasus/neighborhood/norad/alpha/noradalpha.h
    engines/pegasus/neighborhood/norad/alpha/panorama.cpp
    engines/pegasus/neighborhood/norad/alpha/panorama.h
    engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
    engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
    engines/pegasus/neighborhood/norad/constants.h
    engines/pegasus/neighborhood/norad/delta/globegame.cpp
    engines/pegasus/neighborhood/norad/delta/globegame.h
    engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
    engines/pegasus/neighborhood/norad/delta/noraddelta.h
    engines/pegasus/neighborhood/norad/norad.cpp
    engines/pegasus/neighborhood/norad/norad.h
    engines/pegasus/neighborhood/norad/noradelevator.cpp
    engines/pegasus/neighborhood/norad/noradelevator.h
    engines/pegasus/neighborhood/norad/pressuredoor.cpp
    engines/pegasus/neighborhood/norad/pressuredoor.h
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.h
    engines/pegasus/neighborhood/norad/subplatform.cpp
    engines/pegasus/neighborhood/norad/subplatform.h
    engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
    engines/pegasus/neighborhood/prehistoric/prehistoric.h
    engines/pegasus/neighborhood/spot.cpp
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.h
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.h
    engines/pegasus/neighborhood/turn.cpp
    engines/pegasus/neighborhood/turn.h
    engines/pegasus/neighborhood/view.cpp
    engines/pegasus/neighborhood/view.h
    engines/pegasus/neighborhood/wsc/moleculebin.cpp
    engines/pegasus/neighborhood/wsc/wsc.cpp
    engines/pegasus/neighborhood/wsc/wsc.h
    engines/pegasus/neighborhood/zoom.cpp
    engines/pegasus/neighborhood/zoom.h
    engines/pegasus/notification.cpp
    engines/pegasus/notification.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/scoring.h
    engines/pegasus/surface.h
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h
    engines/pegasus/transition.cpp
    engines/pegasus/transition.h
    engines/pegasus/types.h



diff --git a/engines/pegasus/ai/ai_action.cpp b/engines/pegasus/ai/ai_action.cpp
index 36367eb..38d6390 100755
--- a/engines/pegasus/ai/ai_action.cpp
+++ b/engines/pegasus/ai/ai_action.cpp
@@ -38,7 +38,7 @@ void AICompoundAction::performAIAction(AIRule *rule) {
 		(*it)->performAIAction(rule);
 }
 
-AIPlayMessageAction::AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const tInputBits interruptionFilter) {
+AIPlayMessageAction::AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const InputBits interruptionFilter) {
 	_movieName = movieName;
 	_keepLastFrame = keepLastFrame;
 	_interruptionFilter = interruptionFilter;
diff --git a/engines/pegasus/ai/ai_action.h b/engines/pegasus/ai/ai_action.h
index 09a1d13..9ac3078 100755
--- a/engines/pegasus/ai/ai_action.h
+++ b/engines/pegasus/ai/ai_action.h
@@ -79,13 +79,13 @@ protected:
 
 class AIPlayMessageAction : public AIAction {
 public:
-	AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const tInputBits = kWarningInterruption);
+	AIPlayMessageAction(const Common::String &movieName, bool keepLastFrame, const InputBits = kWarningInterruption);
 
 	virtual void performAIAction(AIRule *);
 
 protected:
 	Common::String _movieName;
-	tInputBits _interruptionFilter;
+	InputBits _interruptionFilter;
 	bool _keepLastFrame;
 };
 
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 923df41..6203843 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -135,7 +135,7 @@ void AIArea::setAIVolume(const uint16 volume) {
 // If this function is called while a sequence is playing, it will just "remember"
 // the time value, so that when the sequence finishes, the new time is asserted.
 
-void AIArea::setAIAreaToTime(const tLowerClientSignature client, const tLowerAreaSignature area, const TimeValue time) {
+void AIArea::setAIAreaToTime(const LowerClientSignature client, const LowerAreaSignature area, const TimeValue time) {
 	switch (area) {
 	case kLeftAreaSignature:
 		// Only support kInventorySignature client, since AI never calls SetAIAreaToTime.
@@ -199,7 +199,7 @@ void AIArea::setAIAreaToTime(const tLowerClientSignature client, const tLowerAre
 //		kBiochipSignature		kRightAreaSignature
 //		kInventorySignature		kMiddleAreaSignature
 
-void AIArea::playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature area, const TimeValue start, const TimeValue stop) {
+void AIArea::playAIAreaSequence(const LowerClientSignature, const LowerAreaSignature area, const TimeValue start, const TimeValue stop) {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 
 	lockAIOut();
@@ -260,7 +260,7 @@ void AIArea::playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSig
 	unlockAI();
 }
 
-bool AIArea::playAIMovie(const tLowerAreaSignature area, const Common::String &movieName, bool keepLastFrame, const tInputBits interruptFilter) {
+bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &movieName, bool keepLastFrame, const InputBits interruptFilter) {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 	
 	lockAIOut();
@@ -337,7 +337,7 @@ bool AIArea::playAIMovie(const tLowerAreaSignature area, const Common::String &m
 }
 
 //	Only implemented for kMiddleAreaSignature, kInventorySignature
-void AIArea::loopAIAreaSequence(const tLowerClientSignature owner, const tLowerAreaSignature area, const TimeValue start, const TimeValue stop) {
+void AIArea::loopAIAreaSequence(const LowerClientSignature owner, const LowerAreaSignature area, const TimeValue start, const TimeValue stop) {
 	if (area == kMiddleAreaSignature && owner == kInventorySignature && owner == _middleAreaOwner) {
 		_middleAreaMovie.stop();
 		_middleAreaMovie.setFlags(0);
@@ -361,7 +361,7 @@ void AIArea::setLeftMovieTime(const TimeValue time) {
 	_leftInventoryTime = time;
 }
 
-void AIArea::setMiddleMovieTime(const tLowerClientSignature client, const TimeValue time) {	
+void AIArea::setMiddleMovieTime(const LowerClientSignature client, const TimeValue time) {	
 	if (client == kInventorySignature) {
 		_middleInventoryTime = time;
 		if (_middleAreaOwner == kBiochipSignature) {
@@ -594,7 +594,7 @@ void AIArea::getSmallInfoSegment(TimeValue &start, TimeValue &stop) {
 	}
 }
 
-tLowerClientSignature AIArea::getMiddleAreaOwner() {
+LowerClientSignature AIArea::getMiddleAreaOwner() {
 	return _middleAreaOwner;
 }
 
diff --git a/engines/pegasus/ai/ai_area.h b/engines/pegasus/ai/ai_area.h
index 7387b40..10bfc93 100755
--- a/engines/pegasus/ai/ai_area.h
+++ b/engines/pegasus/ai/ai_area.h
@@ -108,18 +108,18 @@ public:
 	//      kAISignature            kLeftAreaSignature
 	// Further, the kAISignature never sets a static frame time in the left area,
 	// but only plays a sequence from the AI movie.
-	void setAIAreaToTime(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue);
+	void setAIAreaToTime(const LowerClientSignature, const LowerAreaSignature, const TimeValue);
 	
 	// The "Play" functions play the requested sequence synchronously.
-	void playAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue, const TimeValue);
+	void playAIAreaSequence(const LowerClientSignature, const LowerAreaSignature, const TimeValue, const TimeValue);
 
 	// For PlayAIMovie, it is assumed that the client is the AI itself.
 	// This is used to play AI messages as well as Optical Memory video.
 	// Returns true if the movie played all the way through, false if it was interrupted.
-	bool playAIMovie(const tLowerAreaSignature, const Common::String &movieName, bool keepLastFrame, const tInputBits);
+	bool playAIMovie(const LowerAreaSignature, const Common::String &movieName, bool keepLastFrame, const InputBits);
 
 	// Loop the requested sequence indefinitely.
-	void loopAIAreaSequence(const tLowerClientSignature, const tLowerAreaSignature, const TimeValue, const TimeValue);
+	void loopAIAreaSequence(const LowerClientSignature, const LowerAreaSignature, const TimeValue, const TimeValue);
 
 	void addAIRule(AIRule *);
 
@@ -133,7 +133,7 @@ public:
 	void checkMiddleArea();
 	void checkRules();
 
-	tLowerClientSignature getMiddleAreaOwner();
+	LowerClientSignature getMiddleAreaOwner();
 	void toggleMiddleAreaOwner();
 
 	TimeValue getBigInfoTime();
@@ -143,7 +143,7 @@ protected:
 	void useIdleTime();
 
 	void setLeftMovieTime(const TimeValue);
-	void setMiddleMovieTime(const tLowerClientSignature, const TimeValue);
+	void setMiddleMovieTime(const LowerClientSignature, const TimeValue);
 	void setRightMovieTime(const TimeValue);
 
 	Movie _leftAreaMovie;
@@ -151,9 +151,9 @@ protected:
 	Movie _rightAreaMovie;
 	Movie _AIMovie;
 
-	tLowerClientSignature _leftAreaOwner;
-	tLowerClientSignature _middleAreaOwner;
-	tLowerClientSignature _rightAreaOwner;
+	LowerClientSignature _leftAreaOwner;
+	LowerClientSignature _middleAreaOwner;
+	LowerClientSignature _rightAreaOwner;
 
 	TimeValue _leftInventoryTime;
 	TimeValue _middleInventoryTime;
diff --git a/engines/pegasus/ai/ai_condition.cpp b/engines/pegasus/ai/ai_condition.cpp
index 8b77d72..df6d322 100755
--- a/engines/pegasus/ai/ai_condition.cpp
+++ b/engines/pegasus/ai/ai_condition.cpp
@@ -149,20 +149,20 @@ bool AITimerCondition::fireCondition() {
 AILocationCondition::AILocationCondition(uint32 maxLocations) {
 	_numLocations = 0;
 	_maxLocations = maxLocations;
-	_locations = new tRoomViewID[maxLocations];
+	_locations = new RoomViewID[maxLocations];
 }
 
 AILocationCondition::~AILocationCondition() {
 	delete[] _locations;
 }
 
-void AILocationCondition::addLocation(const tRoomViewID location) {
+void AILocationCondition::addLocation(const RoomViewID location) {
 	if (_numLocations < _maxLocations)
 		_locations[_numLocations++] = location;
 }
 
 bool AILocationCondition::fireCondition() {
-	tRoomViewID test = GameState.getCurrentRoomAndView(), *p;
+	RoomViewID test = GameState.getCurrentRoomAndView(), *p;
 	uint32 i;
 
 	for (i = 0, p = _locations; i < _numLocations; i++, p++) {
@@ -180,7 +180,7 @@ void AILocationCondition::writeAICondition(Common::WriteStream *stream) {
 	stream->writeUint32BE(_numLocations);
 
 	uint32 i;
-	tRoomViewID *p;
+	RoomViewID *p;
 	for (i = 0, p = _locations; i < _numLocations; i++, p++)
 		stream->writeUint32BE(*p);
 }
@@ -190,19 +190,19 @@ void AILocationCondition::readAICondition(Common::ReadStream *stream) {
 
 	if (_maxLocations != maxLocations) {
 		delete[] _locations;
-		_locations = new tRoomViewID[maxLocations];
+		_locations = new RoomViewID[maxLocations];
 		_maxLocations = maxLocations;
 	}
 
 	_numLocations = stream->readUint32BE();
 
 	uint32 i;
-	tRoomViewID *p;
+	RoomViewID *p;
 	for (i = 0, p = _locations; i < _numLocations; i++, p++)
 		*p = stream->readUint32BE();
 }
 
-AIDoorOpenedCondition::AIDoorOpenedCondition(tRoomViewID doorLocation) {
+AIDoorOpenedCondition::AIDoorOpenedCondition(RoomViewID doorLocation) {
 	_doorLocation = doorLocation;
 }
 
@@ -210,7 +210,7 @@ bool AIDoorOpenedCondition::fireCondition() {
 	return GameState.getCurrentRoomAndView() == _doorLocation && GameState.isCurrentDoorOpen();
 }
 
-AIHasItemCondition::AIHasItemCondition(const tItemID item) {
+AIHasItemCondition::AIHasItemCondition(const ItemID item) {
 	_item = item;
 }
 
@@ -218,7 +218,7 @@ bool AIHasItemCondition::fireCondition() {
 	return _item == kNoItemID || GameState.isTakenItemID(_item);
 }
 
-AIDoesntHaveItemCondition::AIDoesntHaveItemCondition(const tItemID item) {
+AIDoesntHaveItemCondition::AIDoesntHaveItemCondition(const ItemID item) {
 	_item = item;
 }
 
@@ -226,7 +226,7 @@ bool AIDoesntHaveItemCondition::fireCondition() {
 	return _item == kNoItemID || !GameState.isTakenItemID(_item);
 }
 
-AICurrentItemCondition::AICurrentItemCondition(const tItemID item) {
+AICurrentItemCondition::AICurrentItemCondition(const ItemID item) {
 	_item = item;
 }
 	
@@ -239,7 +239,7 @@ bool AICurrentItemCondition::fireCondition() {
 	return item != 0 && item->getObjectID() == _item;
 }
 
-AICurrentBiochipCondition::AICurrentBiochipCondition(const tItemID biochip)  {
+AICurrentBiochipCondition::AICurrentBiochipCondition(const ItemID biochip)  {
 	_biochip = biochip;
 }
 
@@ -252,7 +252,7 @@ bool AICurrentBiochipCondition::fireCondition() {
 	return biochip != 0 && biochip->getObjectID() == _biochip;
 }
 
-AIItemStateCondition::AIItemStateCondition(const tItemID item, const tItemState state) {
+AIItemStateCondition::AIItemStateCondition(const ItemID item, const ItemState state) {
 	_item = item;
 	_state = state;
 }
@@ -270,15 +270,15 @@ bool AIEnergyMonitorCondition::fireCondition() {
 	return g_energyMonitor != 0 && g_energyMonitor->getCurrentEnergy() < _energyThreshold;
 }
 
-AILastExtraCondition::AILastExtraCondition(const tExtraID lastExtra) {
+AILastExtraCondition::AILastExtraCondition(const ExtraID lastExtra) {
 	_lastExtra = lastExtra;
 }
 
 bool AILastExtraCondition::fireCondition() {
-	return g_neighborhood && (tExtraID)g_neighborhood->getLastExtra() == _lastExtra;
+	return g_neighborhood && (ExtraID)g_neighborhood->getLastExtra() == _lastExtra;
 }
 
-AICondition *makeLocationAndDoesntHaveItemCondition(const tRoomID room, const tDirectionConstant direction, const tItemID item) {
+AICondition *makeLocationAndDoesntHaveItemCondition(const RoomID room, const DirectionConstant direction, const ItemID item) {
 	AILocationCondition *location = new AILocationCondition(1);
 	location->addLocation(MakeRoomView(room, direction));
 	
diff --git a/engines/pegasus/ai/ai_condition.h b/engines/pegasus/ai/ai_condition.h
index 559ec55..ba4f411 100755
--- a/engines/pegasus/ai/ai_condition.h
+++ b/engines/pegasus/ai/ai_condition.h
@@ -151,15 +151,15 @@ public:
 	AILocationCondition(uint32);
 	virtual ~AILocationCondition();
 
-	void addLocation(tRoomViewID);
+	void addLocation(RoomViewID);
 	virtual bool fireCondition();
 
-	virtual void					writeAICondition(Common::WriteStream *);
-	virtual void					readAICondition(Common::ReadStream *);
+	virtual void writeAICondition(Common::WriteStream *);
+	virtual void readAICondition(Common::ReadStream *);
 
 protected:
 	uint32 _numLocations, _maxLocations;
-	tRoomViewID *_locations;
+	RoomViewID *_locations;
 };
 
 /////////////////////////////////////////////
@@ -168,13 +168,13 @@ protected:
 
 class AIDoorOpenedCondition : public AICondition {
 public:
-	AIDoorOpenedCondition(tRoomViewID);
+	AIDoorOpenedCondition(RoomViewID);
 	virtual ~AIDoorOpenedCondition() {}
 
 	virtual bool fireCondition();
 
 protected:
-	tRoomViewID _doorLocation;
+	RoomViewID _doorLocation;
 };
 
 /////////////////////////////////////////////
@@ -183,12 +183,12 @@ protected:
 
 class AIHasItemCondition : public AICondition {
 public:
-	AIHasItemCondition(const tItemID);
+	AIHasItemCondition(const ItemID);
 
 	virtual bool fireCondition();
 
 protected:
-	tItemID _item;
+	ItemID _item;
 };
 
 /////////////////////////////////////////////
@@ -197,12 +197,12 @@ protected:
 
 class AIDoesntHaveItemCondition : public AICondition {
 public:
-	AIDoesntHaveItemCondition(const tItemID);
+	AIDoesntHaveItemCondition(const ItemID);
 
 	virtual bool fireCondition();
 
 protected:
-	tItemID _item;
+	ItemID _item;
 };
 
 /////////////////////////////////////////////
@@ -211,12 +211,12 @@ protected:
 
 class AICurrentItemCondition : public AICondition {
 public:
-	AICurrentItemCondition(const tItemID);
+	AICurrentItemCondition(const ItemID);
 
 	virtual bool fireCondition();
 
 protected:
-	tItemID _item;
+	ItemID _item;
 };
 
 /////////////////////////////////////////////
@@ -225,12 +225,12 @@ protected:
 
 class AICurrentBiochipCondition : public AICondition {
 public:
-	AICurrentBiochipCondition(const tItemID);
+	AICurrentBiochipCondition(const ItemID);
 
 	virtual bool fireCondition();
 
 protected:
-	tItemID _biochip;
+	ItemID _biochip;
 };
 
 /////////////////////////////////////////////
@@ -239,13 +239,13 @@ protected:
 
 class AIItemStateCondition : public AICondition {
 public:
-	AIItemStateCondition(const tItemID, const tItemState);
+	AIItemStateCondition(const ItemID, const ItemState);
 
 	virtual bool fireCondition();
 
 protected:
-	tItemID _item;
-	tItemState _state;
+	ItemID _item;
+	ItemState _state;
 };
 
 /////////////////////////////////////////////
@@ -268,19 +268,19 @@ protected:
 
 class AILastExtraCondition : public AICondition {
 public:
-	AILastExtraCondition(const tExtraID);
+	AILastExtraCondition(const ExtraID);
 
 	virtual bool fireCondition();
 
 protected:
-	tExtraID _lastExtra;
+	ExtraID _lastExtra;
 };
 
 /////////////////////////////////////////////
 //
 //	Helper functions
 
-AICondition *makeLocationAndDoesntHaveItemCondition(const tRoomID room, const tDirectionConstant direction, const tItemID item);
+AICondition *makeLocationAndDoesntHaveItemCondition(const RoomID room, const DirectionConstant direction, const ItemID item);
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/compass.cpp b/engines/pegasus/compass.cpp
index 2c80c5c..6ae4e11 100755
--- a/engines/pegasus/compass.cpp
+++ b/engines/pegasus/compass.cpp
@@ -70,9 +70,9 @@ void Compass::draw(const Common::Rect &r1) {
 		Common::Rect r2;
 		_compassImage.getSurfaceBounds(r2);
 
-		tCoordType width = r2.width();
-		tCoordType offsetH = width / 10 - bounds.width() / 2 + (getFaderValue() * width) / 450 - bounds.left;
-		tCoordType offsetV = -bounds.top;
+		CoordType width = r2.width();
+		CoordType offsetH = width / 10 - bounds.width() / 2 + (getFaderValue() * width) / 450 - bounds.left;
+		CoordType offsetV = -bounds.top;
 		r2 = r1;
 		r2.translate(offsetH, offsetV);
 		_compassImage.drawImage(r2, r1);
diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
index f8008a0..e66859d 100644
--- a/engines/pegasus/console.cpp
+++ b/engines/pegasus/console.cpp
@@ -79,9 +79,9 @@ bool PegasusConsole::Cmd_Jump(int argc, const char **argv) {
 		return true;
 	}
 
-	tNeighborhoodID neighborhood = (tNeighborhoodID)atoi(argv[1]);
-	tRoomID room = (tRoomID)atoi(argv[2]);
-	tDirectionConstant direction = (tDirectionConstant)atoi(argv[3]);
+	NeighborhoodID neighborhood = (NeighborhoodID)atoi(argv[1]);
+	RoomID room = (RoomID)atoi(argv[2]);
+	DirectionConstant direction = (DirectionConstant)atoi(argv[3]);
 
 	if ((neighborhood < kCaldoriaID || neighborhood > kNoradDeltaID || neighborhood == kFinalTSAID) &&
 			neighborhood != kNoradSubChaseID) {
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index 17466b0..e98ebd0 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -35,69 +35,73 @@ namespace Pegasus {
 
 // TODO: Organize these
 
-const tGameID kGameIDNothing = -1;
-
-const tActorID kNoActorID = kGameIDNothing;
-const tActorID kPlayerID = 0;
-const tItemID kNoItemID = kGameIDNothing;
-const tRoomID kNoRoomID = kGameIDNothing;
-const tExtraID kNoExtraID = 0xFFFFFFFF;
-const tNeighborhoodID kNoNeighborhoodID = kGameIDNothing;
-const tAlternateID kNoAlternateID = 0;
-const tGameMenuCommand kMenuCmdNoCommand = 0;
-
-const tHotSpotActivationID kActivateHotSpotAlways = 0;
-const tHotSpotActivationID kActivateHotSpotNever = -1;
-
-const tItemState kNoItemState = -1;
-
-const tDirectionConstant kNoDirection = 0xFF;
-
-const tTurnDirection kNoTurn = 0xFF;
-const tTurnDirection kTurnLeft = 0;
-const tTurnDirection kTurnRight = 1;
-const tTurnDirection kTurnUp = 2;
-const tTurnDirection kTurnDown = 3;
-const tTurnDirection kMaxTurns = 4;
-
-const tGameMode kNoMode = -1;
-const tGameMode kModeNavigation = 0;
-const tGameMode kLastGameShellMode = kModeNavigation;
-
-const tCanMoveForwardReason kCanMoveForward = 0;
-const tCanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
-const tCanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
-const tCanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
-const tCanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
-
-const tCanTurnReason kCanTurn = 0;
-const tCanTurnReason kCantTurnNoTurn = kCanTurn + 1;
-const tCanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
-
-const tCanOpenDoorReason kCanOpenDoor = 0;
-const tCanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
-const tCanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
-const tCanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
-const tCanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
-
-const tDisplayElementID kNoDisplayElement = -1;
-const tDisplayElementID kHighestReservedElementID = -2;
-
-const tDisplayElementID kCursorID = kHighestReservedElementID;
-const tDisplayElementID kLoadScreenID = kCursorID - 1;
-
-const tDisplayOrder kMinAvailableOrder = 0;
-const tDisplayOrder kMaxAvailableOrder = 999998;
-const tDisplayOrder kLoadScreenOrder = 900000;
-const tDisplayOrder kCursorOrder = 1000000;
-
-const tHotSpotID kNoHotSpotID = -1;
-const tHotSpotFlags kNoHotSpotFlags = 0;
-const tHotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
-
-const tNotificationFlags kNoNotificationFlags = 0;
-
-const tDisplayElementID kCurrentDragSpriteID = 1000;
+const GameID kGameIDNothing = -1;
+
+const ActorID kNoActorID = kGameIDNothing;
+const ActorID kPlayerID = 0;
+const ItemID kNoItemID = kGameIDNothing;
+const RoomID kNoRoomID = kGameIDNothing;
+const ExtraID kNoExtraID = 0xFFFFFFFF;
+const NeighborhoodID kNoNeighborhoodID = kGameIDNothing;
+const AlternateID kNoAlternateID = 0;
+const GameMenuCommand kMenuCmdNoCommand = 0;
+
+const HotSpotActivationID kActivateHotSpotAlways = 0;
+const HotSpotActivationID kActivateHotSpotNever = -1;
+
+const ItemState kNoItemState = -1;
+
+const DirectionConstant kNoDirection = 0xFF;
+static const DirectionConstant kNorth = 0;
+static const DirectionConstant kSouth = 1;
+static const DirectionConstant kEast = 2;
+static const DirectionConstant kWest = 3;
+
+const TurnDirection kNoTurn = 0xFF;
+const TurnDirection kTurnLeft = 0;
+const TurnDirection kTurnRight = 1;
+const TurnDirection kTurnUp = 2;
+const TurnDirection kTurnDown = 3;
+const TurnDirection kMaxTurns = 4;
+
+const GameMode kNoMode = -1;
+const GameMode kModeNavigation = 0;
+const GameMode kLastGameShellMode = kModeNavigation;
+
+const CanMoveForwardReason kCanMoveForward = 0;
+const CanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
+const CanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
+const CanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
+const CanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
+
+const CanTurnReason kCanTurn = 0;
+const CanTurnReason kCantTurnNoTurn = kCanTurn + 1;
+const CanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
+
+const CanOpenDoorReason kCanOpenDoor = 0;
+const CanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
+const CanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
+const CanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
+const CanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
+
+const DisplayElementID kNoDisplayElement = -1;
+const DisplayElementID kHighestReservedElementID = -2;
+
+const DisplayElementID kCursorID = kHighestReservedElementID;
+const DisplayElementID kLoadScreenID = kCursorID - 1;
+
+const DisplayOrder kMinAvailableOrder = 0;
+const DisplayOrder kMaxAvailableOrder = 999998;
+const DisplayOrder kLoadScreenOrder = 900000;
+const DisplayOrder kCursorOrder = 1000000;
+
+const HotSpotID kNoHotSpotID = -1;
+const HotSpotFlags kNoHotSpotFlags = 0;
+const HotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
+
+const NotificationFlags kNoNotificationFlags = 0;
+
+const DisplayElementID kCurrentDragSpriteID = 1000;
 
 const TimeScale kDefaultTimeScale = 600;
 
@@ -217,23 +221,23 @@ const TimeValue kPlasmaImpactTime = kTwoSeconds;
 
 const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
 
-const tNotificationID kNeighborhoodNotificationID = 1;
-const tNotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
-
-const tNotificationFlags kNeighborhoodMovieCompletedFlag = 1;
-const tNotificationFlags kMoveForwardCompletedFlag = kNeighborhoodMovieCompletedFlag << 1;
-const tNotificationFlags kStrideCompletedFlag = kMoveForwardCompletedFlag << 1;
-const tNotificationFlags kTurnCompletedFlag = kStrideCompletedFlag << 1;
-const tNotificationFlags kSpotCompletedFlag = kTurnCompletedFlag << 1;
-const tNotificationFlags kDoorOpenCompletedFlag = kSpotCompletedFlag << 1;
-const tNotificationFlags kExtraCompletedFlag = kDoorOpenCompletedFlag << 1;
-const tNotificationFlags kSpotSoundCompletedFlag = kExtraCompletedFlag << 1;
-const tNotificationFlags kDelayCompletedFlag = kSpotSoundCompletedFlag << 1;
-const tNotificationFlags kActionRequestCompletedFlag = kDelayCompletedFlag << 1;
-const tNotificationFlags kDeathExtraCompletedFlag = kActionRequestCompletedFlag << 1;
-const tNotificationFlags kLastNeighborhoodNotificationFlag = kDeathExtraCompletedFlag;
-
-const tNotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
+const NotificationID kNeighborhoodNotificationID = 1;
+const NotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
+
+const NotificationFlags kNeighborhoodMovieCompletedFlag = 1;
+const NotificationFlags kMoveForwardCompletedFlag = kNeighborhoodMovieCompletedFlag << 1;
+const NotificationFlags kStrideCompletedFlag = kMoveForwardCompletedFlag << 1;
+const NotificationFlags kTurnCompletedFlag = kStrideCompletedFlag << 1;
+const NotificationFlags kSpotCompletedFlag = kTurnCompletedFlag << 1;
+const NotificationFlags kDoorOpenCompletedFlag = kSpotCompletedFlag << 1;
+const NotificationFlags kExtraCompletedFlag = kDoorOpenCompletedFlag << 1;
+const NotificationFlags kSpotSoundCompletedFlag = kExtraCompletedFlag << 1;
+const NotificationFlags kDelayCompletedFlag = kSpotSoundCompletedFlag << 1;
+const NotificationFlags kActionRequestCompletedFlag = kDelayCompletedFlag << 1;
+const NotificationFlags kDeathExtraCompletedFlag = kActionRequestCompletedFlag << 1;
+const NotificationFlags kLastNeighborhoodNotificationFlag = kDeathExtraCompletedFlag;
+
+const NotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
 												kMoveForwardCompletedFlag |
 												kStrideCompletedFlag |
 												kTurnCompletedFlag |
@@ -262,146 +266,146 @@ const char kContinueSave = 1;
 
 //	Display IDs.
 
-const tDisplayElementID kNavMovieID = 1;
-const tDisplayElementID kTurnPushID = 2;
+const DisplayElementID kNavMovieID = 1;
+const DisplayElementID kTurnPushID = 2;
 
-const tDisplayElementID kMaxGameShellDisplayID = kTurnPushID;
+const DisplayElementID kMaxGameShellDisplayID = kTurnPushID;
 
 //	Display ordering.
 
-const tDisplayOrder kNavLayer = 10000;
-const tDisplayOrder kNavMovieOrder = kNavLayer;
-const tDisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
+const DisplayOrder kNavLayer = 10000;
+const DisplayOrder kNavMovieOrder = kNavLayer;
+const DisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
 
 /////////////////////////////////////////////
 //
 //	Display IDs.
 
-const tDisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
-const tDisplayElementID kInterface1ID = kScreenDimmerID + 1;
-const tDisplayElementID kInterface2ID = kInterface1ID + 1;
-const tDisplayElementID kInterface3ID = kInterface2ID + 1;
-const tDisplayElementID kInterface4ID = kInterface3ID + 1;
-const tDisplayElementID kDateID = kInterface4ID + 1;
-const tDisplayElementID kCompassID = kDateID + 1;
-const tDisplayElementID kInventoryPushID = kCompassID + 1;
-const tDisplayElementID kInventoryLidID = kInventoryPushID + 1;
-const tDisplayElementID kBiochipPushID = kInventoryLidID + 1;
-const tDisplayElementID kBiochipLidID = kBiochipPushID + 1;
-const tDisplayElementID kEnergyBarID = kBiochipLidID + 1;
-const tDisplayElementID kWarningLightID = kEnergyBarID + 1;
-const tDisplayElementID kAILeftAreaID = kWarningLightID + 1;
-const tDisplayElementID kAIMiddleAreaID = kAILeftAreaID + 1;
-const tDisplayElementID kAIRightAreaID = kAIMiddleAreaID + 1;
-const tDisplayElementID kAIMovieID = kAIRightAreaID + 1;
-const tDisplayElementID kInventoryDropHighlightID = kAIMovieID + 1;
-const tDisplayElementID kBiochipDropHighlightID = kInventoryDropHighlightID + 1;
+const DisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
+const DisplayElementID kInterface1ID = kScreenDimmerID + 1;
+const DisplayElementID kInterface2ID = kInterface1ID + 1;
+const DisplayElementID kInterface3ID = kInterface2ID + 1;
+const DisplayElementID kInterface4ID = kInterface3ID + 1;
+const DisplayElementID kDateID = kInterface4ID + 1;
+const DisplayElementID kCompassID = kDateID + 1;
+const DisplayElementID kInventoryPushID = kCompassID + 1;
+const DisplayElementID kInventoryLidID = kInventoryPushID + 1;
+const DisplayElementID kBiochipPushID = kInventoryLidID + 1;
+const DisplayElementID kBiochipLidID = kBiochipPushID + 1;
+const DisplayElementID kEnergyBarID = kBiochipLidID + 1;
+const DisplayElementID kWarningLightID = kEnergyBarID + 1;
+const DisplayElementID kAILeftAreaID = kWarningLightID + 1;
+const DisplayElementID kAIMiddleAreaID = kAILeftAreaID + 1;
+const DisplayElementID kAIRightAreaID = kAIMiddleAreaID + 1;
+const DisplayElementID kAIMovieID = kAIRightAreaID + 1;
+const DisplayElementID kInventoryDropHighlightID = kAIMovieID + 1;
+const DisplayElementID kBiochipDropHighlightID = kInventoryDropHighlightID + 1;
 
-const tDisplayElementID kDraggingSpriteID = 1000;
+const DisplayElementID kDraggingSpriteID = 1000;
 
-const tDisplayElementID kCroppedMovieID = 2000;
+const DisplayElementID kCroppedMovieID = 2000;
 
-const tDisplayElementID kNeighborhoodDisplayID = 3000;
+const DisplayElementID kNeighborhoodDisplayID = 3000;
 
-const tDisplayElementID kItemPictureBaseID = 5000;
+const DisplayElementID kItemPictureBaseID = 5000;
 
-const tCoordType kNavAreaLeft = 64;
-const tCoordType kNavAreaTop = 64;
+const CoordType kNavAreaLeft = 64;
+const CoordType kNavAreaTop = 64;
 
-const tCoordType kBackground1Left = 0;
-const tCoordType kBackground1Top = 64;
+const CoordType kBackground1Left = 0;
+const CoordType kBackground1Top = 64;
 
-const tCoordType kBackground2Left = 0;
-const tCoordType kBackground2Top = 0;
+const CoordType kBackground2Left = 0;
+const CoordType kBackground2Top = 0;
 
-const tCoordType kBackground3Left = 576;
-const tCoordType kBackground3Top = 64;
+const CoordType kBackground3Left = 576;
+const CoordType kBackground3Top = 64;
 
-const tCoordType kBackground4Left = 0;
-const tCoordType kBackground4Top = 320;
+const CoordType kBackground4Left = 0;
+const CoordType kBackground4Top = 320;
 
-const tCoordType kOverviewControllerLeft = 540;
-const tCoordType kOverviewControllerTop = 348;
+const CoordType kOverviewControllerLeft = 540;
+const CoordType kOverviewControllerTop = 348;
 
-const tCoordType kSwapLeft = 194;
-const tCoordType kSwapTop = 116;
+const CoordType kSwapLeft = 194;
+const CoordType kSwapTop = 116;
 
-const tCoordType kSwapHiliteLeft = 200;
-const tCoordType kSwapHiliteTop = 206;
+const CoordType kSwapHiliteLeft = 200;
+const CoordType kSwapHiliteTop = 206;
 
-const tCoordType kDateLeft = 136;
-const tCoordType kDateTop = 44;
+const CoordType kDateLeft = 136;
+const CoordType kDateTop = 44;
 
-const tCoordType kCompassLeft = 222;
-const tCoordType kCompassTop = 42;
-const tCoordType kCompassWidth = 92;
+const CoordType kCompassLeft = 222;
+const CoordType kCompassTop = 42;
+const CoordType kCompassWidth = 92;
 
-const tCoordType kInventoryPushLeft = 74;
-const tCoordType kInventoryPushTop = 92;
+const CoordType kInventoryPushLeft = 74;
+const CoordType kInventoryPushTop = 92;
 
-const tCoordType kInventoryLidLeft = 74;
-const tCoordType kInventoryLidTop = 316;
+const CoordType kInventoryLidLeft = 74;
+const CoordType kInventoryLidTop = 316;
 
-const tCoordType kBiochipPushLeft = 362;
-const tCoordType kBiochipPushTop = 192;
+const CoordType kBiochipPushLeft = 362;
+const CoordType kBiochipPushTop = 192;
 
-const tCoordType kBiochipLidLeft = 362;
-const tCoordType kBiochipLidTop = 316;
+const CoordType kBiochipLidLeft = 362;
+const CoordType kBiochipLidTop = 316;
 
-const tCoordType kInventoryDropLeft = 0;
-const tCoordType kInventoryDropTop = 320;
-const tCoordType kInventoryDropRight = 232;
-const tCoordType kInventoryDropBottom = 480;
+const CoordType kInventoryDropLeft = 0;
+const CoordType kInventoryDropTop = 320;
+const CoordType kInventoryDropRight = 232;
+const CoordType kInventoryDropBottom = 480;
 
-const tCoordType kBiochipDropLeft = 302;
-const tCoordType kBiochipDropTop = 320;
-const tCoordType kBiochipDropRight = 640;
-const tCoordType kBiochipDropBottom = 480;
+const CoordType kBiochipDropLeft = 302;
+const CoordType kBiochipDropTop = 320;
+const CoordType kBiochipDropRight = 640;
+const CoordType kBiochipDropBottom = 480;
 
-const tCoordType kFinalMessageLeft = kInventoryPushLeft + 1;
-const tCoordType kFinalMessageTop = kInventoryPushTop + 24;
+const CoordType kFinalMessageLeft = kInventoryPushLeft + 1;
+const CoordType kFinalMessageTop = kInventoryPushTop + 24;
 
 /////////////////////////////////////////////
 //
 //	Notifications.
 
-const tNotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
-const tNotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
-const tNotificationID kAINotificationID = kInterfaceNotificationID + 1;
-const tNotificationID kNoradNotificationID = kAINotificationID + 1;
-const tNotificationID kNoradECRNotificationID = kNoradNotificationID + 1;
-const tNotificationID kNoradFillingStationNotificationID = kNoradECRNotificationID + 1;
-const tNotificationID kNoradPressureNotificationID = kNoradFillingStationNotificationID + 1;
-const tNotificationID kNoradUtilityNotificationID = kNoradPressureNotificationID + 1;
-const tNotificationID kNoradElevatorNotificationID = kNoradUtilityNotificationID + 1;
-const tNotificationID kNoradSubPlatformNotificationID = kNoradElevatorNotificationID + 1;
-const tNotificationID kSubControlNotificationID = kNoradSubPlatformNotificationID + 1;
-const tNotificationID kNoradGreenBallNotificationID = kSubControlNotificationID + 1;
-const tNotificationID kNoradGlobeNotificationID = kNoradGreenBallNotificationID + 1;
-const tNotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotificationID + 1;
-const tNotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
-const tNotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
+const NotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
+const NotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
+const NotificationID kAINotificationID = kInterfaceNotificationID + 1;
+const NotificationID kNoradNotificationID = kAINotificationID + 1;
+const NotificationID kNoradECRNotificationID = kNoradNotificationID + 1;
+const NotificationID kNoradFillingStationNotificationID = kNoradECRNotificationID + 1;
+const NotificationID kNoradPressureNotificationID = kNoradFillingStationNotificationID + 1;
+const NotificationID kNoradUtilityNotificationID = kNoradPressureNotificationID + 1;
+const NotificationID kNoradElevatorNotificationID = kNoradUtilityNotificationID + 1;
+const NotificationID kNoradSubPlatformNotificationID = kNoradElevatorNotificationID + 1;
+const NotificationID kSubControlNotificationID = kNoradSubPlatformNotificationID + 1;
+const NotificationID kNoradGreenBallNotificationID = kSubControlNotificationID + 1;
+const NotificationID kNoradGlobeNotificationID = kNoradGreenBallNotificationID + 1;
+const NotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotificationID + 1;
+const NotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
+const NotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
 
 //	Sent to the shell by fShellNotification.
-const tNotificationFlags kGameStartingFlag = 1;
-const tNotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
-const tNotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
+const NotificationFlags kGameStartingFlag = 1;
+const NotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
+const NotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
 
-const tNotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
+const NotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
 														kNeedNewJumpFlag |
 														kPlayerDiedFlag;
 
 //	Sent to the interface.
-const tNotificationFlags kInventoryLidOpenFlag = 1;
-const tNotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
-const tNotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
-const tNotificationFlags kInventoryDrawerDownFlag = kInventoryDrawerUpFlag << 1;
-const tNotificationFlags kBiochipLidOpenFlag = kInventoryDrawerDownFlag << 1;
-const tNotificationFlags kBiochipLidClosedFlag = kBiochipLidOpenFlag << 1;
-const tNotificationFlags kBiochipDrawerUpFlag = kBiochipLidClosedFlag << 1;
-const tNotificationFlags kBiochipDrawerDownFlag = kBiochipDrawerUpFlag << 1;
-
-const tNotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
+const NotificationFlags kInventoryLidOpenFlag = 1;
+const NotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
+const NotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
+const NotificationFlags kInventoryDrawerDownFlag = kInventoryDrawerUpFlag << 1;
+const NotificationFlags kBiochipLidOpenFlag = kInventoryDrawerDownFlag << 1;
+const NotificationFlags kBiochipLidClosedFlag = kBiochipLidOpenFlag << 1;
+const NotificationFlags kBiochipDrawerUpFlag = kBiochipLidClosedFlag << 1;
+const NotificationFlags kBiochipDrawerDownFlag = kBiochipDrawerUpFlag << 1;
+
+const NotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
 														kInventoryLidClosedFlag |
 														kInventoryDrawerUpFlag |
 														kInventoryDrawerDownFlag |
@@ -414,28 +418,28 @@ const tNotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
 
 //	Neighborhood hot spots.
 
-const tHotSpotID kFirstNeighborhoodSpotID = 5000;
+const HotSpotID kFirstNeighborhoodSpotID = 5000;
 
 //	kShellSpotFlag is a flag which marks all hot spots which belong to the shell, like
 //	the current item and current biochip spots.
-const tHotSpotFlags kShellSpotFlag = 1;
+const HotSpotFlags kShellSpotFlag = 1;
 //	kNeighborhoodSpotFlag is a flag which marks all hot spots which belong to a
 //	neighborhood, like buttons on walls and so on.
-const tHotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
+const HotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
 //	kZoomInSpotFlag is a flag which marks all hot spots which indicate a zoom.
-const tHotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
+const HotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
 //	kZoomOutSpotFlag is a flag which marks all hot spots which indicate a zoom.
-const tHotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
+const HotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
 
-const tHotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
-const tHotSpotFlags kPlayExtraSpotFlag = kClickSpotFlag << 1;
-const tHotSpotFlags kPickUpItemSpotFlag = kPlayExtraSpotFlag << 1;
-const tHotSpotFlags kDropItemSpotFlag = kPickUpItemSpotFlag << 1;
-const tHotSpotFlags kOpenDoorSpotFlag = kDropItemSpotFlag << 1;
+const HotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
+const HotSpotFlags kPlayExtraSpotFlag = kClickSpotFlag << 1;
+const HotSpotFlags kPickUpItemSpotFlag = kPlayExtraSpotFlag << 1;
+const HotSpotFlags kDropItemSpotFlag = kPickUpItemSpotFlag << 1;
+const HotSpotFlags kOpenDoorSpotFlag = kDropItemSpotFlag << 1;
 
-const tHotSpotFlags kZoomSpotFlags = kZoomInSpotFlag | kZoomOutSpotFlag;
+const HotSpotFlags kZoomSpotFlags = kZoomInSpotFlag | kZoomOutSpotFlag;
 
-const tHotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
+const HotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
 
 /////////////////////////////////////////////
 //
@@ -444,64 +448,64 @@ const tHotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
 //	Shell hot spots.
 //	The shell reserves all hot spot IDs from 0 to 999
 
-const tHotSpotID kCurrentItemSpotID = 0;
-const tHotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
+const HotSpotID kCurrentItemSpotID = 0;
+const HotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
 
-const tHotSpotID kInventoryDropSpotID = kCurrentBiochipSpotID + 1;
-const tHotSpotID kBiochipDropSpotID = kInventoryDropSpotID + 1;
+const HotSpotID kInventoryDropSpotID = kCurrentBiochipSpotID + 1;
+const HotSpotID kBiochipDropSpotID = kInventoryDropSpotID + 1;
 
-const tHotSpotID kInfoReturnSpotID = kBiochipDropSpotID + 1;
+const HotSpotID kInfoReturnSpotID = kBiochipDropSpotID + 1;
 
-const tHotSpotID kAIHint1SpotID = kInfoReturnSpotID + 1;
-const tHotSpotID kAIHint2SpotID = kAIHint1SpotID + 1;
-const tHotSpotID kAIHint3SpotID = kAIHint2SpotID + 1;
-const tHotSpotID kAISolveSpotID = kAIHint3SpotID + 1;
-const tHotSpotID kAIBriefingSpotID = kAISolveSpotID + 1;
-const tHotSpotID kAIScanSpotID = kAIBriefingSpotID + 1;
+const HotSpotID kAIHint1SpotID = kInfoReturnSpotID + 1;
+const HotSpotID kAIHint2SpotID = kAIHint1SpotID + 1;
+const HotSpotID kAIHint3SpotID = kAIHint2SpotID + 1;
+const HotSpotID kAISolveSpotID = kAIHint3SpotID + 1;
+const HotSpotID kAIBriefingSpotID = kAISolveSpotID + 1;
+const HotSpotID kAIScanSpotID = kAIBriefingSpotID + 1;
 
-const tHotSpotID kPegasusRecallSpotID = kAIScanSpotID + 1;
+const HotSpotID kPegasusRecallSpotID = kAIScanSpotID + 1;
 
-const tHotSpotID kAriesSpotID = kPegasusRecallSpotID + 1;
-const tHotSpotID kMercurySpotID = kAriesSpotID + 1;
-const tHotSpotID kPoseidonSpotID = kMercurySpotID + 1;
+const HotSpotID kAriesSpotID = kPegasusRecallSpotID + 1;
+const HotSpotID kMercurySpotID = kAriesSpotID + 1;
+const HotSpotID kPoseidonSpotID = kMercurySpotID + 1;
 
-const tHotSpotID kAirMaskToggleSpotID = kPoseidonSpotID + 1;
+const HotSpotID kAirMaskToggleSpotID = kPoseidonSpotID + 1;
 
-const tHotSpotID kShuttleEnergySpotID = kAirMaskToggleSpotID + 1;
-const tHotSpotID kShuttleGravitonSpotID = kShuttleEnergySpotID + 1;
-const tHotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
-const tHotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
-const tHotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
+const HotSpotID kShuttleEnergySpotID = kAirMaskToggleSpotID + 1;
+const HotSpotID kShuttleGravitonSpotID = kShuttleEnergySpotID + 1;
+const HotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
+const HotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
+const HotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
 
 //	Most of these are obsolete:
 
 //	kInventoryDropSpotFlag is a flag which marks hot spots which are valid drop spots
 //	for inventory items.
-//	const tHotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
+//	const HotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
 
 //	kBiochipDropSpotFlag is a flag which marks hot spots which are valid drop spots
 //	for biochips.
-//	const tHotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
+//	const HotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
 
 //	kInventorySpotFlag is a flag which marks hot spots which indicate inventory items
 //	in the environment.
-//	const tHotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
+//	const HotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
 
 //	kBiochipSpotFlag is a flag which marks hot spots which indicate biochips
 //	in the environment.
-const tHotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
-const tHotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
+const HotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
+const HotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
 
-const tHotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
+const HotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
 
 //	Biochip and inventory hot spot flags...
 
-const tHotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
-const tHotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
-const tHotSpotFlags kOpticalBiochipSpotFlag = kPegasusBiochipSpotFlag << 1;
-const tHotSpotFlags kAirMaskSpotFlag = kOpticalBiochipSpotFlag << 1;
+const HotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
+const HotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
+const HotSpotFlags kOpticalBiochipSpotFlag = kPegasusBiochipSpotFlag << 1;
+const HotSpotFlags kAirMaskSpotFlag = kOpticalBiochipSpotFlag << 1;
 
-const tHotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
+const HotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
 											kPlayExtraSpotFlag |
 											kOpenDoorSpotFlag |
 											kInfoReturnSpotFlag |
@@ -519,30 +523,30 @@ const int32 kDeathMenuID = 4;
 //
 //	Menu commands.
 
-const tGameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
-const tGameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
-const tGameMenuCommand kMenuCmdStartWalkthrough = kMenuCmdStartAdventure + 1;
-const tGameMenuCommand kMenuCmdRestore = kMenuCmdStartWalkthrough + 1;
-const tGameMenuCommand kMenuCmdCredits = kMenuCmdRestore + 1;
-const tGameMenuCommand kMenuCmdQuit = kMenuCmdCredits + 1;
+const GameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
+const GameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
+const GameMenuCommand kMenuCmdStartWalkthrough = kMenuCmdStartAdventure + 1;
+const GameMenuCommand kMenuCmdRestore = kMenuCmdStartWalkthrough + 1;
+const GameMenuCommand kMenuCmdCredits = kMenuCmdRestore + 1;
+const GameMenuCommand kMenuCmdQuit = kMenuCmdCredits + 1;
 
-const tGameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
+const GameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
 
-const tGameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
-const tGameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
+const GameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
+const GameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
 
-const tGameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathMainMenuDemo + 1;
-const tGameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
+const GameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathMainMenuDemo + 1;
+const GameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
 
-const tGameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
-const tGameMenuCommand kMenuCmdPauseContinue = kMenuCmdPauseSave + 1;
-const tGameMenuCommand kMenuCmdPauseRestore = kMenuCmdPauseContinue + 1;
-const tGameMenuCommand kMenuCmdPauseQuit = kMenuCmdPauseRestore + 1;
+const GameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
+const GameMenuCommand kMenuCmdPauseContinue = kMenuCmdPauseSave + 1;
+const GameMenuCommand kMenuCmdPauseRestore = kMenuCmdPauseContinue + 1;
+const GameMenuCommand kMenuCmdPauseQuit = kMenuCmdPauseRestore + 1;
 
-const tGameMenuCommand kMenuCmdCreditsMainMenu = kMenuCmdPauseQuit + 1;
+const GameMenuCommand kMenuCmdCreditsMainMenu = kMenuCmdPauseQuit + 1;
 
-const tGameMenuCommand kMenuCmdCancelRestart = kMenuCmdCreditsMainMenu + 1;
-const tGameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
+const GameMenuCommand kMenuCmdCancelRestart = kMenuCmdCreditsMainMenu + 1;
+const GameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
 
 const TimeValue kMenuButtonHiliteTime = 20;
 const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
@@ -551,74 +555,74 @@ const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
 
 //	Warning light PICTs:
 
-const tResIDType kLightOffID = 128;
-const tResIDType kLightYellowID = 129;
-const tResIDType kLightOrangeID = 130;
-const tResIDType kLightRedID = 131;
+const ResIDType kLightOffID = 128;
+const ResIDType kLightYellowID = 129;
+const ResIDType kLightOrangeID = 130;
+const ResIDType kLightRedID = 131;
 
 //	Date PICTs:
 
-const tResIDType kDatePrehistoricID = 138;
-const tResIDType kDate2112ID = 139;
-const tResIDType kDate2185ID = 140;
-const tResIDType kDate2310ID = 141;
-const tResIDType kDate2318ID = 142;
+const ResIDType kDatePrehistoricID = 138;
+const ResIDType kDate2112ID = 139;
+const ResIDType kDate2185ID = 140;
+const ResIDType kDate2310ID = 141;
+const ResIDType kDate2318ID = 142;
 
 /////////////////////////////////////////////
 //
 //	Display Order
 
-const tDisplayOrder kCroppedMovieLayer = 11000;
-
-const tDisplayOrder kMonitorLayer = 12000;
-
-const tDisplayOrder kDragSpriteLayer = 15000;
-const tDisplayOrder kDragSpriteOrder = kDragSpriteLayer;
-
-const tDisplayOrder kInterfaceLayer = 20000;
-const tDisplayOrder kBackground1Order = kInterfaceLayer;
-const tDisplayOrder kBackground2Order = kBackground1Order + 1;
-const tDisplayOrder kBackground3Order = kBackground2Order + 1;
-const tDisplayOrder kBackground4Order = kBackground3Order + 1;
-const tDisplayOrder kDateOrder = kBackground4Order + 1;
-const tDisplayOrder kCompassOrder = kDateOrder + 1;
-const tDisplayOrder kEnergyBarOrder = kCompassOrder + 1;
-const tDisplayOrder kEnergyLightOrder = kEnergyBarOrder + 1;
-
-const tDisplayOrder kAILayer = 22000;
-const tDisplayOrder kAILeftAreaOrder = kAILayer;
-const tDisplayOrder kAIMiddleAreaOrder = kAILeftAreaOrder + 1;
-const tDisplayOrder kAIRightAreaOrder = kAIMiddleAreaOrder + 1;
-const tDisplayOrder kAIMovieOrder = kAIRightAreaOrder + 1;
-
-const tDisplayOrder kHilitesLayer = 23000;
-const tDisplayOrder kInventoryHiliteOrder = kHilitesLayer;
-const tDisplayOrder kBiochipHiliteOrder = kInventoryHiliteOrder + 1;
-
-const tDisplayOrder kPanelsLayer = 25000;
-const tDisplayOrder kInventoryPushOrder = kPanelsLayer;
-const tDisplayOrder kInventoryLidOrder = kInventoryPushOrder + 1;
-const tDisplayOrder kBiochipPushOrder = kInventoryLidOrder + 1;
-const tDisplayOrder kBiochipLidOrder = kBiochipPushOrder + 1;
-const tDisplayOrder kFinalMessageOrder = kBiochipLidOrder + 1;
-
-const tDisplayOrder kInfoLayer = 26000;
-const tDisplayOrder kInfoBackgroundOrder = kInfoLayer;
-const tDisplayOrder kInfoSpinOrder = kInfoBackgroundOrder + 1;
-
-const tDisplayOrder kScreenDimmerOrder = 30000;
-
-const tDisplayOrder kPauseScreenLayer = 31000;
-const tDisplayOrder kPauseMenuOrder = kPauseScreenLayer;
-const tDisplayOrder kSaveGameOrder = kPauseMenuOrder + 1;
-const tDisplayOrder kContinueOrder = kSaveGameOrder + 1;
-const tDisplayOrder kRestoreOrder = kContinueOrder + 1;
-const tDisplayOrder kSoundFXOrder = kRestoreOrder + 1;
-const tDisplayOrder kAmbienceOrder = kSoundFXOrder + 1;
-const tDisplayOrder kWalkthruOrder = kAmbienceOrder + 1;
-const tDisplayOrder kQuitToMainMenuOrder = kWalkthruOrder + 1;
-const tDisplayOrder kPauseLargeHiliteOrder = kQuitToMainMenuOrder + 1;
-const tDisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
+const DisplayOrder kCroppedMovieLayer = 11000;
+
+const DisplayOrder kMonitorLayer = 12000;
+
+const DisplayOrder kDragSpriteLayer = 15000;
+const DisplayOrder kDragSpriteOrder = kDragSpriteLayer;
+
+const DisplayOrder kInterfaceLayer = 20000;
+const DisplayOrder kBackground1Order = kInterfaceLayer;
+const DisplayOrder kBackground2Order = kBackground1Order + 1;
+const DisplayOrder kBackground3Order = kBackground2Order + 1;
+const DisplayOrder kBackground4Order = kBackground3Order + 1;
+const DisplayOrder kDateOrder = kBackground4Order + 1;
+const DisplayOrder kCompassOrder = kDateOrder + 1;
+const DisplayOrder kEnergyBarOrder = kCompassOrder + 1;
+const DisplayOrder kEnergyLightOrder = kEnergyBarOrder + 1;
+
+const DisplayOrder kAILayer = 22000;
+const DisplayOrder kAILeftAreaOrder = kAILayer;
+const DisplayOrder kAIMiddleAreaOrder = kAILeftAreaOrder + 1;
+const DisplayOrder kAIRightAreaOrder = kAIMiddleAreaOrder + 1;
+const DisplayOrder kAIMovieOrder = kAIRightAreaOrder + 1;
+
+const DisplayOrder kHilitesLayer = 23000;
+const DisplayOrder kInventoryHiliteOrder = kHilitesLayer;
+const DisplayOrder kBiochipHiliteOrder = kInventoryHiliteOrder + 1;
+
+const DisplayOrder kPanelsLayer = 25000;
+const DisplayOrder kInventoryPushOrder = kPanelsLayer;
+const DisplayOrder kInventoryLidOrder = kInventoryPushOrder + 1;
+const DisplayOrder kBiochipPushOrder = kInventoryLidOrder + 1;
+const DisplayOrder kBiochipLidOrder = kBiochipPushOrder + 1;
+const DisplayOrder kFinalMessageOrder = kBiochipLidOrder + 1;
+
+const DisplayOrder kInfoLayer = 26000;
+const DisplayOrder kInfoBackgroundOrder = kInfoLayer;
+const DisplayOrder kInfoSpinOrder = kInfoBackgroundOrder + 1;
+
+const DisplayOrder kScreenDimmerOrder = 30000;
+
+const DisplayOrder kPauseScreenLayer = 31000;
+const DisplayOrder kPauseMenuOrder = kPauseScreenLayer;
+const DisplayOrder kSaveGameOrder = kPauseMenuOrder + 1;
+const DisplayOrder kContinueOrder = kSaveGameOrder + 1;
+const DisplayOrder kRestoreOrder = kContinueOrder + 1;
+const DisplayOrder kSoundFXOrder = kRestoreOrder + 1;
+const DisplayOrder kAmbienceOrder = kSoundFXOrder + 1;
+const DisplayOrder kWalkthruOrder = kAmbienceOrder + 1;
+const DisplayOrder kQuitToMainMenuOrder = kWalkthruOrder + 1;
+const DisplayOrder kPauseLargeHiliteOrder = kQuitToMainMenuOrder + 1;
+const DisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
 
 /////////////////////////////////////////////
 //
@@ -674,23 +678,23 @@ enum {
 	kPlayerWonGame
 };
 
-static const tCoordType kAILeftAreaLeft = 76;
-static const tCoordType kAILeftAreaTop = 334;
+static const CoordType kAILeftAreaLeft = 76;
+static const CoordType kAILeftAreaTop = 334;
 
-static const tCoordType kAILeftAreaWidth = 96;
-static const tCoordType kAILeftAreaHeight = 96;
+static const CoordType kAILeftAreaWidth = 96;
+static const CoordType kAILeftAreaHeight = 96;
 
-static const tCoordType kAIMiddleAreaLeft = 172;
-static const tCoordType kAIMiddleAreaTop = 334;
+static const CoordType kAIMiddleAreaLeft = 172;
+static const CoordType kAIMiddleAreaTop = 334;
 
-static const tCoordType kAIMiddleAreaWidth = 192;
-static const tCoordType kAIMiddleAreaHeight = 96;
+static const CoordType kAIMiddleAreaWidth = 192;
+static const CoordType kAIMiddleAreaHeight = 96;
 
-static const tCoordType kAIRightAreaLeft = 364;
-static const tCoordType kAIRightAreaTop = 334;
+static const CoordType kAIRightAreaLeft = 364;
+static const CoordType kAIRightAreaTop = 334;
 
-static const tCoordType kAIRightAreaWidth = 96;
-static const tCoordType kAIRightAreaHeight = 96;
+static const CoordType kAIRightAreaWidth = 96;
+static const CoordType kAIRightAreaHeight = 96;
 
 enum {
 	kTSAPlayerNotArrived,				//	initial state, must be zero
@@ -712,18 +716,13 @@ enum {
 	kPlayerFinishedWithTSA
 };
 
-static const tDirectionConstant kNorth = 0;
-static const tDirectionConstant kSouth = 1;
-static const tDirectionConstant kEast = 2;
-static const tDirectionConstant kWest = 3;
-
 /////////////////////////////////////////////
 //
 //	Mode constants.
 
-static const tGameMode kModeInventoryPick = kLastGameShellMode + 1;
-static const tGameMode kModeBiochipPick = kModeInventoryPick + 1;
-static const tGameMode kModeInfoScreen = kModeBiochipPick + 1;
+static const GameMode kModeInventoryPick = kLastGameShellMode + 1;
+static const GameMode kModeBiochipPick = kModeInventoryPick + 1;
+static const GameMode kModeInfoScreen = kModeBiochipPick + 1;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 6fce18f..850b9cb 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -32,7 +32,7 @@
 
 namespace Pegasus {
 
-DisplayElement::DisplayElement(const tDisplayElementID id) : IDObject(id) {
+DisplayElement::DisplayElement(const DisplayElementID id) : IDObject(id) {
 	_elementIsDisplaying = false;
 	_elementIsVisible = false;
 	_elementOrder = 0;
@@ -45,7 +45,7 @@ DisplayElement::~DisplayElement() {
 		((PegasusEngine *)g_engine)->_gfx->removeDisplayElement(this);
 }
 
-void DisplayElement::setDisplayOrder(const tDisplayOrder order) {
+void DisplayElement::setDisplayOrder(const DisplayOrder order) {
 	if (_elementOrder != order) {
 		_elementOrder = order;
 		if (isDisplaying()) {
@@ -70,7 +70,7 @@ void DisplayElement::stopDisplaying() {
 	}
 }
 
-void DisplayElement::setBounds(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
+void DisplayElement::setBounds(const CoordType left, const CoordType top, const CoordType right, const CoordType bottom) {
 	setBounds(Common::Rect(left, top, right, bottom));
 }
 
@@ -78,37 +78,37 @@ void DisplayElement::getBounds(Common::Rect &r) const {
 	r = _bounds;
 }
 
-void DisplayElement::sizeElement(const tCoordType h, const tCoordType v) {
+void DisplayElement::sizeElement(const CoordType h, const CoordType v) {
 	Common::Rect newBounds = _bounds;
 	newBounds.right = _bounds.left + h;
 	newBounds.bottom = _bounds.top + v;
 	setBounds(newBounds);
 }
 
-void DisplayElement::moveElementTo(const tCoordType h, const tCoordType v) {
+void DisplayElement::moveElementTo(const CoordType h, const CoordType v) {
 	Common::Rect newBounds = _bounds;
 	newBounds.moveTo(h, v);
 	setBounds(newBounds);
 }
 
-void DisplayElement::moveElement(const tCoordType dh, const tCoordType dv) {
+void DisplayElement::moveElement(const CoordType dh, const CoordType dv) {
 	Common::Rect newBounds = _bounds;
 	newBounds.translate(dh, dv);
 	setBounds(newBounds);
 }
 
-void DisplayElement::getLocation(tCoordType &h, tCoordType &v) const {
+void DisplayElement::getLocation(CoordType &h, CoordType &v) const {
 	h = _bounds.left;
 	v = _bounds.top;
 }
 
-void DisplayElement::centerElementAt(const tCoordType h, const tCoordType v) {
+void DisplayElement::centerElementAt(const CoordType h, const CoordType v) {
 	Common::Rect newBounds = _bounds;
 	newBounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
 	setBounds(newBounds);
 }
 
-void DisplayElement::getCenter(tCoordType &h, tCoordType &v) const {
+void DisplayElement::getCenter(CoordType &h, CoordType &v) const {
 	h = (_bounds.left + _bounds.right) / 2;
 	v = (_bounds.top + _bounds.bottom) / 2;
 }
@@ -158,14 +158,14 @@ void DisplayElement::setTriggeredElement(DisplayElement *element) {
 		_triggeredElement = this;
 }
 
-bool DisplayElement::validToDraw(tDisplayOrder backLayer, tDisplayOrder frontLayer) {
+bool DisplayElement::validToDraw(DisplayOrder backLayer, DisplayOrder frontLayer) {
 	return	isDisplaying() && _elementIsVisible &&
 			(getObjectID() <= kHighestReservedElementID ||
 			(getDisplayOrder() >= backLayer &&
 			getDisplayOrder() <= frontLayer));
 }
 
-DropHighlight::DropHighlight(const tDisplayElementID id) : DisplayElement(id) {
+DropHighlight::DropHighlight(const DisplayElementID id) : DisplayElement(id) {
 	_highlightColor = 0;
 	_thickness = 2;
 	_cornerDiameter = 0;
@@ -193,7 +193,7 @@ void DropHighlight::draw(const Common::Rect &) {
 	}
 }
 
-IdlerAnimation::IdlerAnimation(const tDisplayElementID id) : Animation(id) {
+IdlerAnimation::IdlerAnimation(const DisplayElementID id) : Animation(id) {
 	_lastTime = 0xffffffff;
 }
 
@@ -224,7 +224,7 @@ void IdlerAnimation::timeChanged(const TimeValue) {
 	triggerRedraw();
 }
 
-FrameSequence::FrameSequence(const tDisplayElementID id) : IdlerAnimation(id) {
+FrameSequence::FrameSequence(const DisplayElementID id) : IdlerAnimation(id) {
 	_duration = 0;
 	_currentFrameNum = 0;
 	_resFork = new Common::MacResManager();
@@ -312,7 +312,7 @@ bool FrameSequence::isSequenceOpen() const {
 	return _numFrames != 0;
 }
 
-Sprite::Sprite(const tDisplayElementID id) : DisplayElement(id) {
+Sprite::Sprite(const DisplayElementID id) : DisplayElement(id) {
 	_numFrames = 0;
 	_currentFrameNum = 0xffffffff;
 	_currentFrame = 0;
@@ -339,13 +339,13 @@ void Sprite::discardFrames() {
 	}
 }
 
-void Sprite::addPICTResourceFrame(const tResIDType pictID, bool transparent, const tCoordType left, const tCoordType top) {
+void Sprite::addPICTResourceFrame(const ResIDType pictID, bool transparent, const CoordType left, const CoordType top) {
 	SpriteFrame *frame = new SpriteFrame();
 	frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, pictID, transparent);
 	addFrame(frame, left, top);
 }
 
-uint32 Sprite::addFrame(SpriteFrame *frame, const tCoordType left, const tCoordType top) {
+uint32 Sprite::addFrame(SpriteFrame *frame, const CoordType left, const CoordType top) {
 	SpriteFrameRec frameRecord;
 	frameRecord.frame = frame;
 	frameRecord.frameLeft = left;
@@ -436,7 +436,7 @@ void Sprite::draw(const Common::Rect &r) {
 	}
 }
 
-SpriteSequence::SpriteSequence(const tDisplayElementID id, const tDisplayElementID spriteID) :
+SpriteSequence::SpriteSequence(const DisplayElementID id, const DisplayElementID spriteID) :
 		FrameSequence(id), _sprite(spriteID), _transparent(false) {
 }
 
@@ -524,7 +524,7 @@ void ScreenDimmer::draw(const Common::Rect &r) {
 #undef DRAW_PIXEL
 #undef SKIP_PIXEL
 
-SoundLevel::SoundLevel(const tDisplayElementID id) : DisplayElement(id) {
+SoundLevel::SoundLevel(const DisplayElementID id) : DisplayElement(id) {
 	_soundLevel = 0;
 }
 
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 6e20e72..009cb3a 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -44,13 +44,13 @@ namespace Pegasus {
 class DisplayElement : public IDObject {
 friend class GraphicsManager;
 public:
-	DisplayElement(const tDisplayElementID);
+	DisplayElement(const DisplayElementID);
 	virtual ~DisplayElement();
 	
-	void setDisplayOrder(const tDisplayOrder);
-	tDisplayOrder getDisplayOrder() const { return _elementOrder; }
+	void setDisplayOrder(const DisplayOrder);
+	DisplayOrder getDisplayOrder() const { return _elementOrder; }
 	
-	bool validToDraw(tDisplayOrder, tDisplayOrder);
+	bool validToDraw(DisplayOrder, DisplayOrder);
 	
 	virtual void draw(const Common::Rect&) {}
 	bool isDisplaying() { return _elementIsDisplaying; }
@@ -65,15 +65,15 @@ public:
 	void triggerRedraw();
 	void setTriggeredElement(DisplayElement *);
 	
-	virtual void setBounds(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
-	virtual void setBounds(const Common::Rect&);
-	virtual void getBounds(Common::Rect&) const;
-	virtual void sizeElement(const tCoordType, const tCoordType);
-	virtual void moveElementTo(const tCoordType, const tCoordType);
-	virtual void moveElement(const tCoordType, const tCoordType);
-	virtual void getLocation(tCoordType&, tCoordType&) const;
-	virtual void getCenter(tCoordType&, tCoordType&) const;
-	virtual void centerElementAt(const tCoordType, const tCoordType);
+	virtual void setBounds(const CoordType, const CoordType, const CoordType, const CoordType);
+	virtual void setBounds(const Common::Rect &);
+	virtual void getBounds(Common::Rect &) const;
+	virtual void sizeElement(const CoordType, const CoordType);
+	virtual void moveElementTo(const CoordType, const CoordType);
+	virtual void moveElement(const CoordType, const CoordType);
+	virtual void getLocation(CoordType &, CoordType &) const;
+	virtual void getCenter(CoordType &, CoordType &) const;
+	virtual void centerElementAt(const CoordType, const CoordType);
 
 protected:
 	Common::Rect _bounds;
@@ -82,7 +82,7 @@ protected:
 
 	// Used only by PegasusEngine
 	bool _elementIsDisplaying;
-	tDisplayOrder _elementOrder;
+	DisplayOrder _elementOrder;
 	DisplayElement *_nextElement;
 };
 
@@ -90,7 +90,7 @@ protected:
 // QuickDraw "hilite" :P (deal with it!)
 class DropHighlight : public DisplayElement {
 public:
-	DropHighlight(const tDisplayElementID);
+	DropHighlight(const DisplayElementID);
 	virtual ~DropHighlight() {}
 
 	void setHighlightColor(const uint32 &highlight) { _highlightColor = highlight; }
@@ -112,12 +112,12 @@ protected:
 
 class Animation : public DisplayElement, public DynamicElement {
 public:
-	Animation(const tDisplayElementID id) : DisplayElement(id) {}
+	Animation(const DisplayElementID id) : DisplayElement(id) {}
 };
 
 class IdlerAnimation : public Animation, public Idler {
 public:
-	IdlerAnimation(const tDisplayElementID);
+	IdlerAnimation(const DisplayElementID);
 	
 	virtual void startDisplaying();
 	virtual void stopDisplaying();
@@ -138,7 +138,7 @@ protected:
 
 class FrameSequence : public IdlerAnimation {
 public:
-	FrameSequence(const tDisplayElementID);
+	FrameSequence(const DisplayElementID);
 	virtual ~FrameSequence();
 
 	void useFileName(const Common::String &fileName);
@@ -169,11 +169,11 @@ class SpriteFrame;
 class Sprite : public DisplayElement {
 friend class SpriteFrame;
 public:
-	Sprite(const tDisplayElementID);
+	Sprite(const DisplayElementID);
 	virtual ~Sprite();
 
-	virtual void addPICTResourceFrame(const tResIDType, const bool, const tCoordType, const tCoordType);
-	virtual uint32 addFrame(SpriteFrame *, const tCoordType, const tCoordType);
+	virtual void addPICTResourceFrame(const ResIDType, const bool, const CoordType, const CoordType);
+	virtual uint32 addFrame(SpriteFrame *, const CoordType, const CoordType);
 	virtual void removeFrame(const uint32);
 	virtual void discardFrames();
 	
@@ -193,8 +193,8 @@ public:
 protected:
 	struct SpriteFrameRec {
 		SpriteFrame *frame;
-		tCoordType frameLeft;
-		tCoordType frameTop;
+		CoordType frameLeft;
+		CoordType frameTop;
 	};
 
 	uint32 _numFrames;
@@ -205,7 +205,7 @@ protected:
 
 class SpriteSequence : public FrameSequence {
 public:
-	SpriteSequence(const tDisplayElementID id, const tDisplayElementID spriteID);
+	SpriteSequence(const DisplayElementID id, const DisplayElementID spriteID);
 	virtual ~SpriteSequence() {}
 
 	void useTransparent(bool transparent) { _transparent = transparent; }
@@ -234,7 +234,7 @@ public:
 
 class SoundLevel : public DisplayElement {
 public:
-	SoundLevel(const tDisplayElementID);
+	SoundLevel(const DisplayElementID);
 	virtual ~SoundLevel() {}
 	
 	void incrementLevel();
diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index 2076ae1..5f12bf4 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -68,7 +68,7 @@ void Blinker::timeChanged(const TimeValue time) {
 	}
 }
 
-static const tNotificationFlags kEnergyExpiredFlag = 1;
+static const NotificationFlags kEnergyExpiredFlag = 1;
 
 EnergyMonitor *g_energyMonitor = 0;
 
@@ -167,7 +167,7 @@ void EnergyMonitor::timeChanged(const TimeValue currentTime) {
 	} else {
 		uint32 currentEnergy = kMaxJMPEnergy - currentTime;
 
-		tEnergyStage newStage;
+		EnergyStage newStage;
 		if (currentEnergy > kWorriedEnergy)
 			newStage = kStageCasual;
 		else if (currentEnergy > kNervousEnergy)
diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
index cb5d449..4c111af 100755
--- a/engines/pegasus/energymonitor.h
+++ b/engines/pegasus/energymonitor.h
@@ -98,7 +98,7 @@ protected:
 
 	uint32 _barColor;
 	Common::Rect _levelRect;
-	tEnergyStage _stage;
+	EnergyStage _stage;
 	Sprite _energyLight;
 	Blinker _lightBlinker;
 	bool _calibrating, _dontFlash;
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
index 8c4fb0b..24ecae0 100755
--- a/engines/pegasus/fader.h
+++ b/engines/pegasus/fader.h
@@ -99,7 +99,7 @@ protected:
 
 class FaderAnimation : public DisplayElement, public Fader {
 public:
-	FaderAnimation(const tDisplayElementID id) : DisplayElement(id) {}
+	FaderAnimation(const DisplayElementID id) : DisplayElement(id) {}
 	virtual ~FaderAnimation() {}
 
 	void setFaderValue(const int32);
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
index 5c889bd..0a8597d 100755
--- a/engines/pegasus/gamestate.cpp
+++ b/engines/pegasus/gamestate.cpp
@@ -40,8 +40,8 @@ Common::Error GameStateManager::writeGameState(Common::WriteStream *stream) {
 	stream->writeUint16BE(_currentNeighborhood);
 	stream->writeUint16BE(_currentRoom);
 	stream->writeByte(_currentDirection);
-	stream->writeUint16BE(_nextNeighborhoodID);
-	stream->writeUint16BE(_nextRoomID);
+	stream->writeUint16BE(_nexNeighborhoodID);
+	stream->writeUint16BE(_nexRoomID);
 	stream->writeByte(_nextDirection);
 	stream->writeUint16BE(_lastNeighborhood);
 	stream->writeUint16BE(_lastRoom);
@@ -70,8 +70,8 @@ Common::Error GameStateManager::readGameState(Common::ReadStream *stream) {
 	_currentNeighborhood = stream->readUint16BE();
 	_currentRoom = stream->readUint16BE();
 	_currentDirection = stream->readByte();
-	_nextNeighborhoodID = stream->readUint16BE();
-	_nextRoomID = stream->readUint16BE();
+	_nexNeighborhoodID = stream->readUint16BE();
+	_nexRoomID = stream->readUint16BE();
 	_nextDirection = stream->readByte();
 	_lastNeighborhood = stream->readUint16BE();
 	_lastRoom = stream->readUint16BE();
@@ -100,8 +100,8 @@ void GameStateManager::resetGameState() {
 	_currentNeighborhood = kNoNeighborhoodID;
 	_currentRoom = kNoRoomID;
 	_currentDirection = kNoDirection;
-	_nextNeighborhoodID = kNoNeighborhoodID;
-	_nextRoomID = kNoRoomID;
+	_nexNeighborhoodID = kNoNeighborhoodID;
+	_nexRoomID = kNoRoomID;
 	_nextDirection = kNoDirection;
 	_lastNeighborhood = kNoNeighborhoodID;
 	_lastRoom = kNoRoomID;
@@ -121,13 +121,13 @@ void GameStateManager::resetGameState() {
 	resetWSCState();
 }
 
-void GameStateManager::getCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+void GameStateManager::getCurrentLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) {
 	neighborhood = _currentNeighborhood;
 	room = _currentRoom;
 	direction = _currentDirection;
 }
 
-void GameStateManager::setCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+void GameStateManager::setCurrentLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 	_lastNeighborhood = _currentNeighborhood;
 	_lastRoom = _currentRoom;
 	_lastDirection = _currentDirection;
@@ -136,140 +136,140 @@ void GameStateManager::setCurrentLocation(const tNeighborhoodID neighborhood, co
 	_currentDirection = direction;
 }
 
-tNeighborhoodID GameStateManager::getCurrentNeighborhood() {
+NeighborhoodID GameStateManager::getCurrentNeighborhood() {
 	return _currentNeighborhood;
 }
 
-void GameStateManager::setCurrentNeighborhood(const tNeighborhoodID neighborhood) {
+void GameStateManager::setCurrentNeighborhood(const NeighborhoodID neighborhood) {
 	_lastNeighborhood = _currentNeighborhood;
 	_currentNeighborhood = neighborhood;
 }
 
-tRoomID GameStateManager::getCurrentRoom() {
+RoomID GameStateManager::getCurrentRoom() {
 	return _currentRoom;
 }
 
-void GameStateManager::setCurrentRoom(const tRoomID room) {
+void GameStateManager::setCurrentRoom(const RoomID room) {
 	_lastRoom = _currentRoom;
 	_currentRoom = room;
 }
 
-tDirectionConstant GameStateManager::getCurrentDirection() {
+DirectionConstant GameStateManager::getCurrentDirection() {
 	return _currentDirection;
 }
 
-void GameStateManager::setCurrentDirection(const tDirectionConstant direction) {
+void GameStateManager::setCurrentDirection(const DirectionConstant direction) {
 	_lastDirection = _currentDirection;
 	_currentDirection = direction;
 }
 
-tRoomViewID GameStateManager::getCurrentRoomAndView() {
+RoomViewID GameStateManager::getCurrentRoomAndView() {
 	return MakeRoomView(_currentRoom, _currentDirection);
 }
 
-void GameStateManager::getNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
-	neighborhood = _nextNeighborhoodID;
-	room = _nextRoomID;
+void GameStateManager::getNextLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) {
+	neighborhood = _nexNeighborhoodID;
+	room = _nexRoomID;
 	direction = _nextDirection;
 }
 
-void GameStateManager::setNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
-	_nextNeighborhoodID = neighborhood;
-	_nextRoomID = room;
+void GameStateManager::setNextLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
+	_nexNeighborhoodID = neighborhood;
+	_nexRoomID = room;
 	_nextDirection = direction;
 }
 
-tNeighborhoodID GameStateManager::getNextNeighborhood() {
-	return _nextNeighborhoodID;
+NeighborhoodID GameStateManager::getNextNeighborhood() {
+	return _nexNeighborhoodID;
 }
 
-void GameStateManager::setNextNeighborhood(const tNeighborhoodID neighborhood) {
-	_nextNeighborhoodID = neighborhood;
+void GameStateManager::setNextNeighborhood(const NeighborhoodID neighborhood) {
+	_nexNeighborhoodID = neighborhood;
 }
 
-tRoomID GameStateManager::getNextRoom() {
-	return _nextRoomID;
+RoomID GameStateManager::getNextRoom() {
+	return _nexRoomID;
 }
 
-void GameStateManager::setNextRoom(const tRoomID room) {
-	_nextRoomID = room;
+void GameStateManager::setNextRoom(const RoomID room) {
+	_nexRoomID = room;
 }
 
-tDirectionConstant GameStateManager::getNextDirection() {
+DirectionConstant GameStateManager::getNextDirection() {
 	return _nextDirection;
 }
 
-void GameStateManager::setNextDirection(const tDirectionConstant direction) {
+void GameStateManager::setNextDirection(const DirectionConstant direction) {
 	_nextDirection = direction;
 }
 
-void GameStateManager::getLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) {
+void GameStateManager::getLastLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) {
 	neighborhood = _currentNeighborhood;
 	room = _currentRoom;
 	direction = _currentDirection;
 }
 
-void GameStateManager::setLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+void GameStateManager::setLastLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 	_currentNeighborhood = neighborhood;
 	_currentRoom = room;
 	_currentDirection = direction;
 }
 
-tNeighborhoodID GameStateManager::getLastNeighborhood() {
+NeighborhoodID GameStateManager::getLastNeighborhood() {
 	return _lastNeighborhood;
 }
 
-void GameStateManager::setLastNeighborhood(const tNeighborhoodID neighborhood) {
+void GameStateManager::setLastNeighborhood(const NeighborhoodID neighborhood) {
 	_lastNeighborhood = neighborhood;
 }
 
-tRoomID GameStateManager::getLastRoom() {
+RoomID GameStateManager::getLastRoom() {
 	return _lastRoom;
 }
 
-void GameStateManager::setLastRoom(const tRoomID room) {
+void GameStateManager::setLastRoom(const RoomID room) {
 	_lastRoom = room;
 }
 
-tDirectionConstant GameStateManager::getLastDirection() {
+DirectionConstant GameStateManager::getLastDirection() {
 	return _lastDirection;
 }
 
-void GameStateManager::setLastDirection(const tDirectionConstant direction) {
+void GameStateManager::setLastDirection(const DirectionConstant direction) {
 	_lastDirection = direction;
 }
 
-tRoomViewID GameStateManager::getLastRoomAndView() {
+RoomViewID GameStateManager::getLastRoomAndView() {
 	return MakeRoomView(_lastRoom, _lastDirection);
 }
 
-void GameStateManager::getOpenDoorLocation(tRoomID &room, tDirectionConstant &direction) {
+void GameStateManager::getOpenDoorLocation(RoomID &room, DirectionConstant &direction) {
 	room = _openDoorRoom;
 	direction = _openDoorDirection;
 }
 
-void GameStateManager::setOpenDoorLocation(const tRoomID room, const tDirectionConstant direction) {
+void GameStateManager::setOpenDoorLocation(const RoomID room, const DirectionConstant direction) {
 	_openDoorRoom = room;
 	_openDoorDirection = direction;
 }
 
-tRoomID GameStateManager::getOpenDoorRoom() {
+RoomID GameStateManager::getOpenDoorRoom() {
 	return _openDoorRoom;
 }
 
-void GameStateManager::setOpenDoorRoom(const tRoomID room) {
+void GameStateManager::setOpenDoorRoom(const RoomID room) {
 	_openDoorRoom = room;
 }
 
-tDirectionConstant GameStateManager::getOpenDoorDirection() {
+DirectionConstant GameStateManager::getOpenDoorDirection() {
 	return _openDoorDirection;
 }
 
-void GameStateManager::setOpenDoorDirection(const tDirectionConstant direction) {
+void GameStateManager::setOpenDoorDirection(const DirectionConstant direction) {
 	_openDoorDirection = direction;
 }
 
-tRoomViewID GameStateManager::getDoorOpenRoomAndView() {
+RoomViewID GameStateManager::getDoorOpenRoomAndView() {
 	return MakeRoomView(_openDoorRoom, _openDoorDirection);
 }
 
@@ -277,8 +277,8 @@ bool GameStateManager::isCurrentDoorOpen() {
 	return _openDoorRoom == _currentRoom && _openDoorDirection == _currentDirection;
 }
 
-tGameScoreType GameStateManager::getCaldoriaTSAScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getCaldoriaTSAScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringSawINNFlag))
 		result += kSawINNScore;
@@ -358,8 +358,8 @@ tGameScoreType GameStateManager::getCaldoriaTSAScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getPrehistoricScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getPrehistoricScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringThrewBreakerFlag))
 		result += kThrewBreakerScore;
@@ -373,8 +373,8 @@ tGameScoreType GameStateManager::getPrehistoricScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getMarsScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getMarsScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringThrownByRobotFlag))
 		result += kThrownByRobotScore;
@@ -422,8 +422,8 @@ tGameScoreType GameStateManager::getMarsScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getNoradScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getNoradScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringSawSecurityMonitorFlag))
 		result += kSawSecurityMonitorScore;
@@ -459,8 +459,8 @@ tGameScoreType GameStateManager::getNoradScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getWSCScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getWSCScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringRemovedDartFlag))
 		result += kRemovedDartScore;
@@ -506,8 +506,8 @@ tGameScoreType GameStateManager::getWSCScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getGandhiScore() {
-	tGameScoreType result = 0;
+GameScoreType GameStateManager::getGandhiScore() {
+	GameScoreType result = 0;
 
 	if (_scoringFlags.getFlag(kScoringMarsGandhiFlag))
 		result += kMarsGandhiScore;
@@ -519,7 +519,7 @@ tGameScoreType GameStateManager::getGandhiScore() {
 	return result;
 }
 
-tGameScoreType GameStateManager::getTotalScore() {
+GameScoreType GameStateManager::getTotalScore() {
 	return	getCaldoriaTSAScore() +
 			getPrehistoricScore() +
 			getMarsScore() +
@@ -607,7 +607,7 @@ void GameStateManager::writeNoradState(Common::WriteStream *stream) {
 void GameStateManager::readNoradState(Common::ReadStream *stream) {
 	_noradFlags.readFromStream(stream);
 	_noradSubRoomPressure = stream->readUint16BE();
-	_noradSubPrepState = (tNoradSubPrepState)stream->readByte();
+	_noradSubPrepState = (NoradSubPrepState)stream->readByte();
 }
 
 void GameStateManager::resetNoradState() {
@@ -1524,11 +1524,11 @@ bool GameStateManager::allTimeZonesFinished() {
 	return getWSCFinished() && getMarsFinished() && getNoradFinished();
 }
 
-void GameStateManager::setTakenItemID(tItemID id, bool value) {
+void GameStateManager::setTakenItemID(ItemID id, bool value) {
 	_itemTakenFlags.setFlag(id, value);
 }
 
-bool GameStateManager::isTakenItemID(tItemID id) {
+bool GameStateManager::isTakenItemID(ItemID id) {
 	return _itemTakenFlags.getFlag(id);
 }
 
@@ -1988,11 +1988,11 @@ uint16 GameStateManager::getNoradSubRoomPressure() {
 	return _noradSubRoomPressure;
 }
 
-void GameStateManager::setNoradSubPrepState(tNoradSubPrepState state) {
+void GameStateManager::setNoradSubPrepState(NoradSubPrepState state) {
 	_noradSubPrepState = state;
 }
 
-tNoradSubPrepState GameStateManager::getNoradSubPrepState() {
+NoradSubPrepState GameStateManager::getNoradSubPrepState() {
 	return _noradSubPrepState;
 }
 
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index b95a5d7..5eab093 100755
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -300,48 +300,48 @@ public:
 	
 	void resetGameState();
 	
-	void getCurrentLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	void setCurrentLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	void getCurrentLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction);
+	void setCurrentLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
 	
-	tNeighborhoodID getCurrentNeighborhood();
-	void setCurrentNeighborhood(const tNeighborhoodID neighborhood);
-	tRoomID getCurrentRoom();
-	void setCurrentRoom(const tRoomID room);
-	tDirectionConstant getCurrentDirection();
-	void setCurrentDirection(const tDirectionConstant direction);
+	NeighborhoodID getCurrentNeighborhood();
+	void setCurrentNeighborhood(const NeighborhoodID neighborhood);
+	RoomID getCurrentRoom();
+	void setCurrentRoom(const RoomID room);
+	DirectionConstant getCurrentDirection();
+	void setCurrentDirection(const DirectionConstant direction);
 	
-	tRoomViewID getCurrentRoomAndView();
+	RoomViewID getCurrentRoomAndView();
 	
-	void getNextLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	void	setNextLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	void getNextLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction);
+	void	setNextLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
 
-	tNeighborhoodID getNextNeighborhood();
-	void setNextNeighborhood(const tNeighborhoodID neighborhood);
-	tRoomID getNextRoom();
-	void setNextRoom(const tRoomID room);
-	tDirectionConstant getNextDirection();
-	void setNextDirection(const tDirectionConstant direction);
+	NeighborhoodID getNextNeighborhood();
+	void setNextNeighborhood(const NeighborhoodID neighborhood);
+	RoomID getNextRoom();
+	void setNextRoom(const RoomID room);
+	DirectionConstant getNextDirection();
+	void setNextDirection(const DirectionConstant direction);
 	
-	void getLastLocation(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction);
-	void setLastLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	void getLastLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction);
+	void setLastLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
 	
-	tNeighborhoodID getLastNeighborhood();
-	void setLastNeighborhood(const tNeighborhoodID neighborhood);
-	tRoomID getLastRoom();
-	void setLastRoom(const tRoomID room);
-	tDirectionConstant getLastDirection();
-	void setLastDirection(const tDirectionConstant direction);
+	NeighborhoodID getLastNeighborhood();
+	void setLastNeighborhood(const NeighborhoodID neighborhood);
+	RoomID getLastRoom();
+	void setLastRoom(const RoomID room);
+	DirectionConstant getLastDirection();
+	void setLastDirection(const DirectionConstant direction);
 	
-	tRoomViewID getLastRoomAndView();
+	RoomViewID getLastRoomAndView();
 	
-	void getOpenDoorLocation(tRoomID &room, tDirectionConstant &direction);
-	void setOpenDoorLocation(const tRoomID room, const tDirectionConstant direction);
-	tRoomID getOpenDoorRoom();
-	void setOpenDoorRoom(const tRoomID room);
-	tDirectionConstant getOpenDoorDirection();
-	void setOpenDoorDirection(const tDirectionConstant direction);
+	void getOpenDoorLocation(RoomID &room, DirectionConstant &direction);
+	void setOpenDoorLocation(const RoomID room, const DirectionConstant direction);
+	RoomID getOpenDoorRoom();
+	void setOpenDoorRoom(const RoomID room);
+	DirectionConstant getOpenDoorDirection();
+	void setOpenDoorDirection(const DirectionConstant direction);
 	
-	tRoomViewID getDoorOpenRoomAndView();
+	RoomViewID getDoorOpenRoomAndView();
 	
 	bool isCurrentDoorOpen();
 
@@ -563,13 +563,13 @@ public:
 	bool					getScoringNoradGandhi();
 	bool					getScoringWSCGandhi();
 
-	tGameScoreType			getCaldoriaTSAScore();
-	tGameScoreType			getPrehistoricScore();
-	tGameScoreType			getMarsScore();
-	tGameScoreType			getNoradScore();
-	tGameScoreType			getWSCScore();
-	tGameScoreType			getGandhiScore();
-	tGameScoreType			getTotalScore();
+	GameScoreType			getCaldoriaTSAScore();
+	GameScoreType			getPrehistoricScore();
+	GameScoreType			getMarsScore();
+	GameScoreType			getNoradScore();
+	GameScoreType			getWSCScore();
+	GameScoreType			getGandhiScore();
+	GameScoreType			getTotalScore();
 
 	void					writeCaldoriaState(Common::WriteStream *stream);
 	void					readCaldoriaState(Common::ReadStream *stream);
@@ -615,10 +615,10 @@ public:
 	void						setNoradFinished(bool);
 	bool					getNoradFinished();
 	bool					allTimeZonesFinished();
-	void						setTakenItemID(tItemID, bool);
-	bool					isTakenItemID(tItemID);
-	void						setTakenItem(Item*, bool);
-	bool					isTakenItem(Item*);
+	void						setTakenItemID(ItemID, bool);
+	bool					isTakenItemID(ItemID);
+	void						setTakenItem(Item *, bool);
+	bool					isTakenItem(Item *);
 	
 	//	Caldoria
 	void						setCaldoriaFuseTimeLimit(const TimeValue);
@@ -739,8 +739,8 @@ public:
 	bool					getNoradWaitingForLaser();
 	void						setNoradSubRoomPressure(uint16);
 	uint16					getNoradSubRoomPressure();
-	void						setNoradSubPrepState(tNoradSubPrepState);
-	tNoradSubPrepState		getNoradSubPrepState();
+	void						setNoradSubPrepState(NoradSubPrepState);
+	NoradSubPrepState		getNoradSubPrepState();
 	void						setNoradArrivedFromSub(bool);
 	bool					getNoradArrivedFromSub();
 	
@@ -841,17 +841,17 @@ protected:
 
 private:
 	// Base
-	tNeighborhoodID _currentNeighborhood;
-	tRoomID _currentRoom;
-	tDirectionConstant _currentDirection;
-	tNeighborhoodID _nextNeighborhoodID;
-	tRoomID _nextRoomID;
-	tDirectionConstant _nextDirection;
-	tNeighborhoodID _lastNeighborhood;
-	tRoomID _lastRoom;
-	tDirectionConstant _lastDirection;
-	tRoomID _openDoorRoom;
-	tDirectionConstant _openDoorDirection;
+	NeighborhoodID _currentNeighborhood;
+	RoomID _currentRoom;
+	DirectionConstant _currentDirection;
+	NeighborhoodID _nexNeighborhoodID;
+	RoomID _nexRoomID;
+	DirectionConstant _nextDirection;
+	NeighborhoodID _lastNeighborhood;
+	RoomID _lastRoom;
+	DirectionConstant _lastDirection;
+	RoomID _openDoorRoom;
+	DirectionConstant _openDoorDirection;
 
 	// Pegasus Prime
 	FlagsArray<byte, kNumGlobalFlags> _globalFlags;
@@ -872,7 +872,7 @@ private:
 	
 	FlagsArray<byte, kNumNoradFlags> _noradFlags;
 	uint16 _noradSubRoomPressure;
-	tNoradSubPrepState _noradSubPrepState;
+	NoradSubPrepState _noradSubPrepState;
 	
 	FlagsArray<byte, kNumMarsFlags> _marsFlags;
 	
diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 06db31f..175f15e 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -188,7 +188,7 @@ void GraphicsManager::clearScreen() {
 	_modifiedScreen = true;
 }
 
-DisplayElement *GraphicsManager::findDisplayElement(const tDisplayElementID id) {
+DisplayElement *GraphicsManager::findDisplayElement(const DisplayElementID id) {
 	DisplayElement *runner = _firstDisplayElement;
 
 	while (runner) {
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 0e5de47..7c5bd69 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -51,14 +51,14 @@ public:
 	void addDisplayElement(DisplayElement *element);
 	void removeDisplayElement(DisplayElement *element);
 	void invalRect(const Common::Rect &rect);
-	tDisplayOrder getBackOfActiveLayer() const { return _backLayer; }
-	tDisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
+	DisplayOrder getBackOfActiveLayer() const { return _backLayer; }
+	DisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
 	void updateDisplay();
 	Graphics::Surface *getCurSurface() { return _curSurface; }
 	void setCurSurface(Graphics::Surface *surface) { _curSurface = surface; }
 	Graphics::Surface *getWorkArea() { return &_workArea; }
 	void clearScreen();
-	DisplayElement *findDisplayElement(const tDisplayElementID id);
+	DisplayElement *findDisplayElement(const DisplayElementID id);
 	void shakeTheWorld(TimeValue time, TimeScale scale);
 	void enableErase();
 	void disableErase();
@@ -75,7 +75,7 @@ private:
 
 	bool _modifiedScreen, _erase;
 	Common::Rect _dirtyRect;
-	tDisplayOrder _backLayer, _frontLayer;
+	DisplayOrder _backLayer, _frontLayer;
 	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 	Graphics::Surface _workArea, *_curSurface;
 
diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
index b8ff97a..84731b7 100755
--- a/engines/pegasus/hotspot.cpp
+++ b/engines/pegasus/hotspot.cpp
@@ -115,7 +115,7 @@ bool Region::pointInRegion(const Common::Point &point) const {
 	return true;
 }
 
-void Region::moveTo(tCoordType h, tCoordType v) {
+void Region::moveTo(CoordType h, CoordType v) {
 	_bounds.moveTo(h, v);
 }
 
@@ -123,7 +123,7 @@ void Region::moveTo(const Common::Point &point) {
 	_bounds.moveTo(point);
 }
 
-void Region::translate(tCoordType h, tCoordType v) {
+void Region::translate(CoordType h, CoordType v) {
 	_bounds.translate(h, v);
 }
 
@@ -131,7 +131,7 @@ void Region::translate(const Common::Point &point) {
 	_bounds.translate(point.x, point.y);
 }
 
-void Region::getCenter(tCoordType &h, tCoordType &v) const {
+void Region::getCenter(CoordType &h, CoordType &v) const {
 	h = (_bounds.left + _bounds.right) / 2;
 	v = (_bounds.top + _bounds.bottom) / 2;
 }
@@ -140,7 +140,7 @@ void Region::getCenter(Common::Point &point) const {
 	getCenter(point.x, point.y);
 }
 
-Hotspot::Hotspot(const tHotSpotID id) : IDObject(id) {
+Hotspot::Hotspot(const HotSpotID id) : IDObject(id) {
 	_spotFlags = kNoHotSpotFlags;
 	_spotActive = false;
 }
@@ -152,7 +152,7 @@ void Hotspot::setArea(const Common::Rect &area) {
 	_spotArea = Region(area);
 }
 
-void Hotspot::setArea(const tCoordType left, const tCoordType top, const tCoordType right, const tCoordType bottom) {
+void Hotspot::setArea(const CoordType left, const CoordType top, const CoordType right, const CoordType bottom) {
 	_spotArea = Region(Common::Rect(left, top, right, bottom));
 }
 
@@ -164,7 +164,7 @@ void Hotspot::getCenter(Common::Point &pt) const {
 	_spotArea.getCenter(pt);
 }
 
-void Hotspot::getCenter(tCoordType &h, tCoordType &v) const {
+void Hotspot::getCenter(CoordType &h, CoordType &v) const {
 	_spotArea.getCenter(h, v);
 }
 
@@ -176,11 +176,11 @@ void Hotspot::setInactive() {
 	_spotActive = false;
 }
 
-void Hotspot::setHotspotFlags(const tHotSpotFlags flags) {
+void Hotspot::setHotspotFlags(const HotSpotFlags flags) {
 	_spotFlags = flags;
 }
 
-void Hotspot::setMaskedHotspotFlags(const tHotSpotFlags flags, const tHotSpotFlags mask) {
+void Hotspot::setMaskedHotspotFlags(const HotSpotFlags flags, const HotSpotFlags mask) {
 	_spotFlags = (_spotFlags & ~mask) | flags;
 }
 
@@ -188,7 +188,7 @@ bool Hotspot::isSpotActive() const {
 	return _spotActive;
 }
 
-void Hotspot::moveSpotTo(const tCoordType h, const tCoordType v) {
+void Hotspot::moveSpotTo(const CoordType h, const CoordType v) {
 	_spotArea.moveTo(h, v);
 }
 
@@ -196,7 +196,7 @@ void Hotspot::moveSpotTo(const Common::Point pt) {
 	_spotArea.moveTo(pt);
 }
 
-void Hotspot::moveSpot(const tCoordType h, const tCoordType v) {
+void Hotspot::moveSpot(const CoordType h, const CoordType v) {
 	_spotArea.translate(h, v);
 }
 
@@ -208,7 +208,7 @@ bool Hotspot::pointInSpot(const Common::Point where) const {
 	return _spotActive && _spotArea.pointInRegion(where);
 }
 
-tHotSpotFlags Hotspot::getHotspotFlags() const {
+HotSpotFlags Hotspot::getHotspotFlags() const {
 	return _spotFlags;
 }
 
@@ -234,12 +234,12 @@ Hotspot *HotspotList::findHotspot(const Common::Point where) {
 	return 0;
 }
 
-tHotSpotID HotspotList::findHotspotID(const Common::Point where) {
+HotSpotID HotspotList::findHotspotID(const Common::Point where) {
 	Hotspot *hotspot = findHotspot(where);
 	return hotspot ? hotspot->getObjectID() : kNoHotSpotID;
 }
 
-Hotspot *HotspotList::findHotspotByID(const tHotSpotID id) {
+Hotspot *HotspotList::findHotspotByID(const HotSpotID id) {
 	for (HotspotIterator it = begin(); it != end(); it++)
 		if ((*it)->getObjectID() == id)
 			return *it;
@@ -247,7 +247,7 @@ Hotspot *HotspotList::findHotspotByID(const tHotSpotID id) {
 	return 0;
 }
 
-Hotspot *HotspotList::findHotspotByMask(const tHotSpotFlags flags) {
+Hotspot *HotspotList::findHotspotByMask(const HotSpotFlags flags) {
 	for (HotspotIterator it = begin(); it != end(); it++)
 		if (((*it)->getHotspotFlags() & flags) == flags)
 			return *it;
@@ -255,7 +255,7 @@ Hotspot *HotspotList::findHotspotByMask(const tHotSpotFlags flags) {
 	return 0;
 }
 
-void HotspotList::activateMaskedHotspots(const tHotSpotFlags flags) {
+void HotspotList::activateMaskedHotspots(const HotSpotFlags flags) {
 	for (HotspotIterator it = begin(); it != end(); it++)
 		if (flags == kNoHotSpotFlags || ((*it)->getHotspotFlags() & flags) != 0)
 			(*it)->setActive();
@@ -266,13 +266,13 @@ void HotspotList::deactivateAllHotspots() {
 		(*it)->setInactive();
 }
 
-void HotspotList::deactivateMaskedHotspots(const tHotSpotFlags flags) {
+void HotspotList::deactivateMaskedHotspots(const HotSpotFlags flags) {
 	for (HotspotIterator it = begin(); it != end(); it++)
 		if (((*it)->getHotspotFlags() & flags) != 0)
 			(*it)->setInactive();
 }
 
-void HotspotList::activateOneHotspot(const tHotSpotID id) {
+void HotspotList::activateOneHotspot(const HotSpotID id) {
 	for (HotspotIterator it = begin(); it != end(); it++) {
 		if ((*it)->getObjectID() == id) {
 			(*it)->setActive();
@@ -281,7 +281,7 @@ void HotspotList::activateOneHotspot(const tHotSpotID id) {
 	}
 }
 
-void HotspotList::deactivateOneHotspot(const tHotSpotID id) {
+void HotspotList::deactivateOneHotspot(const HotSpotID id) {
 	for (HotspotIterator it = begin(); it != end(); it++) {
 		if ((*it)->getObjectID() == id) {
 			(*it)->setInactive();
@@ -290,7 +290,7 @@ void HotspotList::deactivateOneHotspot(const tHotSpotID id) {
 	}
 }
 
-void HotspotList::removeOneHotspot(const tHotSpotID id) {
+void HotspotList::removeOneHotspot(const HotSpotID id) {
 	for (HotspotIterator it = begin(); it != end(); it++) {
 		if ((*it)->getObjectID() == id) {
 			erase(it);
@@ -299,7 +299,7 @@ void HotspotList::removeOneHotspot(const tHotSpotID id) {
 	}
 }
 
-void HotspotList::removeMaskedHotspots(const tHotSpotFlags flags) {
+void HotspotList::removeMaskedHotspots(const HotSpotFlags flags) {
 	if (flags != kNoHotSpotFlags) {
 		for (HotspotIterator it = begin(); it != end(); ) {
 			if (((*it)->getHotspotFlags() & flags) != 0)
@@ -312,13 +312,13 @@ void HotspotList::removeMaskedHotspots(const tHotSpotFlags flags) {
 	}
 }
 
-void HotspotList::setHotspotRect(const tHotSpotID id, const Common::Rect &r) {
+void HotspotList::setHotspotRect(const HotSpotID id, const Common::Rect &r) {
 	Hotspot *hotspot = findHotspotByID(id);
 	if (hotspot)
 		hotspot->setArea(r);
 }
 
-void HotspotList::getHotspotRect(const tHotSpotID id, Common::Rect &r) {
+void HotspotList::getHotspotRect(const HotSpotID id, Common::Rect &r) {
 	Hotspot *hotspot = findHotspotByID(id);
 	if (hotspot)
 		hotspot->getBoundingBox(r);
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
index aafb96c..bc1d054 100755
--- a/engines/pegasus/hotspot.h
+++ b/engines/pegasus/hotspot.h
@@ -61,11 +61,11 @@ public:
 
 	bool pointInRegion(const Common::Point &point) const;
 
-	void moveTo(tCoordType h, tCoordType v);
+	void moveTo(CoordType h, CoordType v);
 	void moveTo(const Common::Point &point);
-	void translate(tCoordType h, tCoordType v);
+	void translate(CoordType h, CoordType v);
 	void translate(const Common::Point &point);
-	void getCenter(tCoordType &h, tCoordType &v) const;
+	void getCenter(CoordType &h, CoordType &v) const;
 	void getCenter(Common::Point &point) const;
 
 private:
@@ -85,20 +85,20 @@ private:
 
 class Hotspot : public IDObject {
 public:
-	Hotspot(const tHotSpotID);
+	Hotspot(const HotSpotID);
 	virtual ~Hotspot();
 
 	void setArea(const Region &region) { _spotArea = region; }
 	void setArea(const Common::Rect &);
-	void setArea(const tCoordType, const tCoordType, const tCoordType, const tCoordType);
+	void setArea(const CoordType, const CoordType, const CoordType, const CoordType);
 	void getBoundingBox(Common::Rect &) const;
 	void getArea(Region &) const;
 	void getCenter(Common::Point&) const;
-	void getCenter(tCoordType&, tCoordType&) const;
+	void getCenter(CoordType&, CoordType&) const;
 	
-	void moveSpotTo(const tCoordType, const tCoordType);
+	void moveSpotTo(const CoordType, const CoordType);
 	void moveSpotTo(const Common::Point);
-	void moveSpot(const tCoordType, const tCoordType);
+	void moveSpot(const CoordType, const CoordType);
 	void moveSpot(const Common::Point);
 	
 	bool pointInSpot(const Common::Point) const;
@@ -107,13 +107,13 @@ public:
 	void setInactive();
 	bool isSpotActive() const;
 	
-	tHotSpotFlags getHotspotFlags() const;
-	void setHotspotFlags(const tHotSpotFlags);
-	void setMaskedHotspotFlags(const tHotSpotFlags flags, const tHotSpotFlags mask);
+	HotSpotFlags getHotspotFlags() const;
+	void setHotspotFlags(const HotSpotFlags);
+	void setMaskedHotspotFlags(const HotSpotFlags flags, const HotSpotFlags mask);
 
 protected:
 	Region _spotArea;
-	tHotSpotFlags _spotFlags;
+	HotSpotFlags _spotFlags;
 	bool _spotActive;
 };
 
@@ -125,22 +125,22 @@ public:
 	void deleteHotspots();
 
 	Hotspot *findHotspot(const Common::Point);
-	tHotSpotID findHotspotID(const Common::Point);
-	Hotspot * findHotspotByID(const tHotSpotID);
-	Hotspot * findHotspotByMask(const tHotSpotFlags);
+	HotSpotID findHotspotID(const Common::Point);
+	Hotspot *findHotspotByID(const HotSpotID);
+	Hotspot *findHotspotByMask(const HotSpotFlags);
 
-	void activateMaskedHotspots(const tHotSpotFlags = kNoHotSpotFlags);
+	void activateMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
 	void deactivateAllHotspots();
-	void deactivateMaskedHotspots(const tHotSpotFlags);
+	void deactivateMaskedHotspots(const HotSpotFlags);
 
-	void activateOneHotspot(const tHotSpotID);
-	void deactivateOneHotspot(const tHotSpotID);
+	void activateOneHotspot(const HotSpotID);
+	void deactivateOneHotspot(const HotSpotID);
 	
-	void removeOneHotspot(const tHotSpotID);
-	void removeMaskedHotspots(const tHotSpotFlags = kNoHotSpotFlags);
+	void removeOneHotspot(const HotSpotID);
+	void removeMaskedHotspots(const HotSpotFlags = kNoHotSpotFlags);
 
-	void setHotspotRect(const tHotSpotID, const Common::Rect&);
-	void getHotspotRect(const tHotSpotID, Common::Rect&);
+	void setHotspotRect(const HotSpotID, const Common::Rect&);
+	void getHotspotRect(const HotSpotID, Common::Rect&);
 };
 
 typedef HotspotList::iterator HotspotIterator;
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index e11b40f..bb5167b 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -39,10 +39,10 @@ InputDevice::InputDevice() {
 InputDevice::~InputDevice() {
 }
 
-void InputDevice::getInput(Input &input, const tInputBits filter) {
+void InputDevice::getInput(Input &input, const InputBits filter) {
 	// TODO: Save/Load keys
 
-	tInputBits currentBits = 0;
+	InputBits currentBits = 0;
 	bool consoleRequested = false;
 	bool altDown = false;
 
@@ -126,7 +126,7 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 	input.setInputLocation(g_system->getEventManager()->getMousePos());
 
 	// Set the outgoing bits
-	tInputBits filteredBits = currentBits & filter;	
+	InputBits filteredBits = currentBits & filter;	
 	input.setInputBits((filteredBits & kAllButtonDownBits) | (filteredBits & _lastRawBits & kAllAutoBits));
 
 	// Update the last bits
@@ -140,7 +140,7 @@ void InputDevice::getInput(Input &input, const tInputBits filter) {
 }
 
 //	Wait until the input device stops returning input allowed by filter...
-void InputDevice::waitInput(const tInputBits filter) {
+void InputDevice::waitInput(const InputBits filter) {
 	if (filter != 0) {
 		for (;;) {
 			Input input;
@@ -162,7 +162,7 @@ int operator!=(const Input &arg1, const Input &arg2) {
 InputHandler *InputHandler::_inputHandler = 0;
 InputDevice InputHandler::_inputDevice;
 bool InputHandler::_invalHotspots = false;
-tInputBits InputHandler::_lastFilter = kFilterNoInput;
+InputBits InputHandler::_lastFilter = kFilterNoInput;
 
 InputHandler *InputHandler::setInputHandler(InputHandler *currentHandler) {
 	InputHandler *result = 0;
@@ -255,7 +255,7 @@ void InputHandler::activateHotspots() {
 		_nextHandler->activateHotspots();
 }
 
-tInputBits InputHandler::getInputFilter() {
+InputBits InputHandler::getInputFilter() {
 	if (_allowInput) {
 		if (_nextHandler)
 			return _nextHandler->getInputFilter();
@@ -266,7 +266,7 @@ tInputBits InputHandler::getInputFilter() {
 	return kFilterNoInput;
 }
 
-tInputBits InputHandler::getClickFilter() {
+InputBits InputHandler::getClickFilter() {
 	if (_allowInput && _nextHandler)
 		return _nextHandler->getClickFilter();
 
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 8778ffb..1aae16c 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -41,12 +41,12 @@ public:
 	InputDevice();
 	~InputDevice();
 
-	void getInput(Input&, const tInputBits);
+	void getInput(Input &, const InputBits);
 
-	void waitInput(const tInputBits);
+	void waitInput(const InputBits);
 
 protected:
-	tInputBits _lastRawBits;
+	InputBits _lastRawBits;
 };
 
 enum {
@@ -267,9 +267,9 @@ enum {
 								kFilterMod3Button
 };
 
-static const tInputBits kHintInterruption = kFilterAllInputNoAuto;
-static const tInputBits kWarningInterruption = kFilterNoInput;
-static const tInputBits kOpticalInterruption = kFilterAllInputNoAuto;
+static const InputBits kHintInterruption = kFilterAllInputNoAuto;
+static const InputBits kWarningInterruption = kFilterNoInput;
+static const InputBits kOpticalInterruption = kFilterAllInputNoAuto;
 
 /*
 
@@ -356,7 +356,7 @@ public:
 	
 	void getInputLocation(Common::Point &where) const { where = _inputLocation; }
 	
-	bool anyInputBitSet(const tInputBits bits) const { return (_inputState & bits) != 0; }
+	bool anyInputBitSet(const InputBits bits) const { return (_inputState & bits) != 0; }
 
 	bool isAltDown() const { return _altDown; }
 	bool isConsoleRequested() const { return _consoleRequested; }
@@ -370,12 +370,12 @@ public:
 	}
 
 protected:
-	void setInputBits(const tInputBits state) { _inputState = state; }
+	void setInputBits(const InputBits state) { _inputState = state; }
 	void setInputLocation(const Common::Point &where) { _inputLocation = where; }
 	void setConsoleRequested(bool consoleRequested) { _consoleRequested = consoleRequested; }
 	void setAltDown(bool altDown) { _altDown = altDown; }
 	
-	tInputBits _inputState;
+	InputBits _inputState;
 	Common::Point _inputLocation;
 	bool _consoleRequested;
 	bool _altDown;
@@ -390,7 +390,7 @@ public:
 	static void getInput(Input&, Hotspot*&);
 	static void readInputDevice(Input&);
 	static void invalHotspots() { _invalHotspots = true; }
-	static tInputBits getCurrentFilter() { return _lastFilter; }
+	static InputBits getCurrentFilter() { return _lastFilter; }
 		
 	InputHandler(InputHandler*);
 	virtual ~InputHandler();
@@ -398,22 +398,22 @@ public:
 	virtual void setNextHandler(InputHandler *nextHandler) { _nextHandler = nextHandler; }
 	virtual InputHandler *getNextHandler() { return _nextHandler; }
 	
-	virtual void handleInput(const Input&, const Hotspot*);
-	virtual void clickInHotspot(const Input&, const Hotspot*);
+	virtual void handleInput(const Input &, const Hotspot *);
+	virtual void clickInHotspot(const Input &, const Hotspot *);
 	
 	virtual void activateHotspots();
-	virtual void updateCursor(const Common::Point, const Hotspot*);
-	virtual bool isClickInput(const Input&, const Hotspot*);
+	virtual void updateCursor(const Common::Point, const Hotspot *);
+	virtual bool isClickInput(const Input &, const Hotspot *);
 	virtual bool wantsCursor();
 	
 	virtual bool releaseInputFocus() { return true; }
 	virtual void grabInputFocus() {}
 	
 	//	This returns bits set for what kinds of input to accept.
-	virtual tInputBits getInputFilter();
+	virtual InputBits getInputFilter();
 
 	//	This returns bits defining what input constitutes a "click."
-	virtual tInputBits getClickFilter();
+	virtual InputBits getClickFilter();
 
 	virtual void allowInput(const bool allow) { _allowInput = allow; }
 
@@ -421,7 +421,7 @@ protected:
 	static InputHandler *_inputHandler;
 	static InputDevice _inputDevice; // TODO: Remove global constructor
 	static bool _invalHotspots;
-	static tInputBits _lastFilter;
+	static InputBits _lastFilter;
 	
 	InputHandler *_nextHandler;
 	bool _allowInput;
@@ -466,14 +466,14 @@ class JMPPPInput {
 public:
 	static bool isMenuButtonPressInput(const Input &input) { return input.twoButtonDown(); }
 
-	static tInputBits getClickInputFilter() { return kFilterTwoButton; }
+	static InputBits getClickInputFilter() { return kFilterTwoButton; }
 	static bool isClickInput(const Input &input) { return input.twoButtonDown(); }
 	static bool isDraggingInput(const Input &input) { return input.twoButtonAnyDown(); }
 	static bool isPressingInput(const Input &input) { return input.twoButtonAnyDown(); }
 
 	static bool isRaiseInventoryInput(const Input &input) { return input.leftFireButtonDown(); }
 	static bool isRaiseBiochipsInput(const Input &input) { return input.rightFireButtonDown(); }
-	static tInputBits getItemPanelsInputFilter() { return kFilterLeftFireButton | kFilterRightFireButton; }
+	static InputBits getItemPanelsInputFilter() { return kFilterLeftFireButton | kFilterRightFireButton; }
 
 	static bool isToggleAIMiddleInput(const Input &input) { return input.threeButtonDown(); }
 
diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h
index b54c59e..b131856 100755
--- a/engines/pegasus/interaction.h
+++ b/engines/pegasus/interaction.h
@@ -31,13 +31,13 @@
 
 namespace Pegasus {
 
-static const tInteractionID kNoInteractionID = -1;
+static const InteractionID kNoInteractionID = -1;
 
 class Neighborhood;
 
 class GameInteraction : public IDObject, public InputHandler {
 public:
-	GameInteraction(const tInteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) {
+	GameInteraction(const InteractionID id, Neighborhood *nextHandler) : IDObject(id), InputHandler((InputHandler *)nextHandler) {
 		_isInteracting = false;
 		_savedHandler = 0;
 		_owner = nextHandler;
diff --git a/engines/pegasus/interface.cpp b/engines/pegasus/interface.cpp
index e9daecb..5e51888 100755
--- a/engines/pegasus/interface.cpp
+++ b/engines/pegasus/interface.cpp
@@ -294,11 +294,11 @@ void Interface::createInterface() {
 	}
 }
 
-tInventoryResult Interface::addInventoryItem(InventoryItem *item) {
+InventoryResult Interface::addInventoryItem(InventoryItem *item) {
 	return _inventoryPanel.addInventoryItem(item);
 }
 
-tInventoryResult Interface::removeInventoryItem(InventoryItem *item) {
+InventoryResult Interface::removeInventoryItem(InventoryItem *item) {
 	return _inventoryPanel.removeInventoryItem(item);
 }
 
@@ -314,11 +314,11 @@ void Interface::setCurrentInventoryItem(InventoryItem *item) {
 	setCurrentInventoryItemID(item->getObjectID());
 }
 
-void Interface::setCurrentInventoryItemID(tItemID id) {
+void Interface::setCurrentInventoryItemID(ItemID id) {
 	_inventoryPanel.setCurrentItemID(id);
 }
 
-tInventoryResult Interface::addBiochip(BiochipItem *item) {
+InventoryResult Interface::addBiochip(BiochipItem *item) {
 	return _biochipPanel.addInventoryItem(item);
 }
 
@@ -334,11 +334,11 @@ void Interface::setCurrentBiochip(BiochipItem *item) {
 	setCurrentBiochipID(item->getObjectID());
 }
 
-void Interface::setCurrentBiochipID(tItemID id) {
+void Interface::setCurrentBiochipID(ItemID id) {
 	_biochipPanel.setCurrentItemID(id);
 }
 
-void Interface::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+void Interface::receiveNotification(Notification *notification, const NotificationFlags flags) {
 	if (notification == &_interfaceNotification) {
 		switch (flags) {
 		case kInventoryLidOpenFlag:
diff --git a/engines/pegasus/interface.h b/engines/pegasus/interface.h
index f8ad714..a65d9a5 100755
--- a/engines/pegasus/interface.h
+++ b/engines/pegasus/interface.h
@@ -63,17 +63,17 @@ public:
 	bool isInventoryUp();
 	bool isInventoryDown();
 
-	tInventoryResult addInventoryItem(InventoryItem*);
-	tInventoryResult removeInventoryItem(InventoryItem*);
+	InventoryResult addInventoryItem(InventoryItem *);
+	InventoryResult removeInventoryItem(InventoryItem *);
 	void removeAllItemsFromInventory();
 	InventoryItem *getCurrentInventoryItem();
-	void setCurrentInventoryItem(InventoryItem*);
-	void setCurrentInventoryItemID(tItemID);
-	tInventoryResult addBiochip(BiochipItem*);
+	void setCurrentInventoryItem(InventoryItem *);
+	void setCurrentInventoryItemID(ItemID);
+	InventoryResult addBiochip(BiochipItem *);
 	void removeAllItemsFromBiochips();
 	BiochipItem *getCurrentBiochip();
-	void setCurrentBiochip(BiochipItem*);
-	void setCurrentBiochipID(tItemID);
+	void setCurrentBiochip(BiochipItem *);
+	void setCurrentBiochipID(ItemID);
 
 	void setDate(const uint16);
 
@@ -100,7 +100,7 @@ protected:
 	void throwAwayBiochipPanel();
 	void throwAwayEnergyMonitor();
 
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 	void inventoryLidOpen(const bool doCallBacks);
 	void inventoryLidClosed();
 	void inventoryDrawerUp();
diff --git a/engines/pegasus/items/biochips/aichip.cpp b/engines/pegasus/items/biochips/aichip.cpp
index d4e4259..5e9fc9f 100755
--- a/engines/pegasus/items/biochips/aichip.cpp
+++ b/engines/pegasus/items/biochips/aichip.cpp
@@ -33,7 +33,7 @@
 namespace Pegasus {
 
 // indexed by [number of hints][number of solves (0, 1, or 2)][which button to highlight]
-static const tItemState s_highlightState[4][3][7] = {
+static const ItemState s_highlightState[4][3][7] = {
 	{
 		{kAI000,	-1,			-1,			-1,			-1,			kAI005,		kAI006},
 		{kAI010,	-1,			-1,			-1,			-1,			kAI015,		kAI016},
@@ -58,7 +58,7 @@ static const tItemState s_highlightState[4][3][7] = {
 
 AIChip *g_AIChip = 0;
 
-AIChip::AIChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+AIChip::AIChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction), _briefingSpot(kAIBriefingSpotID), _scanSpot(kAIScanSpotID),
 		_hint1Spot(kAIHint1SpotID), _hint2Spot(kAIHint2SpotID), _hint3Spot(kAIHint3SpotID), _solveSpot(kAISolveSpotID) {
 	_briefingSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 10, kAIMiddleAreaTop + 27, kAIMiddleAreaLeft + 10 + 81, kAIMiddleAreaTop + 27 + 31));
@@ -186,7 +186,7 @@ void AIChip::showBriefingClicked() {
 		numSolves = 0;
 	}
 
-	tItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIBriefingSpotID - kAIHint1SpotID + 1];
+	ItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIBriefingSpotID - kAIHint1SpotID + 1];
 	if (newState != -1)
 		setItemState(newState);
 }
@@ -206,7 +206,7 @@ void AIChip::showEnvScanClicked() {
 		numSolves = 0;
 	}
 
-	tItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIScanSpotID - kAIHint1SpotID + 1];
+	ItemState newState = s_highlightState[vm->getNumHints()][numSolves][kAIScanSpotID - kAIHint1SpotID + 1];
 
 	if (newState != -1)
 		setItemState(newState);
@@ -217,7 +217,7 @@ void AIChip::clearClicked() {
 	setUpAIChip();
 }
 
-void AIChip::clickInAIHotspot(tHotSpotID id) {
+void AIChip::clickInAIHotspot(HotSpotID id) {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 
 	Common::String movieName;
@@ -243,7 +243,7 @@ void AIChip::clickInAIHotspot(tHotSpotID id) {
 		break;
 	}
 
-	tItemState state = getItemState();
+	ItemState state = getItemState();
 
 	if (!movieName.empty()) {
 		_playingMovie = true;
@@ -258,7 +258,7 @@ void AIChip::clickInAIHotspot(tHotSpotID id) {
 			numSolves = 0;
 		}
 
-		tItemState newState = s_highlightState[vm->getNumHints()][numSolves][id - kAIHint1SpotID + 1];
+		ItemState newState = s_highlightState[vm->getNumHints()][numSolves][id - kAIHint1SpotID + 1];
 
 		if (newState != -1)
 			setItemState(newState);
diff --git a/engines/pegasus/items/biochips/aichip.h b/engines/pegasus/items/biochips/aichip.h
index 96d2fb2..e0cbd99 100755
--- a/engines/pegasus/items/biochips/aichip.h
+++ b/engines/pegasus/items/biochips/aichip.h
@@ -33,7 +33,7 @@ namespace Pegasus {
 
 class AIChip : public BiochipItem {
 public:
-	AIChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	AIChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~AIChip();
 
 	void select();
@@ -44,7 +44,7 @@ public:
 	// own the center area.
 	void setUpAIChipRude();
 	void activateAIHotspots();
-	void clickInAIHotspot(tHotSpotID);
+	void clickInAIHotspot(HotSpotID);
 
 	void takeSharedArea();
 
diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
index 99e6050..5686948 100755
--- a/engines/pegasus/items/biochips/biochipitem.cpp
+++ b/engines/pegasus/items/biochips/biochipitem.cpp
@@ -32,7 +32,7 @@
 
 namespace Pegasus {
 
-BiochipItem::BiochipItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+BiochipItem::BiochipItem(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		Item(id, neighborhood, room, direction) {
 
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
@@ -59,7 +59,7 @@ BiochipItem::~BiochipItem() {
 	delete[] _rightAreaInfo.entries;
 }
 
-tItemType BiochipItem::getItemType() {
+ItemType BiochipItem::getItemType() {
 	return kBiochipItemType;
 }
 
@@ -68,7 +68,7 @@ TimeValue BiochipItem::getRightAreaTime() const {
 		return 0xffffffff;
 
 	TimeValue time;
-	tItemState state;
+	ItemState state;
 
 	findItemStateEntryByState(_rightAreaInfo, _itemState, time);
 	if (time == 0xffffffff)
diff --git a/engines/pegasus/items/biochips/biochipitem.h b/engines/pegasus/items/biochips/biochipitem.h
index 904c23b..24b9ae6 100755
--- a/engines/pegasus/items/biochips/biochipitem.h
+++ b/engines/pegasus/items/biochips/biochipitem.h
@@ -32,10 +32,10 @@ namespace Pegasus {
 
 class BiochipItem : public Item {
 public:
-	BiochipItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	BiochipItem(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~BiochipItem();
 	
-	virtual tItemType getItemType();
+	virtual ItemType getItemType();
 	
 	TimeValue getPanelTime() const { return _biochipInfoPanelTime; }
 	TimeValue getRightAreaTime() const;
diff --git a/engines/pegasus/items/biochips/mapchip.cpp b/engines/pegasus/items/biochips/mapchip.cpp
index de6d4e2..69050d5 100755
--- a/engines/pegasus/items/biochips/mapchip.cpp
+++ b/engines/pegasus/items/biochips/mapchip.cpp
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 MapChip *g_map = 0;
 
-MapChip::MapChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+MapChip::MapChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction) {
 	g_map = this;
 	setItemState(kMapUnavailable);
@@ -69,8 +69,8 @@ void MapChip::deselect() {
 	_image.unloadImage();
 }
 
-void MapChip::moveToMapLocation(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant dir) {
-	tAirQuality airQuality;
+void MapChip::moveToMapLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant dir) {
+	AirQuality airQuality;
 
 	if (g_neighborhood)
 		airQuality = g_neighborhood->getAirQuality(room);
diff --git a/engines/pegasus/items/biochips/mapchip.h b/engines/pegasus/items/biochips/mapchip.h
index 69bfabc..6690090 100755
--- a/engines/pegasus/items/biochips/mapchip.h
+++ b/engines/pegasus/items/biochips/mapchip.h
@@ -38,7 +38,7 @@ namespace Pegasus {
 
 class MapChip : public BiochipItem {
 public:
-	MapChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	MapChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~MapChip();
 
 	void select();
@@ -46,7 +46,7 @@ public:
 	void takeSharedArea();
 	void giveUpSharedArea();
 
-	void moveToMapLocation(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	void moveToMapLocation(const NeighborhoodID, const RoomID, const DirectionConstant);
 
 	void writeToStream(Common::WriteStream *);
 	void readFromStream(Common::ReadStream *);
diff --git a/engines/pegasus/items/biochips/mapimage.cpp b/engines/pegasus/items/biochips/mapimage.cpp
index 6e4a8ec..bd7b8ff 100755
--- a/engines/pegasus/items/biochips/mapimage.cpp
+++ b/engines/pegasus/items/biochips/mapimage.cpp
@@ -55,20 +55,20 @@ static const int kGearRoomFlagHigh = ROOM_TO_FLAG(kMars39, kWest);
 static const int kMazeFlagLow = ROOM_TO_FLAG(kMars60, kNorth);
 static const int kMazeFlagHigh = ROOM_TO_FLAG(kMarsMaze200, kWest);
 
-static const tCoordType kGearRoomScreenOffsetX = 49;
-static const tCoordType kGearRoomScreenOffsetY = 47;
+static const CoordType kGearRoomScreenOffsetX = 49;
+static const CoordType kGearRoomScreenOffsetY = 47;
 
-static const tCoordType kGearRoomGridOriginX = 1;
-static const tCoordType kGearRoomGridOriginY = 4;
+static const CoordType kGearRoomGridOriginX = 1;
+static const CoordType kGearRoomGridOriginY = 4;
 
-static const tCoordType kMazeScreenOffsetX = 16;
-static const tCoordType kMazeScreenOffsetY = 20;
+static const CoordType kMazeScreenOffsetX = 16;
+static const CoordType kMazeScreenOffsetY = 20;
 
-static const tCoordType kMazeGridOriginX = 6;
-static const tCoordType kMazeGridOriginY = 1;
+static const CoordType kMazeGridOriginX = 6;
+static const CoordType kMazeGridOriginY = 1;
 
-static const tCoordType kGridWidth = 4;
-static const tCoordType kGridHeight = 4;
+static const CoordType kGridWidth = 4;
+static const CoordType kGridHeight = 4;
 
 static const uint16 kMapOfMazePICTID = 906;
 static const uint16 kMapOfGearRoomPICTID = 907;
@@ -318,7 +318,7 @@ void MapImage::unloadImage() {
 	_whichArea = kMapNoArea;
 }
 
-void MapImage::moveToMapLocation(const tNeighborhoodID, const tRoomID room, const tDirectionConstant dir) {
+void MapImage::moveToMapLocation(const NeighborhoodID, const RoomID room, const DirectionConstant dir) {
 	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
 
 	int flag = ROOM_TO_FLAG(room, dir);
@@ -346,7 +346,7 @@ void MapImage::addFlagToMask(const int flag) {
 // This function can even be sensitive to open doors.
 // clone2727 notices that it's not, though
 void MapImage::getRevealedRects(const uint32 flag, Common::Rect &r1) {	
-	tCoordType gridX, gridY;
+	CoordType gridX, gridY;
 
 	switch (_whichArea) {
 	case kMapMaze:
@@ -371,7 +371,7 @@ void MapImage::getRevealedRects(const uint32 flag, Common::Rect &r1) {
 void MapImage::drawPlayer() {
 	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 
-	tCoordType gridX, gridY;
+	CoordType gridX, gridY;
 
 	switch (_whichArea) {
 	case kMapMaze:
diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
index 359d67c..d596b58 100755
--- a/engines/pegasus/items/biochips/mapimage.h
+++ b/engines/pegasus/items/biochips/mapimage.h
@@ -49,7 +49,7 @@ public:
 	void loadGearRoomIfNecessary();
 	void loadMazeIfNecessary();
 	void unloadImage();
-	void moveToMapLocation(const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	void moveToMapLocation(const NeighborhoodID, const RoomID, const DirectionConstant);
 	
 	void draw(const Common::Rect &);
 	
diff --git a/engines/pegasus/items/biochips/opticalchip.cpp b/engines/pegasus/items/biochips/opticalchip.cpp
index f6519c7..6a9a41d 100755
--- a/engines/pegasus/items/biochips/opticalchip.cpp
+++ b/engines/pegasus/items/biochips/opticalchip.cpp
@@ -30,7 +30,7 @@ namespace Pegasus {
 
 OpticalChip *g_opticalChip = 0;
 
-OpticalChip::OpticalChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+OpticalChip::OpticalChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction), _ariesHotspot(kAriesSpotID), _mercuryHotspot(kMercurySpotID),
 		_poseidonHotspot(kPoseidonSpotID) {
 	_ariesHotspot.setArea(Common::Rect(kAIMiddleAreaLeft + 60, kAIMiddleAreaTop + 27, kAIMiddleAreaLeft + 60 + 121, kAIMiddleAreaTop + 27 + 20));
@@ -118,11 +118,11 @@ void OpticalChip::activateOpticalHotspots() {
 		_poseidonHotspot.setActive();
 }
 
-void OpticalChip::clickInOpticalHotspot(tHotSpotID id) {
+void OpticalChip::clickInOpticalHotspot(HotSpotID id) {
 	playOpMemMovie(id);
 }
 
-void OpticalChip::playOpMemMovie(tHotSpotID id) {
+void OpticalChip::playOpMemMovie(HotSpotID id) {
 	Common::String movieName;
 	switch (id) {
 	case kAriesSpotID:
@@ -136,7 +136,7 @@ void OpticalChip::playOpMemMovie(tHotSpotID id) {
 		break;
 	}
 
-	tItemState state = getItemState(), newState;
+	ItemState state = getItemState(), newState;
 	switch (state) {
 	case kOptical000:
 		// Can never happen.
diff --git a/engines/pegasus/items/biochips/opticalchip.h b/engines/pegasus/items/biochips/opticalchip.h
index c44a5ea..b1ea87b 100755
--- a/engines/pegasus/items/biochips/opticalchip.h
+++ b/engines/pegasus/items/biochips/opticalchip.h
@@ -34,7 +34,7 @@ namespace Pegasus {
 
 class OpticalChip : public BiochipItem {
 public:
-	OpticalChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	OpticalChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~OpticalChip();
 
 	virtual void writeToStream(Common::WriteStream *);
@@ -45,8 +45,8 @@ public:
 	void addPoseidon();
 
 	void activateOpticalHotspots();
-	void clickInOpticalHotspot(tHotSpotID);
-	void playOpMemMovie(tHotSpotID);
+	void clickInOpticalHotspot(HotSpotID);
+	void playOpMemMovie(HotSpotID);
 
 protected:
 	enum {
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
index 8d369c1..1e3e0d7 100755
--- a/engines/pegasus/items/biochips/pegasuschip.cpp
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -32,7 +32,7 @@
 
 namespace Pegasus {
 
-PegasusChip::PegasusChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+PegasusChip::PegasusChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction), _recallSpot(kPegasusRecallSpotID) {
 	_recallSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 116, kAIMiddleAreaTop + 63, kAIMiddleAreaLeft + 184, kAIMiddleAreaTop + 91));
 	_recallSpot.setHotspotFlags(kPegasusBiochipSpotFlag);
@@ -125,8 +125,8 @@ void PegasusChip::activatePegasusHotspots() {
 void PegasusChip::clickInPegasusHotspot() {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 
-	tItemState thisState = getItemState();
-	tItemState hiliteState;
+	ItemState thisState = getItemState();
+	ItemState hiliteState;
 
 	switch (thisState) {
 	case kPegasusPrehistoric00:
diff --git a/engines/pegasus/items/biochips/pegasuschip.h b/engines/pegasus/items/biochips/pegasuschip.h
index 1ee35b7..7597424 100755
--- a/engines/pegasus/items/biochips/pegasuschip.h
+++ b/engines/pegasus/items/biochips/pegasuschip.h
@@ -33,7 +33,7 @@ namespace Pegasus {
 
 class PegasusChip : public BiochipItem {
 public:
-	PegasusChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	PegasusChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~PegasusChip();
 
 	void select();
diff --git a/engines/pegasus/items/biochips/retscanchip.cpp b/engines/pegasus/items/biochips/retscanchip.cpp
index e990405..84b74a6 100755
--- a/engines/pegasus/items/biochips/retscanchip.cpp
+++ b/engines/pegasus/items/biochips/retscanchip.cpp
@@ -28,7 +28,7 @@
 
 namespace Pegasus {
 
-RetScanChip::RetScanChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+RetScanChip::RetScanChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction) {
 }
 
diff --git a/engines/pegasus/items/biochips/retscanchip.h b/engines/pegasus/items/biochips/retscanchip.h
index 7d8fe6d..e72eaed 100755
--- a/engines/pegasus/items/biochips/retscanchip.h
+++ b/engines/pegasus/items/biochips/retscanchip.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 class RetScanChip : public BiochipItem {
 public:
-	RetScanChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	RetScanChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~RetScanChip() {}
 	
 	void searchForLaser();
diff --git a/engines/pegasus/items/biochips/shieldchip.cpp b/engines/pegasus/items/biochips/shieldchip.cpp
index 4bd0572..58cbfcc 100755
--- a/engines/pegasus/items/biochips/shieldchip.cpp
+++ b/engines/pegasus/items/biochips/shieldchip.cpp
@@ -31,7 +31,7 @@ namespace Pegasus {
 
 ShieldChip *g_shield = 0;
 
-ShieldChip::ShieldChip(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+ShieldChip::ShieldChip(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		BiochipItem(id, neighborhood, room, direction) {
 	g_shield = this;
 }
diff --git a/engines/pegasus/items/biochips/shieldchip.h b/engines/pegasus/items/biochips/shieldchip.h
index c0b9cc5..69c6369 100755
--- a/engines/pegasus/items/biochips/shieldchip.h
+++ b/engines/pegasus/items/biochips/shieldchip.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 class ShieldChip : public BiochipItem {
 public:
-	ShieldChip(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	ShieldChip(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~ShieldChip() {}
 
 	void select();
diff --git a/engines/pegasus/items/inventory.cpp b/engines/pegasus/items/inventory.cpp
index 8f7eb46..e30fcac 100755
--- a/engines/pegasus/items/inventory.cpp
+++ b/engines/pegasus/items/inventory.cpp
@@ -38,13 +38,13 @@ Inventory::Inventory() {
 Inventory::~Inventory() {
 }
 
-void Inventory::setWeightLimit(tWeightType limit) {
+void Inventory::setWeightLimit(WeightType limit) {
 	_weightLimit = limit;
 	//	*** What to do if the new weight limit is greater than the current weight?
 }
 
-tWeightType Inventory::getWeight() {
-	tWeightType	result = 0;
+WeightType Inventory::getWeight() {
+	WeightType	result = 0;
 
 	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++)
 		result += (*it)->getItemWeight();
@@ -53,7 +53,7 @@ tWeightType Inventory::getWeight() {
 }
 
 //	If the item already belongs, just return kInventoryOK.
-tInventoryResult Inventory::addItem(Item *item) {
+InventoryResult Inventory::addItem(Item *item) {
 	if (itemInInventory(item))
 		return kInventoryOK;
 
@@ -67,7 +67,7 @@ tInventoryResult Inventory::addItem(Item *item) {
 	return kInventoryOK;
 }
 
-tInventoryResult Inventory::removeItem(Item *item) {
+InventoryResult Inventory::removeItem(Item *item) {
 	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++) {
 		if (*it == item) {
 			_inventoryList.erase(it);
@@ -81,7 +81,7 @@ tInventoryResult Inventory::removeItem(Item *item) {
 	return kItemNotInInventory;
 }
 
-tInventoryResult Inventory::removeItem(tItemID id) {
+InventoryResult Inventory::removeItem(ItemID id) {
 	Item *item = findItemByID(id);
 	
 	if (item) {
@@ -108,7 +108,7 @@ bool Inventory::itemInInventory(Item *item) {
 	return false;
 }
 
-bool Inventory::itemInInventory(tItemID id) {
+bool Inventory::itemInInventory(ItemID id) {
 	return findItemByID(id) != NULL;
 }
 
@@ -121,7 +121,7 @@ Item *Inventory::getItemAt(int32 index) {
 	return 0;
 }
 
-tItemID Inventory::getItemIDAt(int32 index) {
+ItemID Inventory::getItemIDAt(int32 index) {
 	Item *item = getItemAt(index);
 
 	if (item)
@@ -130,7 +130,7 @@ tItemID Inventory::getItemIDAt(int32 index) {
 	return kNoItemID;
 }
 
-Item *Inventory::findItemByID(tItemID id) {
+Item *Inventory::findItemByID(ItemID id) {
 	return _inventoryList.findItemByID(id);
 }
 
@@ -147,7 +147,7 @@ int32 Inventory::findIndexOf(Item *item) {
 
 //	Return -1 if not found.
 
-int32 Inventory::findIndexOf(tItemID id) {
+int32 Inventory::findIndexOf(ItemID id) {
 	uint32 i = 0;
 	for (ItemIterator it = _inventoryList.begin(); it != _inventoryList.end(); it++, i++)
 		if ((*it)->getObjectID() == id)
@@ -156,7 +156,7 @@ int32 Inventory::findIndexOf(tItemID id) {
 	return -1;
 }
 
-tWeightType Inventory::getWeightLimit() {
+WeightType Inventory::getWeightLimit() {
 	return _weightLimit;
 }
 
@@ -164,11 +164,11 @@ int32 Inventory::getNumItems() {
 	return _inventoryList.size();
 }
 
-void Inventory::setOwnerID(const tActorID id) {
+void Inventory::setOwnerID(const ActorID id) {
 	_ownerID = id;
 }
 
-tActorID Inventory::getOwnerID() const {
+ActorID Inventory::getOwnerID() const {
 	return _ownerID;
 }
 
diff --git a/engines/pegasus/items/inventory.h b/engines/pegasus/items/inventory.h
index 7da782f..db872b1 100755
--- a/engines/pegasus/items/inventory.h
+++ b/engines/pegasus/items/inventory.h
@@ -44,31 +44,31 @@ public:
 	Inventory();
 	virtual ~Inventory();
 	
-	tWeightType getWeightLimit();
-	void setWeightLimit(tWeightType limit);
-	tWeightType getWeight();
+	WeightType getWeightLimit();
+	void setWeightLimit(WeightType limit);
+	WeightType getWeight();
 	
-	virtual tInventoryResult addItem(Item *item);
-	virtual tInventoryResult removeItem(Item *item);
-	virtual tInventoryResult removeItem(tItemID id);
+	virtual InventoryResult addItem(Item *item);
+	virtual InventoryResult removeItem(Item *item);
+	virtual InventoryResult removeItem(ItemID id);
 	virtual bool itemInInventory(Item *item);
-	virtual bool itemInInventory(tItemID id);
+	virtual bool itemInInventory(ItemID id);
 	virtual Item *getItemAt(int32 index);
-	virtual tItemID getItemIDAt(int32 index);
-	virtual Item *findItemByID(tItemID id);
+	virtual ItemID getItemIDAt(int32 index);
+	virtual Item *findItemByID(ItemID id);
 	virtual int32 findIndexOf(Item *item);
-	virtual int32 findIndexOf(tItemID id);
+	virtual int32 findIndexOf(ItemID id);
 	int32 getNumItems();
 	virtual void removeAllItems();
 	
-	void setOwnerID(const tActorID id);
-	tActorID getOwnerID() const;
+	void setOwnerID(const ActorID id);
+	ActorID getOwnerID() const;
 	
 	uint32 getReferenceCount() { return _referenceCount; }
 
 protected:
-	tWeightType _weightLimit;
-	tActorID _ownerID;
+	WeightType _weightLimit;
+	ActorID _ownerID;
 	ItemList _inventoryList;
 
 private:
diff --git a/engines/pegasus/items/inventory/airmask.cpp b/engines/pegasus/items/inventory/airmask.cpp
index 682927d..56f9d6f 100755
--- a/engines/pegasus/items/inventory/airmask.cpp
+++ b/engines/pegasus/items/inventory/airmask.cpp
@@ -40,7 +40,7 @@ void AirMask::airMaskTimerExpired(FunctionPtr *, void *) {
 		g_neighborhood->checkAirMask();
 }
 
-AirMask::AirMask(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+AirMask::AirMask(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		InventoryItem(id, neighborhood, room, direction), _toggleSpot(kAirMaskToggleSpotID) {
 	g_airMask = this;
 	_toggleSpot.setArea(Common::Rect(kAIMiddleAreaLeft + 10, kAIMiddleAreaTop + 17, kAIMiddleAreaLeft + 110, kAIMiddleAreaTop + 57));
@@ -68,7 +68,7 @@ void AirMask::readFromStream(Common::ReadStream *stream) {
 }
 
 void AirMask::putMaskOn() {
-	tAirQuality airQuality;
+	AirQuality airQuality;
 
 	if (g_neighborhood)
 		airQuality = g_neighborhood->getAirQuality(GameState.getCurrentRoom());
@@ -76,8 +76,8 @@ void AirMask::putMaskOn() {
 		airQuality = kAirQualityGood;
 
 	uint airLevel = getAirLeft();
-	tItemState newState = getItemState();
-	tItemState oldState = newState;
+	ItemState newState = getItemState();
+	ItemState oldState = newState;
 
 	if (airLevel == 0) {
 		newState = kAirMaskEmptyFilter;
@@ -99,8 +99,8 @@ void AirMask::putMaskOn() {
 
 void AirMask::takeMaskOff() {	
 	uint airLevel = getAirLeft();
-	tItemState newState = getItemState();
-	tItemState oldState = newState;
+	ItemState newState = getItemState();
+	ItemState oldState = newState;
 
 	if (airLevel == 0)
 		newState = kAirMaskEmptyOff;
@@ -127,7 +127,7 @@ void AirMask::airQualityChanged() {
 		takeMaskOff();
 }
 
-void AirMask::setItemState(const tItemState newState) {
+void AirMask::setItemState(const ItemState newState) {
 	if (newState != getItemState()) {
 		InventoryItem::setItemState(newState);
 
diff --git a/engines/pegasus/items/inventory/airmask.h b/engines/pegasus/items/inventory/airmask.h
index 0e71380..f207f3b 100755
--- a/engines/pegasus/items/inventory/airmask.h
+++ b/engines/pegasus/items/inventory/airmask.h
@@ -34,13 +34,13 @@ namespace Pegasus {
 
 class AirMask : public InventoryItem, private Idler {
 public:
-	AirMask(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	AirMask(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~AirMask();
 
 	virtual void writeToStream(Common::WriteStream *);
 	virtual void readFromStream(Common::ReadStream *);
 
-	virtual void setItemState(const tItemState);
+	virtual void setItemState(const ItemState);
 	void putMaskOn();
 	void takeMaskOff();
 	void toggleItemState();
diff --git a/engines/pegasus/items/inventory/gascanister.cpp b/engines/pegasus/items/inventory/gascanister.cpp
index b6cd883..bf63cc6 100755
--- a/engines/pegasus/items/inventory/gascanister.cpp
+++ b/engines/pegasus/items/inventory/gascanister.cpp
@@ -28,7 +28,7 @@
 
 namespace Pegasus {
 
-GasCanister::GasCanister(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+GasCanister::GasCanister(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		InventoryItem(id, neighborhood, room, direction) {
 }
 
diff --git a/engines/pegasus/items/inventory/gascanister.h b/engines/pegasus/items/inventory/gascanister.h
index 437df12..dae72c1 100755
--- a/engines/pegasus/items/inventory/gascanister.h
+++ b/engines/pegasus/items/inventory/gascanister.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 class GasCanister : public InventoryItem {
 public:
-	GasCanister(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	GasCanister(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~GasCanister() {}
 	
 	void select();
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
index 17f0705..4399708 100755
--- a/engines/pegasus/items/inventory/inventoryitem.cpp
+++ b/engines/pegasus/items/inventory/inventoryitem.cpp
@@ -31,7 +31,7 @@
 
 namespace Pegasus {
 
-InventoryItem::InventoryItem(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+InventoryItem::InventoryItem(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 		Item(id, neighborhood, room, direction) {
 
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
@@ -61,7 +61,7 @@ InventoryItem::~InventoryItem() {
 	delete[] _leftAreaInfo.entries;
 }
 
-tItemType InventoryItem::getItemType() {
+ItemType InventoryItem::getItemType() {
 	return kInventoryItemType;
 }
 
@@ -70,7 +70,7 @@ TimeValue InventoryItem::getLeftAreaTime() const {
 		return 0xffffffff;
 
 	TimeValue time;
-	tItemState state;
+	ItemState state;
 
 	findItemStateEntryByState(_leftAreaInfo, _itemState, time);
 	if (time == 0xffffffff)
diff --git a/engines/pegasus/items/inventory/inventoryitem.h b/engines/pegasus/items/inventory/inventoryitem.h
index d3247d6..b526463 100755
--- a/engines/pegasus/items/inventory/inventoryitem.h
+++ b/engines/pegasus/items/inventory/inventoryitem.h
@@ -39,12 +39,12 @@ struct JMPInventoryInfo {
 
 class InventoryItem : public Item {
 public:
-	InventoryItem(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	InventoryItem(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~InventoryItem();
 	
-	virtual tItemType getItemType();
+	virtual ItemType getItemType();
 	
-	void getPanelTimes(TimeValue&, TimeValue&) const;
+	void getPanelTimes(TimeValue &, TimeValue &) const;
 	TimeValue getLeftAreaTime() const;
 	
 	void setAnimationTime(const TimeValue);
diff --git a/engines/pegasus/items/inventory/keycard.cpp b/engines/pegasus/items/inventory/keycard.cpp
index 53a3f67..c818b66 100755
--- a/engines/pegasus/items/inventory/keycard.cpp
+++ b/engines/pegasus/items/inventory/keycard.cpp
@@ -28,7 +28,7 @@
 
 namespace Pegasus {
 
-KeyCard::KeyCard(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) :
+KeyCard::KeyCard(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) :
 			InventoryItem(id, neighborhood, room, direction) {
 	setItemState(kFlashlightOff);
 }
@@ -40,7 +40,7 @@ void KeyCard::toggleItemState() {
 		setItemState(kFlashlightOff);
 }
 
-void KeyCard::setItemState(const tItemState newState) {
+void KeyCard::setItemState(const ItemState newState) {
 	if (newState != getItemState()) {
 		InventoryItem::setItemState(newState);
 		((PegasusEngine *)g_engine)->checkFlashlight();
diff --git a/engines/pegasus/items/inventory/keycard.h b/engines/pegasus/items/inventory/keycard.h
index 7fdb905..c30c789 100755
--- a/engines/pegasus/items/inventory/keycard.h
+++ b/engines/pegasus/items/inventory/keycard.h
@@ -32,11 +32,11 @@ namespace Pegasus {
 
 class KeyCard : public InventoryItem {
 public:
-	KeyCard(const tItemID, const tNeighborhoodID, const tRoomID, const tDirectionConstant);
+	KeyCard(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 	virtual ~KeyCard() {}
 	
 	virtual void toggleItemState();
-	virtual void setItemState(const tItemState);
+	virtual void setItemState(const ItemState);
 	bool isFlashlightOn();
 
 protected:
diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 04bac44..7be095c 100755
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -31,7 +31,7 @@
 
 namespace Pegasus {
 
-InventoryPicture::InventoryPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+InventoryPicture::InventoryPicture(const DisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
 		InputHandler(nextHandler), Picture(id), _panelMovie(kNoDisplayElement){
 	_inventory = inventory;
 	_lastReferenceCount = 0xffffffff;
@@ -71,7 +71,7 @@ void InventoryPicture::throwAwayInventoryImage() {
 	}
 }
 
-void InventoryPicture::getItemXY(uint32 index, tCoordType &x, tCoordType &y) {
+void InventoryPicture::getItemXY(uint32 index, CoordType &x, CoordType &y) {
 	x = (index % _itemsPerRow) * _itemWidth + _itemX;
 	y = (index / _itemsPerRow) * _itemHeight + _itemY;
 }
@@ -130,14 +130,14 @@ void InventoryPicture::setCurrentItemIndex(int32 index) {
 	}
 }
 
-void InventoryPicture::setCurrentItemID(tItemID id) {
+void InventoryPicture::setCurrentItemID(ItemID id) {
 	int32 index = _inventory->findIndexOf(id);
 	if (index >= 0)
 		setCurrentItemIndex(index);
 }
 
-tInventoryResult InventoryPicture::addInventoryItem(Item *item) {
-	tInventoryResult result = _inventory->addItem(item);
+InventoryResult InventoryPicture::addInventoryItem(Item *item) {
+	InventoryResult result = _inventory->addItem(item);
 
 	if (result == kInventoryOK)
 		setCurrentItemIndex(_inventory->findIndexOf(item));
@@ -145,8 +145,8 @@ tInventoryResult InventoryPicture::addInventoryItem(Item *item) {
 	return result;
 }
 
-tInventoryResult InventoryPicture::removeInventoryItem(Item *item) {	
-	tInventoryResult result = _inventory->removeItem(item);
+InventoryResult InventoryPicture::removeInventoryItem(Item *item) {	
+	InventoryResult result = _inventory->removeItem(item);
 
 	if (result == kInventoryOK)
 		setCurrentItemIndex(getCurrentItemIndex());
@@ -163,7 +163,7 @@ bool InventoryPicture::itemInInventory(Item *item) {
 	return _inventory->itemInInventory(item);
 }
 
-bool InventoryPicture::itemInInventory(const tItemID id) {
+bool InventoryPicture::itemInInventory(const ItemID id) {
 	return _inventory->itemInInventory(id);
 }
 
@@ -181,7 +181,7 @@ void InventoryPicture::activateInventoryPicture() {
 	if (_lastReferenceCount != _inventory->getReferenceCount()) {
 		uint32 numItems = _inventory->getNumItems();
 
-		tCoordType x, y;
+		CoordType x, y;
 		getItemXY(0, x, y);
 		_panelMovie.moveMovieBoxTo(x, y);
 		_panelMovie.show();
@@ -251,12 +251,12 @@ void InventoryPicture::handleInput(const Input &input, const Hotspot *cursorSpot
 }
 
 void InventoryPicture::highlightCurrentItem() {
-	tCoordType x, y;
+	CoordType x, y;
 	getItemXY(_currentItemIndex, x, y);
 	_highlightBounds.moveTo(x, y);
 }
 
-InventoryItemsPicture::InventoryItemsPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+InventoryItemsPicture::InventoryItemsPicture(const DisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
 		InventoryPicture(id, nextHandler, inventory) {
 	_pictName = "Images/Items/Inventory/Inventory Panel";
 	_movieName = "Images/Items/Inventory/Inventory Panel Movie";
@@ -273,7 +273,7 @@ InventoryItemsPicture::InventoryItemsPicture(const tDisplayElementID id, InputHa
 
 void InventoryItemsPicture::loopCurrentItem() {
 	if (_isLooping) {
-		tCoordType x, y;
+		CoordType x, y;
 		getItemXY(_currentItemIndex, x, y);
 		_panelMovie.moveMovieBoxTo(x, y);
 		_highlightBounds.moveTo(x, y);
@@ -339,7 +339,7 @@ void InventoryItemsPicture::playEndMessage(DisplayElement *pushElement) {
 	endMessage.stop();
 }
 
-BiochipPicture::BiochipPicture(const tDisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
+BiochipPicture::BiochipPicture(const DisplayElementID id, InputHandler *nextHandler, Inventory *inventory) :
 		InventoryPicture(id, nextHandler, inventory) {
 	_pictName = "Images/Items/Biochips/Biochip Panel";
 	_movieName = "Images/Items/Biochips/Biochip Panel Movie";
@@ -355,7 +355,7 @@ BiochipPicture::BiochipPicture(const tDisplayElementID id, InputHandler *nextHan
 
 void BiochipPicture::unhighlightCurrentItem() {
 	InventoryPicture::unhighlightCurrentItem();
-	tCoordType x, y;
+	CoordType x, y;
 	getItemXY(_currentItemIndex, x, y);
 	_panelMovie.show();
 	_panelMovie.moveMovieBoxTo(x, y);
diff --git a/engines/pegasus/items/inventorypicture.h b/engines/pegasus/items/inventorypicture.h
index 034354d..18e85ef 100755
--- a/engines/pegasus/items/inventorypicture.h
+++ b/engines/pegasus/items/inventorypicture.h
@@ -39,7 +39,7 @@ class Transition;
 
 class InventoryPicture : public InputHandler, public Picture {
 public:
-	InventoryPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	InventoryPicture(const DisplayElementID, InputHandler *, Inventory *);
 	virtual ~InventoryPicture() {}
 	
 	void initInventoryImage(Transition *);
@@ -51,18 +51,18 @@ public:
 	void handleInput(const Input &, const Hotspot *);
 	bool wantsCursor() { return false; }
 	
-	tInventoryResult addInventoryItem(Item *);
-	tInventoryResult removeInventoryItem(Item *);
+	InventoryResult addInventoryItem(Item *);
+	InventoryResult removeInventoryItem(Item *);
 	void removeAllItems();
 	Item *getCurrentItem() { return _currentItem; }
 	void setCurrentItemIndex(int32);
-	void setCurrentItemID(tItemID);
+	void setCurrentItemID(ItemID);
 	int32 getCurrentItemIndex() { return _currentItemIndex; }
 	bool itemInInventory(Item *);
-	bool itemInInventory(const tItemID);
+	bool itemInInventory(const ItemID);
 
 protected:
-	void getItemXY(uint32, tCoordType &, tCoordType &);
+	void getItemXY(uint32, CoordType &, CoordType &);
 	void draw(const Common::Rect &);
 	void drawItemHighlight(const Common::Rect &);
 	virtual void highlightCurrentItem();
@@ -91,7 +91,7 @@ protected:
 
 class InventoryItemsPicture : public InventoryPicture {
 public:
-	InventoryItemsPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	InventoryItemsPicture(const DisplayElementID, InputHandler *, Inventory *);
 	virtual ~InventoryItemsPicture() {}
 
 	void deactivateInventoryPicture();
@@ -112,7 +112,7 @@ protected:
 
 class BiochipPicture : public InventoryPicture {
 public:
-	BiochipPicture(const tDisplayElementID, InputHandler *, Inventory *);
+	BiochipPicture(const DisplayElementID, InputHandler *, Inventory *);
 	virtual ~BiochipPicture() {}
 	
 protected:
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index bcb85de..83e3b02 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -38,7 +38,7 @@
 
 namespace Pegasus {
 
-Item::Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) : IDObject(id) {
+Item::Item(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) : IDObject(id) {
 	_itemNeighborhood = neighborhood;
 	_itemRoom = room;
 	_itemDirection = direction;
@@ -147,11 +147,11 @@ void Item::readFromStream(Common::ReadStream *stream) {
 	_itemState = stream->readUint16BE();
 }
 
-tActorID Item::getItemOwner() const {
+ActorID Item::getItemOwner() const {
 	return _itemOwnerID;
 }
 
-void Item::setItemOwner(const tActorID owner) {
+void Item::setItemOwner(const ActorID owner) {
 	_itemOwnerID = owner;
 
 	if (owner == kNoActorID) {
@@ -163,15 +163,15 @@ void Item::setItemOwner(const tActorID owner) {
 	}
 }
 
-tWeightType Item::getItemWeight() {
+WeightType Item::getItemWeight() {
 	return _itemWeight;
 }
 
-tItemState Item::getItemState() const {
+ItemState Item::getItemState() const {
 	return _itemState;
 }
 
-void Item::setItemState(const tItemState state) {
+void Item::setItemState(const ItemState state) {
 	if (state != _itemState) {
 		_itemState = state;
 
@@ -182,13 +182,13 @@ void Item::setItemState(const tItemState state) {
 	}
 }
 
-void Item::getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const {
+void Item::getItemRoom(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) const {
 	neighborhood = _itemNeighborhood;
 	room = _itemRoom;
 	direction = _itemDirection;
 }
 
-void Item::setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction) {
+void Item::setItemRoom(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 	_itemNeighborhood = neighborhood;
 	_itemRoom = room;
 	_itemDirection = direction;
@@ -199,7 +199,7 @@ void Item::setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, c
 		dropped();
 }
 
-tNeighborhoodID Item::getItemNeighborhood() const {
+NeighborhoodID Item::getItemNeighborhood() const {
 	return _itemNeighborhood;
 }
 
@@ -208,7 +208,7 @@ TimeValue Item::getSharedAreaTime() const {
 		return 0xffffffff;
 
 	TimeValue time;
-	tItemState state;
+	ItemState state;
 
 	findItemStateEntryByState(_sharedAreaInfo, _itemState, time);
 	if (time == 0xffffffff)
@@ -241,7 +241,7 @@ void Item::deselect() {
 	}
 }
 
-void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state, TimeValue &time) {	
+void Item::getItemStateEntry(ItemStateInfo info, uint32 index, ItemState &state, TimeValue &time) {	
 	if (index < info.numEntries) {
 		state = info.entries[index].itemState;
 		time = info.entries[index].itemTime;
@@ -251,7 +251,7 @@ void Item::getItemStateEntry(ItemStateInfo info, uint32 index, tItemState &state
 	}
 }
 
-void Item::findItemStateEntryByState(ItemStateInfo info, tItemState state, TimeValue &time) {
+void Item::findItemStateEntryByState(ItemStateInfo info, ItemState state, TimeValue &time) {
 	for (uint16 i = 0; i < info.numEntries; i++) {
 		if (info.entries[i].itemState == state) {
 			time = info.entries[i].itemTime;
@@ -275,7 +275,7 @@ ItemStateInfo Item::readItemState(Common::SeekableReadStream *stream) {
 	return info;
 }
 
-Sprite *Item::getDragSprite(const tDisplayElementID id) const {
+Sprite *Item::getDragSprite(const DisplayElementID id) const {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 	Sprite *result = new Sprite(id);
 	SpriteFrame *frame = new SpriteFrame();
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index b74dfc4..6d743c3 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -55,7 +55,7 @@ struct JMPItemInfo {
 //	state of an inventory item.
 
 struct ItemStateEntry {
-	tItemState itemState;
+	ItemState itemState;
 	TimeValue itemTime;
 };
 
@@ -100,158 +100,158 @@ const uint16 kItemBaseResID = 128;
 
 //	Item IDs.
 
-const tItemID kAirMask = 7;
-const tItemID kAntidote = 8;
-const tItemID kArgonCanister = 9;
-const tItemID kCardBomb = 10;
-const tItemID kCrowbar = 11;
-const tItemID kGasCanister = 12;
-const tItemID kHistoricalLog = 13;
-const tItemID kJourneymanKey = 14;
-const tItemID kKeyCard = 15;
-const tItemID kMachineGun = 16;
-const tItemID kMarsCard = 17;
-const tItemID kNitrogenCanister = 18;
-const tItemID kOrangeJuiceGlassFull = 19;
-const tItemID kOrangeJuiceGlassEmpty = 20;
-const tItemID kPoisonDart = 21;
-const tItemID kSinclairKey = 22;
-const tItemID kStunGun = 23;
-const tItemID kArgonPickup = 24;
+const ItemID kAirMask = 7;
+const ItemID kAntidote = 8;
+const ItemID kArgonCanister = 9;
+const ItemID kCardBomb = 10;
+const ItemID kCrowbar = 11;
+const ItemID kGasCanister = 12;
+const ItemID kHistoricalLog = 13;
+const ItemID kJourneymanKey = 14;
+const ItemID kKeyCard = 15;
+const ItemID kMachineGun = 16;
+const ItemID kMarsCard = 17;
+const ItemID kNitrogenCanister = 18;
+const ItemID kOrangeJuiceGlassFull = 19;
+const ItemID kOrangeJuiceGlassEmpty = 20;
+const ItemID kPoisonDart = 21;
+const ItemID kSinclairKey = 22;
+const ItemID kStunGun = 23;
+const ItemID kArgonPickup = 24;
 
 //	Biochips.
 
-const tItemID kAIBiochip = 0;
-const tItemID kInterfaceBiochip = 1;
-const tItemID kMapBiochip = 2;
-const tItemID kOpticalBiochip = 3;
-const tItemID kPegasusBiochip = 4;
-const tItemID kRetinalScanBiochip = 5;
-const tItemID kShieldBiochip = 6;
+const ItemID kAIBiochip = 0;
+const ItemID kInterfaceBiochip = 1;
+const ItemID kMapBiochip = 2;
+const ItemID kOpticalBiochip = 3;
+const ItemID kPegasusBiochip = 4;
+const ItemID kRetinalScanBiochip = 5;
+const ItemID kShieldBiochip = 6;
 
-const tItemID kNumItems = 25;
+const ItemID kNumItems = 25;
 
 //	Item States.
 
-const tItemState kAI000 = 0;
-const tItemState kAI005 = 1;
-const tItemState kAI006 = 2;
-const tItemState kAI010 = 3;
-const tItemState kAI015 = 4;
-const tItemState kAI016 = 5;
-const tItemState kAI020 = 6;
-const tItemState kAI024 = 7;
-const tItemState kAI100 = 8;
-const tItemState kAI101 = 9;
-const tItemState kAI105 = 10;
-const tItemState kAI106 = 11;
-const tItemState kAI110 = 12;
-const tItemState kAI111 = 13;
-const tItemState kAI115 = 14;
-const tItemState kAI116 = 15;
-const tItemState kAI120 = 16;
-const tItemState kAI121 = 17;
-const tItemState kAI124 = 18;
-const tItemState kAI125 = 19;
-const tItemState kAI126 = 20;
-const tItemState kAI200 = 21;
-const tItemState kAI201 = 22;
-const tItemState kAI202 = 23;
-const tItemState kAI205 = 24;
-const tItemState kAI206 = 25;
-const tItemState kAI210 = 26;
-const tItemState kAI211 = 27;
-const tItemState kAI212 = 28;
-const tItemState kAI215 = 29;
-const tItemState kAI216 = 30;
-const tItemState kAI220 = 31;
-const tItemState kAI221 = 32;
-const tItemState kAI222 = 33;
-const tItemState kAI224 = 34;
-const tItemState kAI225 = 35;
-const tItemState kAI226 = 36;
-const tItemState kAI300 = 37;
-const tItemState kAI301 = 38;
-const tItemState kAI302 = 39;
-const tItemState kAI303 = 40;
-const tItemState kAI305 = 41;
-const tItemState kAI306 = 42;
-const tItemState kAI310 = 43;
-const tItemState kAI311 = 44;
-const tItemState kAI312 = 45;
-const tItemState kAI313 = 46;
-const tItemState kAI315 = 47;
-const tItemState kAI316 = 48;
-const tItemState kAI320 = 49;
-const tItemState kAI321 = 50;
-const tItemState kAI322 = 51;
-const tItemState kAI323 = 52;
-const tItemState kAI324 = 53;
-const tItemState kAI325 = 54;
-const tItemState kAI326 = 55;
-const tItemState kNormalItem = 56;
-const tItemState kMapUnavailable = 57;
-const tItemState kMapEngaged = 58;
-const tItemState kOptical000 = 59;
-const tItemState kOptical001 = 60;
-const tItemState kOptical002 = 61;
-const tItemState kOptical010 = 62;
-const tItemState kOptical011 = 63;
-const tItemState kOptical012 = 64;
-const tItemState kOptical020 = 65;
-const tItemState kOptical021 = 66;
-const tItemState kOptical100 = 67;
-const tItemState kOptical101 = 68;
-const tItemState kOptical102 = 69;
-const tItemState kOptical110 = 70;
-const tItemState kOptical111 = 71;
-const tItemState kOptical112 = 72;
-const tItemState kOptical120 = 73;
-const tItemState kOptical121 = 74;
-const tItemState kOptical200 = 75;
-const tItemState kOptical201 = 76;
-const tItemState kOptical210 = 77;
-const tItemState kOptical211 = 78;
-const tItemState kPegasusTSA00 = 79;
-const tItemState kPegasusTSA10 = 80;
-const tItemState kPegasusPrehistoric00 = 81;
-const tItemState kPegasusPrehistoric01 = 82;
-const tItemState kPegasusPrehistoric10 = 83;
-const tItemState kPegasusPrehistoric11 = 84;
-const tItemState kPegasusMars00 = 85;
-const tItemState kPegasusMars01 = 86;
-const tItemState kPegasusMars10 = 87;
-const tItemState kPegasusMars11 = 88;
-const tItemState kPegasusNorad00 = 89;
-const tItemState kPegasusNorad01 = 90;
-const tItemState kPegasusNorad10 = 91;
-const tItemState kPegasusNorad11 = 92;
-const tItemState kPegasusWSC00 = 93;
-const tItemState kPegasusWSC01 = 94;
-const tItemState kPegasusWSC10 = 95;
-const tItemState kPegasusWSC11 = 96;
-const tItemState kPegasusCaldoria = 97;
-const tItemState kRetinalSimulating = 98;
-const tItemState kShieldNormal = 99;
-const tItemState kShieldRadiation = 100;
-const tItemState kShieldPlasma = 101;
-const tItemState kShieldCardBomb = 102;
-const tItemState kShieldDraining = 103;
-const tItemState kAirMaskEmptyOff = 104;
-const tItemState kAirMaskEmptyFilter = 105;
-const tItemState kAirMaskLowOff = 106;
-const tItemState kAirMaskLowFilter = 107;
-const tItemState kAirMaskLowOn = 108;
-const tItemState kAirMaskFullOff = 109;
-const tItemState kAirMaskFullFilter = 110;
-const tItemState kAirMaskFullOn = 111;
-const tItemState kArgonEmpty = 112;
-const tItemState kArgonFull = 113;
-const tItemState kFlashlightOff = 114;
-const tItemState kFlashlightOn = 115;
-const tItemState kNitrogenEmpty = 116;
-const tItemState kNitrogenFull = 117;
-const tItemState kFullGlass = 118;
+const ItemState kAI000 = 0;
+const ItemState kAI005 = 1;
+const ItemState kAI006 = 2;
+const ItemState kAI010 = 3;
+const ItemState kAI015 = 4;
+const ItemState kAI016 = 5;
+const ItemState kAI020 = 6;
+const ItemState kAI024 = 7;
+const ItemState kAI100 = 8;
+const ItemState kAI101 = 9;
+const ItemState kAI105 = 10;
+const ItemState kAI106 = 11;
+const ItemState kAI110 = 12;
+const ItemState kAI111 = 13;
+const ItemState kAI115 = 14;
+const ItemState kAI116 = 15;
+const ItemState kAI120 = 16;
+const ItemState kAI121 = 17;
+const ItemState kAI124 = 18;
+const ItemState kAI125 = 19;
+const ItemState kAI126 = 20;
+const ItemState kAI200 = 21;
+const ItemState kAI201 = 22;
+const ItemState kAI202 = 23;
+const ItemState kAI205 = 24;
+const ItemState kAI206 = 25;
+const ItemState kAI210 = 26;
+const ItemState kAI211 = 27;
+const ItemState kAI212 = 28;
+const ItemState kAI215 = 29;
+const ItemState kAI216 = 30;
+const ItemState kAI220 = 31;
+const ItemState kAI221 = 32;
+const ItemState kAI222 = 33;
+const ItemState kAI224 = 34;
+const ItemState kAI225 = 35;
+const ItemState kAI226 = 36;
+const ItemState kAI300 = 37;
+const ItemState kAI301 = 38;
+const ItemState kAI302 = 39;
+const ItemState kAI303 = 40;
+const ItemState kAI305 = 41;
+const ItemState kAI306 = 42;
+const ItemState kAI310 = 43;
+const ItemState kAI311 = 44;
+const ItemState kAI312 = 45;
+const ItemState kAI313 = 46;
+const ItemState kAI315 = 47;
+const ItemState kAI316 = 48;
+const ItemState kAI320 = 49;
+const ItemState kAI321 = 50;
+const ItemState kAI322 = 51;
+const ItemState kAI323 = 52;
+const ItemState kAI324 = 53;
+const ItemState kAI325 = 54;
+const ItemState kAI326 = 55;
+const ItemState kNormalItem = 56;
+const ItemState kMapUnavailable = 57;
+const ItemState kMapEngaged = 58;
+const ItemState kOptical000 = 59;
+const ItemState kOptical001 = 60;
+const ItemState kOptical002 = 61;
+const ItemState kOptical010 = 62;
+const ItemState kOptical011 = 63;
+const ItemState kOptical012 = 64;
+const ItemState kOptical020 = 65;
+const ItemState kOptical021 = 66;
+const ItemState kOptical100 = 67;
+const ItemState kOptical101 = 68;
+const ItemState kOptical102 = 69;
+const ItemState kOptical110 = 70;
+const ItemState kOptical111 = 71;
+const ItemState kOptical112 = 72;
+const ItemState kOptical120 = 73;
+const ItemState kOptical121 = 74;
+const ItemState kOptical200 = 75;
+const ItemState kOptical201 = 76;
+const ItemState kOptical210 = 77;
+const ItemState kOptical211 = 78;
+const ItemState kPegasusTSA00 = 79;
+const ItemState kPegasusTSA10 = 80;
+const ItemState kPegasusPrehistoric00 = 81;
+const ItemState kPegasusPrehistoric01 = 82;
+const ItemState kPegasusPrehistoric10 = 83;
+const ItemState kPegasusPrehistoric11 = 84;
+const ItemState kPegasusMars00 = 85;
+const ItemState kPegasusMars01 = 86;
+const ItemState kPegasusMars10 = 87;
+const ItemState kPegasusMars11 = 88;
+const ItemState kPegasusNorad00 = 89;
+const ItemState kPegasusNorad01 = 90;
+const ItemState kPegasusNorad10 = 91;
+const ItemState kPegasusNorad11 = 92;
+const ItemState kPegasusWSC00 = 93;
+const ItemState kPegasusWSC01 = 94;
+const ItemState kPegasusWSC10 = 95;
+const ItemState kPegasusWSC11 = 96;
+const ItemState kPegasusCaldoria = 97;
+const ItemState kRetinalSimulating = 98;
+const ItemState kShieldNormal = 99;
+const ItemState kShieldRadiation = 100;
+const ItemState kShieldPlasma = 101;
+const ItemState kShieldCardBomb = 102;
+const ItemState kShieldDraining = 103;
+const ItemState kAirMaskEmptyOff = 104;
+const ItemState kAirMaskEmptyFilter = 105;
+const ItemState kAirMaskLowOff = 106;
+const ItemState kAirMaskLowFilter = 107;
+const ItemState kAirMaskLowOn = 108;
+const ItemState kAirMaskFullOff = 109;
+const ItemState kAirMaskFullFilter = 110;
+const ItemState kAirMaskFullOn = 111;
+const ItemState kArgonEmpty = 112;
+const ItemState kArgonFull = 113;
+const ItemState kFlashlightOff = 114;
+const ItemState kFlashlightOn = 115;
+const ItemState kNitrogenEmpty = 116;
+const ItemState kNitrogenFull = 117;
+const ItemState kFullGlass = 118;
 
 //	Extra IDs.
 
@@ -269,7 +269,7 @@ const uint32 kRemoveGlass = 10;
 const uint32 kRemoveDart = 11;
 const uint32 kRemoveSinclairKey = 12;
 
-enum tItemType {
+enum ItemType {
 	kInventoryItemType,
 	kBiochipItemType
 };
@@ -289,7 +289,7 @@ class Sprite;
 
 class Item : public IDObject {
 public:
-	Item(const tItemID id, const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
+	Item(const ItemID id, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
 	virtual ~Item();
 	
 	// WriteToStream writes everything EXCEPT the item's ID.
@@ -297,25 +297,25 @@ public:
 	virtual void writeToStream(Common::WriteStream *stream);
 	virtual void readFromStream(Common::ReadStream *stream);
 	
-	virtual tActorID getItemOwner() const;
-	virtual void setItemOwner(const tActorID owner);
+	virtual ActorID getItemOwner() const;
+	virtual void setItemOwner(const ActorID owner);
 	
-	void getItemRoom(tNeighborhoodID &neighborhood, tRoomID &room, tDirectionConstant &direction) const;
-	void setItemRoom(const tNeighborhoodID neighborhood, const tRoomID room, const tDirectionConstant direction);
-	tNeighborhoodID getItemNeighborhood() const;
+	void getItemRoom(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) const;
+	void setItemRoom(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
+	NeighborhoodID getItemNeighborhood() const;
 	
-	virtual tWeightType getItemWeight();
+	virtual WeightType getItemWeight();
 	
-	virtual void setItemState(const tItemState state);
-	virtual tItemState getItemState() const;
+	virtual void setItemState(const ItemState state);
+	virtual ItemState getItemState() const;
 
-	virtual tItemType getItemType() = 0;
+	virtual ItemType getItemType() = 0;
 	
 	TimeValue getInfoLeftTime() const;
 	void getInfoRightTimes(TimeValue &, TimeValue &) const;
 	TimeValue getSharedAreaTime() const;
 
-	Sprite *getDragSprite(const tDisplayElementID) const;
+	Sprite *getDragSprite(const DisplayElementID) const;
 	
 	/*
 		select		--	called when this item becomes current. Also called when the inventory
@@ -344,12 +344,12 @@ public:
 	void findItemExtra(const uint32 extraID, ItemExtraEntry &entry);
 
 protected:
-	tNeighborhoodID _itemNeighborhood;
-	tRoomID	_itemRoom;
-	tDirectionConstant _itemDirection;
-	tActorID _itemOwnerID;
-	tWeightType _itemWeight;
-	tItemState _itemState;
+	NeighborhoodID _itemNeighborhood;
+	RoomID	_itemRoom;
+	DirectionConstant _itemDirection;
+	ActorID _itemOwnerID;
+	WeightType _itemWeight;
+	ItemState _itemState;
 
 	JMPItemInfo _itemInfo;
 	ItemStateInfo _sharedAreaInfo;
@@ -357,8 +357,8 @@ protected:
 	bool _isActive;
 	bool _isSelected;
 
-	static void getItemStateEntry(ItemStateInfo, uint32, tItemState&, TimeValue&);
-	static void findItemStateEntryByState(ItemStateInfo, tItemState, TimeValue&);
+	static void getItemStateEntry(ItemStateInfo, uint32, ItemState &, TimeValue &);
+	static void findItemStateEntryByState(ItemStateInfo, ItemState, TimeValue &);
 	static ItemStateInfo readItemState(Common::SeekableReadStream *stream);
 };
 
diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
index cbe4828..4c30975 100755
--- a/engines/pegasus/items/itemlist.cpp
+++ b/engines/pegasus/items/itemlist.cpp
@@ -53,12 +53,12 @@ void ItemList::readFromStream(Common::ReadStream *stream) {
 	uint32 itemCount = stream->readUint32BE();
 
 	for (uint32 i = 0; i < itemCount; i++) {
-		tItemID itemID = stream->readUint16BE();
+		ItemID itemID = stream->readUint16BE();
 		g_allItems.findItemByID(itemID)->readFromStream(stream);
 	}
 }
 
-Item *ItemList::findItemByID(const tItemID id) {
+Item *ItemList::findItemByID(const ItemID id) {
 	for (ItemIterator it = begin(); it != end(); it++)
 		if ((*it)->getObjectID() == id)
 			return *it;
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
index df31b5c..b5a1d48 100755
--- a/engines/pegasus/items/itemlist.h
+++ b/engines/pegasus/items/itemlist.h
@@ -47,7 +47,7 @@ public:
 	virtual void writeToStream(Common::WriteStream *stream);
 	virtual void readFromStream(Common::ReadStream *stream);
 	
-	Item *findItemByID(const tItemID id);
+	Item *findItemByID(const ItemID id);
 };
 
 typedef ItemList::iterator ItemIterator;
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 50a208e..82bafbc 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -43,8 +43,8 @@ void GameMenu::restorePreviousHandler() {
 	InputHandler::setInputHandler(_previousHandler);
 }
 
-void GameMenu::drawScore(tGameScoreType score, tGameScoreType total, const Common::Rect &scoreBounds, Surface *numbers) {
-	tCoordType x = scoreBounds.right;
+void GameMenu::drawScore(GameScoreType score, GameScoreType total, const Common::Rect &scoreBounds, Surface *numbers) {
+	CoordType x = scoreBounds.right;
 	drawNumber(total, x, scoreBounds.top, numbers);
 
 	x -= 12;
@@ -55,7 +55,7 @@ void GameMenu::drawScore(tGameScoreType score, tGameScoreType total, const Commo
 	drawNumber(score, x, scoreBounds.top, numbers);
 }
 
-void GameMenu::drawNumber(tGameScoreType number, tCoordType &x, tCoordType y, Surface *numbers) {
+void GameMenu::drawNumber(GameScoreType number, CoordType &x, CoordType y, Surface *numbers) {
 	Common::Rect r1(0, 0, 12, 12); // Width, height of one digit
 	Common::Rect r2 = r1;
 	r2.moveTo(x - 12, y);
@@ -88,59 +88,59 @@ enum {
 	kLastSelection = kMainMenuQuit
 };
 
-static const tCoordType kStartLeftDemo = 44;
-static const tCoordType kStartTopDemo = 336;
+static const CoordType kStartLeftDemo = 44;
+static const CoordType kStartTopDemo = 336;
 
-static const tCoordType kStartSelectLeftDemo = 40;
-static const tCoordType kStartSelectTopDemo = 331;
+static const CoordType kStartSelectLeftDemo = 40;
+static const CoordType kStartSelectTopDemo = 331;
 
-static const tCoordType kCreditsLeftDemo = 44;
-static const tCoordType kCreditsTopDemo = 372;
+static const CoordType kCreditsLeftDemo = 44;
+static const CoordType kCreditsTopDemo = 372;
 
-static const tCoordType kCreditsSelectLeftDemo = 40;
-static const tCoordType kCreditsSelectTopDemo = 367;
+static const CoordType kCreditsSelectLeftDemo = 40;
+static const CoordType kCreditsSelectTopDemo = 367;
 
-static const tCoordType kMainMenuQuitLeftDemo = 32;
-static const tCoordType kMainMenuQuitTopDemo = 412;
+static const CoordType kMainMenuQuitLeftDemo = 32;
+static const CoordType kMainMenuQuitTopDemo = 412;
 
-static const tCoordType kMainMenuQuitSelectLeftDemo = 28;
-static const tCoordType kMainMenuQuitSelectTopDemo = 408;
+static const CoordType kMainMenuQuitSelectLeftDemo = 28;
+static const CoordType kMainMenuQuitSelectTopDemo = 408;
 
-static const tCoordType kOverviewLeft = 200;
-static const tCoordType kOverviewTop = 208;
+static const CoordType kOverviewLeft = 200;
+static const CoordType kOverviewTop = 208;
 
-static const tCoordType kOverviewSelectLeft = 152;
-static const tCoordType kOverviewSelectTop = 204;
+static const CoordType kOverviewSelectLeft = 152;
+static const CoordType kOverviewSelectTop = 204;
 
-static const tCoordType kStartLeft = 212;
-static const tCoordType kStartTop = 256;
+static const CoordType kStartLeft = 212;
+static const CoordType kStartTop = 256;
 
-static const tCoordType kStartSelectLeft = 152;
-static const tCoordType kStartSelectTop = 252;
+static const CoordType kStartSelectLeft = 152;
+static const CoordType kStartSelectTop = 252;
 
-static const tCoordType kRestoreLeft = 212;
-static const tCoordType kRestoreTop = 296;
+static const CoordType kRestoreLeft = 212;
+static const CoordType kRestoreTop = 296;
 
-static const tCoordType kRestoreSelectLeft = 152;
-static const tCoordType kRestoreSelectTop = 292;
+static const CoordType kRestoreSelectLeft = 152;
+static const CoordType kRestoreSelectTop = 292;
 
-static const tCoordType kDifficultyLeft = 320;
-static const tCoordType kDifficultyTop = 340;
+static const CoordType kDifficultyLeft = 320;
+static const CoordType kDifficultyTop = 340;
 
-static const tCoordType kDifficultySelectLeft = 152;
-static const tCoordType kDifficultySelectTop = 336;
+static const CoordType kDifficultySelectLeft = 152;
+static const CoordType kDifficultySelectTop = 336;
 
-static const tCoordType kCreditsLeft = 212;
-static const tCoordType kCreditsTop = 388;
+static const CoordType kCreditsLeft = 212;
+static const CoordType kCreditsTop = 388;
 
-static const tCoordType kCreditsSelectLeft = 152;
-static const tCoordType kCreditsSelectTop = 384;
+static const CoordType kCreditsSelectLeft = 152;
+static const CoordType kCreditsSelectTop = 384;
 
-static const tCoordType kMainMenuQuitLeft = 212;
-static const tCoordType kMainMenuQuitTop = 428;
+static const CoordType kMainMenuQuitLeft = 212;
+static const CoordType kMainMenuQuitTop = 428;
 
-static const tCoordType kMainMenuQuitSelectLeft = 152;
-static const tCoordType kMainMenuQuitSelectTop = 424;
+static const CoordType kMainMenuQuitSelectLeft = 152;
+static const CoordType kMainMenuQuitSelectTop = 424;
 
 //	Never set the current input handler to the MainMenu.
 MainMenu::MainMenu() : GameMenu(kMainMenuID), _menuBackground(0), _overviewButton(0),
@@ -417,29 +417,29 @@ enum {
 	kCreditsLastSelection = kCreditsMenuMainMenu
 };
 
-static const tCoordType kCreditsMovieLeft = 288;
-static const tCoordType kCreditsMovieTop = 0;
+static const CoordType kCreditsMovieLeft = 288;
+static const CoordType kCreditsMovieTop = 0;
 
-static const tCoordType kCoreTeamSelectLeft = 40;
-static const tCoordType kCoreTeamSelectTop = 223;
+static const CoordType kCoreTeamSelectLeft = 40;
+static const CoordType kCoreTeamSelectTop = 223;
 
-static const tCoordType kSupportTeamSelectLeft = 40;
-static const tCoordType kSupportTeamSelectTop = 259;
+static const CoordType kSupportTeamSelectLeft = 40;
+static const CoordType kSupportTeamSelectTop = 259;
 
-static const tCoordType kOriginalTeamSelectLeft = 40;
-static const tCoordType kOriginalTeamSelectTop = 295;
+static const CoordType kOriginalTeamSelectLeft = 40;
+static const CoordType kOriginalTeamSelectTop = 295;
 
-static const tCoordType kTalentSelectLeft = 40;
-static const tCoordType kTalentSelectTop = 331;
+static const CoordType kTalentSelectLeft = 40;
+static const CoordType kTalentSelectTop = 331;
 
-static const tCoordType kOtherTitlesSelectLeft = 40;
-static const tCoordType kOtherTitlesSelectTop = 367;
+static const CoordType kOtherTitlesSelectLeft = 40;
+static const CoordType kOtherTitlesSelectTop = 367;
 
-static const tCoordType kCreditsMainMenuLeft = 32;
-static const tCoordType kCreditsMainMenuTop = 412;
+static const CoordType kCreditsMainMenuLeft = 32;
+static const CoordType kCreditsMainMenuTop = 412;
 
-static const tCoordType kCreditsMainMenuSelectLeft = 30;
-static const tCoordType kCreditsMainMenuSelectTop = 408;
+static const CoordType kCreditsMainMenuSelectLeft = 30;
+static const CoordType kCreditsMainMenuSelectTop = 408;
 
 static const TimeValue kCoreTeamTime = 0;
 static const TimeValue kSupportTeamTime = 1920;
@@ -578,36 +578,36 @@ void CreditsMenu::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	InputHandler::handleInput(input, cursorSpot);
 }
 
-static const tCoordType kContinueLeft = 44;
-static const tCoordType kContinueTop = 336;
+static const CoordType kContinueLeft = 44;
+static const CoordType kContinueTop = 336;
 
-static const tCoordType kContinueSelectLeft = 40;
-static const tCoordType kContinueSelectTopDemo = 331;
-static const tCoordType kContinueSelectTop = 332;
+static const CoordType kContinueSelectLeft = 40;
+static const CoordType kContinueSelectTopDemo = 331;
+static const CoordType kContinueSelectTop = 332;
 
-static const tCoordType kMainMenuLeftDemo = 44;
-static const tCoordType kMainMenuTopDemo = 372;
+static const CoordType kMainMenuLeftDemo = 44;
+static const CoordType kMainMenuTopDemo = 372;
 
-static const tCoordType kMainMenuSelectLeftDemo = 40;
-static const tCoordType kMainMenuSelectTopDemo = 367;
+static const CoordType kMainMenuSelectLeftDemo = 40;
+static const CoordType kMainMenuSelectTopDemo = 367;
 
-static const tCoordType kQuitLeftDemo = 32;
-static const tCoordType kQuitTopDemo = 412;
+static const CoordType kQuitLeftDemo = 32;
+static const CoordType kQuitTopDemo = 412;
 
-static const tCoordType kQuitSelectLeftDemo = 28;
-static const tCoordType kQuitSelectTopDemo = 408;
+static const CoordType kQuitSelectLeftDemo = 28;
+static const CoordType kQuitSelectTopDemo = 408;
 
-static const tCoordType kRestoreLeftDeath = 44;
-static const tCoordType kRestoreTopDeath = 372;
+static const CoordType kRestoreLeftDeath = 44;
+static const CoordType kRestoreTopDeath = 372;
 
-static const tCoordType kRestoreSelectLeftDeath = 40;
-static const tCoordType kRestoreSelectTopDeath = 368;
+static const CoordType kRestoreSelectLeftDeath = 40;
+static const CoordType kRestoreSelectTopDeath = 368;
 
-static const tCoordType kMainMenuLeft = 32;
-static const tCoordType kMainMenuTop = 412;
+static const CoordType kMainMenuLeft = 32;
+static const CoordType kMainMenuTop = 412;
 
-static const tCoordType kMainMenuSelectLeft = 28;
-static const tCoordType kMainMenuSelectTop = 408;
+static const CoordType kMainMenuSelectLeft = 28;
+static const CoordType kMainMenuSelectTop = 408;
 
 enum {
 	kDeathScreenContinueDemo = 0,
@@ -626,7 +626,7 @@ enum {
 };
 
 // Never set the current input handler to the DeathMenu.
-DeathMenu::DeathMenu(const tDeathReason deathReason) : GameMenu(kDeathMenuID), _deathBackground(0), _continueButton(0),
+DeathMenu::DeathMenu(const DeathReason deathReason) : GameMenu(kDeathMenuID), _deathBackground(0), _continueButton(0),
 		_mainMenuButton(0), _quitButton(0), _restoreButton(0), _largeSelect(0), _smallSelect(0) {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
 	bool isDemo = vm->isDemo();
@@ -848,7 +848,7 @@ void DeathMenu::drawAllScores() {
 	numbers.getImageFromPICTFile("Images/Death Screens/Numbers.pict");
 
 	Common::Rect scoreBounds;
-	tGameScoreType caldoriaTotal = 0;
+	GameScoreType caldoriaTotal = 0;
 
 	switch (_deathReason) {
 	case kDeathCardBomb:
@@ -930,60 +930,60 @@ enum {
 	kLastPauseSelection = kPauseMenuQuitToMainMenu
 };
 
-const tCoordType kPauseLeft = 194;
-const tCoordType kPauseTop = 68;
+const CoordType kPauseLeft = 194;
+const CoordType kPauseTop = 68;
 
-const tCoordType kSaveGameLeft = kPauseLeft + 6;
-const tCoordType kSaveGameTop = kPauseTop + 56;
+const CoordType kSaveGameLeft = kPauseLeft + 6;
+const CoordType kSaveGameTop = kPauseTop + 56;
 
-const tCoordType kSaveGameSelectLeft = kPauseLeft - 44;
-const tCoordType kSaveGameSelectTop = kPauseTop + 52;
+const CoordType kSaveGameSelectLeft = kPauseLeft - 44;
+const CoordType kSaveGameSelectTop = kPauseTop + 52;
 
-const tCoordType kPauseContinueLeft = kPauseLeft + 18;
-const tCoordType kPauseContinueTop = kPauseTop + 100;
+const CoordType kPauseContinueLeft = kPauseLeft + 18;
+const CoordType kPauseContinueTop = kPauseTop + 100;
 
-const tCoordType kPauseContinueSelectLeft = kPauseLeft - 44;
-const tCoordType kPauseContinueSelectTop = kPauseTop + 95;
+const CoordType kPauseContinueSelectLeft = kPauseLeft - 44;
+const CoordType kPauseContinueSelectTop = kPauseTop + 95;
 
-const tCoordType kPauseRestoreLeft = kPauseLeft + 18;
-const tCoordType kPauseRestoreTop = kPauseTop + 136;
+const CoordType kPauseRestoreLeft = kPauseLeft + 18;
+const CoordType kPauseRestoreTop = kPauseTop + 136;
 
-const tCoordType kPauseRestoreSelectLeft = kPauseLeft - 44;
-const tCoordType kPauseRestoreSelectTop = kPauseTop + 131;
+const CoordType kPauseRestoreSelectLeft = kPauseLeft - 44;
+const CoordType kPauseRestoreSelectTop = kPauseTop + 131;
 
-const tCoordType kSoundFXLeft = kPauseLeft + 128;
-const tCoordType kSoundFXTop = kPauseTop + 187;
-const tCoordType kSoundFXRight = kSoundFXLeft + 96;
-const tCoordType kSoundFXBottom = kSoundFXTop + 14;
+const CoordType kSoundFXLeft = kPauseLeft + 128;
+const CoordType kSoundFXTop = kPauseTop + 187;
+const CoordType kSoundFXRight = kSoundFXLeft + 96;
+const CoordType kSoundFXBottom = kSoundFXTop + 14;
 
-const tCoordType kSoundFXSelectLeft = kPauseLeft - 44;
-const tCoordType kSoundFXSelectTop = kPauseTop + 172;
+const CoordType kSoundFXSelectLeft = kPauseLeft - 44;
+const CoordType kSoundFXSelectTop = kPauseTop + 172;
 
-const tCoordType kAmbienceLeft = kPauseLeft + 128;
-const tCoordType kAmbienceTop = kPauseTop + 227;
-const tCoordType kAmbienceRight = kAmbienceLeft + 96;
-const tCoordType kAmbienceBottom = kAmbienceTop + 14;
+const CoordType kAmbienceLeft = kPauseLeft + 128;
+const CoordType kAmbienceTop = kPauseTop + 227;
+const CoordType kAmbienceRight = kAmbienceLeft + 96;
+const CoordType kAmbienceBottom = kAmbienceTop + 14;
 
-const tCoordType kAmbienceSelectLeft = kPauseLeft - 44;
-const tCoordType kAmbienceSelectTop = kPauseTop + 212;
+const CoordType kAmbienceSelectLeft = kPauseLeft - 44;
+const CoordType kAmbienceSelectTop = kPauseTop + 212;
 
-const tCoordType kWalkthruLeft = kPauseLeft + 128;
-const tCoordType kWalkthruTop = kPauseTop + 264;
+const CoordType kWalkthruLeft = kPauseLeft + 128;
+const CoordType kWalkthruTop = kPauseTop + 264;
 
-const tCoordType kWalkthruSelectLeft = kPauseLeft - 44;
-const tCoordType kWalkthruSelectTop = kPauseTop + 255;
+const CoordType kWalkthruSelectLeft = kPauseLeft - 44;
+const CoordType kWalkthruSelectTop = kPauseTop + 255;
 
-const tCoordType kQuitLeft = kPauseLeft + 18;
-const tCoordType kQuitTop = kPauseTop + 302;
+const CoordType kQuitLeft = kPauseLeft + 18;
+const CoordType kQuitTop = kPauseTop + 302;
 
-const tCoordType kQuitSelectLeft = kPauseLeft - 44;
-const tCoordType kQuitSelectTop = kPauseTop + 297;
+const CoordType kQuitSelectLeft = kPauseLeft - 44;
+const CoordType kQuitSelectTop = kPauseTop + 297;
 
 //	These are relative to the pause background.
-const tCoordType kPauseScoreLeft = 130;
-const tCoordType kPauseScoreTop = 34;
-const tCoordType kPauseScoreRight = kPauseScoreLeft + 108;
-const tCoordType kPauseScoreBottom = kPauseScoreTop + 12;
+const CoordType kPauseScoreLeft = 130;
+const CoordType kPauseScoreTop = 34;
+const CoordType kPauseScoreRight = kPauseScoreLeft + 108;
+const CoordType kPauseScoreBottom = kPauseScoreTop + 12;
 
 // Never set the current input handler to the CPauseMenu.
 PauseMenu::PauseMenu() : GameMenu(kPauseMenuID), _pauseBackground(0), _saveButton(0), _restoreButton(0),
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
index 7416623..8b0169a 100755
--- a/engines/pegasus/menu.h
+++ b/engines/pegasus/menu.h
@@ -44,19 +44,19 @@ public:
 	virtual void becomeCurrentHandler();
 	virtual void restorePreviousHandler();
 	
-	tGameMenuCommand getLastCommand() { return _lastCommand; }
+	GameMenuCommand getLastCommand() { return _lastCommand; }
 	void clearLastCommand() { _lastCommand = kMenuCmdNoCommand; }
 
 protected:
-	void setLastCommand(const tGameMenuCommand command) { _lastCommand = command; }
+	void setLastCommand(const GameMenuCommand command) { _lastCommand = command; }
 
 	InputHandler *_previousHandler;
-	tGameMenuCommand _lastCommand;
+	GameMenuCommand _lastCommand;
 
-	void drawScore(tGameScoreType, tGameScoreType, const Common::Rect &, Surface *);
+	void drawScore(GameScoreType, GameScoreType, const Common::Rect &, Surface *);
 
 private:
-	void drawNumber(tGameScoreType, tCoordType &, tCoordType, Surface *);
+	void drawNumber(GameScoreType, CoordType &, CoordType, Surface *);
 };
 
 class Hotspot;
@@ -115,7 +115,7 @@ protected:
 
 class DeathMenu : public GameMenu {
 public:
-	DeathMenu(const tDeathReason);
+	DeathMenu(const DeathReason);
 	virtual ~DeathMenu() {}
 
 	virtual void handleInput(const Input &input, const Hotspot *);
@@ -129,7 +129,7 @@ protected:
 
 	bool _playerWon;
 	int _menuSelection;
-	tDeathReason _deathReason;
+	DeathReason _deathReason;
 
 	Picture _deathBackground;
 	Picture _continueButton;
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 8d6f0fa..14e6f25 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -32,7 +32,7 @@
 
 namespace Pegasus {
 
-Movie::Movie(const tDisplayElementID id) : Animation(id) {
+Movie::Movie(const DisplayElementID id) : Animation(id) {
 	_video = 0;
 	setScale(600);
 }
@@ -117,7 +117,7 @@ void Movie::draw(const Common::Rect &r) {
 	drawImage(r2, r1);
 }
 
-void Movie::moveMovieBoxTo(const tCoordType h, const tCoordType v) {
+void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 	_movieBox.moveTo(h, v);
 }
 
@@ -203,7 +203,7 @@ void Movie::updateTime() {
 	}
 }
 
-GlowingMovie::GlowingMovie(const tDisplayElementID id) : Movie(id) {
+GlowingMovie::GlowingMovie(const DisplayElementID id) : Movie(id) {
 	_glowing = false;
 }
 
@@ -231,7 +231,7 @@ void GlowingMovie::setBounds(const Common::Rect &r) {
 	}
 }
 
-ScalingMovie::ScalingMovie(const tDisplayElementID id) : GlowingMovie(id) {
+ScalingMovie::ScalingMovie(const DisplayElementID id) : GlowingMovie(id) {
 }
 
 void ScalingMovie::draw(const Common::Rect &) {
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index db7b640..593442f 100755
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -39,7 +39,7 @@ namespace Pegasus {
 
 class Movie : public Animation, public PixelImage {
 public:
-	Movie(const tDisplayElementID);
+	Movie(const DisplayElementID);
 	virtual ~Movie();
 
 	virtual void initFromMovieFile(const Common::String &fileName, bool transparent = false);
@@ -60,7 +60,7 @@ public:
 	virtual void resume();
 	virtual void pause();
 
-	virtual void moveMovieBoxTo(const tCoordType, const tCoordType);
+	virtual void moveMovieBoxTo(const CoordType, const CoordType);
 
 	virtual TimeValue getDuration(const TimeScale = 0) const;
 
@@ -77,7 +77,7 @@ protected:
 
 class GlowingMovie : public Movie {
 public:
-	GlowingMovie(tDisplayElementID);
+	GlowingMovie(DisplayElementID);
 	virtual ~GlowingMovie() {}
 
 	virtual void draw(const Common::Rect &);
@@ -92,7 +92,7 @@ protected:
 
 class ScalingMovie : public GlowingMovie {
 public:
-	ScalingMovie(tDisplayElementID);
+	ScalingMovie(DisplayElementID);
 	virtual ~ScalingMovie() {}
 
 	virtual void draw(const Common::Rect &);
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 878b0c3..6f512fa 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -53,8 +53,8 @@ const TimeValue kSinclairInterruptionTime2 = 6835;
 const TimeValue kSinclairInterruptionTime3 = 9835;
 const TimeValue kSinclairInterruptionTime4 = 12555;
 
-const tInputBits kPullbackInterruptFilter = kFilterAllInput;
-const tInputBits kRecalibrationInterruptFilter = kFilterAllInput;
+const InputBits kPullbackInterruptFilter = kFilterAllInput;
+const InputBits kRecalibrationInterruptFilter = kFilterAllInput;
 
 const TimeValue kCaldoriaReplicatorIntroIn = 4933;
 const TimeValue kCaldoriaReplicatorIntroOut = 6557;
@@ -146,9 +146,9 @@ const TimeValue k5To2Time = 41240;
 
 const TimeValue k5To3Time = 41280;
 
-//	MMFuseFunction functions...
+//	FuseFunction functions...
 
-const tNotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
+const NotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
 
 void doorBombTimerExpiredFunction(FunctionPtr *, void *caldoria) {
 	((Caldoria *)caldoria)->doorBombTimerExpired();
@@ -341,7 +341,7 @@ uint16 Caldoria::getDateResID() const {
 	return kDate2318ID;
 }
 
-TimeValue Caldoria::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+TimeValue Caldoria::getViewTime(const RoomID room, const DirectionConstant direction) {
 	ExtraTable::Entry extra;	
 	uint32 extraID = 0xffffffff;
 
@@ -444,7 +444,7 @@ void Caldoria::startSpotOnceOnly(TimeValue startTime, TimeValue stopTime) {
 	}
 }
 
-void Caldoria::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {	
+void Caldoria::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &entry) {	
 	Neighborhood::findSpotEntry(room, direction, flags, entry);
 
 	switch (room) {
@@ -506,7 +506,7 @@ void Caldoria::startDoorOpenMovie(const TimeValue startTime, const TimeValue sto
 		Neighborhood::startDoorOpenMovie(startTime, stopTime);
 }
 
-void Caldoria::startTurnPush(const tTurnDirection turnDirection, const TimeValue newViewTime, const tDirectionConstant destDirection) {
+void Caldoria::startTurnPush(const TurnDirection turnDirection, const TimeValue newViewTime, const DirectionConstant destDirection) {
 	switch (GameState.getCurrentRoom()) {
 	case kCaldoria05:
 	case kCaldoria07:
@@ -540,7 +540,7 @@ void Caldoria::bumpIntoWall() {
 	Neighborhood::bumpIntoWall();
 }
 
-void Caldoria::closeDoorOffScreen(const tRoomID room, const tDirectionConstant direction) {
+void Caldoria::closeDoorOffScreen(const RoomID room, const DirectionConstant direction) {
 	switch (room) {
 	case kCaldoria08:
 		if (direction == kNorth)
@@ -570,7 +570,7 @@ void Caldoria::closeDoorOffScreen(const tRoomID room, const tDirectionConstant d
 	}
 }
 
-int16 Caldoria::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+int16 Caldoria::getStaticCompassAngle(const RoomID room, const DirectionConstant dir) {
 	int16 result = Neighborhood::getStaticCompassAngle(room, dir);
 
 	switch (room) {
@@ -668,7 +668,7 @@ void Caldoria::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec
 }
 
 void Caldoria::loadAmbientLoops() {
-	tRoomID room = GameState.getCurrentRoom();
+	RoomID room = GameState.getCurrentRoom();
 
 	if (room == kCaldoria00 && GameState.getCaldoriaWokenUp())
 		loadLoopSound1("Sounds/Caldoria/Apartment Music.AIFF", 0x100 / 4);
@@ -684,7 +684,7 @@ void Caldoria::loadAmbientLoops() {
 		loadLoopSound1("Sounds/Caldoria/A50NLB00.22K.AIFF", 0x100 / 4);
 }
 
-void Caldoria::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+void Caldoria::checkContinuePoint(const RoomID room, const DirectionConstant direction) {
 	switch (MakeRoomView(room, direction)) {
 	case MakeRoomView(kCaldoria06, kSouth):
 	case MakeRoomView(kCaldoria13, kNorth):
@@ -706,7 +706,7 @@ void Caldoria::spotCompleted() {
 		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
 }
 
-void Caldoria::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+void Caldoria::arriveAt(const RoomID room, const DirectionConstant direction) {
 	switch (room) {
 	case kCaldoria56:
 		if (!GameState.getCaldoriaGunAimed())
@@ -981,7 +981,7 @@ void Caldoria::downButton(const Input &input) {
 	}
 }
 
-void Caldoria::turnTo(const tDirectionConstant direction) {
+void Caldoria::turnTo(const DirectionConstant direction) {
 	Neighborhood::turnTo(direction);
 
 	switch (GameState.getCurrentRoom()) {
@@ -1106,7 +1106,7 @@ void Caldoria::zoomToSinclair() {
 	startExtraSequence(kCa53EastZoomToSinclair, kExtraCompletedFlag, kFilterAllInput);
 }
 
-void Caldoria::receiveNotification(Notification *notification, const tNotificationFlags flags) {	
+void Caldoria::receiveNotification(Notification *notification, const NotificationFlags flags) {	
 	Neighborhood::receiveNotification(notification, flags);
 
 	if ((flags & kExtraCompletedFlag) != 0) {
@@ -1255,8 +1255,8 @@ void Caldoria::receiveNotification(Notification *notification, const tNotificati
 	g_AIArea->checkMiddleArea();
 }
 
-tInputBits Caldoria::getInputFilter() {
-	tInputBits result = Neighborhood::getInputFilter();
+InputBits Caldoria::getInputFilter() {
+	InputBits result = Neighborhood::getInputFilter();
 
 	switch (GameState.getCurrentRoom()) {
 	case kCaldoria00:
@@ -1471,7 +1471,7 @@ void Caldoria::clickInHotspot(const Input &input, const Hotspot *spot) {
 	}
 }
 
-void Caldoria::clickOnDoorbell(const tHotSpotID doorBellSpotID) {
+void Caldoria::clickOnDoorbell(const HotSpotID doorBellSpotID) {
 	uint32 extra;
 	ExtraTable::Entry entry;
 
@@ -1501,7 +1501,7 @@ void Caldoria::clickOnDoorbell(const tHotSpotID doorBellSpotID) {
 	requestSpotSound(kCaldoriaNobodyHomeIn, kCaldoriaNobodyHomeOut, kFilterNoInput, kSpotSoundCompletedFlag);
 }
 
-tCanOpenDoorReason Caldoria::canOpenDoor(DoorTable::Entry &entry) {
+CanOpenDoorReason Caldoria::canOpenDoor(DoorTable::Entry &entry) {
 	switch (GameState.getCurrentRoom()) {
 	case kCaldoria16:
 	case kCaldoria38:
@@ -1519,7 +1519,7 @@ void Caldoria::doorOpened() {
 	_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, false);
 }
 
-GameInteraction *Caldoria::makeInteraction(const tInteractionID interactionID) {
+GameInteraction *Caldoria::makeInteraction(const InteractionID interactionID) {
 	switch (interactionID) {
 	case kCaldoria4DInteractionID:
 		return new Caldoria4DSystem(this);
@@ -1534,7 +1534,7 @@ GameInteraction *Caldoria::makeInteraction(const tInteractionID interactionID) {
 	return 0;
 }
 
-void Caldoria::newInteraction(const tInteractionID interactionID) {
+void Caldoria::newInteraction(const InteractionID interactionID) {
 	Neighborhood::newInteraction(interactionID);
 
 	if (!_currentInteraction) {
@@ -1552,7 +1552,7 @@ void Caldoria::newInteraction(const tInteractionID interactionID) {
 //	the inventory is too full or because the player lets go of the item before
 //	dropping it into the inventory).
 Hotspot *Caldoria::getItemScreenSpot(Item *item, DisplayElement *element) {
-	tHotSpotID destSpotID = kNoHotSpotID;
+	HotSpotID destSpotID = kNoHotSpotID;
 	
 	switch (item->getObjectID()) {
 	case kKeyCard:
@@ -1853,7 +1853,7 @@ Common::String Caldoria::getEnvScanMovie() {
 	Common::String movieName = Neighborhood::getEnvScanMovie();
 
 	if (movieName.empty()) {
-		tRoomID room = GameState.getCurrentRoom();
+		RoomID room = GameState.getCurrentRoom();
 
 		if (room >= kCaldoria00 && room <= kCaldoria14) {
 			// Inside apartment.
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
index 538eaaf..c1e2a2c 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -36,352 +36,352 @@ const TimeScale kCaldoriaFrameDuration = 40;
 
 //	Alternate IDs.
 
-const tAlternateID kAltCaldoriaNormal = 0;
-const tAlternateID kAltCaldoriaRoofDoorBlown = 2;
-const tAlternateID kAltCaldoriaSinclairDown = 3;
+const AlternateID kAltCaldoriaNormal = 0;
+const AlternateID kAltCaldoriaRoofDoorBlown = 2;
+const AlternateID kAltCaldoriaSinclairDown = 3;
 
 //	Room IDs.
 
-const tRoomID kCaldoria00 = 1;
-const tRoomID kCaldoria01 = 2;
-const tRoomID kCaldoria02 = 3;
-const tRoomID kCaldoria03 = 4;
-const tRoomID kCaldoria04 = 5;
-const tRoomID kCaldoria05 = 6;
-const tRoomID kCaldoria06 = 7;
-const tRoomID kCaldoria07 = 8;
-const tRoomID kCaldoria08 = 9;
-const tRoomID kCaldoria09 = 10;
-const tRoomID kCaldoria10 = 11;
-const tRoomID kCaldoriaToilet = 12;
-const tRoomID kCaldoria11 = 13;
-const tRoomID kCaldoria12 = 14;
-const tRoomID kCaldoriaVidPhone = 15;
-const tRoomID kCaldoriaReplicator = 16;
-const tRoomID kCaldoriaDrawers = 17;
-const tRoomID kCaldoria13 = 18;
-const tRoomID kCaldoria14 = 19;
-const tRoomID kCaldoria15 = 20;
-const tRoomID kCaldoria16 = 21;
-const tRoomID kCaldoria17 = 22;
-const tRoomID kCaldoria18 = 23;
-const tRoomID kCaldoria19 = 24;
-const tRoomID kCaldoria20 = 25;
-const tRoomID kCaldoria21 = 26;
-const tRoomID kCaldoria22 = 27;
-const tRoomID kCaldoria23 = 28;
-const tRoomID kCaldoria24 = 29;
-const tRoomID kCaldoria25 = 30;
-const tRoomID kCaldoria26 = 31;
-const tRoomID kCaldoria27 = 32;
-const tRoomID kCaldoria28 = 33;
-const tRoomID kCaldoria29 = 34;
-const tRoomID kCaldoria30 = 35;
-const tRoomID kCaldoria31 = 36;
-const tRoomID kCaldoria32 = 37;
-const tRoomID kCaldoria33 = 38;
-const tRoomID kCaldoria34 = 39;
-const tRoomID kCaldoria35 = 40;
-const tRoomID kCaldoria36 = 41;
-const tRoomID kCaldoria37 = 42;
-const tRoomID kCaldoria38 = 43;
-const tRoomID kCaldoria39 = 44;
-const tRoomID kCaldoria40 = 45;
-const tRoomID kCaldoria41 = 46;
-const tRoomID kCaldoriaBinoculars = 47;
-const tRoomID kCaldoria42 = 48;
-const tRoomID kCaldoriaKiosk = 49;
-const tRoomID kCaldoria44 = 50;
-const tRoomID kCaldoria45 = 51;
-const tRoomID kCaldoria46 = 52;
-const tRoomID kCaldoria47 = 53;
-const tRoomID kCaldoria48 = 54;
-const tRoomID kCaldoria49 = 55;
-const tRoomID kCaldoria50 = 56;
-const tRoomID kCaldoria51 = 57;
-const tRoomID kCaldoria52 = 58;
-const tRoomID kCaldoria53 = 59;
-const tRoomID kCaldoria54 = 60;
-const tRoomID kCaldoria55 = 61;
-const tRoomID kCaldoria56 = 62;
-const tRoomID kCaldoriaDeathRoom = 0;
+const RoomID kCaldoria00 = 1;
+const RoomID kCaldoria01 = 2;
+const RoomID kCaldoria02 = 3;
+const RoomID kCaldoria03 = 4;
+const RoomID kCaldoria04 = 5;
+const RoomID kCaldoria05 = 6;
+const RoomID kCaldoria06 = 7;
+const RoomID kCaldoria07 = 8;
+const RoomID kCaldoria08 = 9;
+const RoomID kCaldoria09 = 10;
+const RoomID kCaldoria10 = 11;
+const RoomID kCaldoriaToilet = 12;
+const RoomID kCaldoria11 = 13;
+const RoomID kCaldoria12 = 14;
+const RoomID kCaldoriaVidPhone = 15;
+const RoomID kCaldoriaReplicator = 16;
+const RoomID kCaldoriaDrawers = 17;
+const RoomID kCaldoria13 = 18;
+const RoomID kCaldoria14 = 19;
+const RoomID kCaldoria15 = 20;
+const RoomID kCaldoria16 = 21;
+const RoomID kCaldoria17 = 22;
+const RoomID kCaldoria18 = 23;
+const RoomID kCaldoria19 = 24;
+const RoomID kCaldoria20 = 25;
+const RoomID kCaldoria21 = 26;
+const RoomID kCaldoria22 = 27;
+const RoomID kCaldoria23 = 28;
+const RoomID kCaldoria24 = 29;
+const RoomID kCaldoria25 = 30;
+const RoomID kCaldoria26 = 31;
+const RoomID kCaldoria27 = 32;
+const RoomID kCaldoria28 = 33;
+const RoomID kCaldoria29 = 34;
+const RoomID kCaldoria30 = 35;
+const RoomID kCaldoria31 = 36;
+const RoomID kCaldoria32 = 37;
+const RoomID kCaldoria33 = 38;
+const RoomID kCaldoria34 = 39;
+const RoomID kCaldoria35 = 40;
+const RoomID kCaldoria36 = 41;
+const RoomID kCaldoria37 = 42;
+const RoomID kCaldoria38 = 43;
+const RoomID kCaldoria39 = 44;
+const RoomID kCaldoria40 = 45;
+const RoomID kCaldoria41 = 46;
+const RoomID kCaldoriaBinoculars = 47;
+const RoomID kCaldoria42 = 48;
+const RoomID kCaldoriaKiosk = 49;
+const RoomID kCaldoria44 = 50;
+const RoomID kCaldoria45 = 51;
+const RoomID kCaldoria46 = 52;
+const RoomID kCaldoria47 = 53;
+const RoomID kCaldoria48 = 54;
+const RoomID kCaldoria49 = 55;
+const RoomID kCaldoria50 = 56;
+const RoomID kCaldoria51 = 57;
+const RoomID kCaldoria52 = 58;
+const RoomID kCaldoria53 = 59;
+const RoomID kCaldoria54 = 60;
+const RoomID kCaldoria55 = 61;
+const RoomID kCaldoria56 = 62;
+const RoomID kCaldoriaDeathRoom = 0;
 
 //	Hot Spot Activation IDs.
 
-const tHotSpotActivationID kActivate4DClosed = 1;
-const tHotSpotActivationID kActivate4DOpen = 2;
-const tHotSpotActivationID kActivateMirrorReady = 3;
-const tHotSpotActivationID kActivateStylistReady = 4;
-const tHotSpotActivationID kActivateReplicatorReady = 5;
-const tHotSpotActivationID kActivateOJOnThePad = 6;
-const tHotSpotActivationID kActivateDrawersClosed = 7;
-const tHotSpotActivationID kActivateRightOpen = 8;
-const tHotSpotActivationID kActivateLeftOpen = 9;
-const tHotSpotActivationID kActivateFocusedOnShip = 10;
-const tHotSpotActivationID kActivateNotFocusedOnShip = 11;
-const tHotSpotActivationID kActivateReadyForCard = 12;
-const tHotSpotActivationID kActivateReadyToTransport = 13;
-const tHotSpotActivationID kActivateRoofSlotEmpty = 14;
-const tHotSpotActivationID kActivateZoomedOnSinclair = 15;
+const HotSpotActivationID kActivate4DClosed = 1;
+const HotSpotActivationID kActivate4DOpen = 2;
+const HotSpotActivationID kActivateMirrorReady = 3;
+const HotSpotActivationID kActivateStylistReady = 4;
+const HotSpotActivationID kActivateReplicatorReady = 5;
+const HotSpotActivationID kActivateOJOnThePad = 6;
+const HotSpotActivationID kActivateDrawersClosed = 7;
+const HotSpotActivationID kActivateRightOpen = 8;
+const HotSpotActivationID kActivateLeftOpen = 9;
+const HotSpotActivationID kActivateFocusedOnShip = 10;
+const HotSpotActivationID kActivateNotFocusedOnShip = 11;
+const HotSpotActivationID kActivateReadyForCard = 12;
+const HotSpotActivationID kActivateReadyToTransport = 13;
+const HotSpotActivationID kActivateRoofSlotEmpty = 14;
+const HotSpotActivationID kActivateZoomedOnSinclair = 15;
 
 //	Hot Spot IDs.
 
-const tHotSpotID kCa4DEnvironOpenSpotID = 5000;
-const tHotSpotID kCa4DEnvironCloseSpotID = 5001;
-const tHotSpotID kCa4DVisualSpotID = 5002;
-const tHotSpotID kCa4DAudioSpotID = 5003;
-const tHotSpotID kCa4DChoice1SpotID = 5004;
-const tHotSpotID kCa4DChoice2SpotID = 5005;
-const tHotSpotID kCa4DChoice3SpotID = 5006;
-const tHotSpotID kCa4DChoice4SpotID = 5007;
-const tHotSpotID kCaBathroomMirrorSpotID = 5008;
-const tHotSpotID kCaHairStyle1SpotID = 5009;
-const tHotSpotID kCaHairStyle2SpotID = 5010;
-const tHotSpotID kCaHairStyle3SpotID = 5011;
-const tHotSpotID kCaShowerSpotID = 5012;
-const tHotSpotID kCaBathroomToiletSpotID = 5013;
-const tHotSpotID kCaldoriaVidPhoneSpotID = 5014;
-const tHotSpotID kCaldoriaReplicatorSpotID = 5015;
-const tHotSpotID kCaldoriaDrawersSpotID = 5016;
-const tHotSpotID kCaldoriaVidPhoneOutSpotID = 5017;
-const tHotSpotID kCaBedroomVidPhoneActivationSpotID = 5018;
-const tHotSpotID kCaldoriaReplicatorOutSpotID = 5019;
-const tHotSpotID kCaldoriaMakeOJSpotID = 5020;
-const tHotSpotID kCaldoriaMakeStickyBunsSpotID = 5021;
-const tHotSpotID kCaldoriaOrangeJuiceSpotID = 5022;
-const tHotSpotID kCaldoriaOrangeJuiceDropSpotID = 5023;
-const tHotSpotID kCaldoriaDrawersOutSpotID = 5024;
-const tHotSpotID kCaldoriaLeftDrawerOpenSpotID = 5025;
-const tHotSpotID kCaldoriaRightDrawerOpenSpotID = 5026;
-const tHotSpotID kCaldoriaKeyCardSpotID = 5027;
-const tHotSpotID kCaldoriaLeftDrawerCloseSpotID = 5028;
-const tHotSpotID kCaldoriaRightDrawerWithKeysCloseSpotID = 5029;
-const tHotSpotID kCaldoriaRightDrawerNoKeysCloseSpotID = 5030;
-const tHotSpotID kCaldoriaFourthFloorElevatorSpotID = 5031;
-const tHotSpotID kCaldoria20DoorbellSpotID = 5032;
-const tHotSpotID kCaldoria21DoorbellSpotID = 5033;
-const tHotSpotID kCaldoria26DoorbellSpotID = 5034;
-const tHotSpotID kCaldoriaFourthFloorElevator1 = 5035;
-const tHotSpotID kCaldoriaFourthFloorElevator2 = 5036;
-const tHotSpotID kCaldoriaFourthFloorElevator3 = 5037;
-const tHotSpotID kCaldoriaFourthFloorElevator4 = 5038;
-const tHotSpotID kCaldoriaFourthFloorElevator5 = 5039;
-const tHotSpotID kCaldoriaGroundElevator1 = 5040;
-const tHotSpotID kCaldoriaGroundElevator2 = 5041;
-const tHotSpotID kCaldoriaGroundElevator3 = 5042;
-const tHotSpotID kCaldoriaGroundElevator4 = 5043;
-const tHotSpotID kCaldoriaGroundElevator5 = 5044;
-const tHotSpotID kCaldoria29DoorbellSpotID = 5045;
-const tHotSpotID kCaldoria34DoorbellSpotID = 5046;
-const tHotSpotID kCaldoria35DoorbellSpotID = 5047;
-const tHotSpotID kCaldoriaGroundElevatorSpotID = 5048;
-const tHotSpotID kCaldoriaBinocularZoomInSpotID = 5049;
-const tHotSpotID kCaldoriaBinocularsOutSpotID = 5050;
-const tHotSpotID kCaldoriaZoomInOnShipSpotID = 5051;
-const tHotSpotID kCaldoriaKioskSpotID = 5052;
-const tHotSpotID kCaldoriaKioskOutSpotID = 5053;
-const tHotSpotID kCaldoriaKioskInfoSpotID = 5054;
-const tHotSpotID kCaldoriaGTCardDropSpotID = 5055;
-const tHotSpotID kCaldoriaGTTokyoSpotID = 5056;
-const tHotSpotID kCaldoriaGTTSASpotID = 5057;
-const tHotSpotID kCaldoriaGTBeachSpotID = 5058;
-const tHotSpotID kCaldoriaGTOtherSpotID = 5059;
-const tHotSpotID kCaldoriaRoofElevator1 = 5060;
-const tHotSpotID kCaldoriaRoofElevator2 = 5061;
-const tHotSpotID kCaldoriaRoofElevator3 = 5062;
-const tHotSpotID kCaldoriaRoofElevator4 = 5063;
-const tHotSpotID kCaldoriaRoofElevator5 = 5064;
-const tHotSpotID kCaldoriaRoofElevatorSpotID = 5065;
-const tHotSpotID kCaldoriaRoofDoorSpotID = 5066;
-const tHotSpotID kCaldoriaRoofCardDropSpotID = 5067;
-const tHotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
+const HotSpotID kCa4DEnvironOpenSpotID = 5000;
+const HotSpotID kCa4DEnvironCloseSpotID = 5001;
+const HotSpotID kCa4DVisualSpotID = 5002;
+const HotSpotID kCa4DAudioSpotID = 5003;
+const HotSpotID kCa4DChoice1SpotID = 5004;
+const HotSpotID kCa4DChoice2SpotID = 5005;
+const HotSpotID kCa4DChoice3SpotID = 5006;
+const HotSpotID kCa4DChoice4SpotID = 5007;
+const HotSpotID kCaBathroomMirrorSpotID = 5008;
+const HotSpotID kCaHairStyle1SpotID = 5009;
+const HotSpotID kCaHairStyle2SpotID = 5010;
+const HotSpotID kCaHairStyle3SpotID = 5011;
+const HotSpotID kCaShowerSpotID = 5012;
+const HotSpotID kCaBathroomToiletSpotID = 5013;
+const HotSpotID kCaldoriaVidPhoneSpotID = 5014;
+const HotSpotID kCaldoriaReplicatorSpotID = 5015;
+const HotSpotID kCaldoriaDrawersSpotID = 5016;
+const HotSpotID kCaldoriaVidPhoneOutSpotID = 5017;
+const HotSpotID kCaBedroomVidPhoneActivationSpotID = 5018;
+const HotSpotID kCaldoriaReplicatorOutSpotID = 5019;
+const HotSpotID kCaldoriaMakeOJSpotID = 5020;
+const HotSpotID kCaldoriaMakeStickyBunsSpotID = 5021;
+const HotSpotID kCaldoriaOrangeJuiceSpotID = 5022;
+const HotSpotID kCaldoriaOrangeJuiceDropSpotID = 5023;
+const HotSpotID kCaldoriaDrawersOutSpotID = 5024;
+const HotSpotID kCaldoriaLeftDrawerOpenSpotID = 5025;
+const HotSpotID kCaldoriaRightDrawerOpenSpotID = 5026;
+const HotSpotID kCaldoriaKeyCardSpotID = 5027;
+const HotSpotID kCaldoriaLeftDrawerCloseSpotID = 5028;
+const HotSpotID kCaldoriaRightDrawerWithKeysCloseSpotID = 5029;
+const HotSpotID kCaldoriaRightDrawerNoKeysCloseSpotID = 5030;
+const HotSpotID kCaldoriaFourthFloorElevatorSpotID = 5031;
+const HotSpotID kCaldoria20DoorbellSpotID = 5032;
+const HotSpotID kCaldoria21DoorbellSpotID = 5033;
+const HotSpotID kCaldoria26DoorbellSpotID = 5034;
+const HotSpotID kCaldoriaFourthFloorElevator1 = 5035;
+const HotSpotID kCaldoriaFourthFloorElevator2 = 5036;
+const HotSpotID kCaldoriaFourthFloorElevator3 = 5037;
+const HotSpotID kCaldoriaFourthFloorElevator4 = 5038;
+const HotSpotID kCaldoriaFourthFloorElevator5 = 5039;
+const HotSpotID kCaldoriaGroundElevator1 = 5040;
+const HotSpotID kCaldoriaGroundElevator2 = 5041;
+const HotSpotID kCaldoriaGroundElevator3 = 5042;
+const HotSpotID kCaldoriaGroundElevator4 = 5043;
+const HotSpotID kCaldoriaGroundElevator5 = 5044;
+const HotSpotID kCaldoria29DoorbellSpotID = 5045;
+const HotSpotID kCaldoria34DoorbellSpotID = 5046;
+const HotSpotID kCaldoria35DoorbellSpotID = 5047;
+const HotSpotID kCaldoriaGroundElevatorSpotID = 5048;
+const HotSpotID kCaldoriaBinocularZoomInSpotID = 5049;
+const HotSpotID kCaldoriaBinocularsOutSpotID = 5050;
+const HotSpotID kCaldoriaZoomInOnShipSpotID = 5051;
+const HotSpotID kCaldoriaKioskSpotID = 5052;
+const HotSpotID kCaldoriaKioskOutSpotID = 5053;
+const HotSpotID kCaldoriaKioskInfoSpotID = 5054;
+const HotSpotID kCaldoriaGTCardDropSpotID = 5055;
+const HotSpotID kCaldoriaGTTokyoSpotID = 5056;
+const HotSpotID kCaldoriaGTTSASpotID = 5057;
+const HotSpotID kCaldoriaGTBeachSpotID = 5058;
+const HotSpotID kCaldoriaGTOtherSpotID = 5059;
+const HotSpotID kCaldoriaRoofElevator1 = 5060;
+const HotSpotID kCaldoriaRoofElevator2 = 5061;
+const HotSpotID kCaldoriaRoofElevator3 = 5062;
+const HotSpotID kCaldoriaRoofElevator4 = 5063;
+const HotSpotID kCaldoriaRoofElevator5 = 5064;
+const HotSpotID kCaldoriaRoofElevatorSpotID = 5065;
+const HotSpotID kCaldoriaRoofDoorSpotID = 5066;
+const HotSpotID kCaldoriaRoofCardDropSpotID = 5067;
+const HotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
 
 //	Extra sequence IDs.
 
-const tExtraID kCaldoriaWakeUpView1 = 0;
-const tExtraID kCaldoria00WakeUp1 = 1;
-const tExtraID kCaldoria00WakeUp2 = 2;
-const tExtraID kCaldoria00SitDown = 3;
-const tExtraID k4DEnvironOpenToINN = 4;
-const tExtraID k4DINNInterruption = 5;
-const tExtraID k4DINNIntro = 6;
-const tExtraID k4DINNMarkJohnson = 7;
-const tExtraID k4DINNMeganLove = 8;
-const tExtraID k4DINNFadeOut = 9;
-const tExtraID k4DEnvironOpenFromINN = 10;
-const tExtraID k4DEnvironOpen = 11;
-const tExtraID k4DEnvironOpenView = 12;
-const tExtraID k4DEnvironClose = 13;
-const tExtraID k4DIslandLoop = 14;
-const tExtraID k4DDesertLoop = 15;
-const tExtraID k4DMountainLoop = 16;
-const tExtraID k4DIsland1ToIsland0 = 17;
-const tExtraID k4DIsland2ToIsland0 = 18;
-const tExtraID k4DIsland0ToDesert0 = 19;
-const tExtraID k4DIsland1ToDesert0 = 20;
-const tExtraID k4DIsland2ToDesert0 = 21;
-const tExtraID k4DIsland0ToMountain0 = 22;
-const tExtraID k4DIsland1ToMountain0 = 23;
-const tExtraID k4DIsland2ToMountain0 = 24;
-const tExtraID k4DDesert0ToIsland0 = 25;
-const tExtraID k4DDesert1ToIsland0 = 26;
-const tExtraID k4DDesert2ToIsland0 = 27;
-const tExtraID k4DDesert0ToMountain0 = 28;
-const tExtraID k4DDesert1ToMountain0 = 29;
-const tExtraID k4DDesert2ToMountain0 = 30;
-const tExtraID k4DMountain0ToIsland0 = 31;
-const tExtraID k4DMountain1ToIsland0 = 32;
-const tExtraID k4DMountain2ToIsland0 = 33;
-const tExtraID k4DMountain0ToDesert0 = 34;
-const tExtraID k4DMountain1ToDesert0 = 35;
-const tExtraID k4DMountain2ToDesert0 = 36;
-const tExtraID kCaBathroomGreeting = 37;
-const tExtraID kCaBathroomBodyFat = 38;
-const tExtraID kCaBathroomStylistIntro = 39;
-const tExtraID kCaBathroomRetrothrash = 40;
-const tExtraID kCaBathroomRetrothrashReturn = 41;
-const tExtraID kCaBathroomGeoWave = 42;
-const tExtraID kCaBathroomGeoWaveReturn = 43;
-const tExtraID kCaBathroomAgencyStandard = 44;
-const tExtraID kCaldoriaShowerTitle = 45;
-const tExtraID kCaldoriaShowerButton = 46;
-const tExtraID kCaldoriaShowerDown = 47;
-const tExtraID kCaldoriaShowerUp = 48;
-const tExtraID kCaBedroomVidPhone = 49;
-const tExtraID kCaBedroomMessage1 = 50;
-const tExtraID kCaBedroomMessage2 = 51;
-const tExtraID kCreateOrangeJuice = 52;
-const tExtraID kDisposeOrangeJuice = 53;
-const tExtraID kReplicatorNorthViewWithOJ = 54;
-const tExtraID kLeftDrawerOpen = 55;
-const tExtraID kLeftDrawerClose = 56;
-const tExtraID kRightDrawerOpenWithKeys = 57;
-const tExtraID kRightDrawerCloseWithKeys = 58;
-const tExtraID kRightDrawerOpenNoKeys = 59;
-const tExtraID kRightDrawerCloseNoKeys = 60;
-const tExtraID kRightDrawerOpenViewWithKeys = 61;
-const tExtraID kRightDrawerOpenViewNoKeys = 62;
-const tExtraID kCaldoria16ElevatorUp = 63;
-const tExtraID kCaldoria16ElevatorDown = 64;
-const tExtraID kCaldoria16SouthViewWithElevator = 65;
-const tExtraID kCaldoria20Doorbell = 66;
-const tExtraID kCaldoria21Doorbell = 67;
-const tExtraID kCaldoria26Doorbell = 68;
-const tExtraID kCaldoriaFourthToGround = 69;
-const tExtraID kCaldoriaRoofToFourth = 70;
-const tExtraID kCaldoriaRoofToGround = 71;
-const tExtraID kCaldoriaGroundToFourth = 72;
-const tExtraID kCaldoriaGroundToRoof = 73;
-const tExtraID kCaldoriaFourthToRoof = 74;
-const tExtraID kCaldoria29Doorbell = 75;
-const tExtraID kCaldoria34Doorbell = 76;
-const tExtraID kCaldoria35Doorbell = 77;
-const tExtraID kBinocularsZoomInOnShip = 78;
-const tExtraID kCaldoriaKioskVideo = 79;
-const tExtraID kCaldoriaTransporterArrowLoop = 80;
-const tExtraID kArriveAtCaldoriaFromTSA = 81;
-const tExtraID kCaGTOtherChoice = 82;
-const tExtraID kCaGTCardSwipe = 83;
-const tExtraID kCaGTSelectTSA = 84;
-const tExtraID kCaGTFryTheFly = 85;
-const tExtraID kCaGTGoToTSA = 86;
-const tExtraID kCaGTSelectBeach = 87;
-const tExtraID kCaGTGoToBeach = 88;
-const tExtraID kCaGTArriveAtBeach = 89;
-const tExtraID kCaGTSelectTokyo = 90;
-const tExtraID kCaGTGoToTokyo = 91;
-const tExtraID kCaGTArriveAtTokyo = 92;
-const tExtraID kCa48NorthRooftopClosed = 93;
-const tExtraID kCa48NorthExplosion = 94;
-const tExtraID kCa48NorthExplosionDeath = 95;
-const tExtraID kCa49NorthVoiceAnalysis = 96;
-const tExtraID kCa50SinclairShoots = 97;
-const tExtraID kCa53EastZoomToSinclair = 98;
-const tExtraID kCa53EastDeath2 = 99;
-const tExtraID kCa53EastShootSinclair = 100;
-const tExtraID kCa53EastZoomOutFromSinclair = 101;
-const tExtraID kCa54SouthDeath = 102;
-const tExtraID kCaldoria56BombStage1 = 103;
-const tExtraID kCaldoria56BombStage2 = 104;
-const tExtraID kCaldoria56BombStage3 = 105;
-const tExtraID kCaldoria56BombStage4 = 106;
-const tExtraID kCaldoria56BombStage5 = 107;
-const tExtraID kCaldoria56BombStage6 = 108;
-const tExtraID kCaldoria56BombStage7 = 109;
-const tExtraID kCaldoria56BombExplodes = 110;
+const ExtraID kCaldoriaWakeUpView1 = 0;
+const ExtraID kCaldoria00WakeUp1 = 1;
+const ExtraID kCaldoria00WakeUp2 = 2;
+const ExtraID kCaldoria00SitDown = 3;
+const ExtraID k4DEnvironOpenToINN = 4;
+const ExtraID k4DINNInterruption = 5;
+const ExtraID k4DINNIntro = 6;
+const ExtraID k4DINNMarkJohnson = 7;
+const ExtraID k4DINNMeganLove = 8;
+const ExtraID k4DINNFadeOut = 9;
+const ExtraID k4DEnvironOpenFromINN = 10;
+const ExtraID k4DEnvironOpen = 11;
+const ExtraID k4DEnvironOpenView = 12;
+const ExtraID k4DEnvironClose = 13;
+const ExtraID k4DIslandLoop = 14;
+const ExtraID k4DDesertLoop = 15;
+const ExtraID k4DMountainLoop = 16;
+const ExtraID k4DIsland1ToIsland0 = 17;
+const ExtraID k4DIsland2ToIsland0 = 18;
+const ExtraID k4DIsland0ToDesert0 = 19;
+const ExtraID k4DIsland1ToDesert0 = 20;
+const ExtraID k4DIsland2ToDesert0 = 21;
+const ExtraID k4DIsland0ToMountain0 = 22;
+const ExtraID k4DIsland1ToMountain0 = 23;
+const ExtraID k4DIsland2ToMountain0 = 24;
+const ExtraID k4DDesert0ToIsland0 = 25;
+const ExtraID k4DDesert1ToIsland0 = 26;
+const ExtraID k4DDesert2ToIsland0 = 27;
+const ExtraID k4DDesert0ToMountain0 = 28;
+const ExtraID k4DDesert1ToMountain0 = 29;
+const ExtraID k4DDesert2ToMountain0 = 30;
+const ExtraID k4DMountain0ToIsland0 = 31;
+const ExtraID k4DMountain1ToIsland0 = 32;
+const ExtraID k4DMountain2ToIsland0 = 33;
+const ExtraID k4DMountain0ToDesert0 = 34;
+const ExtraID k4DMountain1ToDesert0 = 35;
+const ExtraID k4DMountain2ToDesert0 = 36;
+const ExtraID kCaBathroomGreeting = 37;
+const ExtraID kCaBathroomBodyFat = 38;
+const ExtraID kCaBathroomStylistIntro = 39;
+const ExtraID kCaBathroomRetrothrash = 40;
+const ExtraID kCaBathroomRetrothrashReturn = 41;
+const ExtraID kCaBathroomGeoWave = 42;
+const ExtraID kCaBathroomGeoWaveReturn = 43;
+const ExtraID kCaBathroomAgencyStandard = 44;
+const ExtraID kCaldoriaShowerTitle = 45;
+const ExtraID kCaldoriaShowerButton = 46;
+const ExtraID kCaldoriaShowerDown = 47;
+const ExtraID kCaldoriaShowerUp = 48;
+const ExtraID kCaBedroomVidPhone = 49;
+const ExtraID kCaBedroomMessage1 = 50;
+const ExtraID kCaBedroomMessage2 = 51;
+const ExtraID kCreateOrangeJuice = 52;
+const ExtraID kDisposeOrangeJuice = 53;
+const ExtraID kReplicatorNorthViewWithOJ = 54;
+const ExtraID kLeftDrawerOpen = 55;
+const ExtraID kLeftDrawerClose = 56;
+const ExtraID kRightDrawerOpenWithKeys = 57;
+const ExtraID kRightDrawerCloseWithKeys = 58;
+const ExtraID kRightDrawerOpenNoKeys = 59;
+const ExtraID kRightDrawerCloseNoKeys = 60;
+const ExtraID kRightDrawerOpenViewWithKeys = 61;
+const ExtraID kRightDrawerOpenViewNoKeys = 62;
+const ExtraID kCaldoria16ElevatorUp = 63;
+const ExtraID kCaldoria16ElevatorDown = 64;
+const ExtraID kCaldoria16SouthViewWithElevator = 65;
+const ExtraID kCaldoria20Doorbell = 66;
+const ExtraID kCaldoria21Doorbell = 67;
+const ExtraID kCaldoria26Doorbell = 68;
+const ExtraID kCaldoriaFourthToGround = 69;
+const ExtraID kCaldoriaRoofToFourth = 70;
+const ExtraID kCaldoriaRoofToGround = 71;
+const ExtraID kCaldoriaGroundToFourth = 72;
+const ExtraID kCaldoriaGroundToRoof = 73;
+const ExtraID kCaldoriaFourthToRoof = 74;
+const ExtraID kCaldoria29Doorbell = 75;
+const ExtraID kCaldoria34Doorbell = 76;
+const ExtraID kCaldoria35Doorbell = 77;
+const ExtraID kBinocularsZoomInOnShip = 78;
+const ExtraID kCaldoriaKioskVideo = 79;
+const ExtraID kCaldoriaTransporterArrowLoop = 80;
+const ExtraID kArriveAtCaldoriaFromTSA = 81;
+const ExtraID kCaGTOtherChoice = 82;
+const ExtraID kCaGTCardSwipe = 83;
+const ExtraID kCaGTSelectTSA = 84;
+const ExtraID kCaGTFryTheFly = 85;
+const ExtraID kCaGTGoToTSA = 86;
+const ExtraID kCaGTSelectBeach = 87;
+const ExtraID kCaGTGoToBeach = 88;
+const ExtraID kCaGTArriveAtBeach = 89;
+const ExtraID kCaGTSelectTokyo = 90;
+const ExtraID kCaGTGoToTokyo = 91;
+const ExtraID kCaGTArriveAtTokyo = 92;
+const ExtraID kCa48NorthRooftopClosed = 93;
+const ExtraID kCa48NorthExplosion = 94;
+const ExtraID kCa48NorthExplosionDeath = 95;
+const ExtraID kCa49NorthVoiceAnalysis = 96;
+const ExtraID kCa50SinclairShoots = 97;
+const ExtraID kCa53EastZoomToSinclair = 98;
+const ExtraID kCa53EastDeath2 = 99;
+const ExtraID kCa53EastShootSinclair = 100;
+const ExtraID kCa53EastZoomOutFromSinclair = 101;
+const ExtraID kCa54SouthDeath = 102;
+const ExtraID kCaldoria56BombStage1 = 103;
+const ExtraID kCaldoria56BombStage2 = 104;
+const ExtraID kCaldoria56BombStage3 = 105;
+const ExtraID kCaldoria56BombStage4 = 106;
+const ExtraID kCaldoria56BombStage5 = 107;
+const ExtraID kCaldoria56BombStage6 = 108;
+const ExtraID kCaldoria56BombStage7 = 109;
+const ExtraID kCaldoria56BombExplodes = 110;
 
 //	Caldoria interactions.
 
-const tInteractionID kCaldoria4DInteractionID = 0;
-const tInteractionID kCaldoriaBombInteractionID = 1;
-const tInteractionID kCaldoriaMessagesInteractionID = 2;
-const tInteractionID kCaldoriaMirrorInteractionID = 3;
+const InteractionID kCaldoria4DInteractionID = 0;
+const InteractionID kCaldoriaBombInteractionID = 1;
+const InteractionID kCaldoriaMessagesInteractionID = 2;
+const InteractionID kCaldoriaMirrorInteractionID = 3;
 
 //	Caldoria:
 
-const tDisplayOrder kVidPhoneOrder = kMonitorLayer;
-const tDisplayOrder k4DSpritesOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaMessagesOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaElevatorOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaA05LightLoopOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaA07LightLoopOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaBombGridOrder = kMonitorLayer;
-const tDisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
+const DisplayOrder kVidPhoneOrder = kMonitorLayer;
+const DisplayOrder k4DSpritesOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaMessagesOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaElevatorOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaA05LightLoopOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaA07LightLoopOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaBombGridOrder = kMonitorLayer;
+const DisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
 
 /////////////////////////////////////////////
 //
 //	Caldoria
 
-const tCoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
-const tCoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
+const CoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
+const CoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
 
-const tCoordType kCaldoria4DSpritesLeft = kNavAreaLeft + 10;
-const tCoordType kCaldoria4DSpritesTop = kNavAreaTop + 142;
+const CoordType kCaldoria4DSpritesLeft = kNavAreaLeft + 10;
+const CoordType kCaldoria4DSpritesTop = kNavAreaTop + 142;
 
-const tCoordType kCaldoriaMessageLeft = kNavAreaLeft + 202;
-const tCoordType kCaldoriaMessageTop = kNavAreaTop + 26;
+const CoordType kCaldoriaMessageLeft = kNavAreaLeft + 202;
+const CoordType kCaldoriaMessageTop = kNavAreaTop + 26;
 
-const tCoordType kCaldoriaElevatorLeft = kNavAreaLeft + 407;
-const tCoordType kCaldoriaElevatorTop = kNavAreaTop + 138;
+const CoordType kCaldoriaElevatorLeft = kNavAreaLeft + 407;
+const CoordType kCaldoriaElevatorTop = kNavAreaTop + 138;
 
-const tCoordType kCaldoriaA05LightLoopLeft = kNavAreaLeft + 213;
-const tCoordType kCaldoriaA05LightLoopTop = kNavAreaTop + 215;
+const CoordType kCaldoriaA05LightLoopLeft = kNavAreaLeft + 213;
+const CoordType kCaldoriaA05LightLoopTop = kNavAreaTop + 215;
 
-const tCoordType kCaldoriaA07LightLoopLeft = kNavAreaLeft + 414;
-const tCoordType kCaldoriaA07LightLoopTop = kNavAreaTop + 215;
+const CoordType kCaldoriaA07LightLoopLeft = kNavAreaLeft + 414;
+const CoordType kCaldoriaA07LightLoopTop = kNavAreaTop + 215;
 
-const tCoordType kCaldoriaGunSpriteLeft = kNavAreaLeft + 276;
-const tCoordType kCaldoriaGunSpriteTop = kNavAreaTop + 115;
+const CoordType kCaldoriaGunSpriteLeft = kNavAreaLeft + 276;
+const CoordType kCaldoriaGunSpriteTop = kNavAreaTop + 115;
 
-const tCoordType kCaldoria11MessageLoopLeft = kNavAreaLeft + 135;
-const tCoordType kCaldoria11MessageLoopTop = kNavAreaTop + 214;
+const CoordType kCaldoria11MessageLoopLeft = kNavAreaLeft + 135;
+const CoordType kCaldoria11MessageLoopTop = kNavAreaTop + 214;
 
-const tCoordType kCaldoria12MessageLoopLeft = kNavAreaLeft + 209;
-const tCoordType kCaldoria12MessageLoopTop = kNavAreaTop + 170;
+const CoordType kCaldoria12MessageLoopLeft = kNavAreaLeft + 209;
+const CoordType kCaldoria12MessageLoopTop = kNavAreaTop + 170;
 
-const tCoordType kCaldoria13MessageLoopLeft = kNavAreaLeft + 480;
-const tCoordType kCaldoria13MessageLoopTop = kNavAreaTop + 191;
+const CoordType kCaldoria13MessageLoopLeft = kNavAreaLeft + 480;
+const CoordType kCaldoria13MessageLoopTop = kNavAreaTop + 191;
 
-const tCoordType kCaldoria14MessageLoopLeft = kNavAreaLeft + 248;
-const tCoordType kCaldoria14MessageLoopTop = kNavAreaTop + 191;
+const CoordType kCaldoria14MessageLoopLeft = kNavAreaLeft + 248;
+const CoordType kCaldoria14MessageLoopTop = kNavAreaTop + 191;
 
-const tCoordType kCaldoria48CardBombLoopLeft = kNavAreaLeft + 337;
-const tCoordType kCaldoria48CardBombLoopTop = kNavAreaTop + 205;
+const CoordType kCaldoria48CardBombLoopLeft = kNavAreaLeft + 337;
+const CoordType kCaldoria48CardBombLoopTop = kNavAreaTop + 205;
 
-const tCoordType kCaldoriaBombGridLeft = kNavAreaLeft + 290;
-const tCoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
+const CoordType kCaldoriaBombGridLeft = kNavAreaLeft + 290;
+const CoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
 
-const tCoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
-const tCoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
+const CoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
+const CoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
 
 //	Caldoria display IDs.
 
-const tDisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
-const tDisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
-const tDisplayElementID kCaldoriaMessagesID = kCaldoria4DSpritesID + 1;
-const tDisplayElementID kCaldoriaUtilityID = kCaldoriaMessagesID + 1;
-const tDisplayElementID kCaldoriaBombGridID = kCaldoriaUtilityID + 1;
-const tDisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
+const DisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
+const DisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
+const DisplayElementID kCaldoriaMessagesID = kCaldoria4DSpritesID + 1;
+const DisplayElementID kCaldoriaUtilityID = kCaldoriaMessagesID + 1;
+const DisplayElementID kCaldoriaBombGridID = kCaldoriaUtilityID + 1;
+const DisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
 
 const TimeValue kCaldoria4DBlankChoiceIn = 29730;
 const TimeValue kCaldoria4DBlankChoiceOut = 33910;
@@ -412,7 +412,7 @@ public:
 	
 	void pickedUpItem(Item *);
 	
-	virtual GameInteraction *makeInteraction(const tInteractionID);
+	virtual GameInteraction *makeInteraction(const InteractionID);
 	
 	virtual Common::String getBriefingMovie();
 	virtual Common::String getEnvScanMovie();
@@ -422,7 +422,7 @@ public:
 	bool wantsCursor();
 	void flushGameState();
 
-	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+	void checkContinuePoint(const RoomID, const DirectionConstant);
 
 protected:
 	enum {
@@ -452,36 +452,36 @@ protected:
 
 	void setUpAIRules();
 	void doAIRecalibration();
-	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
-	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	TimeValue getViewTime(const RoomID, const DirectionConstant);
+	void findSpotEntry(const RoomID, const DirectionConstant, SpotFlags, SpotTable::Entry &);
 	void startSpotOnceOnly(TimeValue, TimeValue);
 	void startExitMovie(const ExitTable::Entry &);
 	void startZoomMovie(const ZoomTable::Entry &);
 	void startDoorOpenMovie(const TimeValue, const TimeValue);
-	void startTurnPush(const tTurnDirection, const TimeValue, const tDirectionConstant);
+	void startTurnPush(const TurnDirection, const TimeValue, const DirectionConstant);
 	void bumpIntoWall();
-	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	int16 getStaticCompassAngle(const RoomID, const DirectionConstant);
 	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
 	void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec &);
 	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
 	void spotCompleted();
-	void arriveAt(const tRoomID, const tDirectionConstant);
+	void arriveAt(const RoomID, const DirectionConstant);
 	void arriveAtCaldoria00();
 	void arriveAtCaldoriaToilet();
 	void arriveAtCaldoria44();
 	void arriveAtCaldoria49();
 	void arriveAtCaldoria56();
 	void arriveAtCaldoriaDeath();
-	void turnTo(const tDirectionConstant);
+	void turnTo(const DirectionConstant);
 	void zoomTo(const Hotspot *);
 	void downButton(const Input &);
-	void receiveNotification(Notification *, const tNotificationFlags);
-	tInputBits getInputFilter();
+	void receiveNotification(Notification *, const NotificationFlags);
+	InputBits getInputFilter();
 	void activateHotspots();
 	void clickInHotspot(const Input &, const Hotspot *);
-	void newInteraction(const tInteractionID);
+	void newInteraction(const InteractionID);
 	
-	void clickOnDoorbell(const tHotSpotID);
+	void clickOnDoorbell(const HotSpotID);
 	
 	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
 	void dropItemIntoRoom(Item *, Hotspot *);
@@ -489,7 +489,7 @@ protected:
 	void updateElevatorMovie();
 	void openElevatorMovie();
 	void emptyOJGlass();
-	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
+	void closeDoorOffScreen(const RoomID, const DirectionConstant);
 	void doorBombTimerExpired();
 	void sinclairTimerExpired();
 	void checkSinclairShootsOS();
@@ -498,7 +498,7 @@ protected:
 	void playEndMessage();
 	void checkInterruptSinclair();
 	
-	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	CanOpenDoorReason canOpenDoor(DoorTable::Entry &);
 	void doorOpened();
 	
 	void updateCursor(const Common::Point, const Hotspot *);
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
index 252979a..31a102a 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -44,7 +44,7 @@ const TimeValue kSwitchable2Stop = kSwitchable2Start + kSwitchableDuration;
 const TimeValue kSwitchable3Start = kSwitchable2Stop + kNonswitchableDuration;
 const TimeValue kSwitchable3Stop = kSwitchable3Start + kSwitchableDuration;
 
-const tNotificationFlags kVidPhoneDoneFlag = 1;
+const NotificationFlags kVidPhoneDoneFlag = 1;
 
 const TimeValue kRockMusicLoopIn = 0;
 const TimeValue kRockMusicLoopOut = 2088;
@@ -75,28 +75,28 @@ enum {
 	k4DFirstVideoChoice = k4DIslandChoice
 };
 
-tExtraID s_transitionExtras0[3][3] = {
-	{0xffffffff, k4DIsland0ToDesert0, k4DIsland0ToMountain0},
-	{k4DDesert0ToIsland0, 0xffffffff, k4DDesert0ToMountain0},
-	{k4DMountain0ToIsland0, k4DMountain0ToDesert0, 0xffffffff}
+static const ExtraID s_transitionExtras0[3][3] = {
+	{ 0xffffffff, k4DIsland0ToDesert0, k4DIsland0ToMountain0 },
+	{ k4DDesert0ToIsland0, 0xffffffff, k4DDesert0ToMountain0 },
+	{ k4DMountain0ToIsland0, k4DMountain0ToDesert0, 0xffffffff }
 };
 
-tExtraID s_transitionExtras1[3][3] = {
-	{0xffffffff, k4DIsland1ToDesert0, k4DIsland1ToMountain0},
-	{k4DDesert1ToIsland0, 0xffffffff, k4DDesert1ToMountain0},
-	{k4DMountain1ToIsland0, k4DMountain1ToDesert0, 0xffffffff}
+static const ExtraID s_transitionExtras1[3][3] = {
+	{ 0xffffffff, k4DIsland1ToDesert0, k4DIsland1ToMountain0 },
+	{ k4DDesert1ToIsland0, 0xffffffff, k4DDesert1ToMountain0 },
+	{ k4DMountain1ToIsland0, k4DMountain1ToDesert0, 0xffffffff }
 };
 
-tExtraID s_transitionExtras2[3][3] = {
-	{0xffffffff, k4DIsland2ToDesert0, k4DIsland2ToMountain0},
-	{k4DDesert2ToIsland0, 0xffffffff, k4DDesert2ToMountain0},
-	{k4DMountain2ToIsland0, k4DMountain2ToDesert0, 0xffffffff}
+static const ExtraID s_transitionExtras2[3][3] = {
+	{ 0xffffffff, k4DIsland2ToDesert0, k4DIsland2ToMountain0 },
+	{ k4DDesert2ToIsland0, 0xffffffff, k4DDesert2ToMountain0 },
+	{ k4DMountain2ToIsland0, k4DMountain2ToDesert0, 0xffffffff }
 };
 
-tExtraID s_shutDownExtras[3][3] = {
-	{0xffffffff, k4DIsland1ToIsland0, k4DIsland2ToIsland0},
-	{k4DDesert0ToIsland0, k4DDesert1ToIsland0, k4DDesert2ToIsland0},
-	{k4DMountain0ToIsland0, k4DMountain1ToIsland0, k4DMountain2ToIsland0}
+static const ExtraID s_shutDownExtras[3][3] = {
+	{ 0xffffffff, k4DIsland1ToIsland0, k4DIsland2ToIsland0 },
+	{ k4DDesert0ToIsland0, k4DDesert1ToIsland0, k4DDesert2ToIsland0 },
+	{ k4DMountain0ToIsland0, k4DMountain1ToIsland0, k4DMountain2ToIsland0 }
 };
 
 Caldoria4DSystem::Caldoria4DSystem(Neighborhood *owner) : GameInteraction(kCaldoria4DInteractionID, owner),
@@ -128,7 +128,7 @@ void Caldoria4DSystem::openInteraction() {
 	startIdling();
 }
 
-void Caldoria4DSystem::loopExtra(const tExtraID extraID) {
+void Caldoria4DSystem::loopExtra(const ExtraID extraID) {
 	ExtraTable::Entry extraEntry;
 	
 	_owner->getExtraEntry(extraID, extraEntry);
@@ -139,7 +139,7 @@ void Caldoria4DSystem::loopExtra(const tExtraID extraID) {
 void Caldoria4DSystem::useIdleTime() {
 	if (_whichMenu == k4DShuttingDown) {
 		TimeValue movieTime = _owner->getNavMovie()->getTime() - _loopStart;
-		tExtraID extraID;
+		ExtraID extraID;
 
 		if (movieTime < kSwitchable1Stop)
 			extraID = s_shutDownExtras[_videoChoice - k4DFirstVideoChoice][0];
@@ -157,7 +157,7 @@ void Caldoria4DSystem::useIdleTime() {
 		}
 	} else if (_clickedHotspotID != kNoHotSpotID) {
 		TimeValue movieTime = _owner->getNavMovie()->getTime() - _loopStart;
-		tExtraID extraID;
+		ExtraID extraID;
 
 		if (movieTime < kSwitchable1Stop) {
 			extraID = s_transitionExtras0[_videoChoice - k4DFirstVideoChoice][_clickedHotspotID - kCa4DChoice1SpotID];
@@ -289,7 +289,7 @@ void Caldoria4DSystem::clickInHotspot(const Input &input, const Hotspot *spot) {
 	}
 }
 
-void Caldoria4DSystem::receiveNotification(Notification *, const tNotificationFlags) {
+void Caldoria4DSystem::receiveNotification(Notification *, const NotificationFlags) {
 	if (_whichMenu == k4DShuttingDown) {
 		_owner->requestDeleteCurrentInteraction();
 	} else {
@@ -364,7 +364,6 @@ void Caldoria4DSystem::makeAcousticChoice() {
 
 void Caldoria4DSystem::shutDown4DSystem() {
 	_whichMenu = k4DShuttingDown;
-
 }
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
index e021791..63de7e1 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
@@ -50,7 +50,7 @@ protected:
 	void handleInput(const Input &, const Hotspot *);
 	void activateHotspots();
 	void clickInHotspot(const Input &, const Hotspot *);
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 	void setSpritesMovie();
 	void makeIslandChoice();
 	void makeRockChoice();
@@ -61,7 +61,7 @@ protected:
 	void makeAcousticChoice();
 	
 	void useIdleTime();
-	void loopExtra(const tExtraID);
+	void loopExtra(const ExtraID);
 	
 	Movie _4DSpritesMovie;
 	TimeScale _4DSpritesScale;
@@ -70,7 +70,7 @@ protected:
 	uint _audioChoice;
 	Notification *_neighborhoodNotification;
 	TimeValue _loopStart;
-	tHotSpotID _clickedHotspotID;
+	HotSpotID _clickedHotspotID;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
index 9ec3124..c9ee68a 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
@@ -48,12 +48,12 @@ static const uint32 kOnTime3 = kOffTime2 + kFlashOnTime;
 static const uint32 kOffTime3 = kOnTime3 + kFlashOffTime;
 static const uint32 kOnTime4 = kOffTime3 + kFlashOnTime;
 
-static const tHotSpotID kVertextHotSpotBaseID = 10000;
+static const HotSpotID kVertextHotSpotBaseID = 10000;
 
-static const tCoordType kVertextHotSpotWidth = 24;
-static const tCoordType kVertextHotSpotHeight = 24;
+static const CoordType kVertextHotSpotWidth = 24;
+static const CoordType kVertextHotSpotHeight = 24;
 
-static const tNotificationFlags kBombTimerExpiredFlag = 1;
+static const NotificationFlags kBombTimerExpiredFlag = 1;
 
 static const VertexType kBombLevelOne[] = {
 	0, 1, 0, 1, 0,			// hot vertices first.
@@ -696,20 +696,20 @@ static const VertexType kBombLevelSix[] = {
 	0, 0
 };
 
-static const tCoordType kBombGridWidth = 140;
-static const tCoordType kBombGridHeight = 140;
+static const CoordType kBombGridWidth = 140;
+static const CoordType kBombGridHeight = 140;
 
-static const tCoordType kDotOriginX = 0;
-static const tCoordType kDotOriginY = 0;
+static const CoordType kDotOriginX = 0;
+static const CoordType kDotOriginY = 0;
 
-static const tCoordType kVertOriginX = 2;
-static const tCoordType kVertOriginY = 6;
+static const CoordType kVertOriginX = 2;
+static const CoordType kVertOriginY = 6;
 
-static const tCoordType kHorizOriginX = 6;
-static const tCoordType kHorizOriginY = 2;
+static const CoordType kHorizOriginX = 6;
+static const CoordType kHorizOriginY = 2;
 
-static const tCoordType kDiagOriginX = 6;
-static const tCoordType kDiagOriginY = 6;
+static const CoordType kDiagOriginX = 6;
+static const CoordType kDiagOriginY = 6;
 
 static const int g_originsX[] = {
 	kDiagOriginX,
@@ -738,11 +738,11 @@ struct HotVerticesList {
 	VertexType hotVerts[25];
 };
 
-tCoordType vertToX(VertexType vertex) {
+CoordType vertToX(VertexType vertex) {
 	return (vertex % 5) * 32;
 }
 
-tCoordType vertToY(VertexType vertex) {
+CoordType vertToY(VertexType vertex) {
 	return (vertex / 5) * 32;
 }
 
@@ -1000,7 +1000,7 @@ bool allEdgesUsed(BombEdgeList edges) {
 	return true;
 }
 
-BombGrid::BombGrid(const tDisplayElementID id) : Picture(id) {
+BombGrid::BombGrid(const DisplayElementID id) : Picture(id) {
 	Common::Rect bounds(0, 0, kBombGridWidth, kBombGridHeight);
 
 	allocateSurface(bounds);
@@ -1098,7 +1098,7 @@ void BombGrid::drawEdges(BombEdgeList edges) {
 	gfx->setCurSurface(gfx->getWorkArea());
 }
 
-BombTimer::BombTimer(const tDisplayElementID id) : IdlerAnimation(id) {	
+BombTimer::BombTimer(const DisplayElementID id) : IdlerAnimation(id) {	
 	_middle = -1;
 	_leftImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTimerLeftPICTID);
 	_rightImage.getImageFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kTimerRightPICTID);
@@ -1224,7 +1224,7 @@ void CaldoriaBomb::startBombAmbient(Common::String ambient) {
 	_owner->loadLoopSound1(ambient);
 }
 
-void CaldoriaBomb::receiveNotification(Notification *notification, const tNotificationFlags) {	
+void CaldoriaBomb::receiveNotification(Notification *notification, const NotificationFlags) {	
 	if (notification == _neighborhoodNotification) {
 		switch (_owner->getLastExtra()) {
 		case kCaldoria56BombStage1:
@@ -1297,7 +1297,7 @@ void CaldoriaBomb::clickInHotspot(const Input &input, const Hotspot *hotspot) {
 	}
 }
 
-tInputBits CaldoriaBomb::getInputFilter() {
+InputBits CaldoriaBomb::getInputFilter() {
 	// Disallow arrow buttons.
 	return GameInteraction::getInputFilter() & kFilterAllButtons;
 }
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
index fc48231..55d0409 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
@@ -75,7 +75,7 @@ static const VertexType kEdgeOneHalf = 7;
 
 class BombTimer : public IdlerAnimation {
 public:
-	BombTimer(const tDisplayElementID);
+	BombTimer(const DisplayElementID);
 	virtual ~BombTimer() {}
 
 	void draw(const Common::Rect &);
@@ -89,7 +89,7 @@ protected:
 
 class BombGrid : public Picture {
 public:
-	BombGrid(const tDisplayElementID);
+	BombGrid(const DisplayElementID);
 	virtual ~BombGrid() {}
 
 	void drawEdges(BombEdgeList);
@@ -131,11 +131,11 @@ protected:
 	void openInteraction();
 	void initInteraction();
 	void closeInteraction();
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 	void activateHotspots();
 	void clickInHotspot(const Input &, const Hotspot *);
 	void handleInput(const Input &, const Hotspot *);
-	tInputBits getInputFilter();
+	InputBits getInputFilter();
 	void startBombAmbient(Common::String);
 	
 	Notification *_neighborhoodNotification;
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
index bd5480d..3e97f97 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
@@ -30,9 +30,9 @@
 
 namespace Pegasus {
 
-const tNotificationFlags kMessageDoneFlag = 1;
+const NotificationFlags kMessageDoneFlag = 1;
 
-CaldoriaMessages::CaldoriaMessages(Neighborhood *owner, const tNotificationID id, NotificationManager *manager) :
+CaldoriaMessages::CaldoriaMessages(Neighborhood *owner, const NotificationID id, NotificationManager *manager) :
 		GameInteraction(kCaldoriaMessagesInteractionID, owner), Notification(id, manager), _messageMovie(kCaldoriaMessagesID) {
 }
 
@@ -54,7 +54,7 @@ void CaldoriaMessages::closeInteraction() {
 	_neighborhoodNotification->cancelNotification(this);
 }
 
-void CaldoriaMessages::receiveNotification(Notification *notification, const tNotificationFlags) {	
+void CaldoriaMessages::receiveNotification(Notification *notification, const NotificationFlags) {	
 	if (notification == _neighborhoodNotification) {
 		switch (GameInteraction::_owner->getLastExtra()) {
 		case kCaBedroomVidPhone:
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
index 1ef0ab0..04079b5 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
@@ -38,14 +38,14 @@ class Neighborhood;
 
 class CaldoriaMessages : public GameInteraction, public Notification, public NotificationReceiver {
 public:
-	CaldoriaMessages(Neighborhood *, const tNotificationID, NotificationManager *);
+	CaldoriaMessages(Neighborhood *, const NotificationID, NotificationManager *);
 	virtual ~CaldoriaMessages() {}
 
 protected:
 	void openInteraction();
 	void initInteraction();
 	void closeInteraction();
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 	void clickInHotspot(const Input &, const Hotspot *);
 	void play1Message(uint);
 	
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
index 4d6dc6b..2b70ead 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
@@ -109,7 +109,7 @@ void CaldoriaMirror::clickInHotspot(const Input &input, const Hotspot *spot) {
 	}
 }
 
-void CaldoriaMirror::receiveNotification(Notification *, const tNotificationFlags) {
+void CaldoriaMirror::receiveNotification(Notification *, const NotificationFlags) {
 	switch (_owner->getLastExtra()) {
 	case kCaBathroomRetrothrash:
 	case kCaBathroomGeoWave:
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.h b/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
index 6b4339e..1ca47ec 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
@@ -44,7 +44,7 @@ protected:
 	void handleInput(const Input &, const Hotspot *);
 	void activateHotspots();
 	void clickInHotspot(const Input &, const Hotspot *);
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 
 	Notification *_neighborhoodNotification;
 };
diff --git a/engines/pegasus/neighborhood/door.cpp b/engines/pegasus/neighborhood/door.cpp
index 82c83f1..f7ec755 100755
--- a/engines/pegasus/neighborhood/door.cpp
+++ b/engines/pegasus/neighborhood/door.cpp
@@ -53,7 +53,7 @@ void DoorTable::clear() {
 	_entries.clear();
 }
 
-DoorTable::Entry DoorTable::findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode) {
+DoorTable::Entry DoorTable::findEntry(RoomID room, DirectionConstant direction, AlternateID altCode) {
 	for (uint32 i = 0; i < _entries.size(); i++)
 		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode)
 			return _entries[i];
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index db05e22..74e9ac8 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -37,16 +37,16 @@ namespace Common {
 
 namespace Pegasus {
 
-typedef byte tDoorFlags;
+typedef byte DoorFlags;
 
 enum {
 	kDoorPresentBit,				//	Bit set if there is a door here.
 	kDoorLockedBit					//	Bit set if door is locked, clear if unlocked.
 };
 
-const tDoorFlags kNoDoorFlags = 0;
-const tDoorFlags kDoorPresentMask = 1 << kDoorPresentBit;
-const tDoorFlags kDoorLockedMask = 1 << kDoorLockedBit;
+const DoorFlags kNoDoorFlags = 0;
+const DoorFlags kDoorPresentMask = 1 << kDoorPresentBit;
+const DoorFlags kDoorLockedMask = 1 << kDoorLockedBit;
 
 class DoorTable {
 public:
@@ -70,15 +70,15 @@ public:
 			flags = kNoDoorFlags;
 		}
 
-		tRoomID room;
-		tDirectionConstant direction;
-		tAlternateID altCode;
+		RoomID room;
+		DirectionConstant direction;
+		AlternateID altCode;
 		TimeValue movieStart;
 		TimeValue movieEnd;
-		tDoorFlags flags;
+		DoorFlags flags;
 	};
 
-	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
+	Entry findEntry(RoomID room, DirectionConstant direction, AlternateID altCode);
 
 private:
 	Common::Array<Entry> _entries;
diff --git a/engines/pegasus/neighborhood/exit.cpp b/engines/pegasus/neighborhood/exit.cpp
index 0ef12cc..f0dfff1 100755
--- a/engines/pegasus/neighborhood/exit.cpp
+++ b/engines/pegasus/neighborhood/exit.cpp
@@ -59,7 +59,7 @@ void ExitTable::clear() {
 	_entries.clear();
 }
 
-ExitTable::Entry ExitTable::findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode) {
+ExitTable::Entry ExitTable::findEntry(RoomID room, DirectionConstant direction, AlternateID altCode) {
 	for (uint32 i = 0; i < _entries.size(); i++)
 		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode)
 			return _entries[i];
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index d3e8d50..10b1b59 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -63,9 +63,9 @@ public:
 			exitDirection = kNoDirection;
 		}
 
-		tRoomID room;
-		tDirectionConstant direction;
-		tAlternateID altCode;
+		RoomID room;
+		DirectionConstant direction;
+		AlternateID altCode;
 		TimeValue movieStart;
 		TimeValue movieEnd;
 		//	fExitEnd is the end of the optimized run of walks.
@@ -74,11 +74,11 @@ public:
 		//	fExitLoop is the loop start time of the optimized run of walks if the run
 		//	loops back on itself (so far, only in TSA).
 		TimeValue exitLoop;
-		tRoomID exitRoom;
-		tDirectionConstant exitDirection;
+		RoomID exitRoom;
+		DirectionConstant exitDirection;
 	};
 
-	Entry findEntry(tRoomID room, tDirectionConstant direction, tAlternateID altCode);
+	Entry findEntry(RoomID room, DirectionConstant direction, AlternateID altCode);
 
 	typedef Common::Array<Entry>::iterator iterator;
 	iterator begin() { return _entries.begin(); }
diff --git a/engines/pegasus/neighborhood/extra.cpp b/engines/pegasus/neighborhood/extra.cpp
index 44235ff..b8c4e5b 100755
--- a/engines/pegasus/neighborhood/extra.cpp
+++ b/engines/pegasus/neighborhood/extra.cpp
@@ -47,7 +47,7 @@ void ExtraTable::clear() {
 	_entries.clear();
 }
 
-ExtraTable::Entry ExtraTable::findEntry(tExtraID extra) {
+ExtraTable::Entry ExtraTable::findEntry(ExtraID extra) {
 	for (uint32 i = 0; i < _entries.size(); i++)
 		if (_entries[i].extra == extra)
 			return _entries[i];
diff --git a/engines/pegasus/neighborhood/extra.h b/engines/pegasus/neighborhood/extra.h
index 3320f51..9ac858e 100755
--- a/engines/pegasus/neighborhood/extra.h
+++ b/engines/pegasus/neighborhood/extra.h
@@ -51,12 +51,12 @@ public:
 		Entry() { movieStart = 0xffffffff; }
 		bool isEmpty() { return movieStart == 0xffffffff; }
 
-		tExtraID extra;
+		ExtraID extra;
 		TimeValue movieStart;
 		TimeValue movieEnd;
 	};
 
-	Entry findEntry(tExtraID extra);
+	Entry findEntry(ExtraID extra);
 
 private:
 	Common::Array<Entry> _entries;
diff --git a/engines/pegasus/neighborhood/hotspotinfo.cpp b/engines/pegasus/neighborhood/hotspotinfo.cpp
index 1cd2416..c7524f3 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.cpp
+++ b/engines/pegasus/neighborhood/hotspotinfo.cpp
@@ -54,7 +54,7 @@ void HotspotInfoTable::clear() {
 	_entries.clear();
 }
 
-HotspotInfoTable::Entry HotspotInfoTable::findEntry(tHotSpotID hotspot) {
+HotspotInfoTable::Entry HotspotInfoTable::findEntry(HotSpotID hotspot) {
 	for (uint32 i = 0; i < _entries.size(); i++)
 		if (_entries[i].hotspot == hotspot)
 			return _entries[i];
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
index 3c958c9..d75e5e9 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.h
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -51,18 +51,18 @@ public:
 		Entry() { hotspotRoom = kNoRoomID; }
 		bool isEmpty() { return hotspotRoom == kNoRoomID; }
 
-		tHotSpotID hotspot;
-		tHotSpotActivationID hotspotActivation;
+		HotSpotID hotspot;
+		HotSpotActivationID hotspotActivation;
 		//	Location hot spot lives in:
-		tRoomID hotspotRoom;
-		tDirectionConstant hotspotDirection;
+		RoomID hotspotRoom;
+		DirectionConstant hotspotDirection;
 		//	Extra to play if this is a "play extra" hot spot.
-		tExtraID hotspotExtra;
+		ExtraID hotspotExtra;
 		//	Item corresponding to this hot spot if it is an item-related hot spot.
-		tItemID hotspotItem;
+		ItemID hotspotItem;
 	};
 
-	Entry findEntry(tHotSpotID hotspot);
+	Entry findEntry(HotSpotID hotspot);
 
 	typedef Common::Array<Entry>::iterator iterator;
 	iterator begin() { return _entries.begin(); }
diff --git a/engines/pegasus/neighborhood/mars/constants.h b/engines/pegasus/neighborhood/mars/constants.h
index c96a8a1..1035186 100755
--- a/engines/pegasus/neighborhood/mars/constants.h
+++ b/engines/pegasus/neighborhood/mars/constants.h
@@ -32,99 +32,99 @@ namespace Pegasus {
 
 //	Element Coordinates
 
-const tCoordType kUndoHiliteLeft = kNavAreaLeft + 140;
-const tCoordType kUndoHiliteTop = kNavAreaTop + 36;
+const CoordType kUndoHiliteLeft = kNavAreaLeft + 140;
+const CoordType kUndoHiliteTop = kNavAreaTop + 36;
 
-const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
-const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
+const CoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+const CoordType kCurrentGuessTop = kNavAreaTop + 90;
 
-const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
-const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+const CoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+const CoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
 
-const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
-const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
+const CoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+const CoordType kReactorHistoryTop = kNavAreaTop + 39;
 
-const tCoordType kAnswerLeft = kNavAreaLeft + 304;
-const tCoordType kAnswerTop = kNavAreaTop + 180;
+const CoordType kAnswerLeft = kNavAreaLeft + 304;
+const CoordType kAnswerTop = kNavAreaTop + 180;
 
-const tCoordType kShuttle1Left = 0;
-const tCoordType kShuttle1Top = 0;
+const CoordType kShuttle1Left = 0;
+const CoordType kShuttle1Top = 0;
 
-const tCoordType kShuttle2Left = 0;
-const tCoordType kShuttle2Top = 96;
+const CoordType kShuttle2Left = 0;
+const CoordType kShuttle2Top = 96;
 
-const tCoordType kShuttle3Left = 500;
-const tCoordType kShuttle3Top = 96;
+const CoordType kShuttle3Left = 500;
+const CoordType kShuttle3Top = 96;
 
-const tCoordType kShuttle4Left = 0;
-const tCoordType kShuttle4Top = 320;
+const CoordType kShuttle4Left = 0;
+const CoordType kShuttle4Top = 320;
 
-const tCoordType kShuttleWindowLeft = 140;
-const tCoordType kShuttleWindowTop = 96;
-const tCoordType kShuttleWindowWidth = 360;
-const tCoordType kShuttleWindowHeight = 224;
+const CoordType kShuttleWindowLeft = 140;
+const CoordType kShuttleWindowTop = 96;
+const CoordType kShuttleWindowWidth = 360;
+const CoordType kShuttleWindowHeight = 224;
 
-const tCoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
-const tCoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
+const CoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
+const CoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
 
-const tCoordType kShuttleLeftLeft = 0;
-const tCoordType kShuttleLeftTop = 128;
+const CoordType kShuttleLeftLeft = 0;
+const CoordType kShuttleLeftTop = 128;
 
-const tCoordType kShuttleRightLeft = 506;
-const tCoordType kShuttleRightTop = 128;
+const CoordType kShuttleRightLeft = 506;
+const CoordType kShuttleRightTop = 128;
 
-const tCoordType kShuttleLowerLeftLeft = 74;
-const tCoordType kShuttleLowerLeftTop = 358;
+const CoordType kShuttleLowerLeftLeft = 74;
+const CoordType kShuttleLowerLeftTop = 358;
 
-const tCoordType kShuttleLowerRightLeft = 486;
-const tCoordType kShuttleLowerRightTop = 354;
+const CoordType kShuttleLowerRightLeft = 486;
+const CoordType kShuttleLowerRightTop = 354;
 
-const tCoordType kShuttleCenterLeft = 260;
-const tCoordType kShuttleCenterTop = 336;
+const CoordType kShuttleCenterLeft = 260;
+const CoordType kShuttleCenterTop = 336;
 
-const tCoordType kShuttleUpperLeftLeft = 30;
-const tCoordType kShuttleUpperLeftTop = 32;
+const CoordType kShuttleUpperLeftLeft = 30;
+const CoordType kShuttleUpperLeftTop = 32;
 
-const tCoordType kShuttleUpperRightLeft = 506;
-const tCoordType kShuttleUpperRightTop = 52;
+const CoordType kShuttleUpperRightLeft = 506;
+const CoordType kShuttleUpperRightTop = 52;
 
-const tCoordType kShuttleLeftEnergyLeft = 110;
-const tCoordType kShuttleLeftEnergyTop = 186;
+const CoordType kShuttleLeftEnergyLeft = 110;
+const CoordType kShuttleLeftEnergyTop = 186;
 
-const tCoordType kShuttleRightEnergyLeft = 510;
-const tCoordType kShuttleRightEnergyTop = 186;
+const CoordType kShuttleRightEnergyLeft = 510;
+const CoordType kShuttleRightEnergyTop = 186;
 
-const tCoordType kShuttleEnergyLeft = 186;
-const tCoordType kShuttleEnergyTop = 60;
-const tCoordType kShuttleEnergyWidth = 252;
-const tCoordType kShuttleEnergyHeight = 22;
+const CoordType kShuttleEnergyLeft = 186;
+const CoordType kShuttleEnergyTop = 60;
+const CoordType kShuttleEnergyWidth = 252;
+const CoordType kShuttleEnergyHeight = 22;
 
-const tCoordType kPlanetStartLeft = kShuttleWindowLeft;
-const tCoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
+const CoordType kPlanetStartLeft = kShuttleWindowLeft;
+const CoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
 
-const tCoordType kPlanetStopLeft = kShuttleWindowLeft;
-const tCoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
+const CoordType kPlanetStopLeft = kShuttleWindowLeft;
+const CoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
 
-const tCoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
-const tCoordType kShuttleTractorTop = kShuttleWindowTop + 56;
-const tCoordType kShuttleTractorWidth = 348;
-const tCoordType kShuttleTractorHeight = 112;
+const CoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
+const CoordType kShuttleTractorTop = kShuttleWindowTop + 56;
+const CoordType kShuttleTractorWidth = 348;
+const CoordType kShuttleTractorHeight = 112;
 
-const tCoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
-const tCoordType kShuttleJunkTop = kShuttleWindowTop + 6;
+const CoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
+const CoordType kShuttleJunkTop = kShuttleWindowTop + 6;
 
-const tDisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
-const tDisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
-const tDisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
-const tDisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
-const tDisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
-const tDisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
-const tDisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
-const tDisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
-const tDisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
-const tDisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
-const tDisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
-const tDisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
+const DisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
+const DisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
+const DisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
+const DisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
+const DisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
+const DisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
+const DisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
+const DisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
+const DisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
+const DisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
+const DisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
+const DisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
 
 const TimeValue kShuttleSwingStart = 0;
 const TimeValue kShuttleSwingStop = 5 * 600;
@@ -471,465 +471,465 @@ const TimeScale kMarsFrameDuration = 40;
 
 //	Alternate IDs.
 
-const tAlternateID kAltMarsNormal = 0;
-const tAlternateID kAltMarsPodAtMars34 = 1;
-const tAlternateID kAltMarsTookCard = 2;
-const tAlternateID kAltMars35AirlockEast = 3;
-const tAlternateID kAltMars35AirlockWest = 4;
-const tAlternateID kAltMarsPodAtMars45 = 5;
-const tAlternateID kAltMarsTookMask = 6;
-const tAlternateID kAltMarsMaskOnFiller = 7;
-const tAlternateID kAltMars60AirlockEast = 8;
-const tAlternateID kAltMars60AirlockWest = 9;
+const AlternateID kAltMarsNormal = 0;
+const AlternateID kAltMarsPodAtMars34 = 1;
+const AlternateID kAltMarsTookCard = 2;
+const AlternateID kAltMars35AirlockEast = 3;
+const AlternateID kAltMars35AirlockWest = 4;
+const AlternateID kAltMarsPodAtMars45 = 5;
+const AlternateID kAltMarsTookMask = 6;
+const AlternateID kAltMarsMaskOnFiller = 7;
+const AlternateID kAltMars60AirlockEast = 8;
+const AlternateID kAltMars60AirlockWest = 9;
 
 //	Room IDs.
 
-const tRoomID kMars0A = 0;
-const tRoomID kMars00 = 1;
-const tRoomID kMars01 = 2;
-const tRoomID kMars02 = 3;
-const tRoomID kMars03 = 4;
-const tRoomID kMars04 = 5;
-const tRoomID kMars05 = 6;
-const tRoomID kMars06 = 7;
-const tRoomID kMars07 = 8;
-const tRoomID kMars08 = 9;
-const tRoomID kMars09 = 10;
-const tRoomID kMars10 = 11;
-const tRoomID kMars11 = 12;
-const tRoomID kMars12 = 13;
-const tRoomID kMars13 = 14;
-const tRoomID kMars14 = 15;
-const tRoomID kMars15 = 16;
-const tRoomID kMars16 = 17;
-const tRoomID kMars17 = 18;
-const tRoomID kMars18 = 19;
-const tRoomID kMars19 = 20;
-const tRoomID kMars20 = 21;
-const tRoomID kMars21 = 22;
-const tRoomID kMars22 = 23;
-const tRoomID kMars23 = 24;
-const tRoomID kMars24 = 25;
-const tRoomID kMars25 = 26;
-const tRoomID kMars26 = 27;
-const tRoomID kMars27 = 28;
-const tRoomID kMars28 = 29;
-const tRoomID kMars29 = 30;
-const tRoomID kMars30 = 31;
-const tRoomID kMars31 = 32;
-const tRoomID kMars31South = 33;
-const tRoomID kMars32 = 34;
-const tRoomID kMars33 = 35;
-const tRoomID kMars33North = 36;
-const tRoomID kMars34 = 37;
-const tRoomID kMars35 = 38;
-const tRoomID kMars36 = 39;
-const tRoomID kMars37 = 40;
-const tRoomID kMars38 = 41;
-const tRoomID kMars39 = 42;
-const tRoomID kMars41 = 43;
-const tRoomID kMars42 = 44;
-const tRoomID kMars43 = 45;
-const tRoomID kMars44 = 46;
-const tRoomID kMars45 = 47;
-const tRoomID kMars46 = 48;
-const tRoomID kMars47 = 49;
-const tRoomID kMars48 = 50;
-const tRoomID kMars49 = 51;
-const tRoomID kMars50 = 52;
-const tRoomID kMars51 = 53;
-const tRoomID kMars52 = 54;
-const tRoomID kMars54 = 55;
-const tRoomID kMars56 = 56;
-const tRoomID kMars58 = 57;
-const tRoomID kMars60 = 58;
-const tRoomID kMarsRobotShuttle = 59;
-const tRoomID kMarsMaze004 = 60;
-const tRoomID kMarsMaze005 = 61;
-const tRoomID kMarsMaze006 = 62;
-const tRoomID kMarsMaze007 = 63;
-const tRoomID kMarsMaze008 = 64;
-const tRoomID kMarsMaze009 = 65;
-const tRoomID kMarsMaze010 = 66;
-const tRoomID kMarsMaze011 = 67;
-const tRoomID kMarsMaze012 = 68;
-const tRoomID kMarsMaze015 = 69;
-const tRoomID kMarsMaze016 = 70;
-const tRoomID kMarsMaze017 = 71;
-const tRoomID kMarsMaze018 = 72;
-const tRoomID kMarsMaze019 = 73;
-const tRoomID kMarsMaze020 = 74;
-const tRoomID kMarsMaze021 = 75;
-const tRoomID kMarsMaze022 = 76;
-const tRoomID kMarsMaze023 = 77;
-const tRoomID kMarsMaze024 = 78;
-const tRoomID kMarsMaze025 = 79;
-const tRoomID kMarsMaze026 = 80;
-const tRoomID kMarsMaze027 = 81;
-const tRoomID kMarsMaze028 = 82;
-const tRoomID kMarsMaze031 = 83;
-const tRoomID kMarsMaze032 = 84;
-const tRoomID kMarsMaze033 = 85;
-const tRoomID kMarsMaze034 = 86;
-const tRoomID kMarsMaze035 = 87;
-const tRoomID kMarsMaze036 = 88;
-const tRoomID kMarsMaze037 = 89;
-const tRoomID kMarsMaze038 = 90;
-const tRoomID kMarsMaze039 = 91;
-const tRoomID kMarsMaze042 = 92;
-const tRoomID kMarsMaze043 = 93;
-const tRoomID kMarsMaze044 = 94;
-const tRoomID kMarsMaze045 = 95;
-const tRoomID kMarsMaze046 = 96;
-const tRoomID kMarsMaze047 = 97;
-const tRoomID kMarsMaze049 = 98;
-const tRoomID kMarsMaze050 = 99;
-const tRoomID kMarsMaze051 = 100;
-const tRoomID kMarsMaze052 = 101;
-const tRoomID kMarsMaze053 = 102;
-const tRoomID kMarsMaze054 = 103;
-const tRoomID kMarsMaze055 = 104;
-const tRoomID kMarsMaze056 = 105;
-const tRoomID kMarsMaze057 = 106;
-const tRoomID kMarsMaze058 = 107;
-const tRoomID kMarsMaze059 = 108;
-const tRoomID kMarsMaze060 = 109;
-const tRoomID kMarsMaze061 = 110;
-const tRoomID kMarsMaze063 = 111;
-const tRoomID kMarsMaze064 = 112;
-const tRoomID kMarsMaze065 = 113;
-const tRoomID kMarsMaze066 = 114;
-const tRoomID kMarsMaze067 = 115;
-const tRoomID kMarsMaze068 = 116;
-const tRoomID kMarsMaze069 = 117;
-const tRoomID kMarsMaze070 = 118;
-const tRoomID kMarsMaze071 = 119;
-const tRoomID kMarsMaze072 = 120;
-const tRoomID kMarsMaze074 = 121;
-const tRoomID kMarsMaze076 = 122;
-const tRoomID kMarsMaze078 = 123;
-const tRoomID kMarsMaze079 = 124;
-const tRoomID kMarsMaze081 = 125;
-const tRoomID kMarsMaze083 = 126;
-const tRoomID kMarsMaze084 = 127;
-const tRoomID kMarsMaze085 = 128;
-const tRoomID kMarsMaze086 = 129;
-const tRoomID kMarsMaze087 = 130;
-const tRoomID kMarsMaze088 = 131;
-const tRoomID kMarsMaze089 = 132;
-const tRoomID kMarsMaze090 = 133;
-const tRoomID kMarsMaze091 = 134;
-const tRoomID kMarsMaze092 = 135;
-const tRoomID kMarsMaze093 = 136;
-const tRoomID kMarsMaze098 = 137;
-const tRoomID kMarsMaze099 = 138;
-const tRoomID kMarsMaze100 = 139;
-const tRoomID kMarsMaze101 = 140;
-const tRoomID kMarsMaze104 = 141;
-const tRoomID kMarsMaze105 = 142;
-const tRoomID kMarsMaze106 = 143;
-const tRoomID kMarsMaze107 = 144;
-const tRoomID kMarsMaze108 = 145;
-const tRoomID kMarsMaze111 = 146;
-const tRoomID kMarsMaze113 = 147;
-const tRoomID kMarsMaze114 = 148;
-const tRoomID kMarsMaze115 = 149;
-const tRoomID kMarsMaze116 = 150;
-const tRoomID kMarsMaze117 = 151;
-const tRoomID kMarsMaze118 = 152;
-const tRoomID kMarsMaze119 = 153;
-const tRoomID kMarsMaze120 = 154;
-const tRoomID kMarsMaze121 = 155;
-const tRoomID kMarsMaze122 = 156;
-const tRoomID kMarsMaze123 = 157;
-const tRoomID kMarsMaze124 = 158;
-const tRoomID kMarsMaze125 = 159;
-const tRoomID kMarsMaze126 = 160;
-const tRoomID kMarsMaze127 = 161;
-const tRoomID kMarsMaze128 = 162;
-const tRoomID kMarsMaze129 = 163;
-const tRoomID kMarsMaze130 = 164;
-const tRoomID kMarsMaze131 = 165;
-const tRoomID kMarsMaze132 = 166;
-const tRoomID kMarsMaze133 = 167;
-const tRoomID kMarsMaze136 = 168;
-const tRoomID kMarsMaze137 = 169;
-const tRoomID kMarsMaze138 = 170;
-const tRoomID kMarsMaze139 = 171;
-const tRoomID kMarsMaze140 = 172;
-const tRoomID kMarsMaze141 = 173;
-const tRoomID kMarsMaze142 = 174;
-const tRoomID kMarsMaze143 = 175;
-const tRoomID kMarsMaze144 = 176;
-const tRoomID kMarsMaze145 = 177;
-const tRoomID kMarsMaze146 = 178;
-const tRoomID kMarsMaze147 = 179;
-const tRoomID kMarsMaze148 = 180;
-const tRoomID kMarsMaze149 = 181;
-const tRoomID kMarsMaze152 = 182;
-const tRoomID kMarsMaze153 = 183;
-const tRoomID kMarsMaze154 = 184;
-const tRoomID kMarsMaze155 = 185;
-const tRoomID kMarsMaze156 = 186;
-const tRoomID kMarsMaze157 = 187;
-const tRoomID kMarsMaze159 = 188;
-const tRoomID kMarsMaze160 = 189;
-const tRoomID kMarsMaze161 = 190;
-const tRoomID kMarsMaze162 = 191;
-const tRoomID kMarsMaze163 = 192;
-const tRoomID kMarsMaze164 = 193;
-const tRoomID kMarsMaze165 = 194;
-const tRoomID kMarsMaze166 = 195;
-const tRoomID kMarsMaze167 = 196;
-const tRoomID kMarsMaze168 = 197;
-const tRoomID kMarsMaze169 = 198;
-const tRoomID kMarsMaze170 = 199;
-const tRoomID kMarsMaze171 = 200;
-const tRoomID kMarsMaze172 = 201;
-const tRoomID kMarsMaze173 = 202;
-const tRoomID kMarsMaze174 = 203;
-const tRoomID kMarsMaze175 = 204;
-const tRoomID kMarsMaze177 = 205;
-const tRoomID kMarsMaze178 = 206;
-const tRoomID kMarsMaze179 = 207;
-const tRoomID kMarsMaze180 = 208;
-const tRoomID kMarsMaze181 = 209;
-const tRoomID kMarsMaze182 = 210;
-const tRoomID kMarsMaze183 = 211;
-const tRoomID kMarsMaze184 = 212;
-const tRoomID kMarsMaze187 = 213;
-const tRoomID kMarsMaze188 = 214;
-const tRoomID kMarsMaze189 = 215;
-const tRoomID kMarsMaze190 = 216;
-const tRoomID kMarsMaze191 = 217;
-const tRoomID kMarsMaze192 = 218;
-const tRoomID kMarsMaze193 = 219;
-const tRoomID kMarsMaze194 = 220;
-const tRoomID kMarsMaze195 = 221;
-const tRoomID kMarsMaze198 = 222;
-const tRoomID kMarsMaze199 = 223;
-const tRoomID kMarsMaze200 = 224;
-const tRoomID kMarsDeathRoom = 225;
+const RoomID kMars0A = 0;
+const RoomID kMars00 = 1;
+const RoomID kMars01 = 2;
+const RoomID kMars02 = 3;
+const RoomID kMars03 = 4;
+const RoomID kMars04 = 5;
+const RoomID kMars05 = 6;
+const RoomID kMars06 = 7;
+const RoomID kMars07 = 8;
+const RoomID kMars08 = 9;
+const RoomID kMars09 = 10;
+const RoomID kMars10 = 11;
+const RoomID kMars11 = 12;
+const RoomID kMars12 = 13;
+const RoomID kMars13 = 14;
+const RoomID kMars14 = 15;
+const RoomID kMars15 = 16;
+const RoomID kMars16 = 17;
+const RoomID kMars17 = 18;
+const RoomID kMars18 = 19;
+const RoomID kMars19 = 20;
+const RoomID kMars20 = 21;
+const RoomID kMars21 = 22;
+const RoomID kMars22 = 23;
+const RoomID kMars23 = 24;
+const RoomID kMars24 = 25;
+const RoomID kMars25 = 26;
+const RoomID kMars26 = 27;
+const RoomID kMars27 = 28;
+const RoomID kMars28 = 29;
+const RoomID kMars29 = 30;
+const RoomID kMars30 = 31;
+const RoomID kMars31 = 32;
+const RoomID kMars31South = 33;
+const RoomID kMars32 = 34;
+const RoomID kMars33 = 35;
+const RoomID kMars33North = 36;
+const RoomID kMars34 = 37;
+const RoomID kMars35 = 38;
+const RoomID kMars36 = 39;
+const RoomID kMars37 = 40;
+const RoomID kMars38 = 41;
+const RoomID kMars39 = 42;
+const RoomID kMars41 = 43;
+const RoomID kMars42 = 44;
+const RoomID kMars43 = 45;
+const RoomID kMars44 = 46;
+const RoomID kMars45 = 47;
+const RoomID kMars46 = 48;
+const RoomID kMars47 = 49;
+const RoomID kMars48 = 50;
+const RoomID kMars49 = 51;
+const RoomID kMars50 = 52;
+const RoomID kMars51 = 53;
+const RoomID kMars52 = 54;
+const RoomID kMars54 = 55;
+const RoomID kMars56 = 56;
+const RoomID kMars58 = 57;
+const RoomID kMars60 = 58;
+const RoomID kMarsRobotShuttle = 59;
+const RoomID kMarsMaze004 = 60;
+const RoomID kMarsMaze005 = 61;
+const RoomID kMarsMaze006 = 62;
+const RoomID kMarsMaze007 = 63;
+const RoomID kMarsMaze008 = 64;
+const RoomID kMarsMaze009 = 65;
+const RoomID kMarsMaze010 = 66;
+const RoomID kMarsMaze011 = 67;
+const RoomID kMarsMaze012 = 68;
+const RoomID kMarsMaze015 = 69;
+const RoomID kMarsMaze016 = 70;
+const RoomID kMarsMaze017 = 71;
+const RoomID kMarsMaze018 = 72;
+const RoomID kMarsMaze019 = 73;
+const RoomID kMarsMaze020 = 74;
+const RoomID kMarsMaze021 = 75;
+const RoomID kMarsMaze022 = 76;
+const RoomID kMarsMaze023 = 77;
+const RoomID kMarsMaze024 = 78;
+const RoomID kMarsMaze025 = 79;
+const RoomID kMarsMaze026 = 80;
+const RoomID kMarsMaze027 = 81;
+const RoomID kMarsMaze028 = 82;
+const RoomID kMarsMaze031 = 83;
+const RoomID kMarsMaze032 = 84;
+const RoomID kMarsMaze033 = 85;
+const RoomID kMarsMaze034 = 86;
+const RoomID kMarsMaze035 = 87;
+const RoomID kMarsMaze036 = 88;
+const RoomID kMarsMaze037 = 89;
+const RoomID kMarsMaze038 = 90;
+const RoomID kMarsMaze039 = 91;
+const RoomID kMarsMaze042 = 92;
+const RoomID kMarsMaze043 = 93;
+const RoomID kMarsMaze044 = 94;
+const RoomID kMarsMaze045 = 95;
+const RoomID kMarsMaze046 = 96;
+const RoomID kMarsMaze047 = 97;
+const RoomID kMarsMaze049 = 98;
+const RoomID kMarsMaze050 = 99;
+const RoomID kMarsMaze051 = 100;
+const RoomID kMarsMaze052 = 101;
+const RoomID kMarsMaze053 = 102;
+const RoomID kMarsMaze054 = 103;
+const RoomID kMarsMaze055 = 104;
+const RoomID kMarsMaze056 = 105;
+const RoomID kMarsMaze057 = 106;
+const RoomID kMarsMaze058 = 107;
+const RoomID kMarsMaze059 = 108;
+const RoomID kMarsMaze060 = 109;
+const RoomID kMarsMaze061 = 110;
+const RoomID kMarsMaze063 = 111;
+const RoomID kMarsMaze064 = 112;
+const RoomID kMarsMaze065 = 113;
+const RoomID kMarsMaze066 = 114;
+const RoomID kMarsMaze067 = 115;
+const RoomID kMarsMaze068 = 116;
+const RoomID kMarsMaze069 = 117;
+const RoomID kMarsMaze070 = 118;
+const RoomID kMarsMaze071 = 119;
+const RoomID kMarsMaze072 = 120;
+const RoomID kMarsMaze074 = 121;
+const RoomID kMarsMaze076 = 122;
+const RoomID kMarsMaze078 = 123;
+const RoomID kMarsMaze079 = 124;
+const RoomID kMarsMaze081 = 125;
+const RoomID kMarsMaze083 = 126;
+const RoomID kMarsMaze084 = 127;
+const RoomID kMarsMaze085 = 128;
+const RoomID kMarsMaze086 = 129;
+const RoomID kMarsMaze087 = 130;
+const RoomID kMarsMaze088 = 131;
+const RoomID kMarsMaze089 = 132;
+const RoomID kMarsMaze090 = 133;
+const RoomID kMarsMaze091 = 134;
+const RoomID kMarsMaze092 = 135;
+const RoomID kMarsMaze093 = 136;
+const RoomID kMarsMaze098 = 137;
+const RoomID kMarsMaze099 = 138;
+const RoomID kMarsMaze100 = 139;
+const RoomID kMarsMaze101 = 140;
+const RoomID kMarsMaze104 = 141;
+const RoomID kMarsMaze105 = 142;
+const RoomID kMarsMaze106 = 143;
+const RoomID kMarsMaze107 = 144;
+const RoomID kMarsMaze108 = 145;
+const RoomID kMarsMaze111 = 146;
+const RoomID kMarsMaze113 = 147;
+const RoomID kMarsMaze114 = 148;
+const RoomID kMarsMaze115 = 149;
+const RoomID kMarsMaze116 = 150;
+const RoomID kMarsMaze117 = 151;
+const RoomID kMarsMaze118 = 152;
+const RoomID kMarsMaze119 = 153;
+const RoomID kMarsMaze120 = 154;
+const RoomID kMarsMaze121 = 155;
+const RoomID kMarsMaze122 = 156;
+const RoomID kMarsMaze123 = 157;
+const RoomID kMarsMaze124 = 158;
+const RoomID kMarsMaze125 = 159;
+const RoomID kMarsMaze126 = 160;
+const RoomID kMarsMaze127 = 161;
+const RoomID kMarsMaze128 = 162;
+const RoomID kMarsMaze129 = 163;
+const RoomID kMarsMaze130 = 164;
+const RoomID kMarsMaze131 = 165;
+const RoomID kMarsMaze132 = 166;
+const RoomID kMarsMaze133 = 167;
+const RoomID kMarsMaze136 = 168;
+const RoomID kMarsMaze137 = 169;
+const RoomID kMarsMaze138 = 170;
+const RoomID kMarsMaze139 = 171;
+const RoomID kMarsMaze140 = 172;
+const RoomID kMarsMaze141 = 173;
+const RoomID kMarsMaze142 = 174;
+const RoomID kMarsMaze143 = 175;
+const RoomID kMarsMaze144 = 176;
+const RoomID kMarsMaze145 = 177;
+const RoomID kMarsMaze146 = 178;
+const RoomID kMarsMaze147 = 179;
+const RoomID kMarsMaze148 = 180;
+const RoomID kMarsMaze149 = 181;
+const RoomID kMarsMaze152 = 182;
+const RoomID kMarsMaze153 = 183;
+const RoomID kMarsMaze154 = 184;
+const RoomID kMarsMaze155 = 185;
+const RoomID kMarsMaze156 = 186;
+const RoomID kMarsMaze157 = 187;
+const RoomID kMarsMaze159 = 188;
+const RoomID kMarsMaze160 = 189;
+const RoomID kMarsMaze161 = 190;
+const RoomID kMarsMaze162 = 191;
+const RoomID kMarsMaze163 = 192;
+const RoomID kMarsMaze164 = 193;
+const RoomID kMarsMaze165 = 194;
+const RoomID kMarsMaze166 = 195;
+const RoomID kMarsMaze167 = 196;
+const RoomID kMarsMaze168 = 197;
+const RoomID kMarsMaze169 = 198;
+const RoomID kMarsMaze170 = 199;
+const RoomID kMarsMaze171 = 200;
+const RoomID kMarsMaze172 = 201;
+const RoomID kMarsMaze173 = 202;
+const RoomID kMarsMaze174 = 203;
+const RoomID kMarsMaze175 = 204;
+const RoomID kMarsMaze177 = 205;
+const RoomID kMarsMaze178 = 206;
+const RoomID kMarsMaze179 = 207;
+const RoomID kMarsMaze180 = 208;
+const RoomID kMarsMaze181 = 209;
+const RoomID kMarsMaze182 = 210;
+const RoomID kMarsMaze183 = 211;
+const RoomID kMarsMaze184 = 212;
+const RoomID kMarsMaze187 = 213;
+const RoomID kMarsMaze188 = 214;
+const RoomID kMarsMaze189 = 215;
+const RoomID kMarsMaze190 = 216;
+const RoomID kMarsMaze191 = 217;
+const RoomID kMarsMaze192 = 218;
+const RoomID kMarsMaze193 = 219;
+const RoomID kMarsMaze194 = 220;
+const RoomID kMarsMaze195 = 221;
+const RoomID kMarsMaze198 = 222;
+const RoomID kMarsMaze199 = 223;
+const RoomID kMarsMaze200 = 224;
+const RoomID kMarsDeathRoom = 225;
 
 //	Hot Spot Activation IDs.
 
-const tHotSpotActivationID kActivationReadyForKiosk = 1;
-const tHotSpotActivationID kActivationKioskChoice = 2;
-const tHotSpotActivationID kActivationTunnelMapReady = 3;
-const tHotSpotActivationID kActivateMarsPodClosed = 4;
-const tHotSpotActivationID kActivateMarsPodOpen = 5;
-const tHotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
-const tHotSpotActivationID kActivateAirlockPressurized = 7;
-const tHotSpotActivationID kActivateMaskOnHolder = 8;
-const tHotSpotActivationID kActivateMaskOnFiller = 9;
-const tHotSpotActivationID kActivateReactorPlatformOut = 10;
-const tHotSpotActivationID kActivateReactorPlatformIn = 11;
-const tHotSpotActivationID kActivateReactorAskLowerScreen = 12;
-const tHotSpotActivationID kActivateReactorReadyForNitrogen = 13;
-const tHotSpotActivationID kActivateReactorReadyForCrowBar = 14;
-const tHotSpotActivationID kActivateReactorAskOperation = 15;
-const tHotSpotActivationID kActivateReactorRanEvaluation = 16;
-const tHotSpotActivationID kActivateReactorRanDiagnostics = 17;
-const tHotSpotActivationID kActivateReactorAnalyzed = 18;
-const tHotSpotActivationID kActivateReactorInstructions = 19;
-const tHotSpotActivationID kActivateReactorInGame = 20;
-const tHotSpotActivationID kActivateReactorBombSafe = 21;
-const tHotSpotActivationID kActivateReactorBombExposed = 22;
-const tHotSpotActivationID kActivationRobotHeadClosed = 23;
-const tHotSpotActivationID kActivationRobotHeadOpen = 24;
+const HotSpotActivationID kActivationReadyForKiosk = 1;
+const HotSpotActivationID kActivationKioskChoice = 2;
+const HotSpotActivationID kActivationTunnelMapReady = 3;
+const HotSpotActivationID kActivateMarsPodClosed = 4;
+const HotSpotActivationID kActivateMarsPodOpen = 5;
+const HotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
+const HotSpotActivationID kActivateAirlockPressurized = 7;
+const HotSpotActivationID kActivateMaskOnHolder = 8;
+const HotSpotActivationID kActivateMaskOnFiller = 9;
+const HotSpotActivationID kActivateReactorPlatformOut = 10;
+const HotSpotActivationID kActivateReactorPlatformIn = 11;
+const HotSpotActivationID kActivateReactorAskLowerScreen = 12;
+const HotSpotActivationID kActivateReactorReadyForNitrogen = 13;
+const HotSpotActivationID kActivateReactorReadyForCrowBar = 14;
+const HotSpotActivationID kActivateReactorAskOperation = 15;
+const HotSpotActivationID kActivateReactorRanEvaluation = 16;
+const HotSpotActivationID kActivateReactorRanDiagnostics = 17;
+const HotSpotActivationID kActivateReactorAnalyzed = 18;
+const HotSpotActivationID kActivateReactorInstructions = 19;
+const HotSpotActivationID kActivateReactorInGame = 20;
+const HotSpotActivationID kActivateReactorBombSafe = 21;
+const HotSpotActivationID kActivateReactorBombExposed = 22;
+const HotSpotActivationID kActivationRobotHeadClosed = 23;
+const HotSpotActivationID kActivationRobotHeadOpen = 24;
 
 //	Hot Spot IDs.
 
-const tHotSpotID kMars11NorthKioskSpotID = 5000;
-const tHotSpotID kMars11NorthKioskSightsSpotID = 5001;
-const tHotSpotID kMars11NorthKioskColonySpotID = 5002;
-const tHotSpotID kMars12NorthKioskSpotID = 5003;
-const tHotSpotID kMars12NorthKioskSightsSpotID = 5004;
-const tHotSpotID kMars12NorthKioskColonySpotID = 5005;
-const tHotSpotID kMars31SouthSpotID = 5006;
-const tHotSpotID kMars31SouthOutSpotID = 5007;
-const tHotSpotID kMars31SouthCardSpotID = 5008;
-const tHotSpotID kMars33NorthSpotID = 5009;
-const tHotSpotID kMars33NorthOutSpotID = 5010;
-const tHotSpotID kMars33NorthMonitorSpotID = 5011;
-const tHotSpotID kMars34NorthCardDropSpotID = 5012;
-const tHotSpotID kMars34SouthOpenStorageSpotID = 5013;
-const tHotSpotID kMars34SouthCloseStorageSpotID = 5014;
-const tHotSpotID kMars34SouthCrowbarSpotID = 5015;
-const tHotSpotID kMars35EastPressurizeSpotID = 5016;
-const tHotSpotID kMars35EastSpinSpotID = 5017;
-const tHotSpotID kMars35WestPressurizeSpotID = 5018;
-const tHotSpotID kMars35WestSpinSpotID = 5019;
-const tHotSpotID kMars45NorthOpenStorageSpotID = 5020;
-const tHotSpotID kMars45NorthCloseStorageSpotID = 5021;
-const tHotSpotID kMars45NorthCrowbarSpotID = 5022;
-const tHotSpotID kAttackRobotHotSpotID = 5023;
-const tHotSpotID kMars49AirMaskSpotID = 5024;
-const tHotSpotID kMars49AirMaskFilledSpotID = 5025;
-const tHotSpotID kMars49AirFillingDropSpotID = 5026;
-const tHotSpotID kMars52MoveLeftSpotID = 5027;
-const tHotSpotID kMars52MoveRightSpotID = 5028;
-const tHotSpotID kMars52ExtractSpotID = 5029;
-const tHotSpotID kMars53RetractSpotID = 5030;
-const tHotSpotID kMars54MoveLeftSpotID = 5031;
-const tHotSpotID kMars54MoveRightSpotID = 5032;
-const tHotSpotID kMars54ExtractSpotID = 5033;
-const tHotSpotID kMars55RetractSpotID = 5034;
-const tHotSpotID kMars56MoveLeftSpotID = 5035;
-const tHotSpotID kMars56MoveRightSpotID = 5036;
-const tHotSpotID kMars56ExtractSpotID = 5037;
-const tHotSpotID kMars57RetractSpotID = 5038;
-const tHotSpotID kMars57LowerScreenSpotID = 5039;
-const tHotSpotID kMars57Retract2SpotID = 5040;
-const tHotSpotID kMars57DropNitrogenSpotID = 5041;
-const tHotSpotID kMars57DropCrowBarSpotID = 5042;
-const tHotSpotID kMars57CantOpenPanelSpotID = 5043;
-const tHotSpotID kMars57ShieldEvaluationSpotID = 5044;
-const tHotSpotID kMars57MeasureOutputSpotID = 5045;
-const tHotSpotID kMars57RunDiagnosticsSpotID = 5046;
-const tHotSpotID kMars57BackToOperationMenuSpotID = 5047;
-const tHotSpotID kMars57AnalyzeObjectSpotID = 5048;
-const tHotSpotID kMars57RemoveObjectMenuSpotID = 5049;
-const tHotSpotID kMars57CircuitLinkSpotID = 5050;
-const tHotSpotID kMars57CancelCircuitLinkSpotID = 5051;
-const tHotSpotID kMars57GameInstructionsSpotID = 5052;
-const tHotSpotID kMars57UndoMoveSpotID = 5053;
-const tHotSpotID kMars57RedMoveSpotID = 5054;
-const tHotSpotID kMars57YellowMoveSpotID = 5055;
-const tHotSpotID kMars57GreenMoveSpotID = 5056;
-const tHotSpotID kMars57BlueMoveSpotID = 5057;
-const tHotSpotID kMars57PurpleMoveSpotID = 5058;
-const tHotSpotID kMars57LowerScreenSafelySpotID = 5059;
-const tHotSpotID kMars57GrabBombSpotID = 5060;
-const tHotSpotID kMars58MoveLeftSpotID = 5061;
-const tHotSpotID kMars58MoveRightSpotID = 5062;
-const tHotSpotID kMars58ExtractSpotID = 5063;
-const tHotSpotID kMars59RetractSpotID = 5064;
-const tHotSpotID kMars60EastPressurizeSpotID = 5065;
-const tHotSpotID kMars60EastSpinSpotID = 5066;
-const tHotSpotID kMars60WestPressurizeSpotID = 5067;
-const tHotSpotID kMars60WestSpinSpotID = 5068;
-const tHotSpotID kRobotShuttleOpenHeadSpotID = 5069;
-const tHotSpotID kRobotShuttleMapChipSpotID = 5070;
-const tHotSpotID kRobotShuttleOpticalChipSpotID = 5071;
-const tHotSpotID kRobotShuttleShieldChipSpotID = 5072;
+const HotSpotID kMars11NorthKioskSpotID = 5000;
+const HotSpotID kMars11NorthKioskSightsSpotID = 5001;
+const HotSpotID kMars11NorthKioskColonySpotID = 5002;
+const HotSpotID kMars12NorthKioskSpotID = 5003;
+const HotSpotID kMars12NorthKioskSightsSpotID = 5004;
+const HotSpotID kMars12NorthKioskColonySpotID = 5005;
+const HotSpotID kMars31SouthSpotID = 5006;
+const HotSpotID kMars31SouthOutSpotID = 5007;
+const HotSpotID kMars31SouthCardSpotID = 5008;
+const HotSpotID kMars33NorthSpotID = 5009;
+const HotSpotID kMars33NorthOutSpotID = 5010;
+const HotSpotID kMars33NorthMonitorSpotID = 5011;
+const HotSpotID kMars34NorthCardDropSpotID = 5012;
+const HotSpotID kMars34SouthOpenStorageSpotID = 5013;
+const HotSpotID kMars34SouthCloseStorageSpotID = 5014;
+const HotSpotID kMars34SouthCrowbarSpotID = 5015;
+const HotSpotID kMars35EastPressurizeSpotID = 5016;
+const HotSpotID kMars35EastSpinSpotID = 5017;
+const HotSpotID kMars35WestPressurizeSpotID = 5018;
+const HotSpotID kMars35WestSpinSpotID = 5019;
+const HotSpotID kMars45NorthOpenStorageSpotID = 5020;
+const HotSpotID kMars45NorthCloseStorageSpotID = 5021;
+const HotSpotID kMars45NorthCrowbarSpotID = 5022;
+const HotSpotID kAttackRobotHotSpotID = 5023;
+const HotSpotID kMars49AirMaskSpotID = 5024;
+const HotSpotID kMars49AirMaskFilledSpotID = 5025;
+const HotSpotID kMars49AirFillingDropSpotID = 5026;
+const HotSpotID kMars52MoveLeftSpotID = 5027;
+const HotSpotID kMars52MoveRightSpotID = 5028;
+const HotSpotID kMars52ExtractSpotID = 5029;
+const HotSpotID kMars53RetractSpotID = 5030;
+const HotSpotID kMars54MoveLeftSpotID = 5031;
+const HotSpotID kMars54MoveRightSpotID = 5032;
+const HotSpotID kMars54ExtractSpotID = 5033;
+const HotSpotID kMars55RetractSpotID = 5034;
+const HotSpotID kMars56MoveLeftSpotID = 5035;
+const HotSpotID kMars56MoveRightSpotID = 5036;
+const HotSpotID kMars56ExtractSpotID = 5037;
+const HotSpotID kMars57RetractSpotID = 5038;
+const HotSpotID kMars57LowerScreenSpotID = 5039;
+const HotSpotID kMars57Retract2SpotID = 5040;
+const HotSpotID kMars57DropNitrogenSpotID = 5041;
+const HotSpotID kMars57DropCrowBarSpotID = 5042;
+const HotSpotID kMars57CantOpenPanelSpotID = 5043;
+const HotSpotID kMars57ShieldEvaluationSpotID = 5044;
+const HotSpotID kMars57MeasureOutputSpotID = 5045;
+const HotSpotID kMars57RunDiagnosticsSpotID = 5046;
+const HotSpotID kMars57BackToOperationMenuSpotID = 5047;
+const HotSpotID kMars57AnalyzeObjectSpotID = 5048;
+const HotSpotID kMars57RemoveObjectMenuSpotID = 5049;
+const HotSpotID kMars57CircuitLinkSpotID = 5050;
+const HotSpotID kMars57CancelCircuitLinkSpotID = 5051;
+const HotSpotID kMars57GameInstructionsSpotID = 5052;
+const HotSpotID kMars57UndoMoveSpotID = 5053;
+const HotSpotID kMars57RedMoveSpotID = 5054;
+const HotSpotID kMars57YellowMoveSpotID = 5055;
+const HotSpotID kMars57GreenMoveSpotID = 5056;
+const HotSpotID kMars57BlueMoveSpotID = 5057;
+const HotSpotID kMars57PurpleMoveSpotID = 5058;
+const HotSpotID kMars57LowerScreenSafelySpotID = 5059;
+const HotSpotID kMars57GrabBombSpotID = 5060;
+const HotSpotID kMars58MoveLeftSpotID = 5061;
+const HotSpotID kMars58MoveRightSpotID = 5062;
+const HotSpotID kMars58ExtractSpotID = 5063;
+const HotSpotID kMars59RetractSpotID = 5064;
+const HotSpotID kMars60EastPressurizeSpotID = 5065;
+const HotSpotID kMars60EastSpinSpotID = 5066;
+const HotSpotID kMars60WestPressurizeSpotID = 5067;
+const HotSpotID kMars60WestSpinSpotID = 5068;
+const HotSpotID kRobotShuttleOpenHeadSpotID = 5069;
+const HotSpotID kRobotShuttleMapChipSpotID = 5070;
+const HotSpotID kRobotShuttleOpticalChipSpotID = 5071;
+const HotSpotID kRobotShuttleShieldChipSpotID = 5072;
 
 //	Extra sequence IDs.
 
-const tExtraID kMarsArrivalFromTSA = 0;
-const tExtraID kMars0AWatchShuttleDepart = 1;
-const tExtraID kRobotThrowsPlayer = 2;
-const tExtraID kMarsInfoKioskIntro = 3;
-const tExtraID kMarsColonyInfo = 4;
-const tExtraID kMarsSightsInfo = 5;
-const tExtraID kRobotOnWayToShuttle = 6;
-const tExtraID kMars31SouthZoomInNoCard = 7;
-const tExtraID kMars31SouthViewNoCard = 8;
-const tExtraID kMars31SouthZoomOutNoCard = 9;
-const tExtraID kMars31SouthZoomViewNoCard = 10;
-const tExtraID kMars33SlideShow1 = 11;
-const tExtraID kMars33SlideShow2 = 12;
-const tExtraID kMars33SlideShow3 = 13;
-const tExtraID kMars33SlideShow4 = 14;
-const tExtraID kMars34SpotOpenWithBar = 15;
-const tExtraID kMars34SpotCloseWithBar = 16;
-const tExtraID kMars34SpotOpenNoBar = 17;
-const tExtraID kMars34SpotCloseNoBar = 18;
-const tExtraID kMars34ViewOpenWithBar = 19;
-const tExtraID kMars34ViewOpenNoBar = 20;
-const tExtraID kMars34NorthPodGreeting = 21;
-const tExtraID kMarsTurnOnPod = 22;
-const tExtraID kMarsTakePodToMars45 = 23;
-const tExtraID kMars35WestSpinAirlockToEast = 24;
-const tExtraID kMars35EastSpinAirlockToWest = 25;
-const tExtraID kMars45SpotOpenWithBar = 26;
-const tExtraID kMars45SpotCloseWithBar = 27;
-const tExtraID kMars45SpotOpenNoBar = 28;
-const tExtraID kMars45SpotCloseNoBar = 29;
-const tExtraID kMars45ViewOpenWithBar = 30;
-const tExtraID kMars45ViewOpenNoBar = 31;
-const tExtraID kMars48RobotApproaches = 32;
-const tExtraID kMars48RobotKillsPlayer = 33;
-const tExtraID kMars48RobotLoops = 34;
-const tExtraID kMars48RobotView = 35;
-const tExtraID kMars48RobotDefends = 36;
-const tExtraID kMars49SouthViewMaskFilling = 37;
-const tExtraID kMars52SpinLeft = 38;
-const tExtraID kMars52SpinRight = 39;
-const tExtraID kMars52Extend = 40;
-const tExtraID kMars53Retract = 41;
-const tExtraID kMars54SpinLeft = 42;
-const tExtraID kMars54SpinRight = 43;
-const tExtraID kMars54Extend = 44;
-const tExtraID kMars55Retract = 45;
-const tExtraID kMars56SpinLeft = 46;
-const tExtraID kMars56SpinRight = 47;
-const tExtraID kMars56ExtendWithBomb = 48;
-const tExtraID kMars56ExtendNoBomb = 49;
-const tExtraID kMars57RetractWithBomb = 50;
-const tExtraID kMars57RetractNoBomb = 51;
-const tExtraID kMars57LowerScreenClosed = 52;
-const tExtraID kMars57CantOpenPanel = 53;
-const tExtraID kMars57FreezeLock = 54;
-const tExtraID kMars57BreakLock = 55;
-const tExtraID kMars57LockFrozenView = 56;
-const tExtraID kMars57ThawLock = 57;
-const tExtraID kMars57OpenPanel = 58;
-const tExtraID kMars57OpenPanelChoices = 59;
-const tExtraID kMars57ShieldEvaluation = 60;
-const tExtraID kMars57MeasureOutput = 61;
-const tExtraID kMars57ShieldOkayLoop = 62;
-const tExtraID kMars57RunDiagnostics = 63;
-const tExtraID kMars57BombExplodes = 64;
-const tExtraID kMars57BombAnalysis = 65;
-const tExtraID kMars57DontLink = 66;
-const tExtraID kMars57CircuitLink = 67;
-const tExtraID kMars57GameLevel1 = 68;
-const tExtraID kMars57GameLevel2 = 69;
-const tExtraID kMars57GameLevel3 = 70;
-const tExtraID kMars57BombExplodesInGame = 71;
-const tExtraID kMars57GameSolved = 72;
-const tExtraID kMars57ExposeBomb = 73;
-const tExtraID kMars57BackToNormal = 74;
-const tExtraID kMars57ViewOpenNoBomb = 75;
-const tExtraID kMars58SpinLeft = 76;
-const tExtraID kMars58SpinRight = 77;
-const tExtraID kMars58Extend = 78;
-const tExtraID kMars59Retract = 79;
-const tExtraID kMars60WestSpinAirlockToEast = 80;
-const tExtraID kMars60EastSpinAirlockToWest = 81;
-const tExtraID kMarsRobotHeadOpen = 82;
-const tExtraID kMarsRobotHeadClose = 83;
-const tExtraID kMarsRobotHead000 = 84;
-const tExtraID kMarsRobotHead001 = 85;
-const tExtraID kMarsRobotHead010 = 86;
-const tExtraID kMarsRobotHead011 = 87;
-const tExtraID kMarsRobotHead100 = 88;
-const tExtraID kMarsRobotHead101 = 89;
-const tExtraID kMarsRobotHead110 = 90;
-const tExtraID kMarsRobotHead111 = 91;
-const tExtraID kMarsMaze007RobotApproach = 92;
-const tExtraID kMarsMaze007RobotLoop = 93;
-const tExtraID kMarsMaze007RobotDeath = 94;
-const tExtraID kMarsMaze015SouthRobotApproach = 95;
-const tExtraID kMarsMaze015SouthRobotLoop = 96;
-const tExtraID kMarsMaze015SouthRobotDeath = 97;
-const tExtraID kMarsMaze101EastRobotApproach = 98;
-const tExtraID kMarsMaze101EastRobotLoop = 99;
-const tExtraID kMarsMaze101EastRobotDeath = 100;
-const tExtraID kMarsMaze104WestLoop = 101;
-const tExtraID kMarsMaze104WestDeath = 102;
-const tExtraID kMarsMaze133SouthApproach = 103;
-const tExtraID kMarsMaze133SouthLoop = 104;
-const tExtraID kMarsMaze133SouthDeath = 105;
-const tExtraID kMarsMaze136NorthApproach = 106;
-const tExtraID kMarsMaze136NorthLoop = 107;
-const tExtraID kMarsMaze136NorthDeath = 108;
-const tExtraID kMarsMaze184WestLoop = 109;
-const tExtraID kMarsMaze184WestDeath = 110;
-const tExtraID kMars200DeathInBucket = 111;
-
-const tResIDType kReactorUndoHilitePICTID = 900;
+const ExtraID kMarsArrivalFromTSA = 0;
+const ExtraID kMars0AWatchShuttleDepart = 1;
+const ExtraID kRobotThrowsPlayer = 2;
+const ExtraID kMarsInfoKioskIntro = 3;
+const ExtraID kMarsColonyInfo = 4;
+const ExtraID kMarsSightsInfo = 5;
+const ExtraID kRobotOnWayToShuttle = 6;
+const ExtraID kMars31SouthZoomInNoCard = 7;
+const ExtraID kMars31SouthViewNoCard = 8;
+const ExtraID kMars31SouthZoomOutNoCard = 9;
+const ExtraID kMars31SouthZoomViewNoCard = 10;
+const ExtraID kMars33SlideShow1 = 11;
+const ExtraID kMars33SlideShow2 = 12;
+const ExtraID kMars33SlideShow3 = 13;
+const ExtraID kMars33SlideShow4 = 14;
+const ExtraID kMars34SpotOpenWithBar = 15;
+const ExtraID kMars34SpotCloseWithBar = 16;
+const ExtraID kMars34SpotOpenNoBar = 17;
+const ExtraID kMars34SpotCloseNoBar = 18;
+const ExtraID kMars34ViewOpenWithBar = 19;
+const ExtraID kMars34ViewOpenNoBar = 20;
+const ExtraID kMars34NorthPodGreeting = 21;
+const ExtraID kMarsTurnOnPod = 22;
+const ExtraID kMarsTakePodToMars45 = 23;
+const ExtraID kMars35WestSpinAirlockToEast = 24;
+const ExtraID kMars35EastSpinAirlockToWest = 25;
+const ExtraID kMars45SpotOpenWithBar = 26;
+const ExtraID kMars45SpotCloseWithBar = 27;
+const ExtraID kMars45SpotOpenNoBar = 28;
+const ExtraID kMars45SpotCloseNoBar = 29;
+const ExtraID kMars45ViewOpenWithBar = 30;
+const ExtraID kMars45ViewOpenNoBar = 31;
+const ExtraID kMars48RobotApproaches = 32;
+const ExtraID kMars48RobotKillsPlayer = 33;
+const ExtraID kMars48RobotLoops = 34;
+const ExtraID kMars48RobotView = 35;
+const ExtraID kMars48RobotDefends = 36;
+const ExtraID kMars49SouthViewMaskFilling = 37;
+const ExtraID kMars52SpinLeft = 38;
+const ExtraID kMars52SpinRight = 39;
+const ExtraID kMars52Extend = 40;
+const ExtraID kMars53Retract = 41;
+const ExtraID kMars54SpinLeft = 42;
+const ExtraID kMars54SpinRight = 43;
+const ExtraID kMars54Extend = 44;
+const ExtraID kMars55Retract = 45;
+const ExtraID kMars56SpinLeft = 46;
+const ExtraID kMars56SpinRight = 47;
+const ExtraID kMars56ExtendWithBomb = 48;
+const ExtraID kMars56ExtendNoBomb = 49;
+const ExtraID kMars57RetractWithBomb = 50;
+const ExtraID kMars57RetractNoBomb = 51;
+const ExtraID kMars57LowerScreenClosed = 52;
+const ExtraID kMars57CantOpenPanel = 53;
+const ExtraID kMars57FreezeLock = 54;
+const ExtraID kMars57BreakLock = 55;
+const ExtraID kMars57LockFrozenView = 56;
+const ExtraID kMars57ThawLock = 57;
+const ExtraID kMars57OpenPanel = 58;
+const ExtraID kMars57OpenPanelChoices = 59;
+const ExtraID kMars57ShieldEvaluation = 60;
+const ExtraID kMars57MeasureOutput = 61;
+const ExtraID kMars57ShieldOkayLoop = 62;
+const ExtraID kMars57RunDiagnostics = 63;
+const ExtraID kMars57BombExplodes = 64;
+const ExtraID kMars57BombAnalysis = 65;
+const ExtraID kMars57DontLink = 66;
+const ExtraID kMars57CircuitLink = 67;
+const ExtraID kMars57GameLevel1 = 68;
+const ExtraID kMars57GameLevel2 = 69;
+const ExtraID kMars57GameLevel3 = 70;
+const ExtraID kMars57BombExplodesInGame = 71;
+const ExtraID kMars57GameSolved = 72;
+const ExtraID kMars57ExposeBomb = 73;
+const ExtraID kMars57BackToNormal = 74;
+const ExtraID kMars57ViewOpenNoBomb = 75;
+const ExtraID kMars58SpinLeft = 76;
+const ExtraID kMars58SpinRight = 77;
+const ExtraID kMars58Extend = 78;
+const ExtraID kMars59Retract = 79;
+const ExtraID kMars60WestSpinAirlockToEast = 80;
+const ExtraID kMars60EastSpinAirlockToWest = 81;
+const ExtraID kMarsRobotHeadOpen = 82;
+const ExtraID kMarsRobotHeadClose = 83;
+const ExtraID kMarsRobotHead000 = 84;
+const ExtraID kMarsRobotHead001 = 85;
+const ExtraID kMarsRobotHead010 = 86;
+const ExtraID kMarsRobotHead011 = 87;
+const ExtraID kMarsRobotHead100 = 88;
+const ExtraID kMarsRobotHead101 = 89;
+const ExtraID kMarsRobotHead110 = 90;
+const ExtraID kMarsRobotHead111 = 91;
+const ExtraID kMarsMaze007RobotApproach = 92;
+const ExtraID kMarsMaze007RobotLoop = 93;
+const ExtraID kMarsMaze007RobotDeath = 94;
+const ExtraID kMarsMaze015SouthRobotApproach = 95;
+const ExtraID kMarsMaze015SouthRobotLoop = 96;
+const ExtraID kMarsMaze015SouthRobotDeath = 97;
+const ExtraID kMarsMaze101EastRobotApproach = 98;
+const ExtraID kMarsMaze101EastRobotLoop = 99;
+const ExtraID kMarsMaze101EastRobotDeath = 100;
+const ExtraID kMarsMaze104WestLoop = 101;
+const ExtraID kMarsMaze104WestDeath = 102;
+const ExtraID kMarsMaze133SouthApproach = 103;
+const ExtraID kMarsMaze133SouthLoop = 104;
+const ExtraID kMarsMaze133SouthDeath = 105;
+const ExtraID kMarsMaze136NorthApproach = 106;
+const ExtraID kMarsMaze136NorthLoop = 107;
+const ExtraID kMarsMaze136NorthDeath = 108;
+const ExtraID kMarsMaze184WestLoop = 109;
+const ExtraID kMarsMaze184WestDeath = 110;
+const ExtraID kMars200DeathInBucket = 111;
+
+const ResIDType kReactorUndoHilitePICTID = 900;
 
 const int16 kMars52Compass = 90;
 const int16 kMars54Compass = 180;
diff --git a/engines/pegasus/neighborhood/mars/energybeam.cpp b/engines/pegasus/neighborhood/mars/energybeam.cpp
index 6a30c48..85a1596 100755
--- a/engines/pegasus/neighborhood/mars/energybeam.cpp
+++ b/engines/pegasus/neighborhood/mars/energybeam.cpp
@@ -30,8 +30,8 @@ namespace Pegasus {
 
 const TimeValue kEnergyBeamTime = kOneSecond * kShuttleWeaponScale / 2;
 
-const tCoordType kEnergyBeamOriginH = kShuttleWindowMidH;
-const tCoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
+const CoordType kEnergyBeamOriginH = kShuttleWindowMidH;
+const CoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
 
 const float kBeamXOrigin = convertScreenHToSpaceX(kEnergyBeamOriginH, kEnergyBeamMinDistance);
 const float kBeamYOrigin = convertScreenVToSpaceY(kEnergyBeamOriginV, kEnergyBeamMinDistance);
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
index e56fddc..d383cc3 100755
--- a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
@@ -31,16 +31,16 @@ namespace Pegasus {
 
 const TimeValue kGravitonTime = kOneSecond * kShuttleWeaponScale;
 
-const tCoordType kGravitonOriginH = kShuttleWindowLeft - 1;
-const tCoordType kGravitonOriginV = kShuttleWindowMidV;
+const CoordType kGravitonOriginH = kShuttleWindowLeft - 1;
+const CoordType kGravitonOriginV = kShuttleWindowMidV;
 
 const float kGravitonXOrigin = convertScreenHToSpaceX(kGravitonOriginH, kGravitonMinDistance);
 const float kGravitonYOrigin = convertScreenVToSpaceY(kGravitonOriginV, kGravitonMinDistance);
 const float kGravitonZOrigin = kGravitonMinDistance;
 
 //	Width of graviton sprite...
-const tCoordType kGravitonMaxScreenWidth = 78;
-const tCoordType kGravitonMaxScreenHeight = 46;
+const CoordType kGravitonMaxScreenWidth = 78;
+const CoordType kGravitonMaxScreenHeight = 46;
 
 const float kGravitonWidth = convertScreenHToSpaceX(kShuttleWindowMidH + kGravitonMaxScreenWidth / 2, kGravitonMinDistance)
 		- convertScreenHToSpaceX(kShuttleWindowMidH - kGravitonMaxScreenWidth / 2, kGravitonMinDistance);
diff --git a/engines/pegasus/neighborhood/mars/hermite.cpp b/engines/pegasus/neighborhood/mars/hermite.cpp
index 814e92f..dc4a2c5 100755
--- a/engines/pegasus/neighborhood/mars/hermite.cpp
+++ b/engines/pegasus/neighborhood/mars/hermite.cpp
@@ -27,17 +27,17 @@
 
 namespace Pegasus {
 
-tCoordType hermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 time, int32 duration) {	
+CoordType hermite(CoordType p1, CoordType p4, CoordType r1, CoordType r4, int32 time, int32 duration) {	
 	float t = (float)time / duration;
 	float tsq = t * t;
 	float tcu = t * tsq;
 	float tcu2 = tcu + tcu;
 	float tsq2 = tsq + tsq;
 	float tsq3 = tsq2 + tsq;
-	return (tCoordType)((tcu2 - tsq3 + 1) * p1 + (tsq3 - tcu2) * p4 + (tcu - tsq2 + t) * r1 + (tcu - tsq) * r4);
+	return (CoordType)((tcu2 - tsq3 + 1) * p1 + (tsq3 - tcu2) * p4 + (tcu - tsq2 + t) * r1 + (tcu - tsq) * r4);
 }
 
-tCoordType dHermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 time, int32 duration) {	
+CoordType dHermite(CoordType p1, CoordType p4, CoordType r1, CoordType r4, int32 time, int32 duration) {	
 	float t = (float)time / duration;
 	float t2 = t + t;
 	float t4 = t2 + t2;
@@ -45,7 +45,7 @@ tCoordType dHermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4,
 	float tsq = t * t;
 	float tsq3 = tsq + tsq + tsq;
 	float tsq6 = tsq3 + tsq3;
-	return (tCoordType)((tsq6 - t6) * p1 + (t6 - tsq6) * p4 + (tsq3 - t4 + 1) * r1 + (tsq3 - t2) * r4);
+	return (CoordType)((tsq6 - t6) * p1 + (t6 - tsq6) * p4 + (tsq3 - t4 + 1) * r1 + (tsq3 - t2) * r4);
 }
 
 void hermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 time, int32 duration, Common::Point &result) {	
diff --git a/engines/pegasus/neighborhood/mars/hermite.h b/engines/pegasus/neighborhood/mars/hermite.h
index de0122f..44cb3a5 100755
--- a/engines/pegasus/neighborhood/mars/hermite.h
+++ b/engines/pegasus/neighborhood/mars/hermite.h
@@ -31,8 +31,8 @@
 
 namespace Pegasus {
 
-tCoordType hermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 t, int32 duration);
-tCoordType dHermite(tCoordType p1, tCoordType p4, tCoordType r1, tCoordType r4, int32 t, int32 duration);
+CoordType hermite(CoordType p1, CoordType p4, CoordType r1, CoordType r4, int32 t, int32 duration);
+CoordType dHermite(CoordType p1, CoordType p4, CoordType r1, CoordType r4, int32 t, int32 duration);
 void hermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 t, int32 duration, Common::Point &result);
 void dHermite(Common::Point p1, Common::Point p4, Common::Point r1, Common::Point r4, int32 t, int32 duration, Common::Point &result);
 
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 3a9273e..93f9990 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -42,13 +42,13 @@ namespace Pegasus {
 // Probably no one will know the difference.
 const int16 kMarsShieldPanelOffsetAngle = 22;
 
-const tCanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
+const CanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
 
-const tNotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
-const tNotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
-const tNotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
+const NotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
+const NotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
+const NotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
 
-const tNotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
+const NotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
 													kExplosionFinishedFlag |
 													kTimeToTransportFlag;
 
@@ -264,7 +264,7 @@ uint16 Mars::getDateResID() const {
 	return kDate2185ID;
 }
 
-TimeValue Mars::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+TimeValue Mars::getViewTime(const RoomID room, const DirectionConstant direction) {
 	ExtraTable::Entry extra;
 	SpotTable::Entry spotEntry;
 	uint32 extraID = 0xffffffff;
@@ -342,7 +342,7 @@ TimeValue Mars::getViewTime(const tRoomID room, const tDirectionConstant directi
 	return extra.movieEnd - 1;
 }
 
-void Mars::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry) {
+void Mars::getZoomEntry(const HotSpotID spotID, ZoomTable::Entry &entry) {
 	Neighborhood::getZoomEntry(spotID, entry);
 
 	uint32 extraID = 0xffffffff;
@@ -366,7 +366,7 @@ void Mars::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry) {
 	}
 }
 
-void Mars::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &entry) {
+void Mars::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &entry) {
 	Neighborhood::findSpotEntry(room, direction, flags, entry);
 
 	if ((flags & (kSpotOnArrivalMask | kSpotOnTurnMask)) != 0) {
@@ -387,8 +387,8 @@ void Mars::findSpotEntry(const tRoomID room, const tDirectionConstant direction,
 	}
 }
 
-tCanMoveForwardReason Mars::canMoveForward(ExitTable::Entry &entry) {
-	tCanMoveForwardReason reason = Neighborhood::canMoveForward(entry);
+CanMoveForwardReason Mars::canMoveForward(ExitTable::Entry &entry) {
+	CanMoveForwardReason reason = Neighborhood::canMoveForward(entry);
 
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kMars48, kEast):
@@ -404,7 +404,7 @@ tCanMoveForwardReason Mars::canMoveForward(ExitTable::Entry &entry) {
 	return reason;
 }
 
-void Mars::cantMoveThatWay(tCanMoveForwardReason reason) {
+void Mars::cantMoveThatWay(CanMoveForwardReason reason) {
 	if (reason == kCantMoveRobotBlocking) {
 		startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
 		loadLoopSound2("");
@@ -425,7 +425,7 @@ void Mars::bumpIntoWall() {
 	Neighborhood::bumpIntoWall();
 }
 
-tCanOpenDoorReason Mars::canOpenDoor(DoorTable::Entry &entry) {
+CanOpenDoorReason Mars::canOpenDoor(DoorTable::Entry &entry) {
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kMars05, kEast):
 	case MakeRoomView(kMars06, kEast):
@@ -468,7 +468,7 @@ tCanOpenDoorReason Mars::canOpenDoor(DoorTable::Entry &entry) {
 	return Neighborhood::canOpenDoor(entry);
 }
 
-void Mars::cantOpenDoor(tCanOpenDoorReason reason) {
+void Mars::cantOpenDoor(CanOpenDoorReason reason) {
 	switch (GameState.getCurrentRoom()) {
 	case kMars05:
 	case kMars06:
@@ -611,7 +611,7 @@ void Mars::setUpReactorEnergyDrain() {
 	}
 }
 
-void Mars::closeDoorOffScreen(const tRoomID room, const tDirectionConstant direction) {
+void Mars::closeDoorOffScreen(const RoomID room, const DirectionConstant direction) {
 	switch (room) {
 	case kMars51:
 		playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
@@ -727,7 +727,7 @@ void Mars::checkAirlockDoors() {
 	}
 }
 
-int16 Mars::getStaticCompassAngle(const tRoomID room, const tDirectionConstant dir) {
+int16 Mars::getStaticCompassAngle(const RoomID room, const DirectionConstant dir) {
 	int16 angle = Neighborhood::getStaticCompassAngle(room, dir);
 
 	switch (MakeRoomView(room, dir)) {
@@ -895,7 +895,7 @@ void Mars::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &co
 }
 
 void Mars::loadAmbientLoops() {
-	tRoomID room = GameState.getCurrentRoom();
+	RoomID room = GameState.getCurrentRoom();
 
 	if ((room >= kMars0A && room <= kMars21) || (room >= kMars41 && room <= kMars43)) {
 		if (GameState.getMarsSeenTimeStream())
@@ -1044,7 +1044,7 @@ void Mars::loadAmbientLoops() {
 	}
 }
 
-void Mars::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+void Mars::checkContinuePoint(const RoomID room, const DirectionConstant direction) {
 	switch (MakeRoomView(room, direction)) {
 	case MakeRoomView(kMars02, kSouth):
 	case MakeRoomView(kMars19, kEast):
@@ -1143,7 +1143,7 @@ void Mars::timerExpired(const uint32 eventType) {
 	}
 }
 
-void Mars::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+void Mars::arriveAt(const RoomID room, const DirectionConstant direction) {
 	switch (MakeRoomView(room, direction)) {
 	case MakeRoomView(kMars18, kNorth):
 		if (GameState.getMarsPodAtUpperPlatform())
@@ -1462,7 +1462,7 @@ void Mars::shieldOff() {
 	setUpReactorEnergyDrain();
 }
 
-void Mars::turnTo(const tDirectionConstant direction) {
+void Mars::turnTo(const DirectionConstant direction) {
 	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
 	case MakeRoomView(kMars27, kNorth):
 	case MakeRoomView(kMars27, kSouth):
@@ -1788,8 +1788,8 @@ void Mars::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 	}
 }
 
-tInputBits Mars::getInputFilter() {
-	tInputBits result = Neighborhood::getInputFilter();
+InputBits Mars::getInputFilter() {
+	InputBits result = Neighborhood::getInputFilter();
 
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kMars49, kSouth):
@@ -1830,7 +1830,7 @@ tInputBits Mars::getInputFilter() {
 // the inventory is too full or because the player lets go of the item before
 // dropping it into the inventory).
 Hotspot *Mars::getItemScreenSpot(Item *item, DisplayElement *element) {
-	tHotSpotID destSpotID;
+	HotSpotID destSpotID;
 
 	switch (item->getObjectID()) {
 	case kCardBomb:
@@ -2095,7 +2095,7 @@ void Mars::turnRight() {
 	}
 }
 
-void Mars::receiveNotification(Notification *notification, const tNotificationFlags flag) {
+void Mars::receiveNotification(Notification *notification, const NotificationFlags flag) {
 	InventoryItem *item;
 	
 	Neighborhood::receiveNotification(notification, flag);
@@ -3062,7 +3062,7 @@ const int kRobotTooStrong = 1;
 const int kTractorTooWeak = 2;
 const int kCapturedRobotShip = 3;
 
-void Mars::spaceChaseClick(const Input &input, const tHotSpotID id) {
+void Mars::spaceChaseClick(const Input &input, const HotSpotID id) {
 	Common::Point pt;
 
 	switch (id) {
@@ -3217,7 +3217,7 @@ void Mars::spaceChaseClick(const Input &input, const tHotSpotID id) {
 	}
 }
 
-void Mars::showBigExplosion(const Common::Rect &r, const tDisplayOrder order) {
+void Mars::showBigExplosion(const Common::Rect &r, const DisplayOrder order) {
 	if (_explosions.isMovieValid()) {
 		_explosions.setDisplayOrder(order);
 
@@ -3239,7 +3239,7 @@ void Mars::showBigExplosion(const Common::Rect &r, const tDisplayOrder order) {
 	}
 }
 
-void Mars::showLittleExplosion(const Common::Rect &r, const tDisplayOrder order) {	
+void Mars::showLittleExplosion(const Common::Rect &r, const DisplayOrder order) {	
 	if (_explosions.isMovieValid()) {
 		_explosions.setDisplayOrder(order);
 
@@ -3331,7 +3331,7 @@ void Mars::updateCursor(const Common::Point cursorLocation, const Hotspot *curso
 	}
 }
 
-tAirQuality Mars::getAirQuality(const tRoomID room) {
+AirQuality Mars::getAirQuality(const RoomID room) {
 	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
 		return kAirQualityVacuum;
 	if (room == kMars35 && !GameState.getMarsAirlockOpen())
@@ -3553,7 +3553,7 @@ Common::String Mars::getEnvScanMovie() {
 	Common::String movieName = Neighborhood::getEnvScanMovie();
 
 	if (movieName.empty()) {
-		tRoomID room = GameState.getCurrentRoom();
+		RoomID room = GameState.getCurrentRoom();
 
 		if (room >= kMars0A && room <= kMars21)
 			return "Images/AI/Mars/XME1";
@@ -3624,7 +3624,7 @@ uint Mars::getNumHints() {
 			break;
 		case MakeRoomView(kMars56, kEast):
 			if (getCurrentActivation() == kActivateReactorReadyForNitrogen) {
-				if ((tExtraID)_lastExtra == kMars57LowerScreenClosed)
+				if ((ExtraID)_lastExtra == kMars57LowerScreenClosed)
 					numHints = 3;
 			} else if (getCurrentActivation() == kActivateReactorPlatformOut) {
 				if (!GameState.getShieldOn()) {
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
index 01474ab..9aca10a 100755
--- a/engines/pegasus/neighborhood/mars/mars.h
+++ b/engines/pegasus/neighborhood/mars/mars.h
@@ -77,12 +77,12 @@ public:
 
 	virtual uint16 getDateResID() const;
 
-	virtual tAirQuality getAirQuality(const tRoomID);
+	virtual AirQuality getAirQuality(const RoomID);
 
 	void checkAirMask();
 
-	void showBigExplosion(const Common::Rect &, const tDisplayOrder);
-	void showLittleExplosion(const Common::Rect &, const tDisplayOrder);
+	void showBigExplosion(const Common::Rect &, const DisplayOrder);
+	void showLittleExplosion(const Common::Rect &, const DisplayOrder);
 	void hitByJunk();
 	void decreaseRobotShuttleEnergy(const int, Common::Point impactPoint);
 	void setUpNextDropTime();
@@ -95,7 +95,7 @@ public:
 	virtual void shieldOn();
 	virtual void shieldOff();
 
-	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+	void checkContinuePoint(const RoomID, const DirectionConstant);
 
 	void setSoundFXLevel(const uint16);
 
@@ -123,25 +123,25 @@ protected:
 	void init();
 	void start();
 	void setUpAIRules();
-	void arriveAt(const tRoomID, const tDirectionConstant);
+	void arriveAt(const RoomID, const DirectionConstant);
 	void takeItemFromRoom(Item *);
 	void dropItemIntoRoom(Item *, Hotspot *);
 	void activateHotspots();
 	void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
 	void clickInHotspot(const Input &, const Hotspot *);
-	tInputBits getInputFilter();
+	InputBits getInputFilter();
 	
-	TimeValue getViewTime(const tRoomID, const tDirectionConstant);
-	void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
-	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
-	tCanOpenDoorReason canOpenDoor(DoorTable::Entry &);
+	TimeValue getViewTime(const RoomID, const DirectionConstant);
+	void getZoomEntry(const HotSpotID, ZoomTable::Entry &);
+	void findSpotEntry(const RoomID, const DirectionConstant, SpotFlags, SpotTable::Entry &);
+	CanOpenDoorReason canOpenDoor(DoorTable::Entry &);
 	void openDoor();
-	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
-	int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant);
+	void closeDoorOffScreen(const RoomID, const DirectionConstant);
+	int16 getStaticCompassAngle(const RoomID, const DirectionConstant);
 	void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
 	void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec &);
-	void turnTo(const tDirectionConstant);
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void turnTo(const DirectionConstant);
+	void receiveNotification(Notification *, const NotificationFlags);
 	void doorOpened();
 	void setUpReactorEnergyDrain();
 	Hotspot *getItemScreenSpot(Item *, DisplayElement *);
@@ -155,8 +155,8 @@ protected:
 	void doReactorGuess(int32 guess);
 	void bombExplodesInGame();
 	void didntFindBomb();
-	tCanMoveForwardReason canMoveForward(ExitTable::Entry &);
-	void cantMoveThatWay(tCanMoveForwardReason);
+	CanMoveForwardReason canMoveForward(ExitTable::Entry &);
+	void cantMoveThatWay(CanMoveForwardReason);
 	void moveForward();
 	void bumpIntoWall();
 	void turnLeft();
@@ -165,7 +165,7 @@ protected:
 	void loadAmbientLoops();
 	void checkAirlockDoors();
 	void pickedUpItem(Item *item);
-	void cantOpenDoor(tCanOpenDoorReason);
+	void cantOpenDoor(CanOpenDoorReason);
 	void launchMaze007Robot();
 	void launchMaze015Robot();
 	void launchMaze101Robot();
@@ -183,7 +183,7 @@ protected:
 	void startUpFromFinishedSpaceChase();
 	void startUpFromSpaceChase();
 	void transportToRobotShip();
-	void spaceChaseClick(const Input &, const tHotSpotID);
+	void spaceChaseClick(const Input &, const HotSpotID);
 	void updateCursor(const Common::Point, const Hotspot *);
 
 	Common::String getSoundSpotsName();
diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
index 2b28754..7a43c18 100755
--- a/engines/pegasus/neighborhood/mars/planetmover.cpp
+++ b/engines/pegasus/neighborhood/mars/planetmover.cpp
@@ -36,7 +36,7 @@ const TimeScale kRovingScale = kTractorBeamScale;
 const TimeValue kRovingTime = kTenSeconds * kRovingScale;
 const TimeValue kRovingSlop = kTwoSeconds * kRovingScale;
 
-const tCoordType kMaxVelocity = 20;
+const CoordType kMaxVelocity = 20;
 
 PlanetMover::PlanetMover() {
 	setScale(kRovingScale);
@@ -59,8 +59,8 @@ void PlanetMover::stopMoving() {
 
 void PlanetMover::dropPlanetOutOfSight() {	
 	stop();
-	tCoordType currentLoc = hermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
-	tCoordType currentV = dHermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
+	CoordType currentLoc = hermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
+	CoordType currentV = dHermite(_p1, _p4, _r1, _r4, _lastTime, _duration);
 	_p1 = currentLoc;
 	_r1 = currentV;
 	_p4 = kPlanetStartTop;
diff --git a/engines/pegasus/neighborhood/mars/planetmover.h b/engines/pegasus/neighborhood/mars/planetmover.h
index faf76cd..cc2c412 100755
--- a/engines/pegasus/neighborhood/mars/planetmover.h
+++ b/engines/pegasus/neighborhood/mars/planetmover.h
@@ -47,7 +47,7 @@ protected:
 	virtual void timeChanged(const TimeValue);
 	
 	Movie *_planetMovie;
-	tCoordType _p1, _p4, _r1, _r4;
+	CoordType _p1, _p4, _r1, _r4;
 	TimeValue _duration;
 	bool _dropping;
 };
diff --git a/engines/pegasus/neighborhood/mars/reactor.cpp b/engines/pegasus/neighborhood/mars/reactor.cpp
index dd44fc4..b044fc9 100755
--- a/engines/pegasus/neighborhood/mars/reactor.cpp
+++ b/engines/pegasus/neighborhood/mars/reactor.cpp
@@ -28,18 +28,18 @@
 
 namespace Pegasus {
 
-static const tCoordType kCurrentGuessWidth = 121;
-static const tCoordType kCurrentGuessHeight = 23;
+static const CoordType kCurrentGuessWidth = 121;
+static const CoordType kCurrentGuessHeight = 23;
 
-static const tCoordType kOneGuessWidth = 25;
-static const tCoordType kOneGuessHeight = 23;
+static const CoordType kOneGuessWidth = 25;
+static const CoordType kOneGuessHeight = 23;
 
-static const tResIDType kReactorChoicesPICTID = 905;
+static const ResIDType kReactorChoicesPICTID = 905;
 
-static const tCoordType kCurrentGuessLeft = kNavAreaLeft + 146;
-static const tCoordType kCurrentGuessTop = kNavAreaTop + 90;
+static const CoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+static const CoordType kCurrentGuessTop = kNavAreaTop + 90;
 
-ReactorGuess::ReactorGuess(const tDisplayElementID id) : DisplayElement(id) {
+ReactorGuess::ReactorGuess(const DisplayElementID id) : DisplayElement(id) {
 	setBounds(kCurrentGuessLeft, kCurrentGuessTop, kCurrentGuessLeft + kCurrentGuessWidth,
 			kCurrentGuessTop + kCurrentGuessHeight);
 	setDisplayOrder(kMonitorLayer);
@@ -81,10 +81,10 @@ void ReactorGuess::draw(const Common::Rect &) {
 	}
 }
 
-static const tCoordType kReactorChoiceHiliteWidth = 166;
-static const tCoordType kReactorChoiceHiliteHeight = 26;
+static const CoordType kReactorChoiceHiliteWidth = 166;
+static const CoordType kReactorChoiceHiliteHeight = 26;
 
-static const tCoordType kChoiceHiliteLefts[6] = {
+static const CoordType kChoiceHiliteLefts[6] = {
 	0,
 	34,
 	34 + 34,
@@ -93,12 +93,12 @@ static const tCoordType kChoiceHiliteLefts[6] = {
 	34 + 34 + 32 + 34 + 32
 };
 
-static const tResIDType kReactorChoiceHilitePICTID = 901;
+static const ResIDType kReactorChoiceHilitePICTID = 901;
 
-static const tCoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
-static const tCoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+static const CoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+static const CoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
 
-ReactorChoiceHighlight::ReactorChoiceHighlight(const tDisplayElementID id) : DisplayElement(id) {
+ReactorChoiceHighlight::ReactorChoiceHighlight(const DisplayElementID id) : DisplayElement(id) {
 	setBounds(kReactorChoiceHiliteLeft, kReactorChoiceHiliteTop, kReactorChoiceHiliteLeft + kReactorChoiceHiliteWidth,
 			kReactorChoiceHiliteTop + kReactorChoiceHiliteHeight);
 	setDisplayOrder(kMonitorLayer);
@@ -129,14 +129,14 @@ void ReactorChoiceHighlight::draw(const Common::Rect &) {
 	}
 }
 
-static const tCoordType kReactorHistoryWidth = 128;
-static const tCoordType kReactorHistoryHeight = 168;
+static const CoordType kReactorHistoryWidth = 128;
+static const CoordType kReactorHistoryHeight = 168;
 
-static const tCoordType kColorWidths[5] = {24, 25, 25, 26, 27};
-static const tCoordType kColorHeights[5] = {14, 15, 17, 17, 19};
+static const CoordType kColorWidths[5] = { 24, 25, 25, 26, 27 };
+static const CoordType kColorHeights[5] = { 14, 15, 17, 17, 19};
 
 // TODO: Remove global construction
-static const tCoordType kColorTops[5] = {
+static const CoordType kColorTops[5] = {
 	0,
 	kColorHeights[0],
 	kColorHeights[0] + kColorHeights[1],
@@ -144,7 +144,7 @@ static const tCoordType kColorTops[5] = {
 	kColorHeights[0] + kColorHeights[1] + kColorHeights[2] + kColorHeights[3],
 };
 
-static const tCoordType kHistoryLefts[5][3] = {
+static const CoordType kHistoryLefts[5][3] = {
 	{ 302 + kNavAreaLeft, 329 + kNavAreaLeft, 357 + kNavAreaLeft },
 	{ 302 + kNavAreaLeft, 331 + kNavAreaLeft, 360 + kNavAreaLeft },
 	{ 303 + kNavAreaLeft, 333 + kNavAreaLeft, 363 + kNavAreaLeft },
@@ -152,7 +152,7 @@ static const tCoordType kHistoryLefts[5][3] = {
 	{ 305 + kNavAreaLeft, 337 + kNavAreaLeft, 369 + kNavAreaLeft }
 };
 
-static const tCoordType kHistoryTops[5] = {
+static const CoordType kHistoryTops[5] = {
 	39 + kNavAreaTop,
 	61 + kNavAreaTop,
 	84 + kNavAreaTop,
@@ -160,13 +160,13 @@ static const tCoordType kHistoryTops[5] = {
 	137 + kNavAreaTop
 };
 
-static const tCoordType kOneAnswerWidth = 35;
-static const tCoordType kOneAnswerHeight = 27;
+static const CoordType kOneAnswerWidth = 35;
+static const CoordType kOneAnswerHeight = 27;
 
-static const tCoordType kDigitWidth = 16;
-static const tCoordType kDigitHeight = 12;
+static const CoordType kDigitWidth = 16;
+static const CoordType kDigitHeight = 12;
 
-static const tCoordType kCorrectCountLefts[5] = {
+static const CoordType kCorrectCountLefts[5] = {
 	388 + kNavAreaLeft,
 	392 + kNavAreaLeft,
 	398 + kNavAreaLeft,
@@ -174,7 +174,7 @@ static const tCoordType kCorrectCountLefts[5] = {
 	406 + kNavAreaLeft
 };
 
-static const tCoordType kCorrectCountTops[5] = {
+static const CoordType kCorrectCountTops[5] = {
 	40 + kNavAreaTop,
 	62 + kNavAreaTop,
 	86 + kNavAreaTop,
@@ -182,17 +182,17 @@ static const tCoordType kCorrectCountTops[5] = {
 	140 + kNavAreaTop
 };
 
-static const tResIDType kReactorDigitsPICTID = 902;
-static const tResIDType kReactorHistoryPICTID = 903;
-static const tResIDType kReactorAnswerPICTID = 904;
+static const ResIDType kReactorDigitsPICTID = 902;
+static const ResIDType kReactorHistoryPICTID = 903;
+static const ResIDType kReactorAnswerPICTID = 904;
 
-static const tCoordType kReactorHistoryLeft = kNavAreaLeft + 302;
-static const tCoordType kReactorHistoryTop = kNavAreaTop + 39;
+static const CoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+static const CoordType kReactorHistoryTop = kNavAreaTop + 39;
 
-static const tCoordType kAnswerLeft = kNavAreaLeft + 304;
-static const tCoordType kAnswerTop = kNavAreaTop + 180;
+static const CoordType kAnswerLeft = kNavAreaLeft + 304;
+static const CoordType kAnswerTop = kNavAreaTop + 180;
 
-ReactorHistory::ReactorHistory(const tDisplayElementID id) : DisplayElement(id) {
+ReactorHistory::ReactorHistory(const DisplayElementID id) : DisplayElement(id) {
 	setBounds(kReactorHistoryLeft, kReactorHistoryTop, kReactorHistoryLeft + kReactorHistoryWidth,
 			kReactorHistoryTop + kReactorHistoryHeight);
 	setDisplayOrder(kMonitorLayer);
diff --git a/engines/pegasus/neighborhood/mars/reactor.h b/engines/pegasus/neighborhood/mars/reactor.h
index 6719701..86338f8 100755
--- a/engines/pegasus/neighborhood/mars/reactor.h
+++ b/engines/pegasus/neighborhood/mars/reactor.h
@@ -34,7 +34,7 @@ namespace Pegasus {
 
 class ReactorGuess : public DisplayElement {
 public:
-	ReactorGuess(const tDisplayElementID);
+	ReactorGuess(const DisplayElementID);
 	virtual ~ReactorGuess() {}
 
 	void initReactorGuess();
@@ -52,7 +52,7 @@ protected:
 
 class ReactorChoiceHighlight : public DisplayElement {
 public:
-	ReactorChoiceHighlight(const tDisplayElementID);
+	ReactorChoiceHighlight(const DisplayElementID);
 	virtual ~ReactorChoiceHighlight() {}
 
 	void initReactorChoiceHighlight();
@@ -79,7 +79,7 @@ protected:
 
 class ReactorHistory : public DisplayElement {
 public:
-	ReactorHistory(const tDisplayElementID);
+	ReactorHistory(const DisplayElementID);
 	virtual ~ReactorHistory() {}
 
 	void initReactorHistory();
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
index 862a8b2..b1ecdde 100755
--- a/engines/pegasus/neighborhood/mars/robotship.cpp
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -40,18 +40,18 @@ const TimeValue kRovingSlop = kThreeSeconds * kRovingScale;
 const int kNumSpriteColumns = 15;
 const int kNumSpriteRows = 16;
 
-const tCoordType kInitialLocationLeft = kShuttleWindowLeft - 50;
-const tCoordType kInitialLocationTop = kShuttleWindowTop - 50;
-const tCoordType kInitialLocationWidth = kShuttleWindowWidth + 100;
-const tCoordType kInitialLocationHeight = kShuttleWindowHeight + 100;
+const CoordType kInitialLocationLeft = kShuttleWindowLeft - 50;
+const CoordType kInitialLocationTop = kShuttleWindowTop - 50;
+const CoordType kInitialLocationWidth = kShuttleWindowWidth + 100;
+const CoordType kInitialLocationHeight = kShuttleWindowHeight + 100;
 
-const tCoordType kVelocityVectorLength = 100;
-const tCoordType kVelocityVectorSlop = 50;
+const CoordType kVelocityVectorLength = 100;
+const CoordType kVelocityVectorSlop = 50;
 
-const tCoordType kRovingLeft = kShuttleWindowLeft + 20;
-const tCoordType kRovingTop = kShuttleWindowTop + 20;
-const tCoordType kRovingWidth = kShuttleWindowMidH - kRovingLeft;
-const tCoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
+const CoordType kRovingLeft = kShuttleWindowLeft + 20;
+const CoordType kRovingTop = kShuttleWindowTop + 20;
+const CoordType kRovingWidth = kShuttleWindowMidH - kRovingLeft;
+const CoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
 
 RobotShip* g_robotShip = 0;
 
@@ -129,7 +129,7 @@ void RobotShip::setUpNextDropTime() {
 
 void RobotShip::timeToDropJunk() {	
 	if (g_spaceJunk) {
-		tCoordType x, y;
+		CoordType x, y;
 		_spritesMovie.getCenter(x, y);
 		g_spaceJunk->launchJunk(((PegasusEngine *)g_engine)->getRandomNumber(24), x, y);
 	}
@@ -169,7 +169,7 @@ void RobotShip::newDestination() {
 	start();
 }
 
-void RobotShip::moveRobotTo(tCoordType x, tCoordType y) {
+void RobotShip::moveRobotTo(CoordType x, CoordType y) {
 	_currentLocation.x = x;
 	_currentLocation.y = y;
 
@@ -258,8 +258,8 @@ void RobotShip::timeChanged(const TimeValue) {
 	}
 }
 
-void RobotShip::makeVelocityVector(tCoordType x1, tCoordType y1, tCoordType x2, tCoordType y2, Common::Point &vector) {	
-	tCoordType length = ((PegasusEngine *)g_engine)->getRandomNumber(kVelocityVectorSlop - 1) + kVelocityVectorLength;
+void RobotShip::makeVelocityVector(CoordType x1, CoordType y1, CoordType x2, CoordType y2, Common::Point &vector) {	
+	CoordType length = ((PegasusEngine *)g_engine)->getRandomNumber(kVelocityVectorSlop - 1) + kVelocityVectorLength;
 	vector.x = x2 - x1;
 	vector.y = y2 - y1;
 	float oldLength = sqrt(vector.x * vector.x + vector.y * vector.y);
diff --git a/engines/pegasus/neighborhood/mars/robotship.h b/engines/pegasus/neighborhood/mars/robotship.h
index 7c6d996..7921198 100755
--- a/engines/pegasus/neighborhood/mars/robotship.h
+++ b/engines/pegasus/neighborhood/mars/robotship.h
@@ -30,8 +30,8 @@
 
 namespace Pegasus {
 
-const tCoordType kShuttleMovieWidth = 114;
-const tCoordType kShuttleMovieHeight = 42;
+const CoordType kShuttleMovieWidth = 114;
+const CoordType kShuttleMovieHeight = 42;
 
 class RobotShip : IdlerTimeBase {
 friend void timeToDropJunkFunction(FunctionPtr *, void *);
@@ -65,10 +65,10 @@ public:
 
 protected:
 	void newDestination();
-	void moveRobotTo(tCoordType, tCoordType);
+	void moveRobotTo(CoordType, CoordType);
 	void timeToDropJunk();
 	virtual void timeChanged(const TimeValue);
-	void makeVelocityVector(tCoordType, tCoordType, tCoordType, tCoordType, Common::Point &);
+	void makeVelocityVector(CoordType, CoordType, CoordType, CoordType, Common::Point &);
 
 	GlowingMovie _spritesMovie;
 	Common::Rect _shipRange;
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
index 1850926..cac188e 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -30,26 +30,26 @@
 
 namespace Pegasus {
 
-const tCoordType kHUDTargetGridLeft = kShuttleWindowLeft + 16;
-const tCoordType kHUDTargetGridTop = kShuttleWindowTop + 8;
-const tCoordType kHUDTargetGridWidth = 328;
-const tCoordType kHUDTargetGridHeight = 206;
-
-const tCoordType kHUDRS232Left = kHUDTargetGridLeft + 264;
-const tCoordType kHUDRS232Top = kHUDTargetGridTop + 2;
-
-const tCoordType kHUDLockLeft = kShuttleWindowLeft + 101;
-const tCoordType kHUDLockTop = kShuttleWindowTop + 49;
-const tCoordType kHUDLockWidth = 145;
-const tCoordType kHUDLockHeight = 124;
-
-const tCoordType kTractorLockWidth = 50;
-const tCoordType kTractorLockHeight = 30;
-
-const tCoordType kTractorLockLeft = kShuttleWindowMidH - kTractorLockWidth / 2;
-const tCoordType kTractorLockTop = kShuttleWindowMidV - kTractorLockHeight / 2;
-const tCoordType kTractorLockRight = kTractorLockLeft + kTractorLockWidth;
-const tCoordType kTractorLockBottom = kTractorLockTop + kTractorLockHeight;
+const CoordType kHUDTargetGridLeft = kShuttleWindowLeft + 16;
+const CoordType kHUDTargetGridTop = kShuttleWindowTop + 8;
+const CoordType kHUDTargetGridWidth = 328;
+const CoordType kHUDTargetGridHeight = 206;
+
+const CoordType kHUDRS232Left = kHUDTargetGridLeft + 264;
+const CoordType kHUDRS232Top = kHUDTargetGridTop + 2;
+
+const CoordType kHUDLockLeft = kShuttleWindowLeft + 101;
+const CoordType kHUDLockTop = kShuttleWindowTop + 49;
+const CoordType kHUDLockWidth = 145;
+const CoordType kHUDLockHeight = 124;
+
+const CoordType kTractorLockWidth = 50;
+const CoordType kTractorLockHeight = 30;
+
+const CoordType kTractorLockLeft = kShuttleWindowMidH - kTractorLockWidth / 2;
+const CoordType kTractorLockTop = kShuttleWindowMidV - kTractorLockHeight / 2;
+const CoordType kTractorLockRight = kTractorLockLeft + kTractorLockWidth;
+const CoordType kTractorLockBottom = kTractorLockTop + kTractorLockHeight;
 
 static const uint16 s_RS232Data[] = {
 	0xF0E1, 0xCE70,
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
index 14614d1..0151a26 100755
--- a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
@@ -53,7 +53,7 @@ bool ShuttleWeapon::canFireWeapon() {
 	return !isRunning();
 }
 
-void ShuttleWeapon::fireWeapon(const tCoordType hStop, const tCoordType vStop) {	
+void ShuttleWeapon::fireWeapon(const CoordType hStop, const CoordType vStop) {	
 	if (!isRunning()) {
 		stop();
 		setTime(0);
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.h b/engines/pegasus/neighborhood/mars/shuttleweapon.h
index c62cee1..30e42fa 100755
--- a/engines/pegasus/neighborhood/mars/shuttleweapon.h
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.h
@@ -45,7 +45,7 @@ public:
 	virtual void initShuttleWeapon();
 	virtual void cleanUpShuttleWeapon();
 
-	virtual void fireWeapon(const tCoordType, const tCoordType);
+	virtual void fireWeapon(const CoordType, const CoordType);
 
 	bool canFireWeapon();
 
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index a751dc2..2884713 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -31,9 +31,9 @@ namespace Pegasus {
 
 //const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
 //const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
-const tCoordType kMaxBounceSize = 90;
-const tCoordType kBounceTargetHRange = 640 - kMaxBounceSize - 2;
-const tCoordType kBounceTargetVRange = 480 - kMaxBounceSize - 2;
+const CoordType kMaxBounceSize = 90;
+const CoordType kBounceTargetHRange = 640 - kMaxBounceSize - 2;
+const CoordType kBounceTargetVRange = 480 - kMaxBounceSize - 2;
 
 const float kJunkXTarget = 0;
 const float kJunkYTarget = 0;
@@ -41,7 +41,7 @@ const float kJunkZTarget = kJunkMinDistance;
 
 SpaceJunk *g_spaceJunk = 0;
 
-SpaceJunk::SpaceJunk(const tDisplayElementID id) : ScalingMovie(id) {
+SpaceJunk::SpaceJunk(const DisplayElementID id) : ScalingMovie(id) {
 	_timer.setScale(kJunkTimeScale);
 	_bouncing = false;
 	g_spaceJunk = this;
@@ -51,7 +51,7 @@ SpaceJunk::~SpaceJunk() {
 	g_spaceJunk = 0;
 }
 
-void SpaceJunk::launchJunk(int16 whichJunk, tCoordType xOrigin, tCoordType yOrigin) {	
+void SpaceJunk::launchJunk(int16 whichJunk, CoordType xOrigin, CoordType yOrigin) {	
 	_bouncing = false;
 	TimeValue startTime = whichJunk * 16 * 40;
 	TimeValue stopTime = startTime + 16 * 40;
@@ -76,7 +76,7 @@ void SpaceJunk::launchJunk(int16 whichJunk, tCoordType xOrigin, tCoordType yOrig
 	_timer.start();
 }
 
-void SpaceJunk::setCenter(const tCoordType centerX, const tCoordType centerY) {
+void SpaceJunk::setCenter(const CoordType centerX, const CoordType centerY) {
 	_center.x = centerX;
 	_center.y = centerY;
 
@@ -86,7 +86,7 @@ void SpaceJunk::setCenter(const tCoordType centerX, const tCoordType centerY) {
 	setBounds(r);
 }
 
-void SpaceJunk::setScaleSize(const tCoordType size) {
+void SpaceJunk::setScaleSize(const CoordType size) {
 	Common::Rect r;
 	r.left = _center.x - (size >> 1);
 	r.top = _center.y - (size >> 1);
@@ -101,7 +101,7 @@ void SpaceJunk::useIdleTime() {
 		Common::Point pt;
 		pt.x = linearInterp(0, _bounceTime, time, _bounceStart.x, _bounceStop.x);
 		pt.y = linearInterp(0, _bounceTime, time, _bounceStart.y, _bounceStop.y);
-		tCoordType size = linearInterp(0, _bounceTime, time, _bounceSizeStart, _bounceSizeStop);
+		CoordType size = linearInterp(0, _bounceTime, time, _bounceSizeStart, _bounceSizeStop);
 		setCenter(pt.x, pt.y);
 		setScaleSize(size);
 
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.h b/engines/pegasus/neighborhood/mars/spacejunk.h
index ba5aa75..03943b9 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.h
+++ b/engines/pegasus/neighborhood/mars/spacejunk.h
@@ -32,22 +32,22 @@
 
 namespace Pegasus {
 
-const tCoordType kJunkMaxScreenSize = 250;
+const CoordType kJunkMaxScreenSize = 250;
 
 const float kJunkSize = convertScreenVToSpaceY(kShuttleWindowMidV - kJunkMaxScreenSize / 2, kJunkMinDistance) -
 		convertScreenVToSpaceY(kShuttleWindowMidV + kJunkMaxScreenSize / 2, kJunkMinDistance);
 
 class SpaceJunk : public ScalingMovie, public Idler {
 public:
-	SpaceJunk(const tDisplayElementID);
+	SpaceJunk(const DisplayElementID);
 	virtual ~SpaceJunk();
 
-	void setCenter(const tCoordType, const tCoordType);
-	void setScaleSize(const tCoordType);
+	void setCenter(const CoordType, const CoordType);
+	void setScaleSize(const CoordType);
 
 	void useIdleTime();
 	
-	void launchJunk(int16, tCoordType, tCoordType);
+	void launchJunk(int16, CoordType, CoordType);
 	
 	void getJunkPosition(Point3D &);
 	bool isJunkFlying();
@@ -67,7 +67,7 @@ protected:
 	Common::Point _center;
 	bool _bouncing;
 	Common::Point _bounceStart, _bounceStop;
-	tCoordType _bounceSizeStart, _bounceSizeStop;
+	CoordType _bounceSizeStart, _bounceSizeStop;
 	TimeValue _bounceTime;
 };
 
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index ae7f80d..c836367 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -55,7 +55,7 @@ static const TimeValue kStridingSlop = 39;
 
 Neighborhood *g_neighborhood = 0;
 
-Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id)
+Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, NeighborhoodID id)
 		: InputHandler(nextHandler), IDObject(id), _vm(vm), _resName(resName), _navMovie(kNavMovieID), _stridingCallBack(this),
 		_neighborhoodNotification(kNeighborhoodNotificationID, (NotificationManager *)vm), _pushIn(kNoDisplayElement),
 		_turnPush(kTurnPushID), _croppedMovie(kCroppedMovieID) {
@@ -188,7 +188,7 @@ void Neighborhood::start() {
 	arriveAt(GameState.getNextRoom(), GameState.getNextDirection());
 }
 
-void Neighborhood::receiveNotification(Notification *, const tNotificationFlags flags) {
+void Neighborhood::receiveNotification(Notification *, const NotificationFlags flags) {
 	if ((flags & (kNeighborhoodMovieCompletedFlag | kTurnCompletedFlag)) != 0 && g_AIArea)
 		g_AIArea->unlockAI();
 	if (flags & kMoveForwardCompletedFlag)
@@ -205,7 +205,7 @@ void Neighborhood::receiveNotification(Notification *, const tNotificationFlags
 		die(_extraDeathReason);
 }
 
-void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
+void Neighborhood::arriveAt(RoomID room, DirectionConstant direction) {
 	if (g_map)
 		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), room, direction);
 
@@ -242,14 +242,14 @@ void Neighborhood::arriveAt(tRoomID room, tDirectionConstant direction) {
 
 //	These functions can be overridden to tweak the exact frames used.
 
-void Neighborhood::getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry) {
+void Neighborhood::getExitEntry(const RoomID room, const DirectionConstant direction, ExitTable::Entry &entry) {
 	entry = _exitTable.findEntry(room, direction, _currentAlternate);
 
 	if (entry.isEmpty())
 		entry = _exitTable.findEntry(room, direction, kNoAlternateID);
 }
 
-TimeValue Neighborhood::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+TimeValue Neighborhood::getViewTime(const RoomID room, const DirectionConstant direction) {
 	if (GameState.getOpenDoorRoom() == room && GameState.getOpenDoorDirection() == direction) {
 		// If we get here, the door entry for this location must exist.
 		DoorTable::Entry doorEntry = _doorTable.findEntry(room, direction, _currentAlternate);
@@ -268,14 +268,14 @@ TimeValue Neighborhood::getViewTime(const tRoomID room, const tDirectionConstant
 	return viewEntry.time;
 }
 
-void Neighborhood::getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry) {
+void Neighborhood::getDoorEntry(const RoomID room, const DirectionConstant direction, DoorTable::Entry &doorEntry) {
 	doorEntry = _doorTable.findEntry(room, direction, _currentAlternate);
 
 	if (doorEntry.isEmpty())
 		doorEntry = _doorTable.findEntry(room, direction, kNoAlternateID);
 }
 
-tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turnDirection) {
+DirectionConstant Neighborhood::getTurnEntry(const RoomID room, const DirectionConstant direction, const TurnDirection turnDirection) {
 	TurnTable::Entry turnEntry = _turnTable.findEntry(room, direction, turnDirection, _currentAlternate);
 
 	if (turnEntry.isEmpty())
@@ -284,18 +284,18 @@ tDirectionConstant Neighborhood::getTurnEntry(const tRoomID room, const tDirecti
 	return turnEntry.endDirection;
 }
 
-void Neighborhood::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {
+void Neighborhood::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &spotEntry) {
 	spotEntry = _spotTable.findEntry(room, direction, flags, _currentAlternate);
 
 	if (spotEntry.isEmpty())
 		spotEntry = _spotTable.findEntry(room, direction, flags, kNoAlternateID);
 }
 
-void Neighborhood::getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry) {
+void Neighborhood::getZoomEntry(const HotSpotID id, ZoomTable::Entry &zoomEntry) {
 	zoomEntry = _zoomTable.findEntry(id);
 }
 
-void Neighborhood::getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry) {
+void Neighborhood::getHotspotEntry(const HotSpotID id, HotspotInfoTable::Entry &hotspotEntry) {
 	hotspotEntry = _hotspotInfoTable.findEntry(id);
 }
 
@@ -307,7 +307,7 @@ void Neighborhood::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry)
 //
 //	"Can" functions: Called to see whether or not a user is allowed to do something
 
-tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
+CanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	DoorTable::Entry door;
 	
 	getExitEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), entry);
@@ -333,7 +333,7 @@ tCanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	return kCanMoveForward;
 }
 
-tCanTurnReason Neighborhood::canTurn(tTurnDirection turnDirection, tDirectionConstant &nextDir) {
+CanTurnReason Neighborhood::canTurn(TurnDirection turnDirection, DirectionConstant &nextDir) {
 	nextDir = getTurnEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), turnDirection);
 
 	if (nextDir == kNoDirection)
@@ -342,7 +342,7 @@ tCanTurnReason Neighborhood::canTurn(tTurnDirection turnDirection, tDirectionCon
 	return kCanTurn;
 }
 
-tCanOpenDoorReason Neighborhood::canOpenDoor(DoorTable::Entry &entry) {
+CanOpenDoorReason Neighborhood::canOpenDoor(DoorTable::Entry &entry) {
 	getDoorEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), entry);
 
 	if (entry.flags & kDoorPresentMask) {
@@ -390,7 +390,7 @@ void Neighborhood::createNeighborhoodSpots() {
 
 void Neighborhood::popActionQueue() {	
 	if (!_actionQueue.empty()) {
-		tQueueRequest topRequest = _actionQueue.pop();
+		QueueRequest topRequest = _actionQueue.pop();
 
 		switch (topRequest.requestType) {
 		case kNavExtraRequest:
@@ -410,7 +410,7 @@ void Neighborhood::popActionQueue() {
 
 void Neighborhood::serviceActionQueue() {
 	if (!_actionQueue.empty()) {
-		tQueueRequest &topRequest = _actionQueue.front();
+		QueueRequest &topRequest = _actionQueue.front();
 
 		if (!topRequest.playing) {
 			topRequest.playing = true;
@@ -441,10 +441,10 @@ void Neighborhood::serviceActionQueue() {
 	}
 }
 
-void Neighborhood::requestAction(const tQueueRequestType requestType, const tExtraID extra, const TimeValue in, const TimeValue out,
-		const tInputBits interruptionFilter, const tNotificationFlags flags) {
+void Neighborhood::requestAction(const QueueRequestType requestType, const ExtraID extra, const TimeValue in, const TimeValue out,
+		const InputBits interruptionFilter, const NotificationFlags flags) {
 
-	tQueueRequest request;
+	QueueRequest request;
 	
 	request.requestType = requestType;
 	request.extra = extra;
@@ -459,11 +459,11 @@ void Neighborhood::requestAction(const tQueueRequestType requestType, const tExt
 		serviceActionQueue();
 }
 
-void Neighborhood::requestExtraSequence(const tExtraID whichExtra, const tNotificationFlags flags, const tInputBits interruptionFilter) {
+void Neighborhood::requestExtraSequence(const ExtraID whichExtra, const NotificationFlags flags, const InputBits interruptionFilter) {
 	requestAction(kNavExtraRequest, whichExtra, 0, 0, interruptionFilter, flags);
 }
 
-void Neighborhood::requestSpotSound(const TimeValue in, const TimeValue out, const tInputBits interruptionFilter, const tNotificationFlags flags) {
+void Neighborhood::requestSpotSound(const TimeValue in, const TimeValue out, const InputBits interruptionFilter, const NotificationFlags flags) {
 	requestAction(kSpotSoundRequest, 0xFFFFFFFF, in, out, interruptionFilter, flags);
 }
 
@@ -486,16 +486,16 @@ void Neighborhood::playSpotSoundSync(const TimeValue in, const TimeValue out) {
 	}
 }
 
-void Neighborhood::requestDelay(const TimeValue delayDuration, const TimeScale delayScale, const tInputBits interruptionFilter, const tNotificationFlags flags) {
+void Neighborhood::requestDelay(const TimeValue delayDuration, const TimeScale delayScale, const InputBits interruptionFilter, const NotificationFlags flags) {
 	requestAction(kDelayRequest, 0xFFFFFFFF, delayDuration, delayScale, interruptionFilter, flags);
 }
 
-bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2) {
+bool operator==(const QueueRequest &arg1, const QueueRequest &arg2) {
 	return arg1.requestType == arg2.requestType && arg1.extra == arg2.extra &&
 			arg1.start == arg2.start && arg1.stop == arg2.stop;
 }
 
-bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2) {
+bool operator!=(const QueueRequest &arg1, const QueueRequest &arg2) {
 	return !operator==(arg1, arg2);
 }
 
@@ -543,7 +543,7 @@ bool Neighborhood::okayToJump() {
 	return !_vm->playerHasItemID(kGasCanister) && !_vm->playerHasItemID(kMachineGun);
 }
 
-tAirQuality Neighborhood::getAirQuality(const tRoomID) {
+AirQuality Neighborhood::getAirQuality(const RoomID) {
 	return kAirQualityGood;
 }
 
@@ -594,7 +594,7 @@ void Neighborhood::stopStriding() {
 }
 
 //	Compass support
-int16 Neighborhood::getStaticCompassAngle(const tRoomID, const tDirectionConstant dir) {
+int16 Neighborhood::getStaticCompassAngle(const RoomID, const DirectionConstant dir) {
 	//	North, south, east, west
 	static const int16 compassAngles[] = { 0, 180, 90, 270 };
 	return compassAngles[dir];
@@ -615,7 +615,7 @@ void Neighborhood::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMo
 	compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, startAngle, exitEntry.movieEnd, stopAngle);
 }
 
-void Neighborhood::scheduleNavCallBack(tNotificationFlags flags) {
+void Neighborhood::scheduleNavCallBack(NotificationFlags flags) {
 	_navMovieCallBack.cancelCallBack();
 
 	if (flags != 0) {
@@ -624,19 +624,19 @@ void Neighborhood::scheduleNavCallBack(tNotificationFlags flags) {
 	}
 }
 
-void Neighborhood::scheduleStridingCallBack(const TimeValue strideStop, tNotificationFlags flags) {	
+void Neighborhood::scheduleStridingCallBack(const TimeValue strideStop, NotificationFlags flags) {	
 	_stridingCallBack.cancelCallBack();
 
 	if (flags != 0)
 		_stridingCallBack.scheduleCallBack(kTriggerTimeFwd, strideStop, _navMovie.getScale());
 }
 
-void Neighborhood::moveNavTo(const tCoordType h, const tCoordType v) {
-	tCoordType oldH, oldV;
+void Neighborhood::moveNavTo(const CoordType h, const CoordType v) {
+	CoordType oldH, oldV;
 	_navMovie.getLocation(oldH, oldV);
 
-	tCoordType offH = h - oldH;
-	tCoordType offV = v - oldV;
+	CoordType offH = h - oldH;
+	CoordType offV = v - oldV;
 
 	_navMovie.moveElementTo(h, v);
 	_turnPush.moveElementTo(h, v);
@@ -663,10 +663,10 @@ void Neighborhood::activateHotspots() {
 }
 
 void Neighborhood::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {	
-	tHotSpotFlags flags = clickedSpot->getHotspotFlags();
+	HotSpotFlags flags = clickedSpot->getHotspotFlags();
 
 	if ((flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag)) != 0) {
-		tItemID itemID = kNoItemID;
+		ItemID itemID = kNoItemID;
 
 		for (HotspotInfoTable::iterator it = _hotspotInfoTable.begin(); it != _hotspotInfoTable.end(); it++) {
 			if (it->hotspot == clickedSpot->getObjectID()) {
@@ -703,7 +703,7 @@ void Neighborhood::clickInHotspot(const Input &input, const Hotspot *clickedSpot
 	}
 }
 
-void Neighborhood::cantMoveThatWay(tCanMoveForwardReason reason) {
+void Neighborhood::cantMoveThatWay(CanMoveForwardReason reason) {
 	switch (reason) {
 	case kCantMoveDoorClosed:
 	case kCantMoveDoorLocked:
@@ -718,11 +718,11 @@ void Neighborhood::cantMoveThatWay(tCanMoveForwardReason reason) {
 	}
 }
 
-void Neighborhood::cantOpenDoor(tCanOpenDoorReason) {
+void Neighborhood::cantOpenDoor(CanOpenDoorReason) {
 	bumpIntoWall();
 }
 
-void Neighborhood::turnTo(const tDirectionConstant direction) {
+void Neighborhood::turnTo(const DirectionConstant direction) {
 	if (g_map)
 		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), direction);
 
@@ -796,7 +796,7 @@ void Neighborhood::doorOpened() {
 
 void Neighborhood::moveForward() {
 	ExitTable::Entry exitEntry;
-	tCanMoveForwardReason moveReason = canMoveForward(exitEntry);
+	CanMoveForwardReason moveReason = canMoveForward(exitEntry);
 
 	if (moveReason == kCanMoveForward)
 		startExitMovie(exitEntry);
@@ -804,9 +804,9 @@ void Neighborhood::moveForward() {
 		cantMoveThatWay(moveReason);
 }
 
-void Neighborhood::turn(const tTurnDirection turnDirection) {
-	tDirectionConstant nextDir;	
-	tCanTurnReason turnReason = canTurn(turnDirection, nextDir);
+void Neighborhood::turn(const TurnDirection turnDirection) {
+	DirectionConstant nextDir;	
+	CanTurnReason turnReason = canTurn(turnDirection, nextDir);
 
 	if (turnReason == kCanTurn)
 		startTurnPush(turnDirection, getViewTime(GameState.getCurrentRoom(), nextDir), nextDir);
@@ -832,7 +832,7 @@ void Neighborhood::turnDown() {
 
 void Neighborhood::openDoor() {
 	DoorTable::Entry door;	
-	tCanOpenDoorReason doorReason = canOpenDoor(door);
+	CanOpenDoorReason doorReason = canOpenDoor(door);
 
 	if (doorReason == kCanOpenDoor)
 		startDoorOpenMovie(door.movieStart, door.movieEnd);
@@ -851,7 +851,7 @@ void Neighborhood::updateViewFrame() {
 	showViewFrame(getViewTime(GameState.getCurrentRoom(), GameState.getCurrentDirection()));
 }
 
-void Neighborhood::startSpotLoop(TimeValue startTime, TimeValue stopTime, tNotificationFlags flags) {
+void Neighborhood::startSpotLoop(TimeValue startTime, TimeValue stopTime, NotificationFlags flags) {
 	_turnPush.hide();
 	startMovieSequence(startTime, stopTime, flags, true, kFilterAllInput);
 }
@@ -873,7 +873,7 @@ void Neighborhood::showViewFrame(TimeValue viewTime) {
 	}
 }
 
-void Neighborhood::startExtraSequence(const tExtraID extraID, const tNotificationFlags flags, const tInputBits interruptionFilter) {
+void Neighborhood::startExtraSequence(const ExtraID extraID, const NotificationFlags flags, const InputBits interruptionFilter) {
 	ExtraTable::Entry entry;
 	getExtraEntry(extraID, entry);
 
@@ -881,12 +881,12 @@ void Neighborhood::startExtraSequence(const tExtraID extraID, const tNotificatio
 		playExtraMovie(entry, flags, interruptionFilter);
 }
 
-bool Neighborhood::startExtraSequenceSync(const tExtraID extraID, const tInputBits interruptionFilter) {
+bool Neighborhood::startExtraSequenceSync(const ExtraID extraID, const InputBits interruptionFilter) {
 	InputHandler::getCurrentInputDevice()->waitInput(interruptionFilter);
 	return prepareExtraSync(extraID) && waitMovieFinish(&_navMovie, interruptionFilter);
 }
 
-void Neighborhood::loopExtraSequence(const uint32 extraID, tNotificationFlags flags) {
+void Neighborhood::loopExtraSequence(const uint32 extraID, NotificationFlags flags) {
 	ExtraTable::Entry entry;
 	getExtraEntry(extraID, entry);
 	
@@ -900,12 +900,12 @@ bool Neighborhood::navMoviePlaying() {
 	return _navMovie.isRunning();
 }
 
-void Neighborhood::playDeathExtra(tExtraID extra, tDeathReason deathReason) {
+void Neighborhood::playDeathExtra(ExtraID extra, DeathReason deathReason) {
 	_extraDeathReason = deathReason;
 	startExtraSequence(extra, kDeathExtraCompletedFlag, kFilterNoInput);
 }
 
-void Neighborhood::die(const tDeathReason deathReason) {
+void Neighborhood::die(const DeathReason deathReason) {
 	loadLoopSound1("");
 	loadLoopSound2("");
 	_vm->die(deathReason);
@@ -930,7 +930,7 @@ void Neighborhood::setAmbienceLevel(const uint16 ambientLevel) {
 }
 
 // Force the exit taken from (room, direction, alternate) to come to a stop.
-void Neighborhood::forceStridingStop(const tRoomID room, const tDirectionConstant direction, const tAlternateID alternate) {
+void Neighborhood::forceStridingStop(const RoomID room, const DirectionConstant direction, const AlternateID alternate) {
 	ExitTable::Entry entry = _exitTable.findEntry(room, direction, alternate);
 
 	if (entry.movieStart != 0xffffffff) {
@@ -951,7 +951,7 @@ void Neighborhood::forceStridingStop(const tRoomID room, const tDirectionConstan
 }
 
 // Restore the exit taken from (room, direction, alternate) to stride.
-void Neighborhood::restoreStriding(const tRoomID room, const tDirectionConstant direction, const tAlternateID alternate) {
+void Neighborhood::restoreStriding(const RoomID room, const DirectionConstant direction, const AlternateID alternate) {
 	ExitTable::Entry entry = _exitTable.findEntry(room, direction, alternate);
 
 	if (entry.movieStart != 0xffffffff) {
@@ -971,7 +971,7 @@ void Neighborhood::restoreStriding(const tRoomID room, const tDirectionConstant
 	}
 }
 
-HotspotInfoTable::Entry *Neighborhood::findHotspotEntry(const tHotSpotID id) {
+HotspotInfoTable::Entry *Neighborhood::findHotspotEntry(const HotSpotID id) {
 	for (HotspotInfoTable::iterator it = _hotspotInfoTable.begin(); it != _hotspotInfoTable.end(); it++)
 		if (it->hotspot == id)
 			return &(*it);
@@ -1031,7 +1031,7 @@ void Neighborhood::startDoorOpenMovie(const TimeValue startTime, const TimeValue
 	startMovieSequence(startTime, stopTime, kDoorOpenCompletedFlag, kFilterNoInput, false);
 }
 
-void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeValue newView, const tDirectionConstant nextDir) {
+void Neighborhood::startTurnPush(const TurnDirection turnDirection, const TimeValue newView, const DirectionConstant nextDir) {
 	if (g_AIArea)
 		g_AIArea->lockAIOut();
 
@@ -1114,7 +1114,7 @@ void Neighborhood::startTurnPush(const tTurnDirection turnDirection, const TimeV
 	_neighborhoodNotification.setNotificationFlags(kTurnCompletedFlag, kTurnCompletedFlag);
 }
 
-void Neighborhood::playExtraMovie(const ExtraTable::Entry &extraEntry, const tNotificationFlags flags, const tInputBits interruptionInput) {
+void Neighborhood::playExtraMovie(const ExtraTable::Entry &extraEntry, const NotificationFlags flags, const InputBits interruptionInput) {
 	FaderMoveSpec compassMove;
 
 	if (g_compass)
@@ -1128,7 +1128,7 @@ void Neighborhood::playExtraMovie(const ExtraTable::Entry &extraEntry, const tNo
 		g_compass->startFader(compassMove);
 }
 
-void Neighborhood::activateCurrentView(const tRoomID room, const tDirectionConstant direction, tSpotFlags flag) {
+void Neighborhood::activateCurrentView(const RoomID room, const DirectionConstant direction, SpotFlags flag) {
 	SpotTable::Entry entry;
 	findSpotEntry(room, direction, flag, entry);
 
@@ -1161,7 +1161,7 @@ void Neighborhood::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *h
 			if (item &&	item->getItemNeighborhood() == getObjectID())
 				hotspot->setActive();
 		} else {
-			tHotSpotFlags flags = hotspot->getHotspotFlags();
+			HotSpotFlags flags = hotspot->getHotspotFlags();
 
 			if ((flags & kNeighborhoodSpotFlag) != 0) {
 				if (flags & kOpenDoorSpotFlag) {
@@ -1189,8 +1189,8 @@ void Neighborhood::startSpotOnceOnly(TimeValue startTime, TimeValue stopTime) {
 	startMovieSequence(startTime, stopTime, kSpotCompletedFlag, kFilterNoInput, false);
 }
 
-void Neighborhood::startMovieSequence(const TimeValue startTime, const TimeValue stopTime, tNotificationFlags flags, bool loopSequence,
-		const tInputBits interruptionInput, const TimeValue strideStop) {
+void Neighborhood::startMovieSequence(const TimeValue startTime, const TimeValue stopTime, NotificationFlags flags, bool loopSequence,
+		const InputBits interruptionInput, const TimeValue strideStop) {
 	if (!loopSequence && g_AIArea)
 		g_AIArea->lockAIOut();
 	
@@ -1269,7 +1269,7 @@ void Neighborhood::throwAwayInterface() {
 	delete g_interface;
 }
 
-bool Neighborhood::prepareExtraSync(const tExtraID extraID) {
+bool Neighborhood::prepareExtraSync(const ExtraID extraID) {
 	ExtraTable::Entry extraEntry;
 	FaderMoveSpec compassMove;
 	
@@ -1308,7 +1308,7 @@ bool Neighborhood::prepareExtraSync(const tExtraID extraID) {
 	return result;
 }
 
-bool Neighborhood::waitMovieFinish(Movie *movie, const tInputBits interruptionFilter) {
+bool Neighborhood::waitMovieFinish(Movie *movie, const InputBits interruptionFilter) {
 	Input input;
 	bool result = true;
 	bool saveAllowed = _vm->swapSaveAllowed(false);
@@ -1334,7 +1334,7 @@ bool Neighborhood::waitMovieFinish(Movie *movie, const tInputBits interruptionFi
 	return result;
 }
 
-tInputBits Neighborhood::getInputFilter() {
+InputBits Neighborhood::getInputFilter() {
 	return _interruptionFilter & InputHandler::getInputFilter();
 }
 
@@ -1396,14 +1396,14 @@ void Neighborhood::setUpAIRules() {
 	}
 }
 
-GameInteraction *Neighborhood::makeInteraction(const tInteractionID interactionID) {
+GameInteraction *Neighborhood::makeInteraction(const InteractionID interactionID) {
 	if (interactionID == kNoInteractionID)
 		return 0;
 
 	return new GameInteraction(interactionID, this);
 }
 
-void Neighborhood::newInteraction(const tInteractionID interactionID) {
+void Neighborhood::newInteraction(const InteractionID interactionID) {
 	GameInteraction *interaction = makeInteraction(interactionID);
 	_doneWithInteraction = false;
 
@@ -1541,8 +1541,8 @@ void Neighborhood::showExtraView(uint32 extraID) {
 		showViewFrame(entry.movieEnd - 1);
 }
 
-void Neighborhood::startExtraLongSequence(const uint32 firstExtra, const uint32 lastExtra, tNotificationFlags flags,
-		const tInputBits interruptionFilter) {
+void Neighborhood::startExtraLongSequence(const uint32 firstExtra, const uint32 lastExtra, NotificationFlags flags,
+		const InputBits interruptionFilter) {
 	ExtraTable::Entry firstEntry, lastEntry;
 	getExtraEntry(firstExtra, firstEntry);
 
@@ -1554,7 +1554,7 @@ void Neighborhood::startExtraLongSequence(const uint32 firstExtra, const uint32
 	}
 }
 
-void Neighborhood::openCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) {
+void Neighborhood::openCroppedMovie(const Common::String &movieName, CoordType left, CoordType top) {
 	if (_croppedMovie.isMovieValid())
 		closeCroppedMovie();
 
@@ -1564,7 +1564,7 @@ void Neighborhood::openCroppedMovie(const Common::String &movieName, tCoordType
 	_croppedMovie.show();
 }
 
-void Neighborhood::loopCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) {
+void Neighborhood::loopCroppedMovie(const Common::String &movieName, CoordType left, CoordType top) {
 	openCroppedMovie(movieName, left, top);
 	_croppedMovie.redrawMovieWorld();
 	_croppedMovie.setFlags(kLoopTimeBase);
@@ -1575,12 +1575,12 @@ void Neighborhood::closeCroppedMovie() {
 	_croppedMovie.releaseMovie();
 }
 
-void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, tCoordType left, tCoordType top, const tInputBits interruptionFilter) {	
+void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordType left, CoordType top, const InputBits interruptionFilter) {	
 	openCroppedMovie(movieName, left, top);
 	_croppedMovie.redrawMovieWorld();
 	_croppedMovie.start();
 
-	tInputBits oldInterruptionFilter = _interruptionFilter;
+	InputBits oldInterruptionFilter = _interruptionFilter;
 	if (oldInterruptionFilter != kFilterNoInput)
 		_interruptionFilter = kFilterNoInput;
 
@@ -1651,12 +1651,12 @@ void Neighborhood::handleInput(const Input &input, const Hotspot *cursorSpot) {
 	InputHandler::handleInput(input, cursorSpot);
 }
 
-void Neighborhood::setHotspotFlags(const tHotSpotID id, const tHotSpotFlags flags) {
+void Neighborhood::setHotspotFlags(const HotSpotID id, const HotSpotFlags flags) {
 	Hotspot *hotspot = g_allHotspots.findHotspotByID(id);
 	hotspot->setMaskedHotspotFlags(flags, flags);
 }
 
-void Neighborhood::setIsItemTaken(const tItemID id) {
+void Neighborhood::setIsItemTaken(const ItemID id) {
 	GameState.setTakenItemID(id, _vm->playerHasItemID(id));
 }
 
@@ -1693,7 +1693,7 @@ void Neighborhood::downButton(const Input &) {
 	}
 }
 
-void Neighborhood::initOnePicture(Picture *picture, const Common::String &pictureName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) {
+void Neighborhood::initOnePicture(Picture *picture, const Common::String &pictureName, DisplayOrder order, CoordType left, CoordType top, bool show) {
 	picture->initFromPICTFile(pictureName);
 	picture->setDisplayOrder(order);
 	picture->moveElementTo(left, top);
@@ -1702,7 +1702,7 @@ void Neighborhood::initOnePicture(Picture *picture, const Common::String &pictur
 		picture->show();
 }
 
-void Neighborhood::initOneMovie(Movie *movie, const Common::String &movieName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) {
+void Neighborhood::initOneMovie(Movie *movie, const Common::String &movieName, DisplayOrder order, CoordType left, CoordType top, bool show) {
 	movie->initFromMovieFile(movieName);
 	movie->setDisplayOrder(order);
 	movie->moveElementTo(left, top);
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index c11fe78..7b1f867 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -52,24 +52,24 @@ namespace Pegasus {
 class PegasusEngine;
 
 // Pegasus Prime neighborhood id's
-const tNeighborhoodID kCaldoriaID = 0;
-const tNeighborhoodID kFullTSAID = 1;
-const tNeighborhoodID kFinalTSAID = 2;
-const tNeighborhoodID kTinyTSAID = 3;
-const tNeighborhoodID kPrehistoricID = 4;
-const tNeighborhoodID kMarsID = 5;
-const tNeighborhoodID kWSCID = 6;
-const tNeighborhoodID kNoradAlphaID = 7;
-const tNeighborhoodID kNoradDeltaID = 8;
+const NeighborhoodID kCaldoriaID = 0;
+const NeighborhoodID kFullTSAID = 1;
+const NeighborhoodID kFinalTSAID = 2;
+const NeighborhoodID kTinyTSAID = 3;
+const NeighborhoodID kPrehistoricID = 4;
+const NeighborhoodID kMarsID = 5;
+const NeighborhoodID kWSCID = 6;
+const NeighborhoodID kNoradAlphaID = 7;
+const NeighborhoodID kNoradDeltaID = 8;
 // The sub chase is not really a neighborhood, but we define a constant that is used
 // to allow an easy transition out of Norad Alpha.
-const tNeighborhoodID kNoradSubChaseID = 1000;
+const NeighborhoodID kNoradSubChaseID = 1000;
 
 const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
 const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
 const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
 
-enum tQueueRequestType {
+enum QueueRequestType {
 	kNavExtraRequest,
 	kSpotSoundRequest,
 	kDelayRequest
@@ -78,18 +78,18 @@ enum tQueueRequestType {
 // For delay requests, start is interpreted as the total delay and stop is interpreted
 // as the scale the delay is in.
 // For extra requests, start and stop are not used.
-struct tQueueRequest {
-	tQueueRequestType requestType;
-	tExtraID extra;
+struct QueueRequest {
+	QueueRequestType requestType;
+	ExtraID extra;
 	TimeValue start, stop;
-	tInputBits interruptionFilter;
+	InputBits interruptionFilter;
 	bool playing;
-	tNotificationFlags flags;
+	NotificationFlags flags;
 	Notification *notification;
 };
 
-bool operator==(const tQueueRequest &arg1, const tQueueRequest &arg2);
-bool operator!=(const tQueueRequest &arg1, const tQueueRequest &arg2);
+bool operator==(const QueueRequest &arg1, const QueueRequest &arg2);
+bool operator!=(const QueueRequest &arg1, const QueueRequest &arg2);
 
 class GameInteraction;
 class Item;
@@ -106,40 +106,40 @@ protected:
 	Neighborhood *_neighborhood;
 };
 
-typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue;
+typedef Common::Queue<QueueRequest> NeighborhoodActionQueue;
 
 class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler {
 friend class StriderCallBack;
 friend void timerFunction(FunctionPtr *, void *);
 
 public:
-	Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id);
+	Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, NeighborhoodID id);
 	virtual ~Neighborhood();
 
 	virtual void init();
 	virtual void start();
-	virtual void moveNavTo(const tCoordType, const tCoordType);
-	virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0;
+	virtual void moveNavTo(const CoordType, const CoordType);
+	virtual void checkContinuePoint(const RoomID, const DirectionConstant) = 0;
 	void makeContinuePoint();
 
 	virtual void activateHotspots();
 	virtual void clickInHotspot(const Input &, const Hotspot *);
 
-	virtual tCanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
-	virtual tCanTurnReason canTurn(tTurnDirection turn, tDirectionConstant &nextDir);
-	virtual tCanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
+	virtual CanMoveForwardReason canMoveForward(ExitTable::Entry &entry);
+	virtual CanTurnReason canTurn(TurnDirection turn, DirectionConstant &nextDir);
+	virtual CanOpenDoorReason canOpenDoor(DoorTable::Entry &entry);
 
-	virtual void cantMoveThatWay(tCanMoveForwardReason);
-	virtual void cantTurnThatWay(tCanTurnReason) {}
-	virtual void cantOpenDoor(tCanOpenDoorReason);
-	virtual void arriveAt(tRoomID room, tDirectionConstant direction);
-	virtual void turnTo(const tDirectionConstant);
+	virtual void cantMoveThatWay(CanMoveForwardReason);
+	virtual void cantTurnThatWay(CanTurnReason) {}
+	virtual void cantOpenDoor(CanOpenDoorReason);
+	virtual void arriveAt(RoomID room, DirectionConstant direction);
+	virtual void turnTo(const DirectionConstant);
 	virtual void spotCompleted();
 	virtual void doorOpened();
-	virtual void closeDoorOffScreen(const tRoomID, const tDirectionConstant) {}
+	virtual void closeDoorOffScreen(const RoomID, const DirectionConstant) {}
 
 	virtual void moveForward();
-	virtual void turn(const tTurnDirection);
+	virtual void turn(const TurnDirection);
 	virtual void turnLeft();
 	virtual void turnRight();
 	virtual void turnUp();
@@ -149,43 +149,43 @@ public:
 
 	virtual void updateViewFrame();
 	
-	void requestExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
-	void requestSpotSound(const TimeValue, const TimeValue, const tInputBits interruptionFilter, const tNotificationFlags);
+	void requestExtraSequence(const ExtraID, const NotificationFlags, const InputBits interruptionFilter);
+	void requestSpotSound(const TimeValue, const TimeValue, const InputBits interruptionFilter, const NotificationFlags);
 	void playSpotSoundSync(const TimeValue in, const TimeValue out);
-	void requestDelay(const TimeValue, const TimeScale, const tInputBits interruptionFilter, const tNotificationFlags);
+	void requestDelay(const TimeValue, const TimeScale, const InputBits interruptionFilter, const NotificationFlags);
 
 	Notification *getNeighborhoodNotification() { return &_neighborhoodNotification; }
 
 	virtual void getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry);
-	virtual void startSpotLoop(TimeValue, TimeValue, tNotificationFlags = 0);
+	virtual void startSpotLoop(TimeValue, TimeValue, NotificationFlags = 0);
 	virtual bool actionQueueEmpty() { return _actionQueue.empty(); }
 	virtual void showViewFrame(TimeValue);
-	virtual void findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry);
-	virtual void startExtraSequence(const tExtraID, const tNotificationFlags, const tInputBits interruptionFilter);
-	bool startExtraSequenceSync(const tExtraID, const tInputBits);
-	virtual void loopExtraSequence(const uint32, tNotificationFlags = 0);
+	virtual void findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &spotEntry);
+	virtual void startExtraSequence(const ExtraID, const NotificationFlags, const InputBits interruptionFilter);
+	bool startExtraSequenceSync(const ExtraID, const InputBits);
+	virtual void loopExtraSequence(const uint32, NotificationFlags = 0);
 	int32 getLastExtra() const { return _lastExtra; }
-	virtual void scheduleNavCallBack(tNotificationFlags);
+	virtual void scheduleNavCallBack(NotificationFlags);
 	
 	Movie *getNavMovie() { return &_navMovie; }
 	bool navMoviePlaying();
 	
-	void setCurrentAlternate(const tAlternateID alt) { _currentAlternate = alt; }
-	tAlternateID getCurrentAlternate() const { return _currentAlternate; }
+	void setCurrentAlternate(const AlternateID alt) { _currentAlternate = alt; }
+	AlternateID getCurrentAlternate() const { return _currentAlternate; }
 	
-	void setCurrentActivation(const tHotSpotActivationID a) { _currentActivation = a; }
-	tHotSpotActivationID getCurrentActivation() { return _currentActivation; }
+	void setCurrentActivation(const HotSpotActivationID a) { _currentActivation = a; }
+	HotSpotActivationID getCurrentActivation() { return _currentActivation; }
 	
-	virtual void playDeathExtra(tExtraID, tDeathReason);
-	virtual void die(const tDeathReason);
+	virtual void playDeathExtra(ExtraID, DeathReason);
+	virtual void die(const DeathReason);
 
 	virtual void setSoundFXLevel(const uint16);
 	virtual void setAmbienceLevel(const uint16);
 	
-	void forceStridingStop(const tRoomID, const tDirectionConstant, const tAlternateID);
-	void restoreStriding(const tRoomID, const tDirectionConstant, const tAlternateID);
+	void forceStridingStop(const RoomID, const DirectionConstant, const AlternateID);
+	void restoreStriding(const RoomID, const DirectionConstant, const AlternateID);
 	
-	HotspotInfoTable::Entry *findHotspotEntry(const tHotSpotID);
+	HotspotInfoTable::Entry *findHotspotEntry(const HotSpotID);
 	
 	Push *getTurnPush() { return &_turnPush; }
 	Picture *getTurnPushPicture() { return &_pushIn; }
@@ -208,7 +208,7 @@ public:
 
 	virtual bool okayToJump();
 
-	virtual tAirQuality getAirQuality(const tRoomID);
+	virtual AirQuality getAirQuality(const RoomID);
 	virtual void checkAirMask() {}
 	virtual void checkFlashlight() {}
 	virtual void shieldOn() {}
@@ -229,18 +229,18 @@ public:
 	virtual void dropItemIntoRoom(Item *, Hotspot *);
 	virtual Hotspot *getItemScreenSpot(Item *, DisplayElement *) { return 0; }
 
-	virtual GameInteraction *makeInteraction(const tInteractionID);
+	virtual GameInteraction *makeInteraction(const InteractionID);
 	virtual void requestDeleteCurrentInteraction() { _doneWithInteraction = true; }
 
 	virtual uint16 getDateResID() const = 0;
 
 	virtual void showExtraView(uint32);
-	virtual void startExtraLongSequence(const uint32, const uint32, tNotificationFlags, const tInputBits interruptionFilter);
+	virtual void startExtraLongSequence(const uint32, const uint32, NotificationFlags, const InputBits interruptionFilter);
 	
-	void openCroppedMovie(const Common::String &, tCoordType, tCoordType);
-	void loopCroppedMovie(const Common::String &, tCoordType, tCoordType);
+	void openCroppedMovie(const Common::String &, CoordType, CoordType);
+	void loopCroppedMovie(const Common::String &, CoordType, CoordType);
 	void closeCroppedMovie();
-	void playCroppedMovieOnce(const Common::String &, tCoordType, tCoordType, const tInputBits interruptionFilter = kFilterNoInput);
+	void playCroppedMovieOnce(const Common::String &, CoordType, CoordType, const InputBits interruptionFilter = kFilterNoInput);
 
 	void playMovieSegment(Movie *, TimeValue = 0, TimeValue = 0xffffffff);
 
@@ -258,15 +258,15 @@ protected:
 	virtual Common::String getNavMovieName() = 0;
 
 	// Notification function.
-	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual void receiveNotification(Notification *, const NotificationFlags);
 
 	// Map info functions.
-	virtual void getExitEntry(const tRoomID room, const tDirectionConstant direction, ExitTable::Entry &entry);
-	virtual TimeValue getViewTime(const tRoomID room, const tDirectionConstant direction);
-	virtual void getDoorEntry(const tRoomID room, const tDirectionConstant direction, DoorTable::Entry &doorEntry);
-	virtual tDirectionConstant getTurnEntry(const tRoomID room, const tDirectionConstant direction, const tTurnDirection turn);
-	virtual void getZoomEntry(const tHotSpotID id, ZoomTable::Entry &zoomEntry);
-	virtual void getHotspotEntry(const tHotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
+	virtual void getExitEntry(const RoomID room, const DirectionConstant direction, ExitTable::Entry &entry);
+	virtual TimeValue getViewTime(const RoomID room, const DirectionConstant direction);
+	virtual void getDoorEntry(const RoomID room, const DirectionConstant direction, DoorTable::Entry &doorEntry);
+	virtual DirectionConstant getTurnEntry(const RoomID room, const DirectionConstant direction, const TurnDirection turn);
+	virtual void getZoomEntry(const HotSpotID id, ZoomTable::Entry &zoomEntry);
+	virtual void getHotspotEntry(const HotSpotID id, HotspotInfoTable::Entry &hotspotEntry);
 
 	// Nav movie sequences.
 	virtual void startExitMovie(const ExitTable::Entry &);
@@ -274,20 +274,20 @@ protected:
 	virtual void stopStriding();
 	virtual void checkStriding();
 	virtual bool stillMoveForward();
-	virtual void scheduleStridingCallBack(const TimeValue, tNotificationFlags flags);
+	virtual void scheduleStridingCallBack(const TimeValue, NotificationFlags flags);
 	virtual void startZoomMovie(const ZoomTable::Entry &);
 	virtual void startDoorOpenMovie(const TimeValue, const TimeValue);
-	virtual void startTurnPush(const tTurnDirection, const TimeValue, const tDirectionConstant);
-	virtual void playExtraMovie(const ExtraTable::Entry &, const tNotificationFlags, const tInputBits interruptionFilter);
+	virtual void startTurnPush(const TurnDirection, const TimeValue, const DirectionConstant);
+	virtual void playExtraMovie(const ExtraTable::Entry &, const NotificationFlags, const InputBits interruptionFilter);
 	
-	virtual void activateCurrentView(const tRoomID, const tDirectionConstant, tSpotFlags);
+	virtual void activateCurrentView(const RoomID, const DirectionConstant, SpotFlags);
 	
 	virtual void activateOneHotspot(HotspotInfoTable::Entry &, Hotspot *);
 	
 	virtual void startSpotOnceOnly(TimeValue, TimeValue);
 	
-	virtual void startMovieSequence(const TimeValue, const TimeValue, tNotificationFlags,
-  			bool loopSequence, const tInputBits interruptionFilter, const TimeValue strideStop = 0xffffffff);
+	virtual void startMovieSequence(const TimeValue, const TimeValue, NotificationFlags,
+  			bool loopSequence, const InputBits interruptionFilter, const TimeValue strideStop = 0xffffffff);
 	
 	virtual void createNeighborhoodSpots();
 	
@@ -298,34 +298,34 @@ protected:
 	// Action queue stuff
 	void popActionQueue();
 	void serviceActionQueue();
-	void requestAction(const tQueueRequestType, const tExtraID, const TimeValue, const TimeValue, const tInputBits, const tNotificationFlags);
+	void requestAction(const QueueRequestType, const ExtraID, const TimeValue, const TimeValue, const InputBits, const NotificationFlags);
 
-	virtual bool prepareExtraSync(const tExtraID);
-	virtual bool waitMovieFinish(Movie *, const tInputBits);
+	virtual bool prepareExtraSync(const ExtraID);
+	virtual bool waitMovieFinish(Movie *, const InputBits);
 	
-	virtual tInputBits getInputFilter();
+	virtual InputBits getInputFilter();
 
 	// Misc.
-	virtual int16 getStaticCompassAngle(const tRoomID, const tDirectionConstant dir);
+	virtual int16 getStaticCompassAngle(const RoomID, const DirectionConstant dir);
 	virtual void getExitCompassMove(const ExitTable::Entry &, FaderMoveSpec &);
 	virtual void getZoomCompassMove(const ZoomTable::Entry &, FaderMoveSpec&);
 	virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&);
 
 	virtual void setUpAIRules();
-	virtual void setHotspotFlags(const tHotSpotID, const tHotSpotFlags);
-	virtual void setIsItemTaken(const tItemID);
+	virtual void setHotspotFlags(const HotSpotID, const HotSpotFlags);
+	virtual void setIsItemTaken(const ItemID);
 
 	virtual void upButton(const Input &);
 	virtual void leftButton(const Input &);
 	virtual void rightButton(const Input &);
 	virtual void downButton(const Input &);
 
-	void initOnePicture(Picture *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool);
-	void initOneMovie(Movie *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool);
+	void initOnePicture(Picture *, const Common::String &, DisplayOrder, CoordType, CoordType, bool);
+	void initOneMovie(Movie *, const Common::String &, DisplayOrder, CoordType, CoordType, bool);
 
 	void reinstateMonocleInterface();
 
-	virtual void newInteraction(const tInteractionID);
+	virtual void newInteraction(const InteractionID);
 	virtual void useIdleTime();
 	virtual void bumpIntoWall();
 	virtual void zoomUpOrBump();
@@ -349,11 +349,11 @@ protected:
 	TurnTable _turnTable;
 	ViewTable _viewTable;
 	ZoomTable _zoomTable;
-	tAlternateID _currentAlternate;
-	tHotSpotActivationID _currentActivation;
+	AlternateID _currentAlternate;
+	HotSpotActivationID _currentActivation;
 	
 	int32 _lastExtra;
-	tDeathReason _extraDeathReason;
+	DeathReason _extraDeathReason;
 
 	// Graphics
 	Movie _navMovie;
@@ -379,7 +379,7 @@ protected:
 	TimeBase _delayTimer;
 
 	// Interruptibility...
-	tInputBits _interruptionFilter;
+	InputBits _interruptionFilter;
 
 	// Nav hiding (for info support...)
 	bool _isRunning;
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
index 2af4335..ff1f078 100755
--- a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
@@ -30,10 +30,10 @@
 
 namespace Pegasus {
 
-static const tNotificationFlags kECRSection1FinishedFlag = 1;
-static const tNotificationFlags kECRPanFinishedFlag = kECRSection1FinishedFlag << 1;
-static const tNotificationFlags kECRSection2FinishedFlag = kECRPanFinishedFlag << 1;
-static const tNotificationFlags kECRNotificationFlags = kECRSection1FinishedFlag |
+static const NotificationFlags kECRSection1FinishedFlag = 1;
+static const NotificationFlags kECRPanFinishedFlag = kECRSection1FinishedFlag << 1;
+static const NotificationFlags kECRSection2FinishedFlag = kECRPanFinishedFlag << 1;
+static const NotificationFlags kECRNotificationFlags = kECRSection1FinishedFlag |
 													kECRPanFinishedFlag |
 													kECRSection2FinishedFlag;
 
@@ -45,7 +45,7 @@ static const TimeValue kSection2Start = 26;
 static const TimeValue kSection2Stop = 1000;
 
 // Seems to be a good value for a 20 second pan.
-static const tCoordType kPanPixelsPerFrame = 8;
+static const CoordType kPanPixelsPerFrame = 8;
 
 // Interesting times are in seconds.
 static const TimeValue s_ECRInterestingTimes[] = {
@@ -63,7 +63,7 @@ NoradAlphaECRMonitor::NoradAlphaECRMonitor(Neighborhood *nextHandler) : GameInte
 		_ecrPan(kECRPanID) {
 }
 
-void NoradAlphaECRMonitor::receiveNotification(Notification *, const tNotificationFlags flags) {
+void NoradAlphaECRMonitor::receiveNotification(Notification *, const NotificationFlags flags) {
 	if (flags & kECRSection1FinishedFlag)
 		ecrSection1Finished();
 	else if (flags & kECRPanFinishedFlag)
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
index 329dae7..9e286ed 100755
--- a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
+++ b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
@@ -43,7 +43,7 @@ protected:
 	virtual void openInteraction();
 	virtual void closeInteraction();
 
-	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual void receiveNotification(Notification *, const NotificationFlags);
 
 	void ecrSection1Finished();
 	void ecrPanFinished();
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
index c115f90..00cfe71 100755
--- a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
@@ -32,18 +32,18 @@
 
 namespace Pegasus {
 
-const tNotificationFlags kFSPowerUpFinishedFlag = 1;
-const tNotificationFlags kFSSplashFinishedFlag = kFSPowerUpFinishedFlag << 1;
-const tNotificationFlags kFSIntakeWarningFinishedFlag = kFSSplashFinishedFlag << 1;
-const tNotificationFlags kFSIntakeHiliteFinishedFlag = kFSIntakeWarningFinishedFlag << 1;
-const tNotificationFlags kFSDispenseHiliteFinishedFlag = kFSIntakeHiliteFinishedFlag << 1;
-const tNotificationFlags kFSArHiliteFinishedFlag = kFSDispenseHiliteFinishedFlag << 1;
-const tNotificationFlags kFSCO2HiliteFinishedFlag = kFSArHiliteFinishedFlag << 1;
-const tNotificationFlags kFSHeHiliteFinishedFlag = kFSCO2HiliteFinishedFlag << 1;
-const tNotificationFlags kFSOHiliteFinishedFlag = kFSHeHiliteFinishedFlag << 1;
-const tNotificationFlags kFSNHiliteFinishedFlag = kFSOHiliteFinishedFlag << 1;
-
-const tNotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
+const NotificationFlags kFSPowerUpFinishedFlag = 1;
+const NotificationFlags kFSSplashFinishedFlag = kFSPowerUpFinishedFlag << 1;
+const NotificationFlags kFSIntakeWarningFinishedFlag = kFSSplashFinishedFlag << 1;
+const NotificationFlags kFSIntakeHiliteFinishedFlag = kFSIntakeWarningFinishedFlag << 1;
+const NotificationFlags kFSDispenseHiliteFinishedFlag = kFSIntakeHiliteFinishedFlag << 1;
+const NotificationFlags kFSArHiliteFinishedFlag = kFSDispenseHiliteFinishedFlag << 1;
+const NotificationFlags kFSCO2HiliteFinishedFlag = kFSArHiliteFinishedFlag << 1;
+const NotificationFlags kFSHeHiliteFinishedFlag = kFSCO2HiliteFinishedFlag << 1;
+const NotificationFlags kFSOHiliteFinishedFlag = kFSHeHiliteFinishedFlag << 1;
+const NotificationFlags kFSNHiliteFinishedFlag = kFSOHiliteFinishedFlag << 1;
+
+const NotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
 												kFSSplashFinishedFlag |
 												kFSIntakeWarningFinishedFlag |
 												kFSIntakeHiliteFinishedFlag |
@@ -61,12 +61,10 @@ const int16 kDispenseMenu = 3;
 const int16 kWaitingForDispense = 4;
 
 // Dummy itemIDs
+const ItemID kCO2Item = 10000;
+const ItemID kHeItem = 10001;
 
-const tItemID kCO2Item = 10000;
-const tItemID kHeItem = 10001;
-
-//	Interactive points.
-
+// Interactive points.
 const TimeValue kFSPowerUpStartStart = 0;
 const TimeValue kFSPowerUpStartStop = 600;
 const TimeValue kFSSplashStart = 600;
@@ -168,7 +166,7 @@ void NoradAlphaFillingStation::setStaticState(TimeValue time, int16 state) {
 	allowInput(true);
 }
 
-void NoradAlphaFillingStation::setSegmentState(TimeValue start, TimeValue stop, tNotificationFlags flag, int16 state) {	
+void NoradAlphaFillingStation::setSegmentState(TimeValue start, TimeValue stop, NotificationFlags flag, int16 state) {	
 	_rightSideMovie.stop();
 	_rightSideMovie.setSegment(start, stop);
 	_rightSideMovie.setTime(start);
@@ -316,7 +314,7 @@ void NoradAlphaFillingStation::NHighlightFinished() {
 	dispenseGas();
 }
 
-void NoradAlphaFillingStation::receiveNotification(Notification *, const tNotificationFlags flags) {
+void NoradAlphaFillingStation::receiveNotification(Notification *, const NotificationFlags flags) {
 	switch (flags) {
 	case kFSPowerUpFinishedFlag:
 		powerUpFinished();
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.h b/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
index e3fb1f6..eb2088e 100755
--- a/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
@@ -47,7 +47,7 @@ public:
 	void newFillingItem(Item *);
 
 protected:
-	void receiveNotification(Notification *, const tNotificationFlags);
+	void receiveNotification(Notification *, const NotificationFlags);
 
 	virtual void openInteraction();
 	virtual void initInteraction();
@@ -77,13 +77,13 @@ protected:
 	void dispenseGas();
 
 	void setStaticState(TimeValue, int16);
-	void setSegmentState(TimeValue, TimeValue, tNotificationFlags, int16);
+	void setSegmentState(TimeValue, TimeValue, NotificationFlags, int16);
 
 	Movie _rightSideMovie;
 	Notification _rightSideNotification;
 	NotificationCallBack _rightSideCallBack;
 	int16 _state;
-	tItemID _dispenseItemID;
+	ItemID _dispenseItemID;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index 3bab3b8..8391a3f 100755
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -132,9 +132,9 @@ void NoradAlpha::start() {
 		g_energyMonitor->startEnergyDraining();
 	}
 
-	tNeighborhoodID itemNeighborhood;
-	tRoomID itemRoom;
-	tDirectionConstant itemDirection;
+	NeighborhoodID itemNeighborhood;
+	RoomID itemRoom;
+	DirectionConstant itemDirection;
 
 	Item *item = (Item *)g_allItems.findItemByID(kGasCanister);
 	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
@@ -211,7 +211,7 @@ void NoradAlpha::playClawMonitorIntro() {
 	playSpotSoundSync(kLoadClawIntroIn, kLoadClawIntroOut);
 }
 
-GameInteraction *NoradAlpha::makeInteraction(const tInteractionID interactionID) {
+GameInteraction *NoradAlpha::makeInteraction(const InteractionID interactionID) {
 	switch (interactionID) {
 	case kNoradECRMonitorInteractionID:
 		return new NoradAlphaECRMonitor(this);
@@ -250,7 +250,7 @@ void NoradAlpha::loadAmbientLoops() {
 	if (!GameState.getNoradSeenTimeStream())
 		return;
 
-	tRoomID room = GameState.getCurrentRoom();
+	RoomID room = GameState.getCurrentRoom();
 	if (GameState.getNoradGassed()) {
 		if (room >= kNorad11 && room <= kNorad19West)
 			loadLoopSound1("Sounds/Norad/NEW SUB AMB.22K.AIFF", kNoradWarningVolume * 3);
@@ -288,7 +288,7 @@ void NoradAlpha::loadAmbientLoops() {
 	
 }
 
-void NoradAlpha::checkContinuePoint(const tRoomID room, const tDirectionConstant direction) {
+void NoradAlpha::checkContinuePoint(const RoomID room, const DirectionConstant direction) {
 	switch (MakeRoomView(room, direction)) {
 	case MakeRoomView(kNorad02, kEast):
 	case MakeRoomView(kNorad06, kEast):
@@ -301,7 +301,7 @@ void NoradAlpha::checkContinuePoint(const tRoomID room, const tDirectionConstant
 	}
 }
 
-void NoradAlpha::arriveAt(const tRoomID room, const tDirectionConstant direction) {
+void NoradAlpha::arriveAt(const RoomID room, const DirectionConstant direction) {
 	Norad::arriveAt(room, direction);
 
 	switch (GameState.getCurrentRoom()) {
@@ -364,7 +364,7 @@ void NoradAlpha::bumpIntoWall() {
 	Neighborhood::bumpIntoWall();
 }
 
-void NoradAlpha::receiveNotification(Notification *notification, const tNotificationFlags flags) {
+void NoradAlpha::receiveNotification(Notification *notification, const NotificationFlags flags) {
 	if ((flags & kExtraCompletedFlag) != 0) {
 		switch (_lastExtra) {
 		case kNoradArriveFromTSA:
@@ -400,7 +400,7 @@ void NoradAlpha::receiveNotification(Notification *notification, const tNotifica
 	g_AIArea->checkMiddleArea();
 }
 
-void NoradAlpha::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry) {
+void NoradAlpha::getZoomEntry(const HotSpotID spotID, ZoomTable::Entry &entry) {
 	Norad::getZoomEntry(spotID, entry);
 
 	ExtraTable::Entry extra;
@@ -428,7 +428,7 @@ void NoradAlpha::getZoomEntry(const tHotSpotID spotID, ZoomTable::Entry &entry)
 	}
 }
 
-TimeValue NoradAlpha::getViewTime(const tRoomID room, const tDirectionConstant direction) {
+TimeValue NoradAlpha::getViewTime(const RoomID room, const DirectionConstant direction) {
 	ExtraTable::Entry entry;
 	
 	if (room == kNorad01 && direction == kSouth && !GameState.getNoradSeenTimeStream()) {
@@ -511,13 +511,13 @@ void NoradAlpha::activateHotspots() {
 	case MakeRoomView(kNorad01West, kWest):
 		if (_vm->getDragType() == kDragInventoryUse) {
 			if (!_fillingStationItem) {
-				tItemID itemID = _vm->getDraggingItem()->getObjectID();
+				ItemID itemID = _vm->getDraggingItem()->getObjectID();
 				if (itemID == kArgonCanister || itemID == kGasCanister || itemID == kAirMask ||
 						itemID == kNitrogenCanister)
 					g_allHotspots.activateOneHotspot(kN01GasOutletSpotID);
 			}
 		} else {
-			tHotSpotID spotID;
+			HotSpotID spotID;
 
 			if (_fillingStationItem) {
 				switch (_fillingStationItem->getObjectID()) {
@@ -596,9 +596,9 @@ void NoradAlpha::dropItemIntoRoom(Item *item, Hotspot *droppedSpot) {
 	Norad::dropItemIntoRoom(item, droppedSpot);
 }
 
-void NoradAlpha::getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID, tHotSpotID &pinchClawSpotID,
-		tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID, tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID,
-		tHotSpotID &clawCCWSpotID, tHotSpotID &clawCWSpotID, uint32 &clawPosition, const uint32 *&clawExtraIDs) {
+void NoradAlpha::getClawInfo(HotSpotID &outSpotID, HotSpotID &prepSpotID, HotSpotID &clawControlSpotID, HotSpotID &pinchClawSpotID,
+		HotSpotID &moveClawDownSpotID, HotSpotID &moveClawRightSpotID, HotSpotID &moveClawLeftSpotID, HotSpotID &moveClawUpSpotID,
+		HotSpotID &clawCCWSpotID, HotSpotID &clawCWSpotID, uint32 &clawPosition, const uint32 *&clawExtraIDs) {
 	outSpotID = kNorad22MonitorOutSpotID;
 	prepSpotID = kNorad22LaunchPrepSpotID;
 	clawControlSpotID = kNorad22ClawControlSpotID;
@@ -632,7 +632,7 @@ Common::String NoradAlpha::getEnvScanMovie() {
 	Common::String movieName = Neighborhood::getEnvScanMovie();
 
 	if (movieName.empty()) {
-		tRoomID room = GameState.getCurrentRoom();
+		RoomID room = GameState.getCurrentRoom();
 		if (room >= kNorad01 && room <= kNorad01West)
 			return "Images/AI/Norad/XNE1";
 		else if ((room >= kNorad02 && room <= kNorad19West))
@@ -718,7 +718,7 @@ Common::String NoradAlpha::getHintMovie(uint hintNum) {
 	return movieName;
 }
 
-void NoradAlpha::closeDoorOffScreen(const tRoomID room, const tDirectionConstant) {
+void NoradAlpha::closeDoorOffScreen(const RoomID room, const DirectionConstant) {
 	switch (room) {
 	case kNorad12:
 	case kNorad13:
@@ -732,7 +732,7 @@ void NoradAlpha::closeDoorOffScreen(const tRoomID room, const tDirectionConstant
 	}
 }
 
-void NoradAlpha::findSpotEntry(const tRoomID room, const tDirectionConstant direction, tSpotFlags flags, SpotTable::Entry &spotEntry) {
+void NoradAlpha::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &spotEntry) {
 	if (room == kNorad01 && direction == kSouth)
 		spotEntry.clear();
 	else
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
index 9b96d13..b88a6eb 100755
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
@@ -54,12 +54,12 @@ public:
 	virtual void takeItemFromRoom(Item *);
 	virtual void dropItemIntoRoom(Item *, Hotspot *);
 
-	virtual GameInteraction *makeInteraction(const tInteractionID);
+	virtual GameInteraction *makeInteraction(const InteractionID);
 
-	virtual void getClawInfo(tHotSpotID &outSpotID, tHotSpotID &prepSpotID, tHotSpotID &clawControlSpotID,
-			tHotSpotID &pinchClawSpotID, tHotSpotID &moveClawDownSpotID, tHotSpotID &moveClawRightSpotID,
-			tHotSpotID &moveClawLeftSpotID, tHotSpotID &moveClawUpSpotID, tHotSpotID &clawCCWSpotID,
-			tHotSpotID &clawCWSpotID, uint32 &, const uint32 *&);
+	virtual void getClawInfo(HotSpotID &outSpotID, HotSpotID &prepSpotID, HotSpotID &clawControlSpotID,
+			HotSpotID &pinchClawSpotID, HotSpotID &moveClawDownSpotID, HotSpotID &moveClawRightSpotID,
+			HotSpotID &moveClawLeftSpotID, HotSpotID &moveClawUpSpotID, HotSpotID &clawCCWSpotID,
+			HotSpotID &clawCWSpotID, uint32 &, const uint32 *&);
 
 	void loadAmbientLoops();
 
@@ -71,11 +71,11 @@ public:
 	void setSubPrepFailed(bool value) { _subPrepFailed = value; }
 	bool getSubPrepFailed() { return _subPrepFailed; }
 
-	void closeDoorOffScreen(const tRoomID, const tDirectionConstant);
-	void findSpotEntry(const tRoomID, const tDirectionConstant, tSpotFlags, SpotTable::Entry &);
+	void closeDoorOffScreen(const RoomID, const DirectionConstant);
+	void findSpotEntry(const RoomID, const DirectionConstant, SpotFlags, SpotTable::Entry &);
 	void clickInHotspot(const Input &, const Hotspot *);
 
-	void checkContinuePoint(const tRoomID, const tDirectionConstant);
+	void checkContinuePoint(const RoomID, const DirectionConstant);
 
 	bool canSolve();
 	void doSolve();
@@ -89,12 +89,12 @@ protected:
 	virtual void arriveAtNorad04();
 	virtual void arriveAtNorad22();
 	
-	virtual void arriveAt(const tRoomID, const tDirectionConstant);
+	virtual void arriveAt(const RoomID, const DirectionConstant);
 	
-	virtual void getZoomEntry(const tHotSpotID, ZoomTable::Entry &);
-	virtual TimeValue getViewTime(const tRoomID, const tDirectionConstant);
+	virtual void getZoomEntry(const HotSpotID, ZoomTable::Entry &);
+	virtual TimeValue getViewTime(const RoomID, const DirectionConstant);
 	
-	virtual void receiveNotification(Notification *, const tNotificationFlags);
+	virtual void receiveNotification(Notification *, const NotificationFlags);
 
 	virtual void activateHotspots();
 
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
index 417305c..614595b 100755
--- a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
@@ -118,13 +118,13 @@ void Panorama::setViewBounds(const Common::Rect &newView) {
 	}
 
 	if (_viewBounds != r) {
-		tCoordType stripLeft = 0;
+		CoordType stripLeft = 0;
 
 		if (r.width() != _viewBounds.width() || !_panoramaWorld.isSurfaceValid()) {
 			_panoramaWorld.deallocateSurface();
 			makeNewSurface(r);
 		} else {
-			tCoordType stripRight;
+			CoordType stripRight;
 			calcStripRange(r, stripLeft, stripRight);
 			loadStrips(stripLeft, stripRight);
 		}
@@ -159,7 +159,7 @@ void Panorama::drawPanorama(const Common::Rect &destRect) {
 //      _panoramaHeight, _stripWidth is correct.
 //      _panoramaMovie is allocated.
 void Panorama::makeNewSurface(const Common::Rect& view) {
-	tCoordType stripLeft, stripRight;	
+	CoordType stripLeft, stripRight;	
 	calcStripRange(view, stripLeft, stripRight);
 
 	Common::Rect r(0, 0, (stripRight - stripLeft + 1) * _stripWidth, _panoramaHeight);
@@ -169,7 +169,7 @@ void Panorama::makeNewSurface(const Common::Rect& view) {
 }
 
 // Assumes view is not empty.
-void Panorama::calcStripRange(const Common::Rect &view, tCoordType &stripLeft, tCoordType &stripRight) {
+void Panorama::calcStripRange(const Common::Rect &view, CoordType &stripLeft, CoordType &stripRight) {
 	stripLeft = view.left / _stripWidth;
 	stripRight = (view.left - view.left % _stripWidth + _stripWidth - 1 + view.width()) / _stripWidth;
 }
@@ -179,18 +179,18 @@ void Panorama::calcStripRange(const Common::Rect &view, tCoordType &stripLeft, t
 // Assumptions:
 //      Surface is allocated and is big enough for maximum range of
 //          stripLeft and stripRight
-void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {	
+void Panorama::loadStrips(CoordType stripLeft, CoordType stripRight) {	
 	if (_stripLeft == -1) {
 		// Surface has just been allocated.
 		// Load in all strips.
-		for (tCoordType i = stripLeft; i <= stripRight; i++)
+		for (CoordType i = stripLeft; i <= stripRight; i++)
 			loadOneStrip(i, stripLeft);
 
 		_stripLeft = stripLeft;
 		_stripRight = stripRight;
 	} else if (stripLeft != _stripLeft) {
-		tCoordType overlapLeft = MAX(stripLeft, _stripLeft);
-		tCoordType overlapRight = MIN(stripRight, _stripRight);
+		CoordType overlapLeft = MAX(stripLeft, _stripLeft);
+		CoordType overlapRight = MIN(stripRight, _stripRight);
 
 		if (overlapLeft <= overlapRight) {
 			Common::Rect r1((overlapLeft - _stripLeft) * _stripWidth, 0,
@@ -202,18 +202,18 @@ void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {
 				_panoramaWorld.getSurfaceBounds(bounds);
 				_panoramaWorld.getSurface()->move(bounds.right - r1.right, 0, _panoramaHeight);
 
-				for (tCoordType i = stripLeft; i < _stripLeft; i++)
+				for (CoordType i = stripLeft; i < _stripLeft; i++)
 					loadOneStrip(i, stripLeft);
 			} else {
 				_panoramaWorld.getSurface()->move(-r1.left, 0, _panoramaHeight);
 
-				for (tCoordType i = _stripRight + 1; i <= stripRight; i++)
+				for (CoordType i = _stripRight + 1; i <= stripRight; i++)
 					loadOneStrip(i, stripLeft);
 			}
 		} else {
 			// No overlap.
 			// Load everything.
-			for (tCoordType i = stripLeft; i <= stripRight; i++)
+			for (CoordType i = stripLeft; i <= stripRight; i++)
 				loadOneStrip(i, stripLeft);
 		}
 
@@ -221,7 +221,7 @@ void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {
 		_stripRight = stripRight;
 	} else if (stripRight > _stripRight) {
 		// Need to add one or more strips.
-		for (tCoordType i = _stripRight + 1; i <= stripRight; i++)
+		for (CoordType i = _stripRight + 1; i <= stripRight; i++)
 			loadOneStrip(i, _stripLeft);
 
 		_stripRight = stripRight;
@@ -231,7 +231,7 @@ void Panorama::loadStrips(tCoordType stripLeft, tCoordType stripRight) {
 	}
 }
 
-void Panorama::loadOneStrip(tCoordType stripToLoad, tCoordType leftStrip) {
+void Panorama::loadOneStrip(CoordType stripToLoad, CoordType leftStrip) {
 	_panoramaMovie.moveMovieBoxTo((stripToLoad - leftStrip) * _stripWidth, 0);
 	_panoramaMovie.setTime(stripToLoad, 1);
 	_panoramaMovie.redrawMovieWorld();
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.h b/engines/pegasus/neighborhood/norad/alpha/panorama.h
index a773da9..3ca2c1e 100755
--- a/engines/pegasus/neighborhood/norad/alpha/panorama.h
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.h
@@ -79,18 +79,18 @@ public:
 protected:
 	void blankFields();
 	void makeNewSurface(const Common::Rect &);
-	void calcStripRange(const Common::Rect &, tCoordType &, tCoordType &);
-	void loadStrips(tCoordType, tCoordType);
-	void loadOneStrip(tCoordType, tCoordType);
+	void calcStripRange(const Common::Rect &, CoordType &, CoordType &);
+	void loadStrips(CoordType, CoordType);
+	void loadOneStrip(CoordType, CoordType);
 	
 	Movie _panoramaMovie;
 	Surface _panoramaWorld, *_mask;
 	Common::Rect _viewBounds;
 	Common::Rect _drawBounds;
-	tCoordType _panoramaWidth, _panoramaHeight;
-	tCoordType _stripWidth; // Pixels per strip.
-	tCoordType _numStrips;
-	tCoordType _stripLeft, _stripRight;
+	CoordType _panoramaWidth, _panoramaHeight;
+	CoordType _stripWidth; // Pixels per strip.
+	CoordType _numStrips;
+	CoordType _stripLeft, _stripRight;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
index 2b8ff49..fcb49c5 100755
--- a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
@@ -27,7 +27,7 @@
 
 namespace Pegasus {
 
-PanoramaScroll::PanoramaScroll(const tDisplayElementID id) : IdlerAnimation(id) {
+PanoramaScroll::PanoramaScroll(const DisplayElementID id) : IdlerAnimation(id) {
 	_boundsWidth = 0;
 	_totalWidth = 0;
 }
@@ -72,7 +72,7 @@ void PanoramaScroll::draw(const Common::Rect &) {
 }
 
 void PanoramaScroll::timeChanged(const TimeValue newTime) {	
-	tCoordType leftPixel = (_totalWidth - _boundsWidth) * newTime / getDuration();
+	CoordType leftPixel = (_totalWidth - _boundsWidth) * newTime / getDuration();
 
 	Common::Rect r;
 	_panorama.getViewBounds(r);
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
index 8496181..6a3e151 100755
--- a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
+++ b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 class PanoramaScroll : public IdlerAnimation {
 public:
-	PanoramaScroll(const tDisplayElementID);
+	PanoramaScroll(const DisplayElementID);
 	virtual ~PanoramaScroll() {}
 
 	void initFromMovieFile(const Common::String &);
@@ -52,7 +52,7 @@ protected:
 
 	Panorama _panorama;
 	Surface _mask;
-	tCoordType _totalWidth, _boundsWidth;
+	CoordType _totalWidth, _boundsWidth;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/neighborhood/norad/constants.h b/engines/pegasus/neighborhood/norad/constants.h
index 8d5eff4..92319b8 100755
--- a/engines/pegasus/neighborhood/norad/constants.h
+++ b/engines/pegasus/neighborhood/norad/constants.h
@@ -196,9 +196,9 @@ const TimeValue kYouCannotPossiblyOut = 65740;
 const TimeValue kYouWillFailIn = 65740;
 const TimeValue kYouWillFailOut = 67217;
 
-const tCanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
+const CanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
 
-const tNotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
+const NotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
 
 const uint16 kNoradWarningVolume = 0x100 / 3;
 const uint16 kNoradSuckWindVolume = 0x100 / 2;
@@ -209,237 +209,237 @@ const int16 kSubControlCompassAngle = -10;
 
 //	Norad interactions.
 
-const tInteractionID kNoradGlobeGameInteractionID = 0;
-const tInteractionID kNoradECRMonitorInteractionID = 1;
-const tInteractionID kNoradFillingStationInteractionID = 2;
-const tInteractionID kNoradElevatorInteractionID = 3;
-const tInteractionID kNoradPressureDoorInteractionID = 4;
-const tInteractionID kNoradSubControlRoomInteractionID = 5;
-const tInteractionID kNoradSubPlatformInteractionID = 6;
+const InteractionID kNoradGlobeGameInteractionID = 0;
+const InteractionID kNoradECRMonitorInteractionID = 1;
+const InteractionID kNoradFillingStationInteractionID = 2;
+const InteractionID kNoradElevatorInteractionID = 3;
+const InteractionID kNoradPressureDoorInteractionID = 4;
+const InteractionID kNoradSubControlRoomInteractionID = 5;
+const InteractionID kNoradSubPlatformInteractionID = 6;
 
 /////////////////////////////////////////////
 //
 //	Norad Alpha
 
-const tCoordType kECRSlideShowLeft = kNavAreaLeft + 78;
-const tCoordType kECRSlideShowTop = kNavAreaTop + 1;
+const CoordType kECRSlideShowLeft = kNavAreaLeft + 78;
+const CoordType kECRSlideShowTop = kNavAreaTop + 1;
 
-const tCoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
-const tCoordType kECRPanTop = kNavAreaTop + 1 + 4;
-const tCoordType kECRPanRight = kECRPanLeft + 213;
-const tCoordType kECRPanBottom = kECRPanTop + 241;
+const CoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
+const CoordType kECRPanTop = kNavAreaTop + 1 + 4;
+const CoordType kECRPanRight = kECRPanLeft + 213;
+const CoordType kECRPanBottom = kECRPanTop + 241;
 
-const tCoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
-const tCoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
+const CoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
+const CoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
 
-const tCoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
-const tCoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
+const CoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
+const CoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
 
-const tCoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
-const tCoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
+const CoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
+const CoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
 
-const tCoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
-const tCoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
+const CoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
+const CoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
 
-const tCoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
-const tCoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
+const CoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
+const CoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
 
-const tCoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
-const tCoordType kNoradUpperUpTop = kNavAreaTop + 32;
+const CoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
+const CoordType kNoradUpperUpTop = kNavAreaTop + 32;
 
-const tCoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
-const tCoordType kNoradUpperDownTop = kNavAreaTop + 66;
+const CoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
+const CoordType kNoradUpperDownTop = kNavAreaTop + 66;
 
-const tCoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
-const tCoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
+const CoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
+const CoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
 
-const tCoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
-const tCoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
+const CoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
+const CoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
 
-const tCoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
-const tCoordType kNoradLowerUpTop = kNavAreaTop + 164;
+const CoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
+const CoordType kNoradLowerUpTop = kNavAreaTop + 164;
 
-const tCoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
-const tCoordType kNoradLowerDownTop = kNavAreaTop + 212;
+const CoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
+const CoordType kNoradLowerDownTop = kNavAreaTop + 212;
 
-const tCoordType kNoradPlatformLeft = kNavAreaLeft + 36;
-const tCoordType kNoradPlatformTop = kNavAreaTop + 87;
+const CoordType kNoradPlatformLeft = kNavAreaLeft + 36;
+const CoordType kNoradPlatformTop = kNavAreaTop + 87;
 
-const tCoordType kNoradSubControlLeft = kNavAreaLeft + 0;
-const tCoordType kNoradSubControlTop = kNavAreaTop + 84;
+const CoordType kNoradSubControlLeft = kNavAreaLeft + 0;
+const CoordType kNoradSubControlTop = kNavAreaTop + 84;
 
-const tCoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
-const tCoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
+const CoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
+const CoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
 
-const tCoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
-const tCoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
+const CoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
+const CoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
 
-const tCoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
-const tCoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
+const CoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
+const CoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
 
-const tCoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
-const tCoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
+const CoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
+const CoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
 
-const tCoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
-const tCoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
+const CoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
+const CoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
 
-const tCoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
-const tCoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
+const CoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
+const CoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
 
-const tCoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
-const tCoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
+const CoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
+const CoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
 
-const tCoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
-const tCoordType kNoradClawMonitorTop = kNavAreaTop + 97;
+const CoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
+const CoordType kNoradClawMonitorTop = kNavAreaTop + 97;
 
-const tCoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
-const tCoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
+const CoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
+const CoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
 
-const tCoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
-const tCoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
+const CoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
+const CoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
 
-const tCoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
-const tCoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
+const CoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
+const CoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
 
-const tCoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
-const tCoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
+const CoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
+const CoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
 
 /////////////////////////////////////////////
 //
 //	Norad Delta
 
-const tCoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
-const tCoordType kGlobeMonitorTop = kNavAreaTop + 144;
+const CoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
+const CoordType kGlobeMonitorTop = kNavAreaTop + 144;
 
-const tCoordType kGlobeLeft = kNavAreaLeft + 172;
-const tCoordType kGlobeTop = kNavAreaTop;
+const CoordType kGlobeLeft = kNavAreaLeft + 172;
+const CoordType kGlobeTop = kNavAreaTop;
 
-const tCoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
-const tCoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
+const CoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
+const CoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
 
-const tCoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
-const tCoordType kGlobeCircleRightTop = kNavAreaTop + 41;
+const CoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
+const CoordType kGlobeCircleRightTop = kNavAreaTop + 41;
 
-const tCoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
-const tCoordType kGlobeCircleUpTop = kNavAreaTop + 7;
+const CoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
+const CoordType kGlobeCircleUpTop = kNavAreaTop + 7;
 
-const tCoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
-const tCoordType kGlobeCircleDownTop = kNavAreaTop + 142;
+const CoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
+const CoordType kGlobeCircleDownTop = kNavAreaTop + 142;
 
-const tCoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
-const tCoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
+const CoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
+const CoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
 
-const tCoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
-const tCoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
+const CoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
+const CoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
 
-const tCoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
-const tCoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
+const CoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
+const CoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
 
-const tCoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
-const tCoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
+const CoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
+const CoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
 
-const tCoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
-const tCoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
+const CoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
+const CoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
 
-const tCoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
-const tCoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
+const CoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
+const CoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
 
-const tCoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
-const tCoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
+const CoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
+const CoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
 
-const tCoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
-const tCoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
+const CoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
+const CoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
 
-const tCoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
-const tCoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
+const CoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
+const CoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
 
-const tCoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
-const tCoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
+const CoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
+const CoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
 
-const tCoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
-const tCoordType kGlobeCountdownTop = kNavAreaTop + 164;
+const CoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
+const CoordType kGlobeCountdownTop = kNavAreaTop + 164;
 
 //	Norad Alpha display IDs.
 
-const tDisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
-const tDisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
-const tDisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
-const tDisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
-const tDisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
-const tDisplayElementID kN01RightSideID = kN01LeftSideID + 1;
-const tDisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
-const tDisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
-const tDisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
-const tDisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
-const tDisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
-const tDisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
-const tDisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
-const tDisplayElementID kSubControlPinchID = kClawMonitorID + 1;
-const tDisplayElementID kSubControlDownID = kSubControlPinchID + 1;
-const tDisplayElementID kSubControlRightID = kSubControlDownID + 1;
-const tDisplayElementID kSubControlLeftID = kSubControlRightID + 1;
-const tDisplayElementID kSubControlUpID = kSubControlLeftID + 1;
-const tDisplayElementID kSubControlCCWID = kSubControlUpID + 1;
-const tDisplayElementID kSubControlCWID = kSubControlCCWID + 1;
-const tDisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
+const DisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
+const DisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
+const DisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
+const DisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
+const DisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
+const DisplayElementID kN01RightSideID = kN01LeftSideID + 1;
+const DisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
+const DisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
+const DisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
+const DisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
+const DisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
+const DisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
+const DisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
+const DisplayElementID kSubControlPinchID = kClawMonitorID + 1;
+const DisplayElementID kSubControlDownID = kSubControlPinchID + 1;
+const DisplayElementID kSubControlRightID = kSubControlDownID + 1;
+const DisplayElementID kSubControlLeftID = kSubControlRightID + 1;
+const DisplayElementID kSubControlUpID = kSubControlLeftID + 1;
+const DisplayElementID kSubControlCCWID = kSubControlUpID + 1;
+const DisplayElementID kSubControlCWID = kSubControlCCWID + 1;
+const DisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
 
 //	Norad Delta display IDs.
 
-const tDisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
-const tDisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
-const tDisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
-const tDisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
-const tDisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
-const tDisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
-const tDisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
-const tDisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
-const tDisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
-const tDisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
-const tDisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
-const tDisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
-const tDisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
-const tDisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
-const tDisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
-const tDisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
-const tDisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
+const DisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
+const DisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
+const DisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
+const DisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
+const DisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
+const DisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
+const DisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
+const DisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
+const DisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
+const DisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
+const DisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
+const DisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
+const DisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
+const DisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
+const DisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
+const DisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
+const DisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
 
 //	Norad Alpha:
 
-const tDisplayOrder kECRMonitorOrder = kMonitorLayer;
-const tDisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
+const DisplayOrder kECRMonitorOrder = kMonitorLayer;
+const DisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
 
-const tDisplayOrder kN01LeftSideOrder = kMonitorLayer;
-const tDisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
+const DisplayOrder kN01LeftSideOrder = kMonitorLayer;
+const DisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
 
-const tDisplayOrder kElevatorControlsOrder = kMonitorLayer;
+const DisplayOrder kElevatorControlsOrder = kMonitorLayer;
 
-const tDisplayOrder kPressureLevelsOrder = kMonitorLayer;
-const tDisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
-const tDisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
-const tDisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
+const DisplayOrder kPressureLevelsOrder = kMonitorLayer;
+const DisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
+const DisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
+const DisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
 
-const tDisplayOrder kPlatformOrder = kMonitorLayer;
+const DisplayOrder kPlatformOrder = kMonitorLayer;
 
-const tDisplayOrder kSubControlOrder = kMonitorLayer;
-const tDisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
-const tDisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
-const tDisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
-const tDisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
-const tDisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
-const tDisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
-const tDisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
-const tDisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
-const tDisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
+const DisplayOrder kSubControlOrder = kMonitorLayer;
+const DisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
+const DisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
+const DisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
+const DisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
+const DisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
+const DisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
+const DisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
+const DisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
+const DisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
 
 //	Norad Delta:
 
-const tDisplayOrder kGlobeMonitorLayer = kMonitorLayer;
-const tDisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
-const tDisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
-const tDisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
-const tDisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
-const tDisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
-const tDisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
+const DisplayOrder kGlobeMonitorLayer = kMonitorLayer;
+const DisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
+const DisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
+const DisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
+const DisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
+const DisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
+const DisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
 
 //	Norad Alpha Tables
 
@@ -449,204 +449,204 @@ const TimeScale kNoradAlphaFrameDuration = 40;
 
 //	Alternate IDs.
 
-const tAlternateID kAltNoradAlphaNormal = 0;
+const AlternateID kAltNoradAlphaNormal = 0;
 
 //	Room IDs.
 
-const tRoomID kNorad01 = 0;
-const tRoomID kNorad01East = 1;
-const tRoomID kNorad01West = 2;
-const tRoomID kNorad02 = 3;
-const tRoomID kNorad03 = 4;
-const tRoomID kNorad04 = 5;
-const tRoomID kNorad05 = 6;
-const tRoomID kNorad06 = 7;
-const tRoomID kNorad07 = 8;
-const tRoomID kNorad07North = 9;
-const tRoomID kNorad08 = 10;
-const tRoomID kNorad09 = 11;
-const tRoomID kNorad10 = 12;
-const tRoomID kNorad10East = 13;
-const tRoomID kNorad11 = 14;
-const tRoomID kNorad11South = 15;
-const tRoomID kNorad12 = 16;
-const tRoomID kNorad12South = 17;
-const tRoomID kNorad13 = 18;
-const tRoomID kNorad14 = 19;
-const tRoomID kNorad15 = 20;
-const tRoomID kNorad16 = 21;
-const tRoomID kNorad17 = 22;
-const tRoomID kNorad18 = 23;
-const tRoomID kNorad19 = 24;
-const tRoomID kNorad19West = 25;
-const tRoomID kNorad21 = 26;
-const tRoomID kNorad21West = 27;
-const tRoomID kNorad22 = 28;
-const tRoomID kNorad22West = 29;
+const RoomID kNorad01 = 0;
+const RoomID kNorad01East = 1;
+const RoomID kNorad01West = 2;
+const RoomID kNorad02 = 3;
+const RoomID kNorad03 = 4;
+const RoomID kNorad04 = 5;
+const RoomID kNorad05 = 6;
+const RoomID kNorad06 = 7;
+const RoomID kNorad07 = 8;
+const RoomID kNorad07North = 9;
+const RoomID kNorad08 = 10;
+const RoomID kNorad09 = 11;
+const RoomID kNorad10 = 12;
+const RoomID kNorad10East = 13;
+const RoomID kNorad11 = 14;
+const RoomID kNorad11South = 15;
+const RoomID kNorad12 = 16;
+const RoomID kNorad12South = 17;
+const RoomID kNorad13 = 18;
+const RoomID kNorad14 = 19;
+const RoomID kNorad15 = 20;
+const RoomID kNorad16 = 21;
+const RoomID kNorad17 = 22;
+const RoomID kNorad18 = 23;
+const RoomID kNorad19 = 24;
+const RoomID kNorad19West = 25;
+const RoomID kNorad21 = 26;
+const RoomID kNorad21West = 27;
+const RoomID kNorad22 = 28;
+const RoomID kNorad22West = 29;
 
 //	Hot Spot Activation IDs.
 
 
 //	Hot Spot IDs.
 
-const tHotSpotID kNorad01ECRSpotID = 5000;
-const tHotSpotID kNorad01GasSpotID = 5001;
-const tHotSpotID kNorad01ECROutSpotID = 5002;
-const tHotSpotID kNorad01GasOutSpotID = 5003;
-const tHotSpotID kNorad01MonitorSpotID = 5004;
-const tHotSpotID kNorad01IntakeSpotID = 5005;
-const tHotSpotID kNorad01DispenseSpotID = 5006;
-const tHotSpotID kNorad01ArSpotID = 5007;
-const tHotSpotID kNorad01CO2SpotID = 5008;
-const tHotSpotID kNorad01HeSpotID = 5009;
-const tHotSpotID kNorad01OSpotID = 5010;
-const tHotSpotID kNorad01NSpotID = 5011;
-const tHotSpotID kN01GasCanisterSpotID = 5012;
-const tHotSpotID kN01ArgonCanisterSpotID = 5013;
-const tHotSpotID kN01AirMaskSpotID = 5014;
-const tHotSpotID kN01NitrogenCanisterSpotID = 5015;
-const tHotSpotID kN01GasOutletSpotID = 5016;
-const tHotSpotID kNorad07DoorSpotID = 5017;
-const tHotSpotID kNorad07DoorOutSpotID = 5018;
-const tHotSpotID kNorad10DoorSpotID = 5019;
-const tHotSpotID kNorad10EastOutSpotID = 5020;
-const tHotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
-const tHotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
-const tHotSpotID kNorad11ElevatorSpotID = 5023;
-const tHotSpotID kNorad11ElevatorOutSpotID = 5024;
-const tHotSpotID kNorad11ElevatorDownSpotID = 5025;
-const tHotSpotID kNorad12ElevatorSpotID = 5026;
-const tHotSpotID kNorad12ElevatorOutSpotID = 5027;
-const tHotSpotID kNorad12ElevatorUpSpotID = 5028;
-const tHotSpotID kNorad19MonitorSpotID = 5029;
-const tHotSpotID kNorad19MonitorOutSpotID = 5030;


Commit: f72884cb7bbe594888f6d14a3e03c7839ef2c508
    https://github.com/scummvm/scummvm/commit/f72884cb7bbe594888f6d14a3e03c7839ef2c508
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-16T20:24:55-08:00

Commit Message:
PEGASUS: Cleanup some constants

Added missing static qualifiers, get rid of some short/long

Changed paths:
    engines/pegasus/constants.h
    engines/pegasus/items/item.h
    engines/pegasus/menu.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.h
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
    engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/mars/constants.h
    engines/pegasus/neighborhood/mars/energybeam.cpp
    engines/pegasus/neighborhood/mars/gravitoncannon.cpp
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/mars/planetmover.cpp
    engines/pegasus/neighborhood/mars/robotship.cpp
    engines/pegasus/neighborhood/mars/robotship.h
    engines/pegasus/neighborhood/mars/shuttleenergymeter.h
    engines/pegasus/neighborhood/mars/shuttlehud.cpp
    engines/pegasus/neighborhood/mars/shuttleweapon.h
    engines/pegasus/neighborhood/mars/spacechase3d.h
    engines/pegasus/neighborhood/mars/spacejunk.cpp
    engines/pegasus/neighborhood/mars/spacejunk.h
    engines/pegasus/neighborhood/mars/tractorbeam.cpp
    engines/pegasus/neighborhood/neighborhood.h
    engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
    engines/pegasus/neighborhood/norad/constants.h
    engines/pegasus/neighborhood/norad/noradelevator.cpp
    engines/pegasus/neighborhood/norad/pressuredoor.cpp
    engines/pegasus/neighborhood/norad/pressuredoor.h
    engines/pegasus/neighborhood/norad/pressuretracker.h
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.h
    engines/pegasus/neighborhood/norad/subplatform.cpp
    engines/pegasus/neighborhood/prehistoric/prehistoric.h
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.h
    engines/pegasus/neighborhood/tsa/tinytsa.cpp
    engines/pegasus/neighborhood/tsa/tinytsa.h
    engines/pegasus/neighborhood/wsc/wsc.cpp
    engines/pegasus/neighborhood/wsc/wsc.h
    engines/pegasus/scoring.h
    engines/pegasus/transition.h



diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index e98ebd0..eb9a8ab 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -35,209 +35,209 @@ namespace Pegasus {
 
 // TODO: Organize these
 
-const GameID kGameIDNothing = -1;
+static const GameID kGameIDNothing = -1;
 
-const ActorID kNoActorID = kGameIDNothing;
-const ActorID kPlayerID = 0;
-const ItemID kNoItemID = kGameIDNothing;
-const RoomID kNoRoomID = kGameIDNothing;
-const ExtraID kNoExtraID = 0xFFFFFFFF;
-const NeighborhoodID kNoNeighborhoodID = kGameIDNothing;
-const AlternateID kNoAlternateID = 0;
-const GameMenuCommand kMenuCmdNoCommand = 0;
+static const ActorID kNoActorID = kGameIDNothing;
+static const ActorID kPlayerID = 0;
+static const ItemID kNoItemID = kGameIDNothing;
+static const RoomID kNoRoomID = kGameIDNothing;
+static const ExtraID kNoExtraID = 0xFFFFFFFF;
+static const NeighborhoodID kNoNeighborhoodID = kGameIDNothing;
+static const AlternateID kNoAlternateID = 0;
+static const GameMenuCommand kMenuCmdNoCommand = 0;
 
-const HotSpotActivationID kActivateHotSpotAlways = 0;
-const HotSpotActivationID kActivateHotSpotNever = -1;
+static const HotSpotActivationID kActivateHotSpotAlways = 0;
+static const HotSpotActivationID kActivateHotSpotNever = -1;
 
-const ItemState kNoItemState = -1;
+static const ItemState kNoItemState = -1;
 
-const DirectionConstant kNoDirection = 0xFF;
+static const DirectionConstant kNoDirection = 0xFF;
 static const DirectionConstant kNorth = 0;
 static const DirectionConstant kSouth = 1;
 static const DirectionConstant kEast = 2;
 static const DirectionConstant kWest = 3;
 
-const TurnDirection kNoTurn = 0xFF;
-const TurnDirection kTurnLeft = 0;
-const TurnDirection kTurnRight = 1;
-const TurnDirection kTurnUp = 2;
-const TurnDirection kTurnDown = 3;
-const TurnDirection kMaxTurns = 4;
+static const TurnDirection kNoTurn = 0xFF;
+static const TurnDirection kTurnLeft = 0;
+static const TurnDirection kTurnRight = 1;
+static const TurnDirection kTurnUp = 2;
+static const TurnDirection kTurnDown = 3;
+static const TurnDirection kMaxTurns = 4;
 
-const GameMode kNoMode = -1;
-const GameMode kModeNavigation = 0;
-const GameMode kLastGameShellMode = kModeNavigation;
+static const GameMode kNoMode = -1;
+static const GameMode kModeNavigation = 0;
+static const GameMode kLastGameShellMode = kModeNavigation;
 
-const CanMoveForwardReason kCanMoveForward = 0;
-const CanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
-const CanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
-const CanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
-const CanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
+static const CanMoveForwardReason kCanMoveForward = 0;
+static const CanMoveForwardReason kCantMoveBlocked = kCanMoveForward + 1;
+static const CanMoveForwardReason kCantMoveDoorClosed = kCantMoveBlocked + 1;
+static const CanMoveForwardReason kCantMoveDoorLocked = kCantMoveDoorClosed + 1;
+static const CanMoveForwardReason kCantMoveLastReason = kCantMoveDoorLocked;
 
-const CanTurnReason kCanTurn = 0;
-const CanTurnReason kCantTurnNoTurn = kCanTurn + 1;
-const CanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
+static const CanTurnReason kCanTurn = 0;
+static const CanTurnReason kCantTurnNoTurn = kCanTurn + 1;
+static const CanTurnReason kCantTurnLastReason = kCantTurnNoTurn;
 
-const CanOpenDoorReason kCanOpenDoor = 0;
-const CanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
-const CanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
-const CanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
-const CanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
+static const CanOpenDoorReason kCanOpenDoor = 0;
+static const CanOpenDoorReason kCantOpenNoDoor = kCanOpenDoor + 1;
+static const CanOpenDoorReason kCantOpenLocked = kCantOpenNoDoor + 1;
+static const CanOpenDoorReason kCantOpenAlreadyOpen = kCantOpenLocked + 1;
+static const CanOpenDoorReason kCantOpenLastReason = kCantOpenAlreadyOpen;
 
-const DisplayElementID kNoDisplayElement = -1;
-const DisplayElementID kHighestReservedElementID = -2;
+static const DisplayElementID kNoDisplayElement = -1;
+static const DisplayElementID kHighestReservedElementID = -2;
 
-const DisplayElementID kCursorID = kHighestReservedElementID;
-const DisplayElementID kLoadScreenID = kCursorID - 1;
+static const DisplayElementID kCursorID = kHighestReservedElementID;
+static const DisplayElementID kLoadScreenID = kCursorID - 1;
 
-const DisplayOrder kMinAvailableOrder = 0;
-const DisplayOrder kMaxAvailableOrder = 999998;
-const DisplayOrder kLoadScreenOrder = 900000;
-const DisplayOrder kCursorOrder = 1000000;
+static const DisplayOrder kMinAvailableOrder = 0;
+static const DisplayOrder kMaxAvailableOrder = 999998;
+static const DisplayOrder kLoadScreenOrder = 900000;
+static const DisplayOrder kCursorOrder = 1000000;
 
-const HotSpotID kNoHotSpotID = -1;
-const HotSpotFlags kNoHotSpotFlags = 0;
-const HotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
+static const HotSpotID kNoHotSpotID = -1;
+static const HotSpotFlags kNoHotSpotFlags = 0;
+static const HotSpotFlags kAllHotSpotFlags = ~kNoHotSpotFlags;
 
-const NotificationFlags kNoNotificationFlags = 0;
+static const NotificationFlags kNoNotificationFlags = 0;
 
-const DisplayElementID kCurrentDragSpriteID = 1000;
+static const DisplayElementID kCurrentDragSpriteID = 1000;
 
-const TimeScale kDefaultTimeScale = 600;
+static const TimeScale kDefaultTimeScale = 600;
 
 //	Ticks per second.
 
-const TimeScale kOneTickPerSecond = 1;
-const TimeScale kTwoTicksPerSecond = 2;
-const TimeScale kFifteenTicksPerSecond = 15;
-const TimeScale kThirtyTicksPerSecond = 30;
-const TimeScale kSixtyTicksPerSecond = 60;
-const TimeScale kMovieTicksPerSecond = 600;
+static const TimeScale kOneTickPerSecond = 1;
+static const TimeScale kTwoTicksPerSecond = 2;
+static const TimeScale kFifteenTicksPerSecond = 15;
+static const TimeScale kThirtyTicksPerSecond = 30;
+static const TimeScale kSixtyTicksPerSecond = 60;
+static const TimeScale kMovieTicksPerSecond = 600;
 
 //	These times are in seconds.
 
-const TimeValue kOneSecond = 1;
-const TimeValue kTwoSeconds = 2;
-const TimeValue kThreeSeconds = 3;
-const TimeValue kFourSeconds = 4;
-const TimeValue kFiveSeconds = 5;
-const TimeValue kSixSeconds = 6;
-const TimeValue kSevenSeconds = 7;
-const TimeValue kEightSeconds = 8;
-const TimeValue kNineSeconds = 9;
-const TimeValue kTenSeconds = 10;
-const TimeValue kElevenSeconds = 11;
-const TimeValue kTwelveSeconds = 12;
-const TimeValue kThirteenSeconds = 13;
-const TimeValue kFourteenSeconds = 14;
-const TimeValue kFifteenSeconds = 15;
-const TimeValue kSixteenSeconds = 16;
-const TimeValue kSeventeenSeconds = 17;
-const TimeValue kEighteenSeconds = 18;
-const TimeValue kNineteenSeconds = 19;
-const TimeValue kTwentySeconds = 20;
-const TimeValue kThirtySeconds = 30;
-const TimeValue kFortySeconds = 40;
-const TimeValue kFiftySeconds = 50;
-const TimeValue kSixtySeconds = 60;
-const TimeValue kOneMinute = 60;
-const TimeValue kTwoMinutes = kOneMinute * 2;
-const TimeValue kThreeMinutes = kOneMinute * 3;
-const TimeValue kFourMinutes = kOneMinute * 4;
-const TimeValue kFiveMinutes = kOneMinute * 5;
-const TimeValue kSixMinutes = kOneMinute * 6;
-const TimeValue kSevenMinutes = kOneMinute * 7;
-const TimeValue kEightMinutes = kOneMinute * 8;
-const TimeValue kNineMinutes = kOneMinute * 9;
-const TimeValue kTenMinutes = kOneMinute * 10;
-const TimeValue kElevenMinutes = kOneMinute * 11;
-const TimeValue kTwelveMinutes = kOneMinute * 12;
-const TimeValue kThirteenMinutes = kOneMinute * 13;
-const TimeValue kFourteenMinutes = kOneMinute * 14;
-const TimeValue kFifteenMinutes = kOneMinute * 15;
-const TimeValue kSixteenMinutes = kOneMinute * 16;
-const TimeValue kSeventeenMinutes = kOneMinute * 17;
-const TimeValue kEighteenMinutes = kOneMinute * 18;
-const TimeValue kNineteenMinutes = kOneMinute * 19;
-const TimeValue kTwentyMinutes = kOneMinute * 20;
-const TimeValue kThirtyMinutes = kOneMinute * 30;
-const TimeValue kFortyMinutes = kOneMinute * 40;
-const TimeValue kFiftyMinutes = kOneMinute * 50;
-const TimeValue kOneHour = kOneMinute * 60;
-const TimeValue kTwoHours = kOneHour * 2;
+static const TimeValue kOneSecond = 1;
+static const TimeValue kTwoSeconds = 2;
+static const TimeValue kThreeSeconds = 3;
+static const TimeValue kFourSeconds = 4;
+static const TimeValue kFiveSeconds = 5;
+static const TimeValue kSixSeconds = 6;
+static const TimeValue kSevenSeconds = 7;
+static const TimeValue kEightSeconds = 8;
+static const TimeValue kNineSeconds = 9;
+static const TimeValue kTenSeconds = 10;
+static const TimeValue kElevenSeconds = 11;
+static const TimeValue kTwelveSeconds = 12;
+static const TimeValue kThirteenSeconds = 13;
+static const TimeValue kFourteenSeconds = 14;
+static const TimeValue kFifteenSeconds = 15;
+static const TimeValue kSixteenSeconds = 16;
+static const TimeValue kSeventeenSeconds = 17;
+static const TimeValue kEighteenSeconds = 18;
+static const TimeValue kNineteenSeconds = 19;
+static const TimeValue kTwentySeconds = 20;
+static const TimeValue kThirtySeconds = 30;
+static const TimeValue kFortySeconds = 40;
+static const TimeValue kFiftySeconds = 50;
+static const TimeValue kSixtySeconds = 60;
+static const TimeValue kOneMinute = 60;
+static const TimeValue kTwoMinutes = kOneMinute * 2;
+static const TimeValue kThreeMinutes = kOneMinute * 3;
+static const TimeValue kFourMinutes = kOneMinute * 4;
+static const TimeValue kFiveMinutes = kOneMinute * 5;
+static const TimeValue kSixMinutes = kOneMinute * 6;
+static const TimeValue kSevenMinutes = kOneMinute * 7;
+static const TimeValue kEightMinutes = kOneMinute * 8;
+static const TimeValue kNineMinutes = kOneMinute * 9;
+static const TimeValue kTenMinutes = kOneMinute * 10;
+static const TimeValue kElevenMinutes = kOneMinute * 11;
+static const TimeValue kTwelveMinutes = kOneMinute * 12;
+static const TimeValue kThirteenMinutes = kOneMinute * 13;
+static const TimeValue kFourteenMinutes = kOneMinute * 14;
+static const TimeValue kFifteenMinutes = kOneMinute * 15;
+static const TimeValue kSixteenMinutes = kOneMinute * 16;
+static const TimeValue kSeventeenMinutes = kOneMinute * 17;
+static const TimeValue kEighteenMinutes = kOneMinute * 18;
+static const TimeValue kNineteenMinutes = kOneMinute * 19;
+static const TimeValue kTwentyMinutes = kOneMinute * 20;
+static const TimeValue kThirtyMinutes = kOneMinute * 30;
+static const TimeValue kFortyMinutes = kOneMinute * 40;
+static const TimeValue kFiftyMinutes = kOneMinute * 50;
+static const TimeValue kOneHour = kOneMinute * 60;
+static const TimeValue kTwoHours = kOneHour * 2;
 
 //	Common times.
 
-const TimeValue kHalfSecondPerTwoTicks = kTwoTicksPerSecond / 2;
-const TimeValue kHalfSecondPerThirtyTicks = kThirtyTicksPerSecond / 2;
-const TimeValue kHalfSecondPerSixtyTicks = kSixtyTicksPerSecond / 2;
+static const TimeValue kHalfSecondPerTwoTicks = kTwoTicksPerSecond / 2;
+static const TimeValue kHalfSecondPerThirtyTicks = kThirtyTicksPerSecond / 2;
+static const TimeValue kHalfSecondPerSixtyTicks = kSixtyTicksPerSecond / 2;
 
-const TimeValue kOneSecondPerTwoTicks = kTwoTicksPerSecond;
-const TimeValue kOneSecondPerThirtyTicks = kThirtyTicksPerSecond;
-const TimeValue kOneSecondPerSixtyTicks = kSixtyTicksPerSecond;
+static const TimeValue kOneSecondPerTwoTicks = kTwoTicksPerSecond;
+static const TimeValue kOneSecondPerThirtyTicks = kThirtyTicksPerSecond;
+static const TimeValue kOneSecondPerSixtyTicks = kSixtyTicksPerSecond;
 
-const TimeValue kOneMinutePerFifteenTicks = kOneMinute * kFifteenTicksPerSecond;
-const TimeValue kFiveMinutesPerFifteenTicks = kFiveMinutes * kFifteenTicksPerSecond;
-const TimeValue kTenMinutesPerFifteenTicks = kTenMinutes * kFifteenTicksPerSecond;
+static const TimeValue kOneMinutePerFifteenTicks = kOneMinute * kFifteenTicksPerSecond;
+static const TimeValue kFiveMinutesPerFifteenTicks = kFiveMinutes * kFifteenTicksPerSecond;
+static const TimeValue kTenMinutesPerFifteenTicks = kTenMinutes * kFifteenTicksPerSecond;
 
-const TimeValue kOneMinutePerThirtyTicks = kOneMinute * kThirtyTicksPerSecond;
-const TimeValue kFiveMinutesPerThirtyTicks = kFiveMinutes * kThirtyTicksPerSecond;
-const TimeValue kTenMinutesPerThirtyTicks = kTenMinutes * kThirtyTicksPerSecond;
+static const TimeValue kOneMinutePerThirtyTicks = kOneMinute * kThirtyTicksPerSecond;
+static const TimeValue kFiveMinutesPerThirtyTicks = kFiveMinutes * kThirtyTicksPerSecond;
+static const TimeValue kTenMinutesPerThirtyTicks = kTenMinutes * kThirtyTicksPerSecond;
 
-const TimeValue kOneMinutePerSixtyTicks = kOneMinute * kSixtyTicksPerSecond;
-const TimeValue kFiveMinutesPerSixtyTicks = kFiveMinutes * kSixtyTicksPerSecond;
-const TimeValue kTenMinutesPerSixtyTicks = kTenMinutes * kSixtyTicksPerSecond;
+static const TimeValue kOneMinutePerSixtyTicks = kOneMinute * kSixtyTicksPerSecond;
+static const TimeValue kFiveMinutesPerSixtyTicks = kFiveMinutes * kSixtyTicksPerSecond;
+static const TimeValue kTenMinutesPerSixtyTicks = kTenMinutes * kSixtyTicksPerSecond;
 
 //	Time in seconds you can hang around Caldoria without going to work...
-const TimeValue kLateWarning2TimeLimit = kFiveMinutes;
-const TimeValue kLateWarning3TimeLimit = kTenMinutes;
-
-const TimeValue kSinclairShootsTimeLimit = kThreeMinutes;
-const TimeValue kCardBombCountDownTime = kTwelveSeconds;
-
-const TimeValue kOxyMaskFullTime = kThirtyMinutes;
-
-const TimeValue kTSAUncreatedTimeLimit = kFiveMinutes;
-const TimeValue kRipTimeLimit = kTenMinutesPerFifteenTicks;
-const TimeScale kRipTimeScale = kFifteenTicksPerSecond;
-
-const TimeValue kIntroTimeOut = kThirtySeconds;
-
-const TimeValue kMarsRobotPatienceLimit = kFifteenSeconds;
-const TimeValue kLockFreezeTimeLmit = kFifteenSeconds;
-const TimeValue kSpaceChaseTimeLimit = kTenMinutes;
-const TimeValue kVacuumSurvivalTimeLimit = kThirtySeconds;
-const TimeValue kColorMatchingTimeLimit = kFourMinutes;
-const TimeScale kJunkTimeScale = kFifteenTicksPerSecond;
-const TimeValue kJunkDropBaseTime = kFiveSeconds;
-const TimeValue kJunkDropSlopTime = kThreeSeconds;
-const TimeValue kJunkTravelTime = kTenSeconds * kJunkTimeScale;
-const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
-const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
-
-const TimeValue kGawkAtRobotTime = kTenSeconds;
-const TimeValue kGawkAtRobotTime2 = kThirteenSeconds;
-const TimeValue kPlasmaImpactTime = kTwoSeconds;
-
-const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
-
-const NotificationID kNeighborhoodNotificationID = 1;
-const NotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
-
-const NotificationFlags kNeighborhoodMovieCompletedFlag = 1;
-const NotificationFlags kMoveForwardCompletedFlag = kNeighborhoodMovieCompletedFlag << 1;
-const NotificationFlags kStrideCompletedFlag = kMoveForwardCompletedFlag << 1;
-const NotificationFlags kTurnCompletedFlag = kStrideCompletedFlag << 1;
-const NotificationFlags kSpotCompletedFlag = kTurnCompletedFlag << 1;
-const NotificationFlags kDoorOpenCompletedFlag = kSpotCompletedFlag << 1;
-const NotificationFlags kExtraCompletedFlag = kDoorOpenCompletedFlag << 1;
-const NotificationFlags kSpotSoundCompletedFlag = kExtraCompletedFlag << 1;
-const NotificationFlags kDelayCompletedFlag = kSpotSoundCompletedFlag << 1;
-const NotificationFlags kActionRequestCompletedFlag = kDelayCompletedFlag << 1;
-const NotificationFlags kDeathExtraCompletedFlag = kActionRequestCompletedFlag << 1;
-const NotificationFlags kLastNeighborhoodNotificationFlag = kDeathExtraCompletedFlag;
-
-const NotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
+static const TimeValue kLateWarning2TimeLimit = kFiveMinutes;
+static const TimeValue kLateWarning3TimeLimit = kTenMinutes;
+
+static const TimeValue kSinclairShootsTimeLimit = kThreeMinutes;
+static const TimeValue kCardBombCountDownTime = kTwelveSeconds;
+
+static const TimeValue kOxyMaskFullTime = kThirtyMinutes;
+
+static const TimeValue kTSAUncreatedTimeLimit = kFiveMinutes;
+static const TimeValue kRipTimeLimit = kTenMinutesPerFifteenTicks;
+static const TimeScale kRipTimeScale = kFifteenTicksPerSecond;
+
+static const TimeValue kIntroTimeOut = kThirtySeconds;
+
+static const TimeValue kMarsRobotPatienceLimit = kFifteenSeconds;
+static const TimeValue kLockFreezeTimeLmit = kFifteenSeconds;
+static const TimeValue kSpaceChaseTimeLimit = kTenMinutes;
+static const TimeValue kVacuumSurvivalTimeLimit = kThirtySeconds;
+static const TimeValue kColorMatchingTimeLimit = kFourMinutes;
+static const TimeScale kJunkTimeScale = kFifteenTicksPerSecond;
+static const TimeValue kJunkDropBaseTime = kFiveSeconds;
+static const TimeValue kJunkDropSlopTime = kThreeSeconds;
+static const TimeValue kJunkTravelTime = kTenSeconds * kJunkTimeScale;
+static const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
+static const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
+
+static const TimeValue kGawkAtRobotTime = kTenSeconds;
+static const TimeValue kGawkAtRobotTime2 = kThirteenSeconds;
+static const TimeValue kPlasmaImpactTime = kTwoSeconds;
+
+static const TimeValue kNoradAirMaskTimeLimit = kOneMinute + kFifteenSeconds;
+
+static const NotificationID kNeighborhoodNotificationID = 1;
+static const NotificationID kLastNeighborhoodNotificationID = kNeighborhoodNotificationID;
+
+static const NotificationFlags kNeighborhoodMovieCompletedFlag = 1;
+static const NotificationFlags kMoveForwardCompletedFlag = kNeighborhoodMovieCompletedFlag << 1;
+static const NotificationFlags kStrideCompletedFlag = kMoveForwardCompletedFlag << 1;
+static const NotificationFlags kTurnCompletedFlag = kStrideCompletedFlag << 1;
+static const NotificationFlags kSpotCompletedFlag = kTurnCompletedFlag << 1;
+static const NotificationFlags kDoorOpenCompletedFlag = kSpotCompletedFlag << 1;
+static const NotificationFlags kExtraCompletedFlag = kDoorOpenCompletedFlag << 1;
+static const NotificationFlags kSpotSoundCompletedFlag = kExtraCompletedFlag << 1;
+static const NotificationFlags kDelayCompletedFlag = kSpotSoundCompletedFlag << 1;
+static const NotificationFlags kActionRequestCompletedFlag = kDelayCompletedFlag << 1;
+static const NotificationFlags kDeathExtraCompletedFlag = kActionRequestCompletedFlag << 1;
+static const NotificationFlags kLastNeighborhoodNotificationFlag = kDeathExtraCompletedFlag;
+
+static const NotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
 												kMoveForwardCompletedFlag |
 												kStrideCompletedFlag |
 												kTurnCompletedFlag |
@@ -249,163 +249,163 @@ const NotificationFlags kNeighborhoodFlags =	kNeighborhoodMovieCompletedFlag |
 												kActionRequestCompletedFlag |
 												kDeathExtraCompletedFlag;
 
-const uint32 kPegasusPrimeCreator = MKTAG('J', 'P', 'P', 'P');
-const uint32 kPegasusPrimeContinueType = MKTAG('P', 'P', 'C', 'T');
+static const uint32 kPegasusPrimeCreator = MKTAG('J', 'P', 'P', 'P');
+static const uint32 kPegasusPrimeContinueType = MKTAG('P', 'P', 'C', 'T');
 
-const uint32 kPegasusPrimeDisk1GameType = MKTAG('P', 'P', 'G', '1');
-const uint32 kPegasusPrimeDisk2GameType = MKTAG('P', 'P', 'G', '2');
-const uint32 kPegasusPrimeDisk3GameType = MKTAG('P', 'P', 'G', '3');
-const uint32 kPegasusPrimeDisk4GameType = MKTAG('P', 'P', 'G', '4');
+static const uint32 kPegasusPrimeDisk1GameType = MKTAG('P', 'P', 'G', '1');
+static const uint32 kPegasusPrimeDisk2GameType = MKTAG('P', 'P', 'G', '2');
+static const uint32 kPegasusPrimeDisk3GameType = MKTAG('P', 'P', 'G', '3');
+static const uint32 kPegasusPrimeDisk4GameType = MKTAG('P', 'P', 'G', '4');
 
 // We only support one of the save versions; the rest are from betas
 // and we are not supporting them.
-const uint32 kPegasusPrimeVersion = 0x00009019;
+static const uint32 kPegasusPrimeVersion = 0x00009019;
 
-const char kNormalSave = 0;
-const char kContinueSave = 1;
+static const char kNormalSave = 0;
+static const char kContinueSave = 1;
 
 //	Display IDs.
 
-const DisplayElementID kNavMovieID = 1;
-const DisplayElementID kTurnPushID = 2;
+static const DisplayElementID kNavMovieID = 1;
+static const DisplayElementID kTurnPushID = 2;
 
-const DisplayElementID kMaxGameShellDisplayID = kTurnPushID;
+static const DisplayElementID kMaxGameShellDisplayID = kTurnPushID;
 
 //	Display ordering.
 
-const DisplayOrder kNavLayer = 10000;
-const DisplayOrder kNavMovieOrder = kNavLayer;
-const DisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
+static const DisplayOrder kNavLayer = 10000;
+static const DisplayOrder kNavMovieOrder = kNavLayer;
+static const DisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
 
 /////////////////////////////////////////////
 //
 //	Display IDs.
 
-const DisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
-const DisplayElementID kInterface1ID = kScreenDimmerID + 1;
-const DisplayElementID kInterface2ID = kInterface1ID + 1;
-const DisplayElementID kInterface3ID = kInterface2ID + 1;
-const DisplayElementID kInterface4ID = kInterface3ID + 1;
-const DisplayElementID kDateID = kInterface4ID + 1;
-const DisplayElementID kCompassID = kDateID + 1;
-const DisplayElementID kInventoryPushID = kCompassID + 1;
-const DisplayElementID kInventoryLidID = kInventoryPushID + 1;
-const DisplayElementID kBiochipPushID = kInventoryLidID + 1;
-const DisplayElementID kBiochipLidID = kBiochipPushID + 1;
-const DisplayElementID kEnergyBarID = kBiochipLidID + 1;
-const DisplayElementID kWarningLightID = kEnergyBarID + 1;
-const DisplayElementID kAILeftAreaID = kWarningLightID + 1;
-const DisplayElementID kAIMiddleAreaID = kAILeftAreaID + 1;
-const DisplayElementID kAIRightAreaID = kAIMiddleAreaID + 1;
-const DisplayElementID kAIMovieID = kAIRightAreaID + 1;
-const DisplayElementID kInventoryDropHighlightID = kAIMovieID + 1;
-const DisplayElementID kBiochipDropHighlightID = kInventoryDropHighlightID + 1;
+static const DisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
+static const DisplayElementID kInterface1ID = kScreenDimmerID + 1;
+static const DisplayElementID kInterface2ID = kInterface1ID + 1;
+static const DisplayElementID kInterface3ID = kInterface2ID + 1;
+static const DisplayElementID kInterface4ID = kInterface3ID + 1;
+static const DisplayElementID kDateID = kInterface4ID + 1;
+static const DisplayElementID kCompassID = kDateID + 1;
+static const DisplayElementID kInventoryPushID = kCompassID + 1;
+static const DisplayElementID kInventoryLidID = kInventoryPushID + 1;
+static const DisplayElementID kBiochipPushID = kInventoryLidID + 1;
+static const DisplayElementID kBiochipLidID = kBiochipPushID + 1;
+static const DisplayElementID kEnergyBarID = kBiochipLidID + 1;
+static const DisplayElementID kWarningLightID = kEnergyBarID + 1;
+static const DisplayElementID kAILeftAreaID = kWarningLightID + 1;
+static const DisplayElementID kAIMiddleAreaID = kAILeftAreaID + 1;
+static const DisplayElementID kAIRightAreaID = kAIMiddleAreaID + 1;
+static const DisplayElementID kAIMovieID = kAIRightAreaID + 1;
+static const DisplayElementID kInventoryDropHighlightID = kAIMovieID + 1;
+static const DisplayElementID kBiochipDropHighlightID = kInventoryDropHighlightID + 1;
 
-const DisplayElementID kDraggingSpriteID = 1000;
+static const DisplayElementID kDraggingSpriteID = 1000;
 
-const DisplayElementID kCroppedMovieID = 2000;
+static const DisplayElementID kCroppedMovieID = 2000;
 
-const DisplayElementID kNeighborhoodDisplayID = 3000;
+static const DisplayElementID kNeighborhoodDisplayID = 3000;
 
-const DisplayElementID kItemPictureBaseID = 5000;
+static const DisplayElementID kItemPictureBaseID = 5000;
 
-const CoordType kNavAreaLeft = 64;
-const CoordType kNavAreaTop = 64;
+static const CoordType kNavAreaLeft = 64;
+static const CoordType kNavAreaTop = 64;
 
-const CoordType kBackground1Left = 0;
-const CoordType kBackground1Top = 64;
+static const CoordType kBackground1Left = 0;
+static const CoordType kBackground1Top = 64;
 
-const CoordType kBackground2Left = 0;
-const CoordType kBackground2Top = 0;
+static const CoordType kBackground2Left = 0;
+static const CoordType kBackground2Top = 0;
 
-const CoordType kBackground3Left = 576;
-const CoordType kBackground3Top = 64;
+static const CoordType kBackground3Left = 576;
+static const CoordType kBackground3Top = 64;
 
-const CoordType kBackground4Left = 0;
-const CoordType kBackground4Top = 320;
+static const CoordType kBackground4Left = 0;
+static const CoordType kBackground4Top = 320;
 
-const CoordType kOverviewControllerLeft = 540;
-const CoordType kOverviewControllerTop = 348;
+static const CoordType kOverviewControllerLeft = 540;
+static const CoordType kOverviewControllerTop = 348;
 
-const CoordType kSwapLeft = 194;
-const CoordType kSwapTop = 116;
+static const CoordType kSwapLeft = 194;
+static const CoordType kSwapTop = 116;
 
-const CoordType kSwapHiliteLeft = 200;
-const CoordType kSwapHiliteTop = 206;
+static const CoordType kSwapHiliteLeft = 200;
+static const CoordType kSwapHiliteTop = 206;
 
-const CoordType kDateLeft = 136;
-const CoordType kDateTop = 44;
+static const CoordType kDateLeft = 136;
+static const CoordType kDateTop = 44;
 
-const CoordType kCompassLeft = 222;
-const CoordType kCompassTop = 42;
-const CoordType kCompassWidth = 92;
+static const CoordType kCompassLeft = 222;
+static const CoordType kCompassTop = 42;
+static const CoordType kCompassWidth = 92;
 
-const CoordType kInventoryPushLeft = 74;
-const CoordType kInventoryPushTop = 92;
+static const CoordType kInventoryPushLeft = 74;
+static const CoordType kInventoryPushTop = 92;
 
-const CoordType kInventoryLidLeft = 74;
-const CoordType kInventoryLidTop = 316;
+static const CoordType kInventoryLidLeft = 74;
+static const CoordType kInventoryLidTop = 316;
 
-const CoordType kBiochipPushLeft = 362;
-const CoordType kBiochipPushTop = 192;
+static const CoordType kBiochipPushLeft = 362;
+static const CoordType kBiochipPushTop = 192;
 
-const CoordType kBiochipLidLeft = 362;
-const CoordType kBiochipLidTop = 316;
+static const CoordType kBiochipLidLeft = 362;
+static const CoordType kBiochipLidTop = 316;
 
-const CoordType kInventoryDropLeft = 0;
-const CoordType kInventoryDropTop = 320;
-const CoordType kInventoryDropRight = 232;
-const CoordType kInventoryDropBottom = 480;
+static const CoordType kInventoryDropLeft = 0;
+static const CoordType kInventoryDropTop = 320;
+static const CoordType kInventoryDropRight = 232;
+static const CoordType kInventoryDropBottom = 480;
 
-const CoordType kBiochipDropLeft = 302;
-const CoordType kBiochipDropTop = 320;
-const CoordType kBiochipDropRight = 640;
-const CoordType kBiochipDropBottom = 480;
+static const CoordType kBiochipDropLeft = 302;
+static const CoordType kBiochipDropTop = 320;
+static const CoordType kBiochipDropRight = 640;
+static const CoordType kBiochipDropBottom = 480;
 
-const CoordType kFinalMessageLeft = kInventoryPushLeft + 1;
-const CoordType kFinalMessageTop = kInventoryPushTop + 24;
+static const CoordType kFinalMessageLeft = kInventoryPushLeft + 1;
+static const CoordType kFinalMessageTop = kInventoryPushTop + 24;
 
 /////////////////////////////////////////////
 //
 //	Notifications.
 
-const NotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
-const NotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
-const NotificationID kAINotificationID = kInterfaceNotificationID + 1;
-const NotificationID kNoradNotificationID = kAINotificationID + 1;
-const NotificationID kNoradECRNotificationID = kNoradNotificationID + 1;
-const NotificationID kNoradFillingStationNotificationID = kNoradECRNotificationID + 1;
-const NotificationID kNoradPressureNotificationID = kNoradFillingStationNotificationID + 1;
-const NotificationID kNoradUtilityNotificationID = kNoradPressureNotificationID + 1;
-const NotificationID kNoradElevatorNotificationID = kNoradUtilityNotificationID + 1;
-const NotificationID kNoradSubPlatformNotificationID = kNoradElevatorNotificationID + 1;
-const NotificationID kSubControlNotificationID = kNoradSubPlatformNotificationID + 1;
-const NotificationID kNoradGreenBallNotificationID = kSubControlNotificationID + 1;
-const NotificationID kNoradGlobeNotificationID = kNoradGreenBallNotificationID + 1;
-const NotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotificationID + 1;
-const NotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
-const NotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
+static const NotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
+static const NotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
+static const NotificationID kAINotificationID = kInterfaceNotificationID + 1;
+static const NotificationID kNoradNotificationID = kAINotificationID + 1;
+static const NotificationID kNoradECRNotificationID = kNoradNotificationID + 1;
+static const NotificationID kNoradFillingStationNotificationID = kNoradECRNotificationID + 1;
+static const NotificationID kNoradPressureNotificationID = kNoradFillingStationNotificationID + 1;
+static const NotificationID kNoradUtilityNotificationID = kNoradPressureNotificationID + 1;
+static const NotificationID kNoradElevatorNotificationID = kNoradUtilityNotificationID + 1;
+static const NotificationID kNoradSubPlatformNotificationID = kNoradElevatorNotificationID + 1;
+static const NotificationID kSubControlNotificationID = kNoradSubPlatformNotificationID + 1;
+static const NotificationID kNoradGreenBallNotificationID = kSubControlNotificationID + 1;
+static const NotificationID kNoradGlobeNotificationID = kNoradGreenBallNotificationID + 1;
+static const NotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotificationID + 1;
+static const NotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
+static const NotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
 
 //	Sent to the shell by fShellNotification.
-const NotificationFlags kGameStartingFlag = 1;
-const NotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
-const NotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
+static const NotificationFlags kGameStartingFlag = 1;
+static const NotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
+static const NotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
 
-const NotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
+static const NotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
 														kNeedNewJumpFlag |
 														kPlayerDiedFlag;
 
 //	Sent to the interface.
-const NotificationFlags kInventoryLidOpenFlag = 1;
-const NotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
-const NotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
-const NotificationFlags kInventoryDrawerDownFlag = kInventoryDrawerUpFlag << 1;
-const NotificationFlags kBiochipLidOpenFlag = kInventoryDrawerDownFlag << 1;
-const NotificationFlags kBiochipLidClosedFlag = kBiochipLidOpenFlag << 1;
-const NotificationFlags kBiochipDrawerUpFlag = kBiochipLidClosedFlag << 1;
-const NotificationFlags kBiochipDrawerDownFlag = kBiochipDrawerUpFlag << 1;
-
-const NotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
+static const NotificationFlags kInventoryLidOpenFlag = 1;
+static const NotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
+static const NotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
+static const NotificationFlags kInventoryDrawerDownFlag = kInventoryDrawerUpFlag << 1;
+static const NotificationFlags kBiochipLidOpenFlag = kInventoryDrawerDownFlag << 1;
+static const NotificationFlags kBiochipLidClosedFlag = kBiochipLidOpenFlag << 1;
+static const NotificationFlags kBiochipDrawerUpFlag = kBiochipLidClosedFlag << 1;
+static const NotificationFlags kBiochipDrawerDownFlag = kBiochipDrawerUpFlag << 1;
+
+static const NotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
 														kInventoryLidClosedFlag |
 														kInventoryDrawerUpFlag |
 														kInventoryDrawerDownFlag |
@@ -418,28 +418,28 @@ const NotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFlag |
 
 //	Neighborhood hot spots.
 
-const HotSpotID kFirstNeighborhoodSpotID = 5000;
+static const HotSpotID kFirstNeighborhoodSpotID = 5000;
 
 //	kShellSpotFlag is a flag which marks all hot spots which belong to the shell, like
 //	the current item and current biochip spots.
-const HotSpotFlags kShellSpotFlag = 1;
+static const HotSpotFlags kShellSpotFlag = 1;
 //	kNeighborhoodSpotFlag is a flag which marks all hot spots which belong to a
 //	neighborhood, like buttons on walls and so on.
-const HotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
+static const HotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
 //	kZoomInSpotFlag is a flag which marks all hot spots which indicate a zoom.
-const HotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
+static const HotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
 //	kZoomOutSpotFlag is a flag which marks all hot spots which indicate a zoom.
-const HotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
+static const HotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
 
-const HotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
-const HotSpotFlags kPlayExtraSpotFlag = kClickSpotFlag << 1;
-const HotSpotFlags kPickUpItemSpotFlag = kPlayExtraSpotFlag << 1;
-const HotSpotFlags kDropItemSpotFlag = kPickUpItemSpotFlag << 1;
-const HotSpotFlags kOpenDoorSpotFlag = kDropItemSpotFlag << 1;
+static const HotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
+static const HotSpotFlags kPlayExtraSpotFlag = kClickSpotFlag << 1;
+static const HotSpotFlags kPickUpItemSpotFlag = kPlayExtraSpotFlag << 1;
+static const HotSpotFlags kDropItemSpotFlag = kPickUpItemSpotFlag << 1;
+static const HotSpotFlags kOpenDoorSpotFlag = kDropItemSpotFlag << 1;
 
-const HotSpotFlags kZoomSpotFlags = kZoomInSpotFlag | kZoomOutSpotFlag;
+static const HotSpotFlags kZoomSpotFlags = kZoomInSpotFlag | kZoomOutSpotFlag;
 
-const HotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
+static const HotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
 
 /////////////////////////////////////////////
 //
@@ -448,64 +448,64 @@ const HotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
 //	Shell hot spots.
 //	The shell reserves all hot spot IDs from 0 to 999
 
-const HotSpotID kCurrentItemSpotID = 0;
-const HotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
+static const HotSpotID kCurrentItemSpotID = 0;
+static const HotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
 
-const HotSpotID kInventoryDropSpotID = kCurrentBiochipSpotID + 1;
-const HotSpotID kBiochipDropSpotID = kInventoryDropSpotID + 1;
+static const HotSpotID kInventoryDropSpotID = kCurrentBiochipSpotID + 1;
+static const HotSpotID kBiochipDropSpotID = kInventoryDropSpotID + 1;
 
-const HotSpotID kInfoReturnSpotID = kBiochipDropSpotID + 1;
+static const HotSpotID kInfoReturnSpotID = kBiochipDropSpotID + 1;
 
-const HotSpotID kAIHint1SpotID = kInfoReturnSpotID + 1;
-const HotSpotID kAIHint2SpotID = kAIHint1SpotID + 1;
-const HotSpotID kAIHint3SpotID = kAIHint2SpotID + 1;
-const HotSpotID kAISolveSpotID = kAIHint3SpotID + 1;
-const HotSpotID kAIBriefingSpotID = kAISolveSpotID + 1;
-const HotSpotID kAIScanSpotID = kAIBriefingSpotID + 1;
+static const HotSpotID kAIHint1SpotID = kInfoReturnSpotID + 1;
+static const HotSpotID kAIHint2SpotID = kAIHint1SpotID + 1;
+static const HotSpotID kAIHint3SpotID = kAIHint2SpotID + 1;
+static const HotSpotID kAISolveSpotID = kAIHint3SpotID + 1;
+static const HotSpotID kAIBriefingSpotID = kAISolveSpotID + 1;
+static const HotSpotID kAIScanSpotID = kAIBriefingSpotID + 1;
 
-const HotSpotID kPegasusRecallSpotID = kAIScanSpotID + 1;
+static const HotSpotID kPegasusRecallSpotID = kAIScanSpotID + 1;
 
-const HotSpotID kAriesSpotID = kPegasusRecallSpotID + 1;
-const HotSpotID kMercurySpotID = kAriesSpotID + 1;
-const HotSpotID kPoseidonSpotID = kMercurySpotID + 1;
+static const HotSpotID kAriesSpotID = kPegasusRecallSpotID + 1;
+static const HotSpotID kMercurySpotID = kAriesSpotID + 1;
+static const HotSpotID kPoseidonSpotID = kMercurySpotID + 1;
 
-const HotSpotID kAirMaskToggleSpotID = kPoseidonSpotID + 1;
+static const HotSpotID kAirMaskToggleSpotID = kPoseidonSpotID + 1;
 
-const HotSpotID kShuttleEnergySpotID = kAirMaskToggleSpotID + 1;
-const HotSpotID kShuttleGravitonSpotID = kShuttleEnergySpotID + 1;
-const HotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
-const HotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
-const HotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
+static const HotSpotID kShuttleEnergySpotID = kAirMaskToggleSpotID + 1;
+static const HotSpotID kShuttleGravitonSpotID = kShuttleEnergySpotID + 1;
+static const HotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
+static const HotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
+static const HotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
 
 //	Most of these are obsolete:
 
 //	kInventoryDropSpotFlag is a flag which marks hot spots which are valid drop spots
 //	for inventory items.
-//	const HotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
+//	static const HotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
 
 //	kBiochipDropSpotFlag is a flag which marks hot spots which are valid drop spots
 //	for biochips.
-//	const HotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
+//	static const HotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
 
 //	kInventorySpotFlag is a flag which marks hot spots which indicate inventory items
 //	in the environment.
-//	const HotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
+//	static const HotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
 
 //	kBiochipSpotFlag is a flag which marks hot spots which indicate biochips
 //	in the environment.
-const HotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
-const HotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
+static const HotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
+static const HotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
 
-const HotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
+static const HotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
 
 //	Biochip and inventory hot spot flags...
 
-const HotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
-const HotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
-const HotSpotFlags kOpticalBiochipSpotFlag = kPegasusBiochipSpotFlag << 1;
-const HotSpotFlags kAirMaskSpotFlag = kOpticalBiochipSpotFlag << 1;
+static const HotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
+static const HotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
+static const HotSpotFlags kOpticalBiochipSpotFlag = kPegasusBiochipSpotFlag << 1;
+static const HotSpotFlags kAirMaskSpotFlag = kOpticalBiochipSpotFlag << 1;
 
-const HotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
+static const HotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
 											kPlayExtraSpotFlag |
 											kOpenDoorSpotFlag |
 											kInfoReturnSpotFlag |
@@ -514,115 +514,115 @@ const HotSpotFlags kJMPClickingSpotFlags = kClickSpotFlag |
 											kOpticalBiochipSpotFlag |
 											kAirMaskSpotFlag;
 
-const int32 kMainMenuID = 1;
-const int32 kPauseMenuID = 2;
-const int32 kCreditsMenuID = 3;
-const int32 kDeathMenuID = 4;
+static const int32 kMainMenuID = 1;
+static const int32 kPauseMenuID = 2;
+static const int32 kCreditsMenuID = 3;
+static const int32 kDeathMenuID = 4;
 
 /////////////////////////////////////////////
 //
 //	Menu commands.
 
-const GameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
-const GameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
-const GameMenuCommand kMenuCmdStartWalkthrough = kMenuCmdStartAdventure + 1;
-const GameMenuCommand kMenuCmdRestore = kMenuCmdStartWalkthrough + 1;
-const GameMenuCommand kMenuCmdCredits = kMenuCmdRestore + 1;
-const GameMenuCommand kMenuCmdQuit = kMenuCmdCredits + 1;
+static const GameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
+static const GameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
+static const GameMenuCommand kMenuCmdStartWalkthrough = kMenuCmdStartAdventure + 1;
+static const GameMenuCommand kMenuCmdRestore = kMenuCmdStartWalkthrough + 1;
+static const GameMenuCommand kMenuCmdCredits = kMenuCmdRestore + 1;
+static const GameMenuCommand kMenuCmdQuit = kMenuCmdCredits + 1;
 
-const GameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
+static const GameMenuCommand kMenuCmdDeathContinue = kMenuCmdQuit + 1;
 
-const GameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
-const GameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
+static const GameMenuCommand kMenuCmdDeathQuitDemo = kMenuCmdDeathContinue + 1;
+static const GameMenuCommand kMenuCmdDeathMainMenuDemo = kMenuCmdDeathQuitDemo + 1;
 
-const GameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathMainMenuDemo + 1;
-const GameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
+static const GameMenuCommand kMenuCmdDeathRestore = kMenuCmdDeathMainMenuDemo + 1;
+static const GameMenuCommand kMenuCmdDeathMainMenu = kMenuCmdDeathRestore + 1;
 
-const GameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
-const GameMenuCommand kMenuCmdPauseContinue = kMenuCmdPauseSave + 1;
-const GameMenuCommand kMenuCmdPauseRestore = kMenuCmdPauseContinue + 1;
-const GameMenuCommand kMenuCmdPauseQuit = kMenuCmdPauseRestore + 1;
+static const GameMenuCommand kMenuCmdPauseSave = kMenuCmdDeathMainMenu + 1;
+static const GameMenuCommand kMenuCmdPauseContinue = kMenuCmdPauseSave + 1;
+static const GameMenuCommand kMenuCmdPauseRestore = kMenuCmdPauseContinue + 1;
+static const GameMenuCommand kMenuCmdPauseQuit = kMenuCmdPauseRestore + 1;
 
-const GameMenuCommand kMenuCmdCreditsMainMenu = kMenuCmdPauseQuit + 1;
+static const GameMenuCommand kMenuCmdCreditsMainMenu = kMenuCmdPauseQuit + 1;
 
-const GameMenuCommand kMenuCmdCancelRestart = kMenuCmdCreditsMainMenu + 1;
-const GameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
+static const GameMenuCommand kMenuCmdCancelRestart = kMenuCmdCreditsMainMenu + 1;
+static const GameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
 
-const TimeValue kMenuButtonHiliteTime = 20;
-const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
+static const TimeValue kMenuButtonHiliteTime = 20;
+static const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
 
 //	PICT resources:
 
 //	Warning light PICTs:
 
-const ResIDType kLightOffID = 128;
-const ResIDType kLightYellowID = 129;
-const ResIDType kLightOrangeID = 130;
-const ResIDType kLightRedID = 131;
+static const ResIDType kLightOffID = 128;
+static const ResIDType kLightYellowID = 129;
+static const ResIDType kLightOrangeID = 130;
+static const ResIDType kLightRedID = 131;
 
 //	Date PICTs:
 
-const ResIDType kDatePrehistoricID = 138;
-const ResIDType kDate2112ID = 139;
-const ResIDType kDate2185ID = 140;
-const ResIDType kDate2310ID = 141;
-const ResIDType kDate2318ID = 142;
+static const ResIDType kDatePrehistoricID = 138;
+static const ResIDType kDate2112ID = 139;
+static const ResIDType kDate2185ID = 140;
+static const ResIDType kDate2310ID = 141;
+static const ResIDType kDate2318ID = 142;
 
 /////////////////////////////////////////////
 //
 //	Display Order
 
-const DisplayOrder kCroppedMovieLayer = 11000;
-
-const DisplayOrder kMonitorLayer = 12000;
-
-const DisplayOrder kDragSpriteLayer = 15000;
-const DisplayOrder kDragSpriteOrder = kDragSpriteLayer;
-
-const DisplayOrder kInterfaceLayer = 20000;
-const DisplayOrder kBackground1Order = kInterfaceLayer;
-const DisplayOrder kBackground2Order = kBackground1Order + 1;
-const DisplayOrder kBackground3Order = kBackground2Order + 1;
-const DisplayOrder kBackground4Order = kBackground3Order + 1;
-const DisplayOrder kDateOrder = kBackground4Order + 1;
-const DisplayOrder kCompassOrder = kDateOrder + 1;
-const DisplayOrder kEnergyBarOrder = kCompassOrder + 1;
-const DisplayOrder kEnergyLightOrder = kEnergyBarOrder + 1;
-
-const DisplayOrder kAILayer = 22000;
-const DisplayOrder kAILeftAreaOrder = kAILayer;
-const DisplayOrder kAIMiddleAreaOrder = kAILeftAreaOrder + 1;
-const DisplayOrder kAIRightAreaOrder = kAIMiddleAreaOrder + 1;
-const DisplayOrder kAIMovieOrder = kAIRightAreaOrder + 1;
-
-const DisplayOrder kHilitesLayer = 23000;
-const DisplayOrder kInventoryHiliteOrder = kHilitesLayer;
-const DisplayOrder kBiochipHiliteOrder = kInventoryHiliteOrder + 1;
-
-const DisplayOrder kPanelsLayer = 25000;
-const DisplayOrder kInventoryPushOrder = kPanelsLayer;
-const DisplayOrder kInventoryLidOrder = kInventoryPushOrder + 1;
-const DisplayOrder kBiochipPushOrder = kInventoryLidOrder + 1;
-const DisplayOrder kBiochipLidOrder = kBiochipPushOrder + 1;
-const DisplayOrder kFinalMessageOrder = kBiochipLidOrder + 1;
-
-const DisplayOrder kInfoLayer = 26000;
-const DisplayOrder kInfoBackgroundOrder = kInfoLayer;
-const DisplayOrder kInfoSpinOrder = kInfoBackgroundOrder + 1;
-
-const DisplayOrder kScreenDimmerOrder = 30000;
-
-const DisplayOrder kPauseScreenLayer = 31000;
-const DisplayOrder kPauseMenuOrder = kPauseScreenLayer;
-const DisplayOrder kSaveGameOrder = kPauseMenuOrder + 1;
-const DisplayOrder kContinueOrder = kSaveGameOrder + 1;
-const DisplayOrder kRestoreOrder = kContinueOrder + 1;
-const DisplayOrder kSoundFXOrder = kRestoreOrder + 1;
-const DisplayOrder kAmbienceOrder = kSoundFXOrder + 1;
-const DisplayOrder kWalkthruOrder = kAmbienceOrder + 1;
-const DisplayOrder kQuitToMainMenuOrder = kWalkthruOrder + 1;
-const DisplayOrder kPauseLargeHiliteOrder = kQuitToMainMenuOrder + 1;
-const DisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
+static const DisplayOrder kCroppedMovieLayer = 11000;
+
+static const DisplayOrder kMonitorLayer = 12000;
+
+static const DisplayOrder kDragSpriteLayer = 15000;
+static const DisplayOrder kDragSpriteOrder = kDragSpriteLayer;
+
+static const DisplayOrder kInterfaceLayer = 20000;
+static const DisplayOrder kBackground1Order = kInterfaceLayer;
+static const DisplayOrder kBackground2Order = kBackground1Order + 1;
+static const DisplayOrder kBackground3Order = kBackground2Order + 1;
+static const DisplayOrder kBackground4Order = kBackground3Order + 1;
+static const DisplayOrder kDateOrder = kBackground4Order + 1;
+static const DisplayOrder kCompassOrder = kDateOrder + 1;
+static const DisplayOrder kEnergyBarOrder = kCompassOrder + 1;
+static const DisplayOrder kEnergyLightOrder = kEnergyBarOrder + 1;
+
+static const DisplayOrder kAILayer = 22000;
+static const DisplayOrder kAILeftAreaOrder = kAILayer;
+static const DisplayOrder kAIMiddleAreaOrder = kAILeftAreaOrder + 1;
+static const DisplayOrder kAIRightAreaOrder = kAIMiddleAreaOrder + 1;
+static const DisplayOrder kAIMovieOrder = kAIRightAreaOrder + 1;
+
+static const DisplayOrder kHilitesLayer = 23000;
+static const DisplayOrder kInventoryHiliteOrder = kHilitesLayer;
+static const DisplayOrder kBiochipHiliteOrder = kInventoryHiliteOrder + 1;
+
+static const DisplayOrder kPanelsLayer = 25000;
+static const DisplayOrder kInventoryPushOrder = kPanelsLayer;
+static const DisplayOrder kInventoryLidOrder = kInventoryPushOrder + 1;
+static const DisplayOrder kBiochipPushOrder = kInventoryLidOrder + 1;
+static const DisplayOrder kBiochipLidOrder = kBiochipPushOrder + 1;
+static const DisplayOrder kFinalMessageOrder = kBiochipLidOrder + 1;
+
+static const DisplayOrder kInfoLayer = 26000;
+static const DisplayOrder kInfoBackgroundOrder = kInfoLayer;
+static const DisplayOrder kInfoSpinOrder = kInfoBackgroundOrder + 1;
+
+static const DisplayOrder kScreenDimmerOrder = 30000;
+
+static const DisplayOrder kPauseScreenLayer = 31000;
+static const DisplayOrder kPauseMenuOrder = kPauseScreenLayer;
+static const DisplayOrder kSaveGameOrder = kPauseMenuOrder + 1;
+static const DisplayOrder kContinueOrder = kSaveGameOrder + 1;
+static const DisplayOrder kRestoreOrder = kContinueOrder + 1;
+static const DisplayOrder kSoundFXOrder = kRestoreOrder + 1;
+static const DisplayOrder kAmbienceOrder = kSoundFXOrder + 1;
+static const DisplayOrder kWalkthruOrder = kAmbienceOrder + 1;
+static const DisplayOrder kQuitToMainMenuOrder = kWalkthruOrder + 1;
+static const DisplayOrder kPauseLargeHiliteOrder = kQuitToMainMenuOrder + 1;
+static const DisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
 
 /////////////////////////////////////////////
 //
@@ -718,7 +718,7 @@ enum {
 
 /////////////////////////////////////////////
 //
-//	Mode constants.
+//	Mode static constants.
 
 static const GameMode kModeInventoryPick = kLastGameShellMode + 1;
 static const GameMode kModeBiochipPick = kModeInventoryPick + 1;
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index 6d743c3..b50f850 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -68,9 +68,9 @@ struct ItemStateInfo {
 
 //	ItemExtraEntry
 
-const short kLeftAreaExtra = 0;
-const short kMiddleAreaExtra = 1;
-const short kRightAreaExtra = 2;
+static const short kLeftAreaExtra = 0;
+static const short kMiddleAreaExtra = 1;
+static const short kRightAreaExtra = 2;
 
 struct ItemExtraEntry {
 	uint32 extraID;
@@ -90,184 +90,184 @@ struct ItemExtraInfo {
 //	Individual inventory items are stored in these resource types.
 //	Resource ID is item ID + kItemBaseResID.
 
-const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm');       // JMPItemInfoHandle
-const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't');   // ItemStateInfoHandle
-const uint32 kMiddleAreaInfoResType = MKTAG('M', 'i', 'd', 'l'); // ItemStateInfoHandle
-const uint32 kRightAreaInfoResType = MKTAG('R', 'g', 'h', 't');  // ItemStateInfoHandle
-const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r');	 // ItemExtraInfoHandle
+static const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm');       // JMPItemInfoHandle
+static const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't');   // ItemStateInfoHandle
+static const uint32 kMiddleAreaInfoResType = MKTAG('M', 'i', 'd', 'l'); // ItemStateInfoHandle
+static const uint32 kRightAreaInfoResType = MKTAG('R', 'g', 'h', 't');  // ItemStateInfoHandle
+static const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r');	 // ItemExtraInfoHandle
 
-const uint16 kItemBaseResID = 128;
+static const uint16 kItemBaseResID = 128;
 
 //	Item IDs.
 
-const ItemID kAirMask = 7;
-const ItemID kAntidote = 8;
-const ItemID kArgonCanister = 9;
-const ItemID kCardBomb = 10;
-const ItemID kCrowbar = 11;
-const ItemID kGasCanister = 12;
-const ItemID kHistoricalLog = 13;
-const ItemID kJourneymanKey = 14;
-const ItemID kKeyCard = 15;
-const ItemID kMachineGun = 16;
-const ItemID kMarsCard = 17;
-const ItemID kNitrogenCanister = 18;
-const ItemID kOrangeJuiceGlassFull = 19;
-const ItemID kOrangeJuiceGlassEmpty = 20;
-const ItemID kPoisonDart = 21;
-const ItemID kSinclairKey = 22;
-const ItemID kStunGun = 23;
-const ItemID kArgonPickup = 24;
+static const ItemID kAirMask = 7;
+static const ItemID kAntidote = 8;
+static const ItemID kArgonCanister = 9;
+static const ItemID kCardBomb = 10;
+static const ItemID kCrowbar = 11;
+static const ItemID kGasCanister = 12;
+static const ItemID kHistoricalLog = 13;
+static const ItemID kJourneymanKey = 14;
+static const ItemID kKeyCard = 15;
+static const ItemID kMachineGun = 16;
+static const ItemID kMarsCard = 17;
+static const ItemID kNitrogenCanister = 18;
+static const ItemID kOrangeJuiceGlassFull = 19;
+static const ItemID kOrangeJuiceGlassEmpty = 20;
+static const ItemID kPoisonDart = 21;
+static const ItemID kSinclairKey = 22;
+static const ItemID kStunGun = 23;
+static const ItemID kArgonPickup = 24;
 
 //	Biochips.
 
-const ItemID kAIBiochip = 0;
-const ItemID kInterfaceBiochip = 1;
-const ItemID kMapBiochip = 2;
-const ItemID kOpticalBiochip = 3;
-const ItemID kPegasusBiochip = 4;
-const ItemID kRetinalScanBiochip = 5;
-const ItemID kShieldBiochip = 6;
+static const ItemID kAIBiochip = 0;
+static const ItemID kInterfaceBiochip = 1;
+static const ItemID kMapBiochip = 2;
+static const ItemID kOpticalBiochip = 3;
+static const ItemID kPegasusBiochip = 4;
+static const ItemID kRetinalScanBiochip = 5;
+static const ItemID kShieldBiochip = 6;
 
-const ItemID kNumItems = 25;
+static const ItemID kNumItems = 25;
 
 //	Item States.
 
-const ItemState kAI000 = 0;
-const ItemState kAI005 = 1;
-const ItemState kAI006 = 2;
-const ItemState kAI010 = 3;
-const ItemState kAI015 = 4;
-const ItemState kAI016 = 5;
-const ItemState kAI020 = 6;
-const ItemState kAI024 = 7;
-const ItemState kAI100 = 8;
-const ItemState kAI101 = 9;
-const ItemState kAI105 = 10;
-const ItemState kAI106 = 11;
-const ItemState kAI110 = 12;
-const ItemState kAI111 = 13;
-const ItemState kAI115 = 14;
-const ItemState kAI116 = 15;
-const ItemState kAI120 = 16;
-const ItemState kAI121 = 17;
-const ItemState kAI124 = 18;
-const ItemState kAI125 = 19;
-const ItemState kAI126 = 20;
-const ItemState kAI200 = 21;
-const ItemState kAI201 = 22;
-const ItemState kAI202 = 23;
-const ItemState kAI205 = 24;
-const ItemState kAI206 = 25;
-const ItemState kAI210 = 26;
-const ItemState kAI211 = 27;
-const ItemState kAI212 = 28;
-const ItemState kAI215 = 29;
-const ItemState kAI216 = 30;
-const ItemState kAI220 = 31;
-const ItemState kAI221 = 32;
-const ItemState kAI222 = 33;
-const ItemState kAI224 = 34;
-const ItemState kAI225 = 35;
-const ItemState kAI226 = 36;
-const ItemState kAI300 = 37;
-const ItemState kAI301 = 38;
-const ItemState kAI302 = 39;
-const ItemState kAI303 = 40;
-const ItemState kAI305 = 41;
-const ItemState kAI306 = 42;
-const ItemState kAI310 = 43;
-const ItemState kAI311 = 44;
-const ItemState kAI312 = 45;
-const ItemState kAI313 = 46;
-const ItemState kAI315 = 47;
-const ItemState kAI316 = 48;
-const ItemState kAI320 = 49;
-const ItemState kAI321 = 50;
-const ItemState kAI322 = 51;
-const ItemState kAI323 = 52;
-const ItemState kAI324 = 53;
-const ItemState kAI325 = 54;
-const ItemState kAI326 = 55;
-const ItemState kNormalItem = 56;
-const ItemState kMapUnavailable = 57;
-const ItemState kMapEngaged = 58;
-const ItemState kOptical000 = 59;
-const ItemState kOptical001 = 60;
-const ItemState kOptical002 = 61;
-const ItemState kOptical010 = 62;
-const ItemState kOptical011 = 63;
-const ItemState kOptical012 = 64;
-const ItemState kOptical020 = 65;
-const ItemState kOptical021 = 66;
-const ItemState kOptical100 = 67;
-const ItemState kOptical101 = 68;
-const ItemState kOptical102 = 69;
-const ItemState kOptical110 = 70;
-const ItemState kOptical111 = 71;
-const ItemState kOptical112 = 72;
-const ItemState kOptical120 = 73;
-const ItemState kOptical121 = 74;
-const ItemState kOptical200 = 75;
-const ItemState kOptical201 = 76;
-const ItemState kOptical210 = 77;
-const ItemState kOptical211 = 78;
-const ItemState kPegasusTSA00 = 79;
-const ItemState kPegasusTSA10 = 80;
-const ItemState kPegasusPrehistoric00 = 81;
-const ItemState kPegasusPrehistoric01 = 82;
-const ItemState kPegasusPrehistoric10 = 83;
-const ItemState kPegasusPrehistoric11 = 84;
-const ItemState kPegasusMars00 = 85;
-const ItemState kPegasusMars01 = 86;
-const ItemState kPegasusMars10 = 87;
-const ItemState kPegasusMars11 = 88;
-const ItemState kPegasusNorad00 = 89;
-const ItemState kPegasusNorad01 = 90;
-const ItemState kPegasusNorad10 = 91;
-const ItemState kPegasusNorad11 = 92;
-const ItemState kPegasusWSC00 = 93;
-const ItemState kPegasusWSC01 = 94;
-const ItemState kPegasusWSC10 = 95;
-const ItemState kPegasusWSC11 = 96;
-const ItemState kPegasusCaldoria = 97;
-const ItemState kRetinalSimulating = 98;
-const ItemState kShieldNormal = 99;
-const ItemState kShieldRadiation = 100;
-const ItemState kShieldPlasma = 101;
-const ItemState kShieldCardBomb = 102;
-const ItemState kShieldDraining = 103;
-const ItemState kAirMaskEmptyOff = 104;
-const ItemState kAirMaskEmptyFilter = 105;
-const ItemState kAirMaskLowOff = 106;
-const ItemState kAirMaskLowFilter = 107;
-const ItemState kAirMaskLowOn = 108;
-const ItemState kAirMaskFullOff = 109;
-const ItemState kAirMaskFullFilter = 110;
-const ItemState kAirMaskFullOn = 111;
-const ItemState kArgonEmpty = 112;
-const ItemState kArgonFull = 113;
-const ItemState kFlashlightOff = 114;
-const ItemState kFlashlightOn = 115;
-const ItemState kNitrogenEmpty = 116;
-const ItemState kNitrogenFull = 117;
-const ItemState kFullGlass = 118;
+static const ItemState kAI000 = 0;
+static const ItemState kAI005 = 1;
+static const ItemState kAI006 = 2;
+static const ItemState kAI010 = 3;
+static const ItemState kAI015 = 4;
+static const ItemState kAI016 = 5;
+static const ItemState kAI020 = 6;
+static const ItemState kAI024 = 7;
+static const ItemState kAI100 = 8;
+static const ItemState kAI101 = 9;
+static const ItemState kAI105 = 10;
+static const ItemState kAI106 = 11;
+static const ItemState kAI110 = 12;
+static const ItemState kAI111 = 13;
+static const ItemState kAI115 = 14;
+static const ItemState kAI116 = 15;
+static const ItemState kAI120 = 16;
+static const ItemState kAI121 = 17;
+static const ItemState kAI124 = 18;
+static const ItemState kAI125 = 19;
+static const ItemState kAI126 = 20;
+static const ItemState kAI200 = 21;
+static const ItemState kAI201 = 22;
+static const ItemState kAI202 = 23;
+static const ItemState kAI205 = 24;
+static const ItemState kAI206 = 25;
+static const ItemState kAI210 = 26;
+static const ItemState kAI211 = 27;
+static const ItemState kAI212 = 28;
+static const ItemState kAI215 = 29;
+static const ItemState kAI216 = 30;
+static const ItemState kAI220 = 31;
+static const ItemState kAI221 = 32;
+static const ItemState kAI222 = 33;
+static const ItemState kAI224 = 34;
+static const ItemState kAI225 = 35;
+static const ItemState kAI226 = 36;
+static const ItemState kAI300 = 37;
+static const ItemState kAI301 = 38;
+static const ItemState kAI302 = 39;
+static const ItemState kAI303 = 40;
+static const ItemState kAI305 = 41;
+static const ItemState kAI306 = 42;
+static const ItemState kAI310 = 43;
+static const ItemState kAI311 = 44;
+static const ItemState kAI312 = 45;
+static const ItemState kAI313 = 46;
+static const ItemState kAI315 = 47;
+static const ItemState kAI316 = 48;
+static const ItemState kAI320 = 49;
+static const ItemState kAI321 = 50;
+static const ItemState kAI322 = 51;
+static const ItemState kAI323 = 52;
+static const ItemState kAI324 = 53;
+static const ItemState kAI325 = 54;
+static const ItemState kAI326 = 55;
+static const ItemState kNormalItem = 56;
+static const ItemState kMapUnavailable = 57;
+static const ItemState kMapEngaged = 58;
+static const ItemState kOptical000 = 59;
+static const ItemState kOptical001 = 60;
+static const ItemState kOptical002 = 61;
+static const ItemState kOptical010 = 62;
+static const ItemState kOptical011 = 63;
+static const ItemState kOptical012 = 64;
+static const ItemState kOptical020 = 65;
+static const ItemState kOptical021 = 66;
+static const ItemState kOptical100 = 67;
+static const ItemState kOptical101 = 68;
+static const ItemState kOptical102 = 69;
+static const ItemState kOptical110 = 70;
+static const ItemState kOptical111 = 71;
+static const ItemState kOptical112 = 72;
+static const ItemState kOptical120 = 73;
+static const ItemState kOptical121 = 74;
+static const ItemState kOptical200 = 75;
+static const ItemState kOptical201 = 76;
+static const ItemState kOptical210 = 77;
+static const ItemState kOptical211 = 78;
+static const ItemState kPegasusTSA00 = 79;
+static const ItemState kPegasusTSA10 = 80;
+static const ItemState kPegasusPrehistoric00 = 81;
+static const ItemState kPegasusPrehistoric01 = 82;
+static const ItemState kPegasusPrehistoric10 = 83;
+static const ItemState kPegasusPrehistoric11 = 84;
+static const ItemState kPegasusMars00 = 85;
+static const ItemState kPegasusMars01 = 86;
+static const ItemState kPegasusMars10 = 87;
+static const ItemState kPegasusMars11 = 88;
+static const ItemState kPegasusNorad00 = 89;
+static const ItemState kPegasusNorad01 = 90;
+static const ItemState kPegasusNorad10 = 91;
+static const ItemState kPegasusNorad11 = 92;
+static const ItemState kPegasusWSC00 = 93;
+static const ItemState kPegasusWSC01 = 94;
+static const ItemState kPegasusWSC10 = 95;
+static const ItemState kPegasusWSC11 = 96;
+static const ItemState kPegasusCaldoria = 97;
+static const ItemState kRetinalSimulating = 98;
+static const ItemState kShieldNormal = 99;
+static const ItemState kShieldRadiation = 100;
+static const ItemState kShieldPlasma = 101;
+static const ItemState kShieldCardBomb = 102;
+static const ItemState kShieldDraining = 103;
+static const ItemState kAirMaskEmptyOff = 104;
+static const ItemState kAirMaskEmptyFilter = 105;
+static const ItemState kAirMaskLowOff = 106;
+static const ItemState kAirMaskLowFilter = 107;
+static const ItemState kAirMaskLowOn = 108;
+static const ItemState kAirMaskFullOff = 109;
+static const ItemState kAirMaskFullFilter = 110;
+static const ItemState kAirMaskFullOn = 111;
+static const ItemState kArgonEmpty = 112;
+static const ItemState kArgonFull = 113;
+static const ItemState kFlashlightOff = 114;
+static const ItemState kFlashlightOn = 115;
+static const ItemState kNitrogenEmpty = 116;
+static const ItemState kNitrogenFull = 117;
+static const ItemState kFullGlass = 118;
 
 //	Extra IDs.
 
-const uint32 kRetinalScanSearching = 0;
-const uint32 kRetinalScanActivated = 1;
-const uint32 kShieldIntro = 2;
-const uint32 kRemoveAirMask = 3;
-const uint32 kRemoveArgon = 4;
-const uint32 kRemoveCrowbar = 5;
-const uint32 kGasCanLoop = 6;
-const uint32 kRemoveJourneymanKey = 7;
-const uint32 kRemoveMarsCard = 8;
-const uint32 kRemoveNitrogen = 9;
-const uint32 kRemoveGlass = 10;
-const uint32 kRemoveDart = 11;
-const uint32 kRemoveSinclairKey = 12;
+static const uint32 kRetinalScanSearching = 0;
+static const uint32 kRetinalScanActivated = 1;
+static const uint32 kShieldIntro = 2;
+static const uint32 kRemoveAirMask = 3;
+static const uint32 kRemoveArgon = 4;
+static const uint32 kRemoveCrowbar = 5;
+static const uint32 kGasCanLoop = 6;
+static const uint32 kRemoveJourneymanKey = 7;
+static const uint32 kRemoveMarsCard = 8;
+static const uint32 kRemoveNitrogen = 9;
+static const uint32 kRemoveGlass = 10;
+static const uint32 kRemoveDart = 11;
+static const uint32 kRemoveSinclairKey = 12;
 
 enum ItemType {
 	kInventoryItemType,
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 82bafbc..b1763a5 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -930,60 +930,60 @@ enum {
 	kLastPauseSelection = kPauseMenuQuitToMainMenu
 };
 
-const CoordType kPauseLeft = 194;
-const CoordType kPauseTop = 68;
+static const CoordType kPauseLeft = 194;
+static const CoordType kPauseTop = 68;
 
-const CoordType kSaveGameLeft = kPauseLeft + 6;
-const CoordType kSaveGameTop = kPauseTop + 56;
+static const CoordType kSaveGameLeft = kPauseLeft + 6;
+static const CoordType kSaveGameTop = kPauseTop + 56;
 
-const CoordType kSaveGameSelectLeft = kPauseLeft - 44;
-const CoordType kSaveGameSelectTop = kPauseTop + 52;
+static const CoordType kSaveGameSelectLeft = kPauseLeft - 44;
+static const CoordType kSaveGameSelectTop = kPauseTop + 52;
 
-const CoordType kPauseContinueLeft = kPauseLeft + 18;
-const CoordType kPauseContinueTop = kPauseTop + 100;
+static const CoordType kPauseContinueLeft = kPauseLeft + 18;
+static const CoordType kPauseContinueTop = kPauseTop + 100;
 
-const CoordType kPauseContinueSelectLeft = kPauseLeft - 44;
-const CoordType kPauseContinueSelectTop = kPauseTop + 95;
+static const CoordType kPauseContinueSelectLeft = kPauseLeft - 44;
+static const CoordType kPauseContinueSelectTop = kPauseTop + 95;
 
-const CoordType kPauseRestoreLeft = kPauseLeft + 18;
-const CoordType kPauseRestoreTop = kPauseTop + 136;
+static const CoordType kPauseRestoreLeft = kPauseLeft + 18;
+static const CoordType kPauseRestoreTop = kPauseTop + 136;
 
-const CoordType kPauseRestoreSelectLeft = kPauseLeft - 44;
-const CoordType kPauseRestoreSelectTop = kPauseTop + 131;
+static const CoordType kPauseRestoreSelectLeft = kPauseLeft - 44;
+static const CoordType kPauseRestoreSelectTop = kPauseTop + 131;
 
-const CoordType kSoundFXLeft = kPauseLeft + 128;
-const CoordType kSoundFXTop = kPauseTop + 187;
-const CoordType kSoundFXRight = kSoundFXLeft + 96;
-const CoordType kSoundFXBottom = kSoundFXTop + 14;
+static const CoordType kSoundFXLeft = kPauseLeft + 128;
+static const CoordType kSoundFXTop = kPauseTop + 187;
+static const CoordType kSoundFXRight = kSoundFXLeft + 96;
+static const CoordType kSoundFXBottom = kSoundFXTop + 14;
 
-const CoordType kSoundFXSelectLeft = kPauseLeft - 44;
-const CoordType kSoundFXSelectTop = kPauseTop + 172;
+static const CoordType kSoundFXSelectLeft = kPauseLeft - 44;
+static const CoordType kSoundFXSelectTop = kPauseTop + 172;
 
-const CoordType kAmbienceLeft = kPauseLeft + 128;
-const CoordType kAmbienceTop = kPauseTop + 227;
-const CoordType kAmbienceRight = kAmbienceLeft + 96;
-const CoordType kAmbienceBottom = kAmbienceTop + 14;
+static const CoordType kAmbienceLeft = kPauseLeft + 128;
+static const CoordType kAmbienceTop = kPauseTop + 227;
+static const CoordType kAmbienceRight = kAmbienceLeft + 96;
+static const CoordType kAmbienceBottom = kAmbienceTop + 14;
 
-const CoordType kAmbienceSelectLeft = kPauseLeft - 44;
-const CoordType kAmbienceSelectTop = kPauseTop + 212;
+static const CoordType kAmbienceSelectLeft = kPauseLeft - 44;
+static const CoordType kAmbienceSelectTop = kPauseTop + 212;
 
-const CoordType kWalkthruLeft = kPauseLeft + 128;
-const CoordType kWalkthruTop = kPauseTop + 264;
+static const CoordType kWalkthruLeft = kPauseLeft + 128;
+static const CoordType kWalkthruTop = kPauseTop + 264;
 
-const CoordType kWalkthruSelectLeft = kPauseLeft - 44;
-const CoordType kWalkthruSelectTop = kPauseTop + 255;
+static const CoordType kWalkthruSelectLeft = kPauseLeft - 44;
+static const CoordType kWalkthruSelectTop = kPauseTop + 255;
 
-const CoordType kQuitLeft = kPauseLeft + 18;
-const CoordType kQuitTop = kPauseTop + 302;
+static const CoordType kQuitLeft = kPauseLeft + 18;
+static const CoordType kQuitTop = kPauseTop + 302;
 
-const CoordType kQuitSelectLeft = kPauseLeft - 44;
-const CoordType kQuitSelectTop = kPauseTop + 297;
+static const CoordType kQuitSelectLeft = kPauseLeft - 44;
+static const CoordType kQuitSelectTop = kPauseTop + 297;
 
 //	These are relative to the pause background.
-const CoordType kPauseScoreLeft = 130;
-const CoordType kPauseScoreTop = 34;
-const CoordType kPauseScoreRight = kPauseScoreLeft + 108;
-const CoordType kPauseScoreBottom = kPauseScoreTop + 12;
+static const CoordType kPauseScoreLeft = 130;
+static const CoordType kPauseScoreTop = 34;
+static const CoordType kPauseScoreRight = kPauseScoreLeft + 108;
+static const CoordType kPauseScoreBottom = kPauseScoreTop + 12;
 
 // Never set the current input handler to the CPauseMenu.
 PauseMenu::PauseMenu() : GameMenu(kPauseMenuID), _pauseBackground(0), _saveButton(0), _restoreButton(0),
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 6f512fa..1ea6e12 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -42,109 +42,109 @@
 
 namespace Pegasus {
 
-const short kVidPhoneAngle = 30;
-const short kReplicatorAngle = 50;
-const short kDrawersAngle = -30;
-const short kCaldoria53Angle = 45;
-const short kCaldoria55Angle = -45;
+static const int16 kVidPhoneAngle = 30;
+static const int16 kReplicatorAngle = 50;
+static const int16 kDrawersAngle = -30;
+static const int16 kCaldoria53Angle = 45;
+static const int16 kCaldoria55Angle = -45;
 
-const TimeValue kSinclairInterruptionTime1 = 2955;
-const TimeValue kSinclairInterruptionTime2 = 6835;
-const TimeValue kSinclairInterruptionTime3 = 9835;
-const TimeValue kSinclairInterruptionTime4 = 12555;
+static const TimeValue kSinclairInterruptionTime1 = 2955;
+static const TimeValue kSinclairInterruptionTime2 = 6835;
+static const TimeValue kSinclairInterruptionTime3 = 9835;
+static const TimeValue kSinclairInterruptionTime4 = 12555;
 
-const InputBits kPullbackInterruptFilter = kFilterAllInput;
-const InputBits kRecalibrationInterruptFilter = kFilterAllInput;
+static const InputBits kPullbackInterruptFilter = kFilterAllInput;
+static const InputBits kRecalibrationInterruptFilter = kFilterAllInput;
 
-const TimeValue kCaldoriaReplicatorIntroIn = 4933;
-const TimeValue kCaldoriaReplicatorIntroOut = 6557;
+static const TimeValue kCaldoriaReplicatorIntroIn = 4933;
+static const TimeValue kCaldoriaReplicatorIntroOut = 6557;
 
-const TimeValue kCaldoriaReplicatorWrongChoiceIn = 6557;
-const TimeValue kCaldoriaReplicatorWrongChoiceOut = 8586;
+static const TimeValue kCaldoriaReplicatorWrongChoiceIn = 6557;
+static const TimeValue kCaldoriaReplicatorWrongChoiceOut = 8586;
 
-const TimeValue kCaldoriaReplicatorOJChoiceIn = 8586;
-const TimeValue kCaldoriaReplicatorOJChoiceOut = 11687;
+static const TimeValue kCaldoriaReplicatorOJChoiceIn = 8586;
+static const TimeValue kCaldoriaReplicatorOJChoiceOut = 11687;
 
-const TimeValue kCaldoriaMessagesIntroIn = 11687;
-const TimeValue kCaldoriaMessagesIntroOut = 13641;
+static const TimeValue kCaldoriaMessagesIntroIn = 11687;
+static const TimeValue kCaldoriaMessagesIntroOut = 13641;
 
-const TimeValue kCaldoriaFirstMessageIn = 13641;
-const TimeValue kCaldoriaFirstMessageOut = 14203;
+static const TimeValue kCaldoriaFirstMessageIn = 13641;
+static const TimeValue kCaldoriaFirstMessageOut = 14203;
 
-const TimeValue kCaldoriaSecondMessageIn = 14203;
-const TimeValue kCaldoriaSecondMessageOut = 14750;
+static const TimeValue kCaldoriaSecondMessageIn = 14203;
+static const TimeValue kCaldoriaSecondMessageOut = 14750;
 
-const TimeValue kCaldoriaDoorCloseIn = 14750;
-const TimeValue kCaldoriaDoorCloseOut = 15472;
+static const TimeValue kCaldoriaDoorCloseIn = 14750;
+static const TimeValue kCaldoriaDoorCloseOut = 15472;
 
-const TimeValue kCaldoriaElevatorCloseIn = 15472;
-const TimeValue kCaldoriaElevatorCloseOut = 16336;
+static const TimeValue kCaldoriaElevatorCloseIn = 15472;
+static const TimeValue kCaldoriaElevatorCloseOut = 16336;
 
-const TimeValue kCaldoriaShowerCloseIn = 16336;
-const TimeValue kCaldoriaShowerCloseOut = 17101;
+static const TimeValue kCaldoriaShowerCloseIn = 16336;
+static const TimeValue kCaldoriaShowerCloseOut = 17101;
 
-const TimeValue kCaldoriaGTDoorCloseIn = 17101;
-const TimeValue kCaldoriaGTDoorCloseOut = 18523;
+static const TimeValue kCaldoriaGTDoorCloseIn = 17101;
+static const TimeValue kCaldoriaGTDoorCloseOut = 18523;
 
-const TimeValue kCaldoriaNobodyHomeIn = 18523;
-const TimeValue kCaldoriaNobodyHomeOut = 21469;
+static const TimeValue kCaldoriaNobodyHomeIn = 18523;
+static const TimeValue kCaldoriaNobodyHomeOut = 21469;
 
-const TimeValue kCaldoriaNoOtherFloorIn = 21469;
-const TimeValue kCaldoriaNoOtherFloorOut = 28013;
+static const TimeValue kCaldoriaNoOtherFloorIn = 21469;
+static const TimeValue kCaldoriaNoOtherFloorOut = 28013;
 
-const TimeValue kCaldoria4DInstructionsIn = 28013;
-const TimeValue kCaldoria4DInstructionsOut = 29730;
+static const TimeValue kCaldoria4DInstructionsIn = 28013;
+static const TimeValue kCaldoria4DInstructionsOut = 29730;
 
-const TimeValue kCaldoriaDrinkOJIn = 33910;
-const TimeValue kCaldoriaDrinkOJOut = 35846;
+static const TimeValue kCaldoriaDrinkOJIn = 33910;
+static const TimeValue kCaldoriaDrinkOJOut = 35846;
 
-const TimeValue kCaldoriaNoOtherDestinationIn = 35846;
-const TimeValue kCaldoriaNoOtherDestinationOut = 37877;
+static const TimeValue kCaldoriaNoOtherDestinationIn = 35846;
+static const TimeValue kCaldoriaNoOtherDestinationOut = 37877;
 
-const TimeValue kCaldoriaUhghIn = 37877;
-const TimeValue kCaldoriaUhghOut = 38025;
+static const TimeValue kCaldoriaUhghIn = 37877;
+static const TimeValue kCaldoriaUhghOut = 38025;
 
-const TimeValue kCaldoriaSinclairShootsOSIn = 38025;
-const TimeValue kCaldoriaSinclairShootsOSOut = 40649;
+static const TimeValue kCaldoriaSinclairShootsOSIn = 38025;
+static const TimeValue kCaldoriaSinclairShootsOSOut = 40649;
 
-const TimeValue kCaldoriaScreamingAfterIn = 40649;
-const TimeValue kCaldoriaScreamingAfterOut = 47661;
+static const TimeValue kCaldoriaScreamingAfterIn = 40649;
+static const TimeValue kCaldoriaScreamingAfterOut = 47661;
 
-const TimeValue k4FloorTime = 0;
+static const TimeValue k4FloorTime = 0;
 
-const TimeValue k4To1Start = 40;
-const TimeValue k4To1Stop = 7720;
+static const TimeValue k4To1Start = 40;
+static const TimeValue k4To1Stop = 7720;
 
-const TimeValue k4To5Start = 7720;
-const TimeValue k4To5Stop = 10280;
+static const TimeValue k4To5Start = 7720;
+static const TimeValue k4To5Stop = 10280;
 
-const TimeValue k4To2Time = 10280;
+static const TimeValue k4To2Time = 10280;
 
-const TimeValue k4To3Time = 10320;
+static const TimeValue k4To3Time = 10320;
 
-const TimeValue k1FloorTime = 10360;
+static const TimeValue k1FloorTime = 10360;
 
-const TimeValue k1To4Start = 10400;
-const TimeValue k1To4Stop = 18080;
+static const TimeValue k1To4Start = 10400;
+static const TimeValue k1To4Stop = 18080;
 
-const TimeValue k1To5Start = 18080;
-const TimeValue k1To5Stop = 28320;
+static const TimeValue k1To5Start = 18080;
+static const TimeValue k1To5Stop = 28320;
 
-const TimeValue k1To2Time = 28320;
+static const TimeValue k1To2Time = 28320;
 
-const TimeValue k1To3Time = 28360;
+static const TimeValue k1To3Time = 28360;
 
-const TimeValue k5FloorTime = 28400;
+static const TimeValue k5FloorTime = 28400;
 
-const TimeValue k5To1Start = 28440;
-const TimeValue k5To1Stop = 38680;
+static const TimeValue k5To1Start = 28440;
+static const TimeValue k5To1Stop = 38680;
 
-const TimeValue k5To4Start = 38680;
-const TimeValue k5To4Stop = 41240;
+static const TimeValue k5To4Start = 38680;
+static const TimeValue k5To4Stop = 41240;
 
-const TimeValue k5To2Time = 41240;
+static const TimeValue k5To2Time = 41240;
 
-const TimeValue k5To3Time = 41280;
+static const TimeValue k5To3Time = 41280;
 
 //	FuseFunction functions...
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
index c1e2a2c..64e566e 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -30,361 +30,361 @@
 
 namespace Pegasus {
 
-const TimeScale kCaldoriaMovieScale = 600;
-const TimeScale kCaldoriaFramesPerSecond = 15;
-const TimeScale kCaldoriaFrameDuration = 40;
+static const TimeScale kCaldoriaMovieScale = 600;
+static const TimeScale kCaldoriaFramesPerSecond = 15;
+static const TimeScale kCaldoriaFrameDuration = 40;
 
 //	Alternate IDs.
 
-const AlternateID kAltCaldoriaNormal = 0;
-const AlternateID kAltCaldoriaRoofDoorBlown = 2;
-const AlternateID kAltCaldoriaSinclairDown = 3;
+static const AlternateID kAltCaldoriaNormal = 0;
+static const AlternateID kAltCaldoriaRoofDoorBlown = 2;
+static const AlternateID kAltCaldoriaSinclairDown = 3;
 
 //	Room IDs.
 
-const RoomID kCaldoria00 = 1;
-const RoomID kCaldoria01 = 2;
-const RoomID kCaldoria02 = 3;
-const RoomID kCaldoria03 = 4;
-const RoomID kCaldoria04 = 5;
-const RoomID kCaldoria05 = 6;
-const RoomID kCaldoria06 = 7;
-const RoomID kCaldoria07 = 8;
-const RoomID kCaldoria08 = 9;
-const RoomID kCaldoria09 = 10;
-const RoomID kCaldoria10 = 11;
-const RoomID kCaldoriaToilet = 12;
-const RoomID kCaldoria11 = 13;
-const RoomID kCaldoria12 = 14;
-const RoomID kCaldoriaVidPhone = 15;
-const RoomID kCaldoriaReplicator = 16;
-const RoomID kCaldoriaDrawers = 17;
-const RoomID kCaldoria13 = 18;
-const RoomID kCaldoria14 = 19;
-const RoomID kCaldoria15 = 20;
-const RoomID kCaldoria16 = 21;
-const RoomID kCaldoria17 = 22;
-const RoomID kCaldoria18 = 23;
-const RoomID kCaldoria19 = 24;
-const RoomID kCaldoria20 = 25;
-const RoomID kCaldoria21 = 26;
-const RoomID kCaldoria22 = 27;
-const RoomID kCaldoria23 = 28;
-const RoomID kCaldoria24 = 29;
-const RoomID kCaldoria25 = 30;
-const RoomID kCaldoria26 = 31;
-const RoomID kCaldoria27 = 32;
-const RoomID kCaldoria28 = 33;
-const RoomID kCaldoria29 = 34;
-const RoomID kCaldoria30 = 35;
-const RoomID kCaldoria31 = 36;
-const RoomID kCaldoria32 = 37;
-const RoomID kCaldoria33 = 38;
-const RoomID kCaldoria34 = 39;
-const RoomID kCaldoria35 = 40;
-const RoomID kCaldoria36 = 41;
-const RoomID kCaldoria37 = 42;
-const RoomID kCaldoria38 = 43;
-const RoomID kCaldoria39 = 44;
-const RoomID kCaldoria40 = 45;
-const RoomID kCaldoria41 = 46;
-const RoomID kCaldoriaBinoculars = 47;
-const RoomID kCaldoria42 = 48;
-const RoomID kCaldoriaKiosk = 49;
-const RoomID kCaldoria44 = 50;
-const RoomID kCaldoria45 = 51;
-const RoomID kCaldoria46 = 52;
-const RoomID kCaldoria47 = 53;
-const RoomID kCaldoria48 = 54;
-const RoomID kCaldoria49 = 55;
-const RoomID kCaldoria50 = 56;
-const RoomID kCaldoria51 = 57;
-const RoomID kCaldoria52 = 58;
-const RoomID kCaldoria53 = 59;
-const RoomID kCaldoria54 = 60;
-const RoomID kCaldoria55 = 61;
-const RoomID kCaldoria56 = 62;
-const RoomID kCaldoriaDeathRoom = 0;
+static const RoomID kCaldoria00 = 1;
+static const RoomID kCaldoria01 = 2;
+static const RoomID kCaldoria02 = 3;
+static const RoomID kCaldoria03 = 4;
+static const RoomID kCaldoria04 = 5;
+static const RoomID kCaldoria05 = 6;
+static const RoomID kCaldoria06 = 7;
+static const RoomID kCaldoria07 = 8;
+static const RoomID kCaldoria08 = 9;
+static const RoomID kCaldoria09 = 10;
+static const RoomID kCaldoria10 = 11;
+static const RoomID kCaldoriaToilet = 12;
+static const RoomID kCaldoria11 = 13;
+static const RoomID kCaldoria12 = 14;
+static const RoomID kCaldoriaVidPhone = 15;
+static const RoomID kCaldoriaReplicator = 16;
+static const RoomID kCaldoriaDrawers = 17;
+static const RoomID kCaldoria13 = 18;
+static const RoomID kCaldoria14 = 19;
+static const RoomID kCaldoria15 = 20;
+static const RoomID kCaldoria16 = 21;
+static const RoomID kCaldoria17 = 22;
+static const RoomID kCaldoria18 = 23;
+static const RoomID kCaldoria19 = 24;
+static const RoomID kCaldoria20 = 25;
+static const RoomID kCaldoria21 = 26;
+static const RoomID kCaldoria22 = 27;
+static const RoomID kCaldoria23 = 28;
+static const RoomID kCaldoria24 = 29;
+static const RoomID kCaldoria25 = 30;
+static const RoomID kCaldoria26 = 31;
+static const RoomID kCaldoria27 = 32;
+static const RoomID kCaldoria28 = 33;
+static const RoomID kCaldoria29 = 34;
+static const RoomID kCaldoria30 = 35;
+static const RoomID kCaldoria31 = 36;
+static const RoomID kCaldoria32 = 37;
+static const RoomID kCaldoria33 = 38;
+static const RoomID kCaldoria34 = 39;
+static const RoomID kCaldoria35 = 40;
+static const RoomID kCaldoria36 = 41;
+static const RoomID kCaldoria37 = 42;
+static const RoomID kCaldoria38 = 43;
+static const RoomID kCaldoria39 = 44;
+static const RoomID kCaldoria40 = 45;
+static const RoomID kCaldoria41 = 46;
+static const RoomID kCaldoriaBinoculars = 47;
+static const RoomID kCaldoria42 = 48;
+static const RoomID kCaldoriaKiosk = 49;
+static const RoomID kCaldoria44 = 50;
+static const RoomID kCaldoria45 = 51;
+static const RoomID kCaldoria46 = 52;
+static const RoomID kCaldoria47 = 53;
+static const RoomID kCaldoria48 = 54;
+static const RoomID kCaldoria49 = 55;
+static const RoomID kCaldoria50 = 56;
+static const RoomID kCaldoria51 = 57;
+static const RoomID kCaldoria52 = 58;
+static const RoomID kCaldoria53 = 59;
+static const RoomID kCaldoria54 = 60;
+static const RoomID kCaldoria55 = 61;
+static const RoomID kCaldoria56 = 62;
+static const RoomID kCaldoriaDeathRoom = 0;
 
 //	Hot Spot Activation IDs.
 
-const HotSpotActivationID kActivate4DClosed = 1;
-const HotSpotActivationID kActivate4DOpen = 2;
-const HotSpotActivationID kActivateMirrorReady = 3;
-const HotSpotActivationID kActivateStylistReady = 4;
-const HotSpotActivationID kActivateReplicatorReady = 5;
-const HotSpotActivationID kActivateOJOnThePad = 6;
-const HotSpotActivationID kActivateDrawersClosed = 7;
-const HotSpotActivationID kActivateRightOpen = 8;
-const HotSpotActivationID kActivateLeftOpen = 9;
-const HotSpotActivationID kActivateFocusedOnShip = 10;
-const HotSpotActivationID kActivateNotFocusedOnShip = 11;
-const HotSpotActivationID kActivateReadyForCard = 12;
-const HotSpotActivationID kActivateReadyToTransport = 13;
-const HotSpotActivationID kActivateRoofSlotEmpty = 14;
-const HotSpotActivationID kActivateZoomedOnSinclair = 15;
+static const HotSpotActivationID kActivate4DClosed = 1;
+static const HotSpotActivationID kActivate4DOpen = 2;
+static const HotSpotActivationID kActivateMirrorReady = 3;
+static const HotSpotActivationID kActivateStylistReady = 4;
+static const HotSpotActivationID kActivateReplicatorReady = 5;
+static const HotSpotActivationID kActivateOJOnThePad = 6;
+static const HotSpotActivationID kActivateDrawersClosed = 7;
+static const HotSpotActivationID kActivateRightOpen = 8;
+static const HotSpotActivationID kActivateLeftOpen = 9;
+static const HotSpotActivationID kActivateFocusedOnShip = 10;
+static const HotSpotActivationID kActivateNotFocusedOnShip = 11;
+static const HotSpotActivationID kActivateReadyForCard = 12;
+static const HotSpotActivationID kActivateReadyToTransport = 13;
+static const HotSpotActivationID kActivateRoofSlotEmpty = 14;
+static const HotSpotActivationID kActivateZoomedOnSinclair = 15;
 
 //	Hot Spot IDs.
 
-const HotSpotID kCa4DEnvironOpenSpotID = 5000;
-const HotSpotID kCa4DEnvironCloseSpotID = 5001;
-const HotSpotID kCa4DVisualSpotID = 5002;
-const HotSpotID kCa4DAudioSpotID = 5003;
-const HotSpotID kCa4DChoice1SpotID = 5004;
-const HotSpotID kCa4DChoice2SpotID = 5005;
-const HotSpotID kCa4DChoice3SpotID = 5006;
-const HotSpotID kCa4DChoice4SpotID = 5007;
-const HotSpotID kCaBathroomMirrorSpotID = 5008;
-const HotSpotID kCaHairStyle1SpotID = 5009;
-const HotSpotID kCaHairStyle2SpotID = 5010;
-const HotSpotID kCaHairStyle3SpotID = 5011;
-const HotSpotID kCaShowerSpotID = 5012;
-const HotSpotID kCaBathroomToiletSpotID = 5013;
-const HotSpotID kCaldoriaVidPhoneSpotID = 5014;
-const HotSpotID kCaldoriaReplicatorSpotID = 5015;
-const HotSpotID kCaldoriaDrawersSpotID = 5016;
-const HotSpotID kCaldoriaVidPhoneOutSpotID = 5017;
-const HotSpotID kCaBedroomVidPhoneActivationSpotID = 5018;
-const HotSpotID kCaldoriaReplicatorOutSpotID = 5019;
-const HotSpotID kCaldoriaMakeOJSpotID = 5020;
-const HotSpotID kCaldoriaMakeStickyBunsSpotID = 5021;
-const HotSpotID kCaldoriaOrangeJuiceSpotID = 5022;
-const HotSpotID kCaldoriaOrangeJuiceDropSpotID = 5023;
-const HotSpotID kCaldoriaDrawersOutSpotID = 5024;
-const HotSpotID kCaldoriaLeftDrawerOpenSpotID = 5025;
-const HotSpotID kCaldoriaRightDrawerOpenSpotID = 5026;
-const HotSpotID kCaldoriaKeyCardSpotID = 5027;
-const HotSpotID kCaldoriaLeftDrawerCloseSpotID = 5028;
-const HotSpotID kCaldoriaRightDrawerWithKeysCloseSpotID = 5029;
-const HotSpotID kCaldoriaRightDrawerNoKeysCloseSpotID = 5030;
-const HotSpotID kCaldoriaFourthFloorElevatorSpotID = 5031;
-const HotSpotID kCaldoria20DoorbellSpotID = 5032;
-const HotSpotID kCaldoria21DoorbellSpotID = 5033;
-const HotSpotID kCaldoria26DoorbellSpotID = 5034;
-const HotSpotID kCaldoriaFourthFloorElevator1 = 5035;
-const HotSpotID kCaldoriaFourthFloorElevator2 = 5036;
-const HotSpotID kCaldoriaFourthFloorElevator3 = 5037;
-const HotSpotID kCaldoriaFourthFloorElevator4 = 5038;
-const HotSpotID kCaldoriaFourthFloorElevator5 = 5039;
-const HotSpotID kCaldoriaGroundElevator1 = 5040;
-const HotSpotID kCaldoriaGroundElevator2 = 5041;
-const HotSpotID kCaldoriaGroundElevator3 = 5042;
-const HotSpotID kCaldoriaGroundElevator4 = 5043;
-const HotSpotID kCaldoriaGroundElevator5 = 5044;
-const HotSpotID kCaldoria29DoorbellSpotID = 5045;
-const HotSpotID kCaldoria34DoorbellSpotID = 5046;
-const HotSpotID kCaldoria35DoorbellSpotID = 5047;
-const HotSpotID kCaldoriaGroundElevatorSpotID = 5048;
-const HotSpotID kCaldoriaBinocularZoomInSpotID = 5049;
-const HotSpotID kCaldoriaBinocularsOutSpotID = 5050;
-const HotSpotID kCaldoriaZoomInOnShipSpotID = 5051;
-const HotSpotID kCaldoriaKioskSpotID = 5052;
-const HotSpotID kCaldoriaKioskOutSpotID = 5053;
-const HotSpotID kCaldoriaKioskInfoSpotID = 5054;
-const HotSpotID kCaldoriaGTCardDropSpotID = 5055;
-const HotSpotID kCaldoriaGTTokyoSpotID = 5056;
-const HotSpotID kCaldoriaGTTSASpotID = 5057;
-const HotSpotID kCaldoriaGTBeachSpotID = 5058;
-const HotSpotID kCaldoriaGTOtherSpotID = 5059;
-const HotSpotID kCaldoriaRoofElevator1 = 5060;
-const HotSpotID kCaldoriaRoofElevator2 = 5061;
-const HotSpotID kCaldoriaRoofElevator3 = 5062;
-const HotSpotID kCaldoriaRoofElevator4 = 5063;
-const HotSpotID kCaldoriaRoofElevator5 = 5064;
-const HotSpotID kCaldoriaRoofElevatorSpotID = 5065;
-const HotSpotID kCaldoriaRoofDoorSpotID = 5066;
-const HotSpotID kCaldoriaRoofCardDropSpotID = 5067;
-const HotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
+static const HotSpotID kCa4DEnvironOpenSpotID = 5000;
+static const HotSpotID kCa4DEnvironCloseSpotID = 5001;
+static const HotSpotID kCa4DVisualSpotID = 5002;
+static const HotSpotID kCa4DAudioSpotID = 5003;
+static const HotSpotID kCa4DChoice1SpotID = 5004;
+static const HotSpotID kCa4DChoice2SpotID = 5005;
+static const HotSpotID kCa4DChoice3SpotID = 5006;
+static const HotSpotID kCa4DChoice4SpotID = 5007;
+static const HotSpotID kCaBathroomMirrorSpotID = 5008;
+static const HotSpotID kCaHairStyle1SpotID = 5009;
+static const HotSpotID kCaHairStyle2SpotID = 5010;
+static const HotSpotID kCaHairStyle3SpotID = 5011;
+static const HotSpotID kCaShowerSpotID = 5012;
+static const HotSpotID kCaBathroomToiletSpotID = 5013;
+static const HotSpotID kCaldoriaVidPhoneSpotID = 5014;
+static const HotSpotID kCaldoriaReplicatorSpotID = 5015;
+static const HotSpotID kCaldoriaDrawersSpotID = 5016;
+static const HotSpotID kCaldoriaVidPhoneOutSpotID = 5017;
+static const HotSpotID kCaBedroomVidPhoneActivationSpotID = 5018;
+static const HotSpotID kCaldoriaReplicatorOutSpotID = 5019;
+static const HotSpotID kCaldoriaMakeOJSpotID = 5020;
+static const HotSpotID kCaldoriaMakeStickyBunsSpotID = 5021;
+static const HotSpotID kCaldoriaOrangeJuiceSpotID = 5022;
+static const HotSpotID kCaldoriaOrangeJuiceDropSpotID = 5023;
+static const HotSpotID kCaldoriaDrawersOutSpotID = 5024;
+static const HotSpotID kCaldoriaLeftDrawerOpenSpotID = 5025;
+static const HotSpotID kCaldoriaRightDrawerOpenSpotID = 5026;
+static const HotSpotID kCaldoriaKeyCardSpotID = 5027;
+static const HotSpotID kCaldoriaLeftDrawerCloseSpotID = 5028;
+static const HotSpotID kCaldoriaRightDrawerWithKeysCloseSpotID = 5029;
+static const HotSpotID kCaldoriaRightDrawerNoKeysCloseSpotID = 5030;
+static const HotSpotID kCaldoriaFourthFloorElevatorSpotID = 5031;
+static const HotSpotID kCaldoria20DoorbellSpotID = 5032;
+static const HotSpotID kCaldoria21DoorbellSpotID = 5033;
+static const HotSpotID kCaldoria26DoorbellSpotID = 5034;
+static const HotSpotID kCaldoriaFourthFloorElevator1 = 5035;
+static const HotSpotID kCaldoriaFourthFloorElevator2 = 5036;
+static const HotSpotID kCaldoriaFourthFloorElevator3 = 5037;
+static const HotSpotID kCaldoriaFourthFloorElevator4 = 5038;
+static const HotSpotID kCaldoriaFourthFloorElevator5 = 5039;
+static const HotSpotID kCaldoriaGroundElevator1 = 5040;
+static const HotSpotID kCaldoriaGroundElevator2 = 5041;
+static const HotSpotID kCaldoriaGroundElevator3 = 5042;
+static const HotSpotID kCaldoriaGroundElevator4 = 5043;
+static const HotSpotID kCaldoriaGroundElevator5 = 5044;
+static const HotSpotID kCaldoria29DoorbellSpotID = 5045;
+static const HotSpotID kCaldoria34DoorbellSpotID = 5046;
+static const HotSpotID kCaldoria35DoorbellSpotID = 5047;
+static const HotSpotID kCaldoriaGroundElevatorSpotID = 5048;
+static const HotSpotID kCaldoriaBinocularZoomInSpotID = 5049;
+static const HotSpotID kCaldoriaBinocularsOutSpotID = 5050;
+static const HotSpotID kCaldoriaZoomInOnShipSpotID = 5051;
+static const HotSpotID kCaldoriaKioskSpotID = 5052;
+static const HotSpotID kCaldoriaKioskOutSpotID = 5053;
+static const HotSpotID kCaldoriaKioskInfoSpotID = 5054;
+static const HotSpotID kCaldoriaGTCardDropSpotID = 5055;
+static const HotSpotID kCaldoriaGTTokyoSpotID = 5056;
+static const HotSpotID kCaldoriaGTTSASpotID = 5057;
+static const HotSpotID kCaldoriaGTBeachSpotID = 5058;
+static const HotSpotID kCaldoriaGTOtherSpotID = 5059;
+static const HotSpotID kCaldoriaRoofElevator1 = 5060;
+static const HotSpotID kCaldoriaRoofElevator2 = 5061;
+static const HotSpotID kCaldoriaRoofElevator3 = 5062;
+static const HotSpotID kCaldoriaRoofElevator4 = 5063;
+static const HotSpotID kCaldoriaRoofElevator5 = 5064;
+static const HotSpotID kCaldoriaRoofElevatorSpotID = 5065;
+static const HotSpotID kCaldoriaRoofDoorSpotID = 5066;
+static const HotSpotID kCaldoriaRoofCardDropSpotID = 5067;
+static const HotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
 
 //	Extra sequence IDs.
 
-const ExtraID kCaldoriaWakeUpView1 = 0;
-const ExtraID kCaldoria00WakeUp1 = 1;
-const ExtraID kCaldoria00WakeUp2 = 2;
-const ExtraID kCaldoria00SitDown = 3;
-const ExtraID k4DEnvironOpenToINN = 4;
-const ExtraID k4DINNInterruption = 5;
-const ExtraID k4DINNIntro = 6;
-const ExtraID k4DINNMarkJohnson = 7;
-const ExtraID k4DINNMeganLove = 8;
-const ExtraID k4DINNFadeOut = 9;
-const ExtraID k4DEnvironOpenFromINN = 10;
-const ExtraID k4DEnvironOpen = 11;
-const ExtraID k4DEnvironOpenView = 12;
-const ExtraID k4DEnvironClose = 13;
-const ExtraID k4DIslandLoop = 14;
-const ExtraID k4DDesertLoop = 15;
-const ExtraID k4DMountainLoop = 16;
-const ExtraID k4DIsland1ToIsland0 = 17;
-const ExtraID k4DIsland2ToIsland0 = 18;
-const ExtraID k4DIsland0ToDesert0 = 19;
-const ExtraID k4DIsland1ToDesert0 = 20;
-const ExtraID k4DIsland2ToDesert0 = 21;
-const ExtraID k4DIsland0ToMountain0 = 22;
-const ExtraID k4DIsland1ToMountain0 = 23;
-const ExtraID k4DIsland2ToMountain0 = 24;
-const ExtraID k4DDesert0ToIsland0 = 25;
-const ExtraID k4DDesert1ToIsland0 = 26;
-const ExtraID k4DDesert2ToIsland0 = 27;
-const ExtraID k4DDesert0ToMountain0 = 28;
-const ExtraID k4DDesert1ToMountain0 = 29;
-const ExtraID k4DDesert2ToMountain0 = 30;
-const ExtraID k4DMountain0ToIsland0 = 31;
-const ExtraID k4DMountain1ToIsland0 = 32;
-const ExtraID k4DMountain2ToIsland0 = 33;
-const ExtraID k4DMountain0ToDesert0 = 34;
-const ExtraID k4DMountain1ToDesert0 = 35;
-const ExtraID k4DMountain2ToDesert0 = 36;
-const ExtraID kCaBathroomGreeting = 37;
-const ExtraID kCaBathroomBodyFat = 38;
-const ExtraID kCaBathroomStylistIntro = 39;
-const ExtraID kCaBathroomRetrothrash = 40;
-const ExtraID kCaBathroomRetrothrashReturn = 41;
-const ExtraID kCaBathroomGeoWave = 42;
-const ExtraID kCaBathroomGeoWaveReturn = 43;
-const ExtraID kCaBathroomAgencyStandard = 44;
-const ExtraID kCaldoriaShowerTitle = 45;
-const ExtraID kCaldoriaShowerButton = 46;
-const ExtraID kCaldoriaShowerDown = 47;
-const ExtraID kCaldoriaShowerUp = 48;
-const ExtraID kCaBedroomVidPhone = 49;
-const ExtraID kCaBedroomMessage1 = 50;
-const ExtraID kCaBedroomMessage2 = 51;
-const ExtraID kCreateOrangeJuice = 52;
-const ExtraID kDisposeOrangeJuice = 53;
-const ExtraID kReplicatorNorthViewWithOJ = 54;
-const ExtraID kLeftDrawerOpen = 55;
-const ExtraID kLeftDrawerClose = 56;
-const ExtraID kRightDrawerOpenWithKeys = 57;
-const ExtraID kRightDrawerCloseWithKeys = 58;
-const ExtraID kRightDrawerOpenNoKeys = 59;
-const ExtraID kRightDrawerCloseNoKeys = 60;
-const ExtraID kRightDrawerOpenViewWithKeys = 61;
-const ExtraID kRightDrawerOpenViewNoKeys = 62;
-const ExtraID kCaldoria16ElevatorUp = 63;
-const ExtraID kCaldoria16ElevatorDown = 64;
-const ExtraID kCaldoria16SouthViewWithElevator = 65;
-const ExtraID kCaldoria20Doorbell = 66;
-const ExtraID kCaldoria21Doorbell = 67;
-const ExtraID kCaldoria26Doorbell = 68;
-const ExtraID kCaldoriaFourthToGround = 69;
-const ExtraID kCaldoriaRoofToFourth = 70;
-const ExtraID kCaldoriaRoofToGround = 71;
-const ExtraID kCaldoriaGroundToFourth = 72;
-const ExtraID kCaldoriaGroundToRoof = 73;
-const ExtraID kCaldoriaFourthToRoof = 74;
-const ExtraID kCaldoria29Doorbell = 75;
-const ExtraID kCaldoria34Doorbell = 76;
-const ExtraID kCaldoria35Doorbell = 77;
-const ExtraID kBinocularsZoomInOnShip = 78;
-const ExtraID kCaldoriaKioskVideo = 79;
-const ExtraID kCaldoriaTransporterArrowLoop = 80;
-const ExtraID kArriveAtCaldoriaFromTSA = 81;
-const ExtraID kCaGTOtherChoice = 82;
-const ExtraID kCaGTCardSwipe = 83;
-const ExtraID kCaGTSelectTSA = 84;
-const ExtraID kCaGTFryTheFly = 85;
-const ExtraID kCaGTGoToTSA = 86;
-const ExtraID kCaGTSelectBeach = 87;
-const ExtraID kCaGTGoToBeach = 88;
-const ExtraID kCaGTArriveAtBeach = 89;
-const ExtraID kCaGTSelectTokyo = 90;
-const ExtraID kCaGTGoToTokyo = 91;
-const ExtraID kCaGTArriveAtTokyo = 92;
-const ExtraID kCa48NorthRooftopClosed = 93;
-const ExtraID kCa48NorthExplosion = 94;
-const ExtraID kCa48NorthExplosionDeath = 95;
-const ExtraID kCa49NorthVoiceAnalysis = 96;
-const ExtraID kCa50SinclairShoots = 97;
-const ExtraID kCa53EastZoomToSinclair = 98;
-const ExtraID kCa53EastDeath2 = 99;
-const ExtraID kCa53EastShootSinclair = 100;
-const ExtraID kCa53EastZoomOutFromSinclair = 101;
-const ExtraID kCa54SouthDeath = 102;
-const ExtraID kCaldoria56BombStage1 = 103;
-const ExtraID kCaldoria56BombStage2 = 104;
-const ExtraID kCaldoria56BombStage3 = 105;
-const ExtraID kCaldoria56BombStage4 = 106;
-const ExtraID kCaldoria56BombStage5 = 107;
-const ExtraID kCaldoria56BombStage6 = 108;
-const ExtraID kCaldoria56BombStage7 = 109;
-const ExtraID kCaldoria56BombExplodes = 110;
+static const ExtraID kCaldoriaWakeUpView1 = 0;
+static const ExtraID kCaldoria00WakeUp1 = 1;
+static const ExtraID kCaldoria00WakeUp2 = 2;
+static const ExtraID kCaldoria00SitDown = 3;
+static const ExtraID k4DEnvironOpenToINN = 4;
+static const ExtraID k4DINNInterruption = 5;
+static const ExtraID k4DINNIntro = 6;
+static const ExtraID k4DINNMarkJohnson = 7;
+static const ExtraID k4DINNMeganLove = 8;
+static const ExtraID k4DINNFadeOut = 9;
+static const ExtraID k4DEnvironOpenFromINN = 10;
+static const ExtraID k4DEnvironOpen = 11;
+static const ExtraID k4DEnvironOpenView = 12;
+static const ExtraID k4DEnvironClose = 13;
+static const ExtraID k4DIslandLoop = 14;
+static const ExtraID k4DDesertLoop = 15;
+static const ExtraID k4DMountainLoop = 16;
+static const ExtraID k4DIsland1ToIsland0 = 17;
+static const ExtraID k4DIsland2ToIsland0 = 18;
+static const ExtraID k4DIsland0ToDesert0 = 19;
+static const ExtraID k4DIsland1ToDesert0 = 20;
+static const ExtraID k4DIsland2ToDesert0 = 21;
+static const ExtraID k4DIsland0ToMountain0 = 22;
+static const ExtraID k4DIsland1ToMountain0 = 23;
+static const ExtraID k4DIsland2ToMountain0 = 24;
+static const ExtraID k4DDesert0ToIsland0 = 25;
+static const ExtraID k4DDesert1ToIsland0 = 26;
+static const ExtraID k4DDesert2ToIsland0 = 27;
+static const ExtraID k4DDesert0ToMountain0 = 28;
+static const ExtraID k4DDesert1ToMountain0 = 29;
+static const ExtraID k4DDesert2ToMountain0 = 30;
+static const ExtraID k4DMountain0ToIsland0 = 31;
+static const ExtraID k4DMountain1ToIsland0 = 32;
+static const ExtraID k4DMountain2ToIsland0 = 33;
+static const ExtraID k4DMountain0ToDesert0 = 34;
+static const ExtraID k4DMountain1ToDesert0 = 35;
+static const ExtraID k4DMountain2ToDesert0 = 36;
+static const ExtraID kCaBathroomGreeting = 37;
+static const ExtraID kCaBathroomBodyFat = 38;
+static const ExtraID kCaBathroomStylistIntro = 39;
+static const ExtraID kCaBathroomRetrothrash = 40;
+static const ExtraID kCaBathroomRetrothrashReturn = 41;
+static const ExtraID kCaBathroomGeoWave = 42;
+static const ExtraID kCaBathroomGeoWaveReturn = 43;
+static const ExtraID kCaBathroomAgencyStandard = 44;
+static const ExtraID kCaldoriaShowerTitle = 45;
+static const ExtraID kCaldoriaShowerButton = 46;
+static const ExtraID kCaldoriaShowerDown = 47;
+static const ExtraID kCaldoriaShowerUp = 48;
+static const ExtraID kCaBedroomVidPhone = 49;
+static const ExtraID kCaBedroomMessage1 = 50;
+static const ExtraID kCaBedroomMessage2 = 51;
+static const ExtraID kCreateOrangeJuice = 52;
+static const ExtraID kDisposeOrangeJuice = 53;
+static const ExtraID kReplicatorNorthViewWithOJ = 54;
+static const ExtraID kLeftDrawerOpen = 55;
+static const ExtraID kLeftDrawerClose = 56;
+static const ExtraID kRightDrawerOpenWithKeys = 57;
+static const ExtraID kRightDrawerCloseWithKeys = 58;
+static const ExtraID kRightDrawerOpenNoKeys = 59;
+static const ExtraID kRightDrawerCloseNoKeys = 60;
+static const ExtraID kRightDrawerOpenViewWithKeys = 61;
+static const ExtraID kRightDrawerOpenViewNoKeys = 62;
+static const ExtraID kCaldoria16ElevatorUp = 63;
+static const ExtraID kCaldoria16ElevatorDown = 64;
+static const ExtraID kCaldoria16SouthViewWithElevator = 65;
+static const ExtraID kCaldoria20Doorbell = 66;
+static const ExtraID kCaldoria21Doorbell = 67;
+static const ExtraID kCaldoria26Doorbell = 68;
+static const ExtraID kCaldoriaFourthToGround = 69;
+static const ExtraID kCaldoriaRoofToFourth = 70;
+static const ExtraID kCaldoriaRoofToGround = 71;
+static const ExtraID kCaldoriaGroundToFourth = 72;
+static const ExtraID kCaldoriaGroundToRoof = 73;
+static const ExtraID kCaldoriaFourthToRoof = 74;
+static const ExtraID kCaldoria29Doorbell = 75;
+static const ExtraID kCaldoria34Doorbell = 76;
+static const ExtraID kCaldoria35Doorbell = 77;
+static const ExtraID kBinocularsZoomInOnShip = 78;
+static const ExtraID kCaldoriaKioskVideo = 79;
+static const ExtraID kCaldoriaTransporterArrowLoop = 80;
+static const ExtraID kArriveAtCaldoriaFromTSA = 81;
+static const ExtraID kCaGTOtherChoice = 82;
+static const ExtraID kCaGTCardSwipe = 83;
+static const ExtraID kCaGTSelectTSA = 84;
+static const ExtraID kCaGTFryTheFly = 85;
+static const ExtraID kCaGTGoToTSA = 86;
+static const ExtraID kCaGTSelectBeach = 87;
+static const ExtraID kCaGTGoToBeach = 88;
+static const ExtraID kCaGTArriveAtBeach = 89;
+static const ExtraID kCaGTSelectTokyo = 90;
+static const ExtraID kCaGTGoToTokyo = 91;
+static const ExtraID kCaGTArriveAtTokyo = 92;
+static const ExtraID kCa48NorthRooftopClosed = 93;
+static const ExtraID kCa48NorthExplosion = 94;
+static const ExtraID kCa48NorthExplosionDeath = 95;
+static const ExtraID kCa49NorthVoiceAnalysis = 96;
+static const ExtraID kCa50SinclairShoots = 97;
+static const ExtraID kCa53EastZoomToSinclair = 98;
+static const ExtraID kCa53EastDeath2 = 99;
+static const ExtraID kCa53EastShootSinclair = 100;
+static const ExtraID kCa53EastZoomOutFromSinclair = 101;
+static const ExtraID kCa54SouthDeath = 102;
+static const ExtraID kCaldoria56BombStage1 = 103;
+static const ExtraID kCaldoria56BombStage2 = 104;
+static const ExtraID kCaldoria56BombStage3 = 105;
+static const ExtraID kCaldoria56BombStage4 = 106;
+static const ExtraID kCaldoria56BombStage5 = 107;
+static const ExtraID kCaldoria56BombStage6 = 108;
+static const ExtraID kCaldoria56BombStage7 = 109;
+static const ExtraID kCaldoria56BombExplodes = 110;
 
 //	Caldoria interactions.
 
-const InteractionID kCaldoria4DInteractionID = 0;
-const InteractionID kCaldoriaBombInteractionID = 1;
-const InteractionID kCaldoriaMessagesInteractionID = 2;
-const InteractionID kCaldoriaMirrorInteractionID = 3;
+static const InteractionID kCaldoria4DInteractionID = 0;
+static const InteractionID kCaldoriaBombInteractionID = 1;
+static const InteractionID kCaldoriaMessagesInteractionID = 2;
+static const InteractionID kCaldoriaMirrorInteractionID = 3;
 
 //	Caldoria:
 
-const DisplayOrder kVidPhoneOrder = kMonitorLayer;
-const DisplayOrder k4DSpritesOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaMessagesOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaElevatorOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaA05LightLoopOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaA07LightLoopOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaBombGridOrder = kMonitorLayer;
-const DisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
+static const DisplayOrder kVidPhoneOrder = kMonitorLayer;
+static const DisplayOrder k4DSpritesOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaMessagesOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaElevatorOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaA05LightLoopOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaA07LightLoopOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaBombGridOrder = kMonitorLayer;
+static const DisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
 
 /////////////////////////////////////////////
 //
 //	Caldoria
 
-const CoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
-const CoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
+static const CoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
+static const CoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
 
-const CoordType kCaldoria4DSpritesLeft = kNavAreaLeft + 10;
-const CoordType kCaldoria4DSpritesTop = kNavAreaTop + 142;
+static const CoordType kCaldoria4DSpritesLeft = kNavAreaLeft + 10;
+static const CoordType kCaldoria4DSpritesTop = kNavAreaTop + 142;
 
-const CoordType kCaldoriaMessageLeft = kNavAreaLeft + 202;
-const CoordType kCaldoriaMessageTop = kNavAreaTop + 26;
+static const CoordType kCaldoriaMessageLeft = kNavAreaLeft + 202;
+static const CoordType kCaldoriaMessageTop = kNavAreaTop + 26;
 
-const CoordType kCaldoriaElevatorLeft = kNavAreaLeft + 407;
-const CoordType kCaldoriaElevatorTop = kNavAreaTop + 138;
+static const CoordType kCaldoriaElevatorLeft = kNavAreaLeft + 407;
+static const CoordType kCaldoriaElevatorTop = kNavAreaTop + 138;
 
-const CoordType kCaldoriaA05LightLoopLeft = kNavAreaLeft + 213;
-const CoordType kCaldoriaA05LightLoopTop = kNavAreaTop + 215;
+static const CoordType kCaldoriaA05LightLoopLeft = kNavAreaLeft + 213;
+static const CoordType kCaldoriaA05LightLoopTop = kNavAreaTop + 215;
 
-const CoordType kCaldoriaA07LightLoopLeft = kNavAreaLeft + 414;
-const CoordType kCaldoriaA07LightLoopTop = kNavAreaTop + 215;
+static const CoordType kCaldoriaA07LightLoopLeft = kNavAreaLeft + 414;
+static const CoordType kCaldoriaA07LightLoopTop = kNavAreaTop + 215;
 
-const CoordType kCaldoriaGunSpriteLeft = kNavAreaLeft + 276;
-const CoordType kCaldoriaGunSpriteTop = kNavAreaTop + 115;
+static const CoordType kCaldoriaGunSpriteLeft = kNavAreaLeft + 276;
+static const CoordType kCaldoriaGunSpriteTop = kNavAreaTop + 115;
 
-const CoordType kCaldoria11MessageLoopLeft = kNavAreaLeft + 135;
-const CoordType kCaldoria11MessageLoopTop = kNavAreaTop + 214;
+static const CoordType kCaldoria11MessageLoopLeft = kNavAreaLeft + 135;
+static const CoordType kCaldoria11MessageLoopTop = kNavAreaTop + 214;
 
-const CoordType kCaldoria12MessageLoopLeft = kNavAreaLeft + 209;
-const CoordType kCaldoria12MessageLoopTop = kNavAreaTop + 170;
+static const CoordType kCaldoria12MessageLoopLeft = kNavAreaLeft + 209;
+static const CoordType kCaldoria12MessageLoopTop = kNavAreaTop + 170;
 
-const CoordType kCaldoria13MessageLoopLeft = kNavAreaLeft + 480;
-const CoordType kCaldoria13MessageLoopTop = kNavAreaTop + 191;
+static const CoordType kCaldoria13MessageLoopLeft = kNavAreaLeft + 480;
+static const CoordType kCaldoria13MessageLoopTop = kNavAreaTop + 191;
 
-const CoordType kCaldoria14MessageLoopLeft = kNavAreaLeft + 248;
-const CoordType kCaldoria14MessageLoopTop = kNavAreaTop + 191;
+static const CoordType kCaldoria14MessageLoopLeft = kNavAreaLeft + 248;
+static const CoordType kCaldoria14MessageLoopTop = kNavAreaTop + 191;
 
-const CoordType kCaldoria48CardBombLoopLeft = kNavAreaLeft + 337;
-const CoordType kCaldoria48CardBombLoopTop = kNavAreaTop + 205;
+static const CoordType kCaldoria48CardBombLoopLeft = kNavAreaLeft + 337;
+static const CoordType kCaldoria48CardBombLoopTop = kNavAreaTop + 205;
 
-const CoordType kCaldoriaBombGridLeft = kNavAreaLeft + 290;
-const CoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
+static const CoordType kCaldoriaBombGridLeft = kNavAreaLeft + 290;
+static const CoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
 
-const CoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
-const CoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
+static const CoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
+static const CoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
 
 //	Caldoria display IDs.
 
-const DisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
-const DisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
-const DisplayElementID kCaldoriaMessagesID = kCaldoria4DSpritesID + 1;
-const DisplayElementID kCaldoriaUtilityID = kCaldoriaMessagesID + 1;
-const DisplayElementID kCaldoriaBombGridID = kCaldoriaUtilityID + 1;
-const DisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
+static const DisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
+static const DisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
+static const DisplayElementID kCaldoriaMessagesID = kCaldoria4DSpritesID + 1;
+static const DisplayElementID kCaldoriaUtilityID = kCaldoriaMessagesID + 1;
+static const DisplayElementID kCaldoriaBombGridID = kCaldoriaUtilityID + 1;
+static const DisplayElementID kCaldoriaBombTimerID = kCaldoriaBombGridID + 1;
 
-const TimeValue kCaldoria4DBlankChoiceIn = 29730;
-const TimeValue kCaldoria4DBlankChoiceOut = 33910;
+static const TimeValue kCaldoria4DBlankChoiceIn = 29730;
+static const TimeValue kCaldoria4DBlankChoiceOut = 33910;
 
 class Caldoria;
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
index 31a102a..0326bb7 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -29,34 +29,34 @@
 
 namespace Pegasus {
 
-const TimeValue kSwitchableSlop = 3 * kCaldoriaFrameDuration;
+static const TimeValue kSwitchableSlop = 3 * kCaldoriaFrameDuration;
 //	Two seconds - some slop
-const TimeValue kSwitchableDuration = kCaldoriaMovieScale * 2 - kSwitchableSlop;
+static const TimeValue kSwitchableDuration = kCaldoriaMovieScale * 2 - kSwitchableSlop;
 //	Twelve frames + some slop
-const TimeValue kNonswitchableDuration = kCaldoriaFrameDuration * 12 + kSwitchableSlop;
+static const TimeValue kNonswitchableDuration = kCaldoriaFrameDuration * 12 + kSwitchableSlop;
 
-const TimeValue kSwitchable1Start = 0;
-const TimeValue kSwitchable1Stop = kSwitchable1Start + kSwitchableDuration;
+static const TimeValue kSwitchable1Start = 0;
+static const TimeValue kSwitchable1Stop = kSwitchable1Start + kSwitchableDuration;
 
-const TimeValue kSwitchable2Start = kSwitchable1Stop + kNonswitchableDuration;
-const TimeValue kSwitchable2Stop = kSwitchable2Start + kSwitchableDuration;
+static const TimeValue kSwitchable2Start = kSwitchable1Stop + kNonswitchableDuration;
+static const TimeValue kSwitchable2Stop = kSwitchable2Start + kSwitchableDuration;
 
-const TimeValue kSwitchable3Start = kSwitchable2Stop + kNonswitchableDuration;
-const TimeValue kSwitchable3Stop = kSwitchable3Start + kSwitchableDuration;
+static const TimeValue kSwitchable3Start = kSwitchable2Stop + kNonswitchableDuration;
+static const TimeValue kSwitchable3Stop = kSwitchable3Start + kSwitchableDuration;
 
-const NotificationFlags kVidPhoneDoneFlag = 1;
+static const NotificationFlags kVidPhoneDoneFlag = 1;
 
-const TimeValue kRockMusicLoopIn = 0;
-const TimeValue kRockMusicLoopOut = 2088;
+static const TimeValue kRockMusicLoopIn = 0;
+static const TimeValue kRockMusicLoopOut = 2088;
 
-const TimeValue kOrchestralMusicLoopIn = 2088;
-const TimeValue kOrchestralMusicLoopOut = 4985;
+static const TimeValue kOrchestralMusicLoopIn = 2088;
+static const TimeValue kOrchestralMusicLoopOut = 4985;
 
-const TimeValue kRhythmsMusicLoopIn = 4985;
-const TimeValue kRhythmsMusicLoopOut = 6824;
+static const TimeValue kRhythmsMusicLoopIn = 4985;
+static const TimeValue kRhythmsMusicLoopOut = 6824;
 
-const TimeValue kAcousticMusicLoopIn = 6824;
-const TimeValue kAcousticMusicLoopOut = 9387;
+static const TimeValue kAcousticMusicLoopIn = 6824;
+static const TimeValue kAcousticMusicLoopOut = 9387;
 
 enum {
 	k4DVideoMenu,
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
index 3e97f97..5b9a823 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
@@ -30,7 +30,7 @@
 
 namespace Pegasus {
 
-const NotificationFlags kMessageDoneFlag = 1;
+static const NotificationFlags kMessageDoneFlag = 1;
 
 CaldoriaMessages::CaldoriaMessages(Neighborhood *owner, const NotificationID id, NotificationManager *manager) :
 		GameInteraction(kCaldoriaMessagesInteractionID, owner), Notification(id, manager), _messageMovie(kCaldoriaMessagesID) {
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index 74e9ac8..55c36b6 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -44,9 +44,9 @@ enum {
 	kDoorLockedBit					//	Bit set if door is locked, clear if unlocked.
 };
 
-const DoorFlags kNoDoorFlags = 0;
-const DoorFlags kDoorPresentMask = 1 << kDoorPresentBit;
-const DoorFlags kDoorLockedMask = 1 << kDoorLockedBit;
+static const DoorFlags kNoDoorFlags = 0;
+static const DoorFlags kDoorPresentMask = 1 << kDoorPresentBit;
+static const DoorFlags kDoorLockedMask = 1 << kDoorLockedBit;
 
 class DoorTable {
 public:
diff --git a/engines/pegasus/neighborhood/mars/constants.h b/engines/pegasus/neighborhood/mars/constants.h
index 1035186..b1013da 100755
--- a/engines/pegasus/neighborhood/mars/constants.h
+++ b/engines/pegasus/neighborhood/mars/constants.h
@@ -32,909 +32,909 @@ namespace Pegasus {
 
 //	Element Coordinates
 
-const CoordType kUndoHiliteLeft = kNavAreaLeft + 140;
-const CoordType kUndoHiliteTop = kNavAreaTop + 36;
+static const CoordType kUndoHiliteLeft = kNavAreaLeft + 140;
+static const CoordType kUndoHiliteTop = kNavAreaTop + 36;
 
-const CoordType kCurrentGuessLeft = kNavAreaLeft + 146;
-const CoordType kCurrentGuessTop = kNavAreaTop + 90;
+static const CoordType kCurrentGuessLeft = kNavAreaLeft + 146;
+static const CoordType kCurrentGuessTop = kNavAreaTop + 90;
 
-const CoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
-const CoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
+static const CoordType kReactorChoiceHiliteLeft = kNavAreaLeft + 116;
+static const CoordType kReactorChoiceHiliteTop = kNavAreaTop + 158;
 
-const CoordType kReactorHistoryLeft = kNavAreaLeft + 302;
-const CoordType kReactorHistoryTop = kNavAreaTop + 39;
+static const CoordType kReactorHistoryLeft = kNavAreaLeft + 302;
+static const CoordType kReactorHistoryTop = kNavAreaTop + 39;
 
-const CoordType kAnswerLeft = kNavAreaLeft + 304;
-const CoordType kAnswerTop = kNavAreaTop + 180;
+static const CoordType kAnswerLeft = kNavAreaLeft + 304;
+static const CoordType kAnswerTop = kNavAreaTop + 180;
 
-const CoordType kShuttle1Left = 0;
-const CoordType kShuttle1Top = 0;
+static const CoordType kShuttle1Left = 0;
+static const CoordType kShuttle1Top = 0;
 
-const CoordType kShuttle2Left = 0;
-const CoordType kShuttle2Top = 96;
+static const CoordType kShuttle2Left = 0;
+static const CoordType kShuttle2Top = 96;
 
-const CoordType kShuttle3Left = 500;
-const CoordType kShuttle3Top = 96;
+static const CoordType kShuttle3Left = 500;
+static const CoordType kShuttle3Top = 96;
 
-const CoordType kShuttle4Left = 0;
-const CoordType kShuttle4Top = 320;
+static const CoordType kShuttle4Left = 0;
+static const CoordType kShuttle4Top = 320;
 
-const CoordType kShuttleWindowLeft = 140;
-const CoordType kShuttleWindowTop = 96;
-const CoordType kShuttleWindowWidth = 360;
-const CoordType kShuttleWindowHeight = 224;
+static const CoordType kShuttleWindowLeft = 140;
+static const CoordType kShuttleWindowTop = 96;
+static const CoordType kShuttleWindowWidth = 360;
+static const CoordType kShuttleWindowHeight = 224;
 
-const CoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
-const CoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
+static const CoordType kShuttleWindowMidH = (kShuttleWindowLeft * 2 + kShuttleWindowWidth) / 2;
+static const CoordType kShuttleWindowMidV = (kShuttleWindowTop * 2 + kShuttleWindowHeight) / 2;
 
-const CoordType kShuttleLeftLeft = 0;
-const CoordType kShuttleLeftTop = 128;
+static const CoordType kShuttleLeftLeft = 0;
+static const CoordType kShuttleLeftTop = 128;
 
-const CoordType kShuttleRightLeft = 506;
-const CoordType kShuttleRightTop = 128;
+static const CoordType kShuttleRightLeft = 506;
+static const CoordType kShuttleRightTop = 128;
 
-const CoordType kShuttleLowerLeftLeft = 74;
-const CoordType kShuttleLowerLeftTop = 358;
+static const CoordType kShuttleLowerLeftLeft = 74;
+static const CoordType kShuttleLowerLeftTop = 358;
 
-const CoordType kShuttleLowerRightLeft = 486;
-const CoordType kShuttleLowerRightTop = 354;
+static const CoordType kShuttleLowerRightLeft = 486;
+static const CoordType kShuttleLowerRightTop = 354;
 
-const CoordType kShuttleCenterLeft = 260;
-const CoordType kShuttleCenterTop = 336;
+static const CoordType kShuttleCenterLeft = 260;
+static const CoordType kShuttleCenterTop = 336;
 
-const CoordType kShuttleUpperLeftLeft = 30;
-const CoordType kShuttleUpperLeftTop = 32;
+static const CoordType kShuttleUpperLeftLeft = 30;
+static const CoordType kShuttleUpperLeftTop = 32;
 
-const CoordType kShuttleUpperRightLeft = 506;
-const CoordType kShuttleUpperRightTop = 52;
+static const CoordType kShuttleUpperRightLeft = 506;
+static const CoordType kShuttleUpperRightTop = 52;
 
-const CoordType kShuttleLeftEnergyLeft = 110;
-const CoordType kShuttleLeftEnergyTop = 186;
+static const CoordType kShuttleLeftEnergyLeft = 110;
+static const CoordType kShuttleLeftEnergyTop = 186;
 
-const CoordType kShuttleRightEnergyLeft = 510;
-const CoordType kShuttleRightEnergyTop = 186;
+static const CoordType kShuttleRightEnergyLeft = 510;
+static const CoordType kShuttleRightEnergyTop = 186;
 
-const CoordType kShuttleEnergyLeft = 186;
-const CoordType kShuttleEnergyTop = 60;
-const CoordType kShuttleEnergyWidth = 252;
-const CoordType kShuttleEnergyHeight = 22;
+static const CoordType kShuttleEnergyLeft = 186;
+static const CoordType kShuttleEnergyTop = 60;
+static const CoordType kShuttleEnergyWidth = 252;
+static const CoordType kShuttleEnergyHeight = 22;
 
-const CoordType kPlanetStartLeft = kShuttleWindowLeft;
-const CoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
+static const CoordType kPlanetStartLeft = kShuttleWindowLeft;
+static const CoordType kPlanetStartTop = kShuttleWindowTop + kShuttleWindowHeight;
 
-const CoordType kPlanetStopLeft = kShuttleWindowLeft;
-const CoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
+static const CoordType kPlanetStopLeft = kShuttleWindowLeft;
+static const CoordType kPlanetStopTop = kShuttleWindowTop + kShuttleWindowHeight - 100;
 
-const CoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
-const CoordType kShuttleTractorTop = kShuttleWindowTop + 56;
-const CoordType kShuttleTractorWidth = 348;
-const CoordType kShuttleTractorHeight = 112;
+static const CoordType kShuttleTractorLeft = kShuttleWindowLeft + 6;
+static const CoordType kShuttleTractorTop = kShuttleWindowTop + 56;
+static const CoordType kShuttleTractorWidth = 348;
+static const CoordType kShuttleTractorHeight = 112;
 
-const CoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
-const CoordType kShuttleJunkTop = kShuttleWindowTop + 6;
+static const CoordType kShuttleJunkLeft = kShuttleWindowLeft + 6;
+static const CoordType kShuttleJunkTop = kShuttleWindowTop + 6;
 
-const DisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
-const DisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
-const DisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
-const DisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
-const DisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
-const DisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
-const DisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
-const DisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
-const DisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
-const DisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
-const DisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
-const DisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
+static const DisplayOrder kShuttlePlanetOrder = kInterfaceLayer;
+static const DisplayOrder kShuttleAlienShipOrder = kShuttlePlanetOrder + 1;
+static const DisplayOrder kShuttleRobotShipOrder = kShuttleAlienShipOrder + 1;
+static const DisplayOrder kShuttleTractorBeamMovieOrder = kShuttleRobotShipOrder + 1;
+static const DisplayOrder kShuttleWeaponBackOrder = kShuttleTractorBeamMovieOrder + 1;
+static const DisplayOrder kShuttleJunkOrder = kShuttleWeaponBackOrder + 1;
+static const DisplayOrder kShuttleWeaponFrontOrder = kShuttleJunkOrder + 1;
+static const DisplayOrder kShuttleTractorBeamOrder = kShuttleWeaponFrontOrder + 1;
+static const DisplayOrder kShuttleHUDOrder = kShuttleTractorBeamOrder + 1;
+static const DisplayOrder kShuttleBackgroundOrder = kShuttleHUDOrder + 1;
+static const DisplayOrder kShuttleMonitorOrder = kShuttleBackgroundOrder + 1;
+static const DisplayOrder kShuttleStatusOrder = kShuttleMonitorOrder + 1;
 
-const TimeValue kShuttleSwingStart = 0;
-const TimeValue kShuttleSwingStop = 5 * 600;
+static const TimeValue kShuttleSwingStart = 0;
+static const TimeValue kShuttleSwingStop = 5 * 600;
 
-const TimeValue kCanyonChaseStart = kShuttleSwingStop;
-const TimeValue kCanyonChaseStop = 60 * 600 + 43 * 600 + 14 * 40;
+static const TimeValue kCanyonChaseStart = kShuttleSwingStop;
+static const TimeValue kCanyonChaseStop = 60 * 600 + 43 * 600 + 14 * 40;
 
-const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonChaseStart;
-const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
+static const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonChaseStart;
+static const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
 											kLaunchTubeReachedTime;
 
 //	Left shuttle.
 
-const TimeValue kShuttleLeftIntroStart = 0;
-const TimeValue kShuttleLeftIntroStop = 400;
+static const TimeValue kShuttleLeftIntroStart = 0;
+static const TimeValue kShuttleLeftIntroStop = 400;
 
-const TimeValue kShuttleLeftBlankTime = 400;
+static const TimeValue kShuttleLeftBlankTime = 400;
 
-const TimeValue kShuttleLeftNormalTime = 440;
+static const TimeValue kShuttleLeftNormalTime = 440;
 
-const TimeValue kShuttleLeftAutoTestTime = 480;
+static const TimeValue kShuttleLeftAutoTestTime = 480;
 
-const TimeValue kShuttleLeftDamagedTime = 520;
+static const TimeValue kShuttleLeftDamagedTime = 520;
 
-const TimeValue kShuttleLeftDampingTime = 560;
+static const TimeValue kShuttleLeftDampingTime = 560;
 
-const TimeValue kShuttleLeftGravitonTime = 600;
+static const TimeValue kShuttleLeftGravitonTime = 600;
 
-const TimeValue kShuttleLeftTractorTime = 640;
+static const TimeValue kShuttleLeftTractorTime = 640;
 
 //	Right shuttle.
 
-const TimeValue kShuttleRightIntroStart = 0;
-const TimeValue kShuttleRightIntroStop = 400;
+static const TimeValue kShuttleRightIntroStart = 0;
+static const TimeValue kShuttleRightIntroStop = 400;
 
-const TimeValue kShuttleRightDestroyedStart = 400;
-const TimeValue kShuttleRightDestroyedStop = 840;
+static const TimeValue kShuttleRightDestroyedStart = 400;
+static const TimeValue kShuttleRightDestroyedStop = 840;
 
-const TimeValue kShuttleRightBlankTime = 840;
+static const TimeValue kShuttleRightBlankTime = 840;
 
-const TimeValue kShuttleRightNormalTime = 880;
+static const TimeValue kShuttleRightNormalTime = 880;
 
-const TimeValue kShuttleRightDamagedTime = 920;
+static const TimeValue kShuttleRightDamagedTime = 920;
 
-const TimeValue kShuttleRightTargetLockTime = 960;
+static const TimeValue kShuttleRightTargetLockTime = 960;
 
-const TimeValue kShuttleRightGravitonTime = 1000;
+static const TimeValue kShuttleRightGravitonTime = 1000;
 
-const TimeValue kShuttleRightOverloadTime = 1040;
+static const TimeValue kShuttleRightOverloadTime = 1040;
 
 //	Lower Left shuttle.
 
-const TimeValue kShuttleLowerLeftCollisionTime = 0;
+static const TimeValue kShuttleLowerLeftCollisionTime = 0;
 
-const TimeValue kShuttleLowerLeftTubeTime = 40;
+static const TimeValue kShuttleLowerLeftTubeTime = 40;
 
-const TimeValue kShuttleLowerLeftAutopilotTime = 80;
+static const TimeValue kShuttleLowerLeftAutopilotTime = 80;
 
 //	Lower Right shuttle.
 
-const TimeValue kShuttleLowerRightOffTime = 0;
+static const TimeValue kShuttleLowerRightOffTime = 0;
 
-const TimeValue kShuttleLowerRightTrackingTime = 40;
+static const TimeValue kShuttleLowerRightTrackingTime = 40;
 
-const TimeValue kShuttleLowerRightTransportTime = 80;
+static const TimeValue kShuttleLowerRightTransportTime = 80;
 
-const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
+static const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
 
 //	Center shuttle.
 
-const TimeValue kShuttleCenterBoardingTime = 0;
+static const TimeValue kShuttleCenterBoardingTime = 0;
 
-const TimeValue kShuttleCenterCheckTime = 40;
+static const TimeValue kShuttleCenterCheckTime = 40;
 
-const TimeValue kShuttleCenterNavCompTime = 80;
+static const TimeValue kShuttleCenterNavCompTime = 80;
 
-const TimeValue kShuttleCenterCommTime = 120;
+static const TimeValue kShuttleCenterCommTime = 120;
 
-const TimeValue kShuttleCenterWeaponsTime = 160;
+static const TimeValue kShuttleCenterWeaponsTime = 160;
 
-const TimeValue kShuttleCenterAllSystemsTime = 200;
+static const TimeValue kShuttleCenterAllSystemsTime = 200;
 
-const TimeValue kShuttleCenterSecureLooseTime = 240;
+static const TimeValue kShuttleCenterSecureLooseTime = 240;
 
-const TimeValue kShuttleCenterAutoTestTime = 280;
+static const TimeValue kShuttleCenterAutoTestTime = 280;
 
-const TimeValue kShuttleCenterLaunchTime = 320;
+static const TimeValue kShuttleCenterLaunchTime = 320;
 
-const TimeValue kShuttleCenterEnterTubeTime = 360;
+static const TimeValue kShuttleCenterEnterTubeTime = 360;
 
-const TimeValue kShuttleCenterTargetSightedTime = 400;
+static const TimeValue kShuttleCenterTargetSightedTime = 400;
 
-const TimeValue kShuttleCenterVerifyingTime = 440;
+static const TimeValue kShuttleCenterVerifyingTime = 440;
 
-const TimeValue kShuttleCenterScanningTime = 480;
+static const TimeValue kShuttleCenterScanningTime = 480;
 
-const TimeValue kShuttleCenterSafeTime = 520;
+static const TimeValue kShuttleCenterSafeTime = 520;
 
 //	Upper Left shuttle.
 
-const TimeValue kShuttleUpperLeftDimTime = 0;
+static const TimeValue kShuttleUpperLeftDimTime = 0;
 
-const TimeValue kShuttleUpperLeftDampingTime = 40;
+static const TimeValue kShuttleUpperLeftDampingTime = 40;
 
-const TimeValue kShuttleUpperLeftGravitonTime = 80;
+static const TimeValue kShuttleUpperLeftGravitonTime = 80;
 
-const TimeValue kShuttleUpperLeftTractorTime = 120;
+static const TimeValue kShuttleUpperLeftTractorTime = 120;
 
 //	Upper Right shuttle.
 
-const TimeValue kShuttleUpperRightLockedTime = 0;
+static const TimeValue kShuttleUpperRightLockedTime = 0;
 
-const TimeValue kShuttleUpperRightArmedTime = 40;
+static const TimeValue kShuttleUpperRightArmedTime = 40;
 
-const TimeValue kShuttleUpperRightAlienDestroyedTime = 80;
+static const TimeValue kShuttleUpperRightAlienDestroyedTime = 80;
 
-const TimeValue kShuttleUpperRightOverloadTime = 120;
+static const TimeValue kShuttleUpperRightOverloadTime = 120;
 
-const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
+static const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
 
 //	Shuttle distance
 
-const int kShuttleDistance = 500;
+static const int kShuttleDistance = 500;
 
-const int kJunkMaxDistance = kShuttleDistance;
-const int kJunkMinDistance = 40;
+static const int kJunkMaxDistance = kShuttleDistance;
+static const int kJunkMinDistance = 40;
 
-const int kEnergyBeamMaxDistance = kShuttleDistance;
-const int kEnergyBeamMinDistance = 40;
+static const int kEnergyBeamMaxDistance = kShuttleDistance;
+static const int kEnergyBeamMinDistance = 40;
 
-const int kGravitonMaxDistance = kShuttleDistance;
-const int kGravitonMinDistance = 40;
+static const int kGravitonMaxDistance = kShuttleDistance;
+static const int kGravitonMinDistance = 40;
 
-const TimeValue kMarsOxyMaskOnIn = 0;
-const TimeValue kMarsOxyMaskOnOut = 1560;
+static const TimeValue kMarsOxyMaskOnIn = 0;
+static const TimeValue kMarsOxyMaskOnOut = 1560;
 
-const TimeValue kMarsAirlockButtonBeepIn = 1560;
-const TimeValue kMarsAirlockButtonBeepOut = 1620;
+static const TimeValue kMarsAirlockButtonBeepIn = 1560;
+static const TimeValue kMarsAirlockButtonBeepOut = 1620;
 
-const TimeValue kMarsColorMatchingButtonBeepIn = 1620;
-const TimeValue kMarsColorMatchingButtonBeepOut = 1680;
+static const TimeValue kMarsColorMatchingButtonBeepIn = 1620;
+static const TimeValue kMarsColorMatchingButtonBeepOut = 1680;
 
-const TimeValue kMarsKioskBeepIn = 1680;
-const TimeValue kMarsKioskBeepOut = 1740;
+static const TimeValue kMarsKioskBeepIn = 1680;
+static const TimeValue kMarsKioskBeepOut = 1740;
 
-const TimeValue kMarsBumpIntoWallIn = 1740;
-const TimeValue kMarsBumpIntoWallOut = 1888;
+static const TimeValue kMarsBumpIntoWallIn = 1740;
+static const TimeValue kMarsBumpIntoWallOut = 1888;
 
-const TimeValue kMarsGantryDoorCloseIn = 1888;
-const TimeValue kMarsGantryDoorCloseOut = 2866;
+static const TimeValue kMarsGantryDoorCloseIn = 1888;
+static const TimeValue kMarsGantryDoorCloseOut = 2866;
 
-const TimeValue kMarsTransportDoorCloseIn = 2866;
-const TimeValue kMarsTransportDoorCloseOut = 3593;
+static const TimeValue kMarsTransportDoorCloseIn = 2866;
+static const TimeValue kMarsTransportDoorCloseOut = 3593;
 
-const TimeValue kMarsAirlockPressurizeIn = 3593;
-const TimeValue kMarsAirlockPressurizeOut = 4766;
+static const TimeValue kMarsAirlockPressurizeIn = 3593;
+static const TimeValue kMarsAirlockPressurizeOut = 4766;
 
-const TimeValue kMarsBigAirlockDoorCloseIn = 4766;
-const TimeValue kMarsBigAirlockDoorCloseOut = 7872;
+static const TimeValue kMarsBigAirlockDoorCloseIn = 4766;
+static const TimeValue kMarsBigAirlockDoorCloseOut = 7872;
 
-const TimeValue kMarsSmallAirlockDoorCloseIn = 7872;
-const TimeValue kMarsSmallAirlockDoorCloseOut = 10000;
+static const TimeValue kMarsSmallAirlockDoorCloseIn = 7872;
+static const TimeValue kMarsSmallAirlockDoorCloseOut = 10000;
 
-const TimeValue kMarsMazeDoorCloseIn = 10000;
-const TimeValue kMarsMazeDoorCloseOut = 10969;
+static const TimeValue kMarsMazeDoorCloseIn = 10000;
+static const TimeValue kMarsMazeDoorCloseOut = 10969;
 
-const TimeValue kMarsRobotTakesTransportIn = 10969;
-const TimeValue kMarsRobotTakesTransportOut = 12802;
+static const TimeValue kMarsRobotTakesTransportIn = 10969;
+static const TimeValue kMarsRobotTakesTransportOut = 12802;
 
-const TimeValue kMarsPodDepartedUpperPlatformIn = 12802;
-const TimeValue kMarsPodDepartedUpperPlatformOut = 15783;
+static const TimeValue kMarsPodDepartedUpperPlatformIn = 12802;
+static const TimeValue kMarsPodDepartedUpperPlatformOut = 15783;
 
-const TimeValue kMarsPodDepartedLowerPlatformIn = 15783;
-const TimeValue kMarsPodDepartedLowerPlatformOut = 18736;
+static const TimeValue kMarsPodDepartedLowerPlatformIn = 15783;
+static const TimeValue kMarsPodDepartedLowerPlatformOut = 18736;
 
-const TimeValue kMarsPodArrivedUpperPlatformIn = 18736;
-const TimeValue kMarsPodArrivedUpperPlatformOut = 21605;
+static const TimeValue kMarsPodArrivedUpperPlatformIn = 18736;
+static const TimeValue kMarsPodArrivedUpperPlatformOut = 21605;
 
-const TimeValue kMarsCheckInRequiredIn = 21605;
-const TimeValue kMarsCheckInRequiredOut = 27463;
+static const TimeValue kMarsCheckInRequiredIn = 21605;
+static const TimeValue kMarsCheckInRequiredOut = 27463;
 
-const TimeValue kMarsCantOpenShuttleIn = 27463;
-const TimeValue kMarsCantOpenShuttleOut = 29214;
+static const TimeValue kMarsCantOpenShuttleIn = 27463;
+static const TimeValue kMarsCantOpenShuttleOut = 29214;
 
-const TimeValue kMarsShuttleLockOverrideIn = 29214;
-const TimeValue kMarsShuttleLockOverrideOut = 30330;
+static const TimeValue kMarsShuttleLockOverrideIn = 29214;
+static const TimeValue kMarsShuttleLockOverrideOut = 30330;
 
-const TimeValue kMarsNoShuttleIn = 30330;
-const TimeValue kMarsNoShuttleOut = 31502;
+static const TimeValue kMarsNoShuttleIn = 30330;
+static const TimeValue kMarsNoShuttleOut = 31502;
 
-const TimeValue kMustBeUnlockedIn = 31502;
-const TimeValue kMustBeUnlockedOut = 33960;
+static const TimeValue kMustBeUnlockedIn = 31502;
+static const TimeValue kMustBeUnlockedOut = 33960;
 
-const TimeValue kColorMatchBlueIn = 33960;
-const TimeValue kColorMatchBlueOut = 34240;
+static const TimeValue kColorMatchBlueIn = 33960;
+static const TimeValue kColorMatchBlueOut = 34240;
 
-const TimeValue kColorMatchRedIn = 34240;
-const TimeValue kColorMatchRedOut = 34538;
+static const TimeValue kColorMatchRedIn = 34240;
+static const TimeValue kColorMatchRedOut = 34538;
 
-const TimeValue kColorMatchGreenIn = 34538;
-const TimeValue kColorMatchGreenOut = 34827;
+static const TimeValue kColorMatchGreenIn = 34538;
+static const TimeValue kColorMatchGreenOut = 34827;
 
-const TimeValue kColorMatchYellowIn = 34827;
-const TimeValue kColorMatchYellowOut = 35162;
+static const TimeValue kColorMatchYellowIn = 34827;
+static const TimeValue kColorMatchYellowOut = 35162;
 
-const TimeValue kColorMatchPurpleIn = 35162;
-const TimeValue kColorMatchPurpleOut = 35426;
+static const TimeValue kColorMatchPurpleIn = 35162;
+static const TimeValue kColorMatchPurpleOut = 35426;
 
-const TimeValue kColorMatchZeroNodesIn = 35426;
-const TimeValue kColorMatchZeroNodesOut = 36376;
+static const TimeValue kColorMatchZeroNodesIn = 35426;
+static const TimeValue kColorMatchZeroNodesOut = 36376;
 
-const TimeValue kColorMatchOneNodeIn = 36376;
-const TimeValue kColorMatchOneNodeOut = 37209;
+static const TimeValue kColorMatchOneNodeIn = 36376;
+static const TimeValue kColorMatchOneNodeOut = 37209;
 
-const TimeValue kColorMatchTwoNodesIn = 37209;
-const TimeValue kColorMatchTwoNodesOut = 37983;
+static const TimeValue kColorMatchTwoNodesIn = 37209;
+static const TimeValue kColorMatchTwoNodesOut = 37983;
 
-const TimeValue kColorMatchThreeNodesIn = 37983;
-const TimeValue kColorMatchThreeNodesOut = 38784;
+static const TimeValue kColorMatchThreeNodesIn = 37983;
+static const TimeValue kColorMatchThreeNodesOut = 38784;
 
-const TimeValue kMarsShuttle1DepartedIn = 38784;
-const TimeValue kMarsShuttle1DepartedOut = 40323;
+static const TimeValue kMarsShuttle1DepartedIn = 38784;
+static const TimeValue kMarsShuttle1DepartedOut = 40323;
 
-const TimeValue kMarsShuttle2DepartedIn = 40323;
-const TimeValue kMarsShuttle2DepartedOut = 41824;
+static const TimeValue kMarsShuttle2DepartedIn = 40323;
+static const TimeValue kMarsShuttle2DepartedOut = 41824;
 
-const TimeValue kShuttleCockpitIn = 41824;
-const TimeValue kShuttleCockpitOut = 43126;
+static const TimeValue kShuttleCockpitIn = 41824;
+static const TimeValue kShuttleCockpitOut = 43126;
 
-const TimeValue kShuttleOnboardIn = 43126;
-const TimeValue kShuttleOnboardOut = 44284;
+static const TimeValue kShuttleOnboardIn = 43126;
+static const TimeValue kShuttleOnboardOut = 44284;
 
-const TimeValue kShuttleNavigationIn = 44284;
-const TimeValue kShuttleNavigationOut = 46049;
+static const TimeValue kShuttleNavigationIn = 44284;
+static const TimeValue kShuttleNavigationOut = 46049;
 
-const TimeValue kShuttleCommunicationIn = 46049;
-const TimeValue kShuttleCommunicationOut = 47288;
+static const TimeValue kShuttleCommunicationIn = 46049;
+static const TimeValue kShuttleCommunicationOut = 47288;
 
-const TimeValue kShuttleAutoTestingIn = 47288;
-const TimeValue kShuttleAutoTestingOut = 48179;
+static const TimeValue kShuttleAutoTestingIn = 47288;
+static const TimeValue kShuttleAutoTestingOut = 48179;
 
-const TimeValue kMarsThrusterAutoTestIn = 48179;
-const TimeValue kMarsThrusterAutoTestOut = 49979;
+static const TimeValue kMarsThrusterAutoTestIn = 48179;
+static const TimeValue kMarsThrusterAutoTestOut = 49979;
 
-const TimeValue kShuttleAllSystemsIn = 49979;
-const TimeValue kShuttleAllSystemsOut = 51065;
+static const TimeValue kShuttleAllSystemsIn = 49979;
+static const TimeValue kShuttleAllSystemsOut = 51065;
 
-const TimeValue kShuttleSecureLooseIn = 51065;
-const TimeValue kShuttleSecureLooseOut = 52346;
+static const TimeValue kShuttleSecureLooseIn = 51065;
+static const TimeValue kShuttleSecureLooseOut = 52346;
 
-const TimeValue kShuttlePrepareForDropIn = 52346;
-const TimeValue kShuttlePrepareForDropOut = 53216;
+static const TimeValue kShuttlePrepareForDropIn = 52346;
+static const TimeValue kShuttlePrepareForDropOut = 53216;
 
-const TimeValue kShuttleAllClearIn = 53216;
-const TimeValue kShuttleAllClearOut = 54031;
+static const TimeValue kShuttleAllClearIn = 53216;
+static const TimeValue kShuttleAllClearOut = 54031;
 
-const TimeValue kShuttleConfiguringIn = 54031;
-const TimeValue kShuttleConfiguringOut = 54994;
+static const TimeValue kShuttleConfiguringIn = 54031;
+static const TimeValue kShuttleConfiguringOut = 54994;
 
-const TimeValue kShuttleGeneratingIn = 54994;
-const TimeValue kShuttleGeneratingOut = 56033;
+static const TimeValue kShuttleGeneratingIn = 54994;
+static const TimeValue kShuttleGeneratingOut = 56033;
 
-const TimeValue kShuttleBreakawayIn = 56033;
-const TimeValue kShuttleBreakawayOut = 57346;
+static const TimeValue kShuttleBreakawayIn = 56033;
+static const TimeValue kShuttleBreakawayOut = 57346;
 
-const TimeValue kMarsAtmosphericBreakawayIn = 57346;
-const TimeValue kMarsAtmosphericBreakawayOut = 59237;
+static const TimeValue kMarsAtmosphericBreakawayIn = 57346;
+static const TimeValue kMarsAtmosphericBreakawayOut = 59237;
 
-const TimeValue kMarsCockpitChatterIn = 59237;
-const TimeValue kMarsCockpitChatterOut = 70344;
+static const TimeValue kMarsCockpitChatterIn = 59237;
+static const TimeValue kMarsCockpitChatterOut = 70344;
 
-const TimeValue kShuttleDamperDescIn = 70344;
-const TimeValue kShuttleDamperDescOut = 73262;
+static const TimeValue kShuttleDamperDescIn = 70344;
+static const TimeValue kShuttleDamperDescOut = 73262;
 
-const TimeValue kShuttleGravitonDescIn = 73262;
-const TimeValue kShuttleGravitonDescOut = 75296;
+static const TimeValue kShuttleGravitonDescIn = 73262;
+static const TimeValue kShuttleGravitonDescOut = 75296;
 
-const TimeValue kShuttleTractorDescIn = 75296;
-const TimeValue kShuttleTractorDescOut = 78381;
+static const TimeValue kShuttleTractorDescIn = 75296;
+static const TimeValue kShuttleTractorDescOut = 78381;
 
-const TimeValue kShuttleTargetSightedIn = 78381;
-const TimeValue kShuttleTargetSightedOut = 79074;
+static const TimeValue kShuttleTargetSightedIn = 78381;
+static const TimeValue kShuttleTargetSightedOut = 79074;
 
-const TimeValue kShuttleAutopilotEngagedIn = 79074;
-const TimeValue kShuttleAutopilotEngagedOut = 80414;
+static const TimeValue kShuttleAutopilotEngagedIn = 79074;
+static const TimeValue kShuttleAutopilotEngagedOut = 80414;
 
-const TimeValue kMarsEDBBlastIn = 80414;
-const TimeValue kMarsEDBBlastOut = 80705;
+static const TimeValue kMarsEDBBlastIn = 80414;
+static const TimeValue kMarsEDBBlastOut = 80705;
 
-const TimeValue kMarsGravitonBlastIn = 80705;
-const TimeValue kMarsGravitonBlastOut = 81199;
+static const TimeValue kMarsGravitonBlastIn = 80705;
+static const TimeValue kMarsGravitonBlastOut = 81199;
 
-const TimeValue kMarsJunkCollisionIn = 81199;
-const TimeValue kMarsJunkCollisionOut = 81961;
+static const TimeValue kMarsJunkCollisionIn = 81199;
+static const TimeValue kMarsJunkCollisionOut = 81961;
 
-const TimeValue kShuttleGravitonIn = 81961;
-const TimeValue kShuttleGravitonOut = 82587;
+static const TimeValue kShuttleGravitonIn = 81961;
+static const TimeValue kShuttleGravitonOut = 82587;
 
-const TimeValue kShuttleDampingBeamIn = 82587;
-const TimeValue kShuttleDampingBeamOut = 83331;
+static const TimeValue kShuttleDampingBeamIn = 82587;
+static const TimeValue kShuttleDampingBeamOut = 83331;
 
-const TimeValue kShuttleTractorBeamIn = 83331;
-const TimeValue kShuttleTractorBeamOut = 83802;
+static const TimeValue kShuttleTractorBeamIn = 83331;
+static const TimeValue kShuttleTractorBeamOut = 83802;
 
-const TimeValue kShuttleHullBreachIn = 83802;
-const TimeValue kShuttleHullBreachOut = 84721;
+static const TimeValue kShuttleHullBreachIn = 83802;
+static const TimeValue kShuttleHullBreachOut = 84721;
 
-const TimeValue kShuttleWingDamageIn = 84721;
-const TimeValue kShuttleWingDamageOut = 85640;
+static const TimeValue kShuttleWingDamageIn = 84721;
+static const TimeValue kShuttleWingDamageOut = 85640;
 
-const TimeValue kShuttleHullDamageIn = 85640;
-const TimeValue kShuttleHullDamageOut = 86513;
+static const TimeValue kShuttleHullDamageIn = 85640;
+static const TimeValue kShuttleHullDamageOut = 86513;
 
-const TimeValue kShuttleEnergyTooLowIn = 86513;
-const TimeValue kShuttleEnergyTooLowOut = 87578;
+static const TimeValue kShuttleEnergyTooLowIn = 86513;
+static const TimeValue kShuttleEnergyTooLowOut = 87578;
 
-const TimeValue kShuttleTractorLimitedIn = 87578;
-const TimeValue kShuttleTractorLimitedOut = 89164;
+static const TimeValue kShuttleTractorLimitedIn = 87578;
+static const TimeValue kShuttleTractorLimitedOut = 89164;
 
-const TimeValue kShuttleCantHoldIn = 89164;
-const TimeValue kShuttleCantHoldOut = 90945;
+static const TimeValue kShuttleCantHoldIn = 89164;
+static const TimeValue kShuttleCantHoldOut = 90945;
 
-const TimeValue kShuttleBrokeFreeIn = 90945;
-const TimeValue kShuttleBrokeFreeOut = 92322;
+static const TimeValue kShuttleBrokeFreeIn = 90945;
+static const TimeValue kShuttleBrokeFreeOut = 92322;
 
-const TimeValue kShuttleDestroyedIn = 92322;
-const TimeValue kShuttleDestroyedOut = 93189;
+static const TimeValue kShuttleDestroyedIn = 92322;
+static const TimeValue kShuttleDestroyedOut = 93189;
 
-const TimeValue kShuttleCoordinatesIn = 93189;
-const TimeValue kShuttleCoordinatesOut = 94018;
+static const TimeValue kShuttleCoordinatesIn = 93189;
+static const TimeValue kShuttleCoordinatesOut = 94018;
 
-const TimeValue kShuttleScanningIn = 94018;
-const TimeValue kShuttleScanningOut = 94975;
+static const TimeValue kShuttleScanningIn = 94018;
+static const TimeValue kShuttleScanningOut = 94975;
 
-const TimeValue kShuttleSafeIn = 94975;
-const TimeValue kShuttleSafeOut = 96176;
+static const TimeValue kShuttleSafeIn = 94975;
+static const TimeValue kShuttleSafeOut = 96176;
 
-const TimeValue kShuttleOverloadedIn = 96176;
-const TimeValue kShuttleOverloadedOut = 101308;
+static const TimeValue kShuttleOverloadedIn = 96176;
+static const TimeValue kShuttleOverloadedOut = 101308;
 
-const TimeScale kMarsMovieScale = 600;
-const TimeScale kMarsFramesPerSecond = 15;
-const TimeScale kMarsFrameDuration = 40;
+static const TimeScale kMarsMovieScale = 600;
+static const TimeScale kMarsFramesPerSecond = 15;
+static const TimeScale kMarsFrameDuration = 40;
 
 //	Alternate IDs.
 
-const AlternateID kAltMarsNormal = 0;
-const AlternateID kAltMarsPodAtMars34 = 1;
-const AlternateID kAltMarsTookCard = 2;
-const AlternateID kAltMars35AirlockEast = 3;
-const AlternateID kAltMars35AirlockWest = 4;
-const AlternateID kAltMarsPodAtMars45 = 5;
-const AlternateID kAltMarsTookMask = 6;
-const AlternateID kAltMarsMaskOnFiller = 7;
-const AlternateID kAltMars60AirlockEast = 8;
-const AlternateID kAltMars60AirlockWest = 9;
+static const AlternateID kAltMarsNormal = 0;
+static const AlternateID kAltMarsPodAtMars34 = 1;
+static const AlternateID kAltMarsTookCard = 2;
+static const AlternateID kAltMars35AirlockEast = 3;
+static const AlternateID kAltMars35AirlockWest = 4;
+static const AlternateID kAltMarsPodAtMars45 = 5;
+static const AlternateID kAltMarsTookMask = 6;
+static const AlternateID kAltMarsMaskOnFiller = 7;
+static const AlternateID kAltMars60AirlockEast = 8;
+static const AlternateID kAltMars60AirlockWest = 9;
 
 //	Room IDs.
 
-const RoomID kMars0A = 0;
-const RoomID kMars00 = 1;
-const RoomID kMars01 = 2;
-const RoomID kMars02 = 3;
-const RoomID kMars03 = 4;
-const RoomID kMars04 = 5;
-const RoomID kMars05 = 6;
-const RoomID kMars06 = 7;
-const RoomID kMars07 = 8;
-const RoomID kMars08 = 9;
-const RoomID kMars09 = 10;
-const RoomID kMars10 = 11;
-const RoomID kMars11 = 12;
-const RoomID kMars12 = 13;
-const RoomID kMars13 = 14;
-const RoomID kMars14 = 15;
-const RoomID kMars15 = 16;
-const RoomID kMars16 = 17;
-const RoomID kMars17 = 18;
-const RoomID kMars18 = 19;
-const RoomID kMars19 = 20;
-const RoomID kMars20 = 21;
-const RoomID kMars21 = 22;
-const RoomID kMars22 = 23;
-const RoomID kMars23 = 24;
-const RoomID kMars24 = 25;
-const RoomID kMars25 = 26;
-const RoomID kMars26 = 27;
-const RoomID kMars27 = 28;
-const RoomID kMars28 = 29;
-const RoomID kMars29 = 30;
-const RoomID kMars30 = 31;
-const RoomID kMars31 = 32;
-const RoomID kMars31South = 33;
-const RoomID kMars32 = 34;
-const RoomID kMars33 = 35;
-const RoomID kMars33North = 36;
-const RoomID kMars34 = 37;
-const RoomID kMars35 = 38;
-const RoomID kMars36 = 39;
-const RoomID kMars37 = 40;
-const RoomID kMars38 = 41;
-const RoomID kMars39 = 42;
-const RoomID kMars41 = 43;
-const RoomID kMars42 = 44;
-const RoomID kMars43 = 45;
-const RoomID kMars44 = 46;
-const RoomID kMars45 = 47;
-const RoomID kMars46 = 48;
-const RoomID kMars47 = 49;
-const RoomID kMars48 = 50;
-const RoomID kMars49 = 51;
-const RoomID kMars50 = 52;
-const RoomID kMars51 = 53;
-const RoomID kMars52 = 54;
-const RoomID kMars54 = 55;
-const RoomID kMars56 = 56;
-const RoomID kMars58 = 57;
-const RoomID kMars60 = 58;
-const RoomID kMarsRobotShuttle = 59;
-const RoomID kMarsMaze004 = 60;
-const RoomID kMarsMaze005 = 61;
-const RoomID kMarsMaze006 = 62;
-const RoomID kMarsMaze007 = 63;
-const RoomID kMarsMaze008 = 64;
-const RoomID kMarsMaze009 = 65;
-const RoomID kMarsMaze010 = 66;
-const RoomID kMarsMaze011 = 67;
-const RoomID kMarsMaze012 = 68;
-const RoomID kMarsMaze015 = 69;
-const RoomID kMarsMaze016 = 70;
-const RoomID kMarsMaze017 = 71;
-const RoomID kMarsMaze018 = 72;
-const RoomID kMarsMaze019 = 73;
-const RoomID kMarsMaze020 = 74;
-const RoomID kMarsMaze021 = 75;
-const RoomID kMarsMaze022 = 76;
-const RoomID kMarsMaze023 = 77;
-const RoomID kMarsMaze024 = 78;
-const RoomID kMarsMaze025 = 79;
-const RoomID kMarsMaze026 = 80;
-const RoomID kMarsMaze027 = 81;
-const RoomID kMarsMaze028 = 82;
-const RoomID kMarsMaze031 = 83;
-const RoomID kMarsMaze032 = 84;
-const RoomID kMarsMaze033 = 85;
-const RoomID kMarsMaze034 = 86;
-const RoomID kMarsMaze035 = 87;
-const RoomID kMarsMaze036 = 88;
-const RoomID kMarsMaze037 = 89;
-const RoomID kMarsMaze038 = 90;
-const RoomID kMarsMaze039 = 91;
-const RoomID kMarsMaze042 = 92;
-const RoomID kMarsMaze043 = 93;
-const RoomID kMarsMaze044 = 94;
-const RoomID kMarsMaze045 = 95;
-const RoomID kMarsMaze046 = 96;
-const RoomID kMarsMaze047 = 97;
-const RoomID kMarsMaze049 = 98;
-const RoomID kMarsMaze050 = 99;
-const RoomID kMarsMaze051 = 100;
-const RoomID kMarsMaze052 = 101;
-const RoomID kMarsMaze053 = 102;
-const RoomID kMarsMaze054 = 103;
-const RoomID kMarsMaze055 = 104;
-const RoomID kMarsMaze056 = 105;
-const RoomID kMarsMaze057 = 106;
-const RoomID kMarsMaze058 = 107;
-const RoomID kMarsMaze059 = 108;
-const RoomID kMarsMaze060 = 109;
-const RoomID kMarsMaze061 = 110;
-const RoomID kMarsMaze063 = 111;
-const RoomID kMarsMaze064 = 112;
-const RoomID kMarsMaze065 = 113;
-const RoomID kMarsMaze066 = 114;
-const RoomID kMarsMaze067 = 115;
-const RoomID kMarsMaze068 = 116;
-const RoomID kMarsMaze069 = 117;
-const RoomID kMarsMaze070 = 118;
-const RoomID kMarsMaze071 = 119;
-const RoomID kMarsMaze072 = 120;
-const RoomID kMarsMaze074 = 121;
-const RoomID kMarsMaze076 = 122;
-const RoomID kMarsMaze078 = 123;
-const RoomID kMarsMaze079 = 124;
-const RoomID kMarsMaze081 = 125;
-const RoomID kMarsMaze083 = 126;
-const RoomID kMarsMaze084 = 127;
-const RoomID kMarsMaze085 = 128;
-const RoomID kMarsMaze086 = 129;
-const RoomID kMarsMaze087 = 130;
-const RoomID kMarsMaze088 = 131;
-const RoomID kMarsMaze089 = 132;
-const RoomID kMarsMaze090 = 133;
-const RoomID kMarsMaze091 = 134;
-const RoomID kMarsMaze092 = 135;
-const RoomID kMarsMaze093 = 136;
-const RoomID kMarsMaze098 = 137;
-const RoomID kMarsMaze099 = 138;
-const RoomID kMarsMaze100 = 139;
-const RoomID kMarsMaze101 = 140;
-const RoomID kMarsMaze104 = 141;
-const RoomID kMarsMaze105 = 142;
-const RoomID kMarsMaze106 = 143;
-const RoomID kMarsMaze107 = 144;
-const RoomID kMarsMaze108 = 145;
-const RoomID kMarsMaze111 = 146;
-const RoomID kMarsMaze113 = 147;
-const RoomID kMarsMaze114 = 148;
-const RoomID kMarsMaze115 = 149;
-const RoomID kMarsMaze116 = 150;
-const RoomID kMarsMaze117 = 151;
-const RoomID kMarsMaze118 = 152;
-const RoomID kMarsMaze119 = 153;
-const RoomID kMarsMaze120 = 154;
-const RoomID kMarsMaze121 = 155;
-const RoomID kMarsMaze122 = 156;
-const RoomID kMarsMaze123 = 157;
-const RoomID kMarsMaze124 = 158;
-const RoomID kMarsMaze125 = 159;
-const RoomID kMarsMaze126 = 160;
-const RoomID kMarsMaze127 = 161;
-const RoomID kMarsMaze128 = 162;
-const RoomID kMarsMaze129 = 163;
-const RoomID kMarsMaze130 = 164;
-const RoomID kMarsMaze131 = 165;
-const RoomID kMarsMaze132 = 166;
-const RoomID kMarsMaze133 = 167;
-const RoomID kMarsMaze136 = 168;
-const RoomID kMarsMaze137 = 169;
-const RoomID kMarsMaze138 = 170;
-const RoomID kMarsMaze139 = 171;
-const RoomID kMarsMaze140 = 172;
-const RoomID kMarsMaze141 = 173;
-const RoomID kMarsMaze142 = 174;
-const RoomID kMarsMaze143 = 175;
-const RoomID kMarsMaze144 = 176;
-const RoomID kMarsMaze145 = 177;
-const RoomID kMarsMaze146 = 178;
-const RoomID kMarsMaze147 = 179;
-const RoomID kMarsMaze148 = 180;
-const RoomID kMarsMaze149 = 181;
-const RoomID kMarsMaze152 = 182;
-const RoomID kMarsMaze153 = 183;
-const RoomID kMarsMaze154 = 184;
-const RoomID kMarsMaze155 = 185;
-const RoomID kMarsMaze156 = 186;
-const RoomID kMarsMaze157 = 187;
-const RoomID kMarsMaze159 = 188;
-const RoomID kMarsMaze160 = 189;
-const RoomID kMarsMaze161 = 190;
-const RoomID kMarsMaze162 = 191;
-const RoomID kMarsMaze163 = 192;
-const RoomID kMarsMaze164 = 193;
-const RoomID kMarsMaze165 = 194;
-const RoomID kMarsMaze166 = 195;
-const RoomID kMarsMaze167 = 196;
-const RoomID kMarsMaze168 = 197;
-const RoomID kMarsMaze169 = 198;
-const RoomID kMarsMaze170 = 199;
-const RoomID kMarsMaze171 = 200;
-const RoomID kMarsMaze172 = 201;
-const RoomID kMarsMaze173 = 202;
-const RoomID kMarsMaze174 = 203;
-const RoomID kMarsMaze175 = 204;
-const RoomID kMarsMaze177 = 205;
-const RoomID kMarsMaze178 = 206;
-const RoomID kMarsMaze179 = 207;
-const RoomID kMarsMaze180 = 208;
-const RoomID kMarsMaze181 = 209;
-const RoomID kMarsMaze182 = 210;
-const RoomID kMarsMaze183 = 211;
-const RoomID kMarsMaze184 = 212;
-const RoomID kMarsMaze187 = 213;
-const RoomID kMarsMaze188 = 214;
-const RoomID kMarsMaze189 = 215;
-const RoomID kMarsMaze190 = 216;
-const RoomID kMarsMaze191 = 217;
-const RoomID kMarsMaze192 = 218;
-const RoomID kMarsMaze193 = 219;
-const RoomID kMarsMaze194 = 220;
-const RoomID kMarsMaze195 = 221;
-const RoomID kMarsMaze198 = 222;
-const RoomID kMarsMaze199 = 223;
-const RoomID kMarsMaze200 = 224;
-const RoomID kMarsDeathRoom = 225;
+static const RoomID kMars0A = 0;
+static const RoomID kMars00 = 1;
+static const RoomID kMars01 = 2;
+static const RoomID kMars02 = 3;
+static const RoomID kMars03 = 4;
+static const RoomID kMars04 = 5;
+static const RoomID kMars05 = 6;
+static const RoomID kMars06 = 7;
+static const RoomID kMars07 = 8;
+static const RoomID kMars08 = 9;
+static const RoomID kMars09 = 10;
+static const RoomID kMars10 = 11;
+static const RoomID kMars11 = 12;
+static const RoomID kMars12 = 13;
+static const RoomID kMars13 = 14;
+static const RoomID kMars14 = 15;
+static const RoomID kMars15 = 16;
+static const RoomID kMars16 = 17;
+static const RoomID kMars17 = 18;
+static const RoomID kMars18 = 19;
+static const RoomID kMars19 = 20;
+static const RoomID kMars20 = 21;
+static const RoomID kMars21 = 22;
+static const RoomID kMars22 = 23;
+static const RoomID kMars23 = 24;
+static const RoomID kMars24 = 25;
+static const RoomID kMars25 = 26;
+static const RoomID kMars26 = 27;
+static const RoomID kMars27 = 28;
+static const RoomID kMars28 = 29;
+static const RoomID kMars29 = 30;
+static const RoomID kMars30 = 31;
+static const RoomID kMars31 = 32;
+static const RoomID kMars31South = 33;
+static const RoomID kMars32 = 34;
+static const RoomID kMars33 = 35;
+static const RoomID kMars33North = 36;
+static const RoomID kMars34 = 37;
+static const RoomID kMars35 = 38;
+static const RoomID kMars36 = 39;
+static const RoomID kMars37 = 40;
+static const RoomID kMars38 = 41;
+static const RoomID kMars39 = 42;
+static const RoomID kMars41 = 43;
+static const RoomID kMars42 = 44;
+static const RoomID kMars43 = 45;
+static const RoomID kMars44 = 46;
+static const RoomID kMars45 = 47;
+static const RoomID kMars46 = 48;
+static const RoomID kMars47 = 49;
+static const RoomID kMars48 = 50;
+static const RoomID kMars49 = 51;
+static const RoomID kMars50 = 52;
+static const RoomID kMars51 = 53;
+static const RoomID kMars52 = 54;
+static const RoomID kMars54 = 55;
+static const RoomID kMars56 = 56;
+static const RoomID kMars58 = 57;
+static const RoomID kMars60 = 58;
+static const RoomID kMarsRobotShuttle = 59;
+static const RoomID kMarsMaze004 = 60;
+static const RoomID kMarsMaze005 = 61;
+static const RoomID kMarsMaze006 = 62;
+static const RoomID kMarsMaze007 = 63;
+static const RoomID kMarsMaze008 = 64;
+static const RoomID kMarsMaze009 = 65;
+static const RoomID kMarsMaze010 = 66;
+static const RoomID kMarsMaze011 = 67;
+static const RoomID kMarsMaze012 = 68;
+static const RoomID kMarsMaze015 = 69;
+static const RoomID kMarsMaze016 = 70;
+static const RoomID kMarsMaze017 = 71;
+static const RoomID kMarsMaze018 = 72;
+static const RoomID kMarsMaze019 = 73;
+static const RoomID kMarsMaze020 = 74;
+static const RoomID kMarsMaze021 = 75;
+static const RoomID kMarsMaze022 = 76;
+static const RoomID kMarsMaze023 = 77;
+static const RoomID kMarsMaze024 = 78;
+static const RoomID kMarsMaze025 = 79;
+static const RoomID kMarsMaze026 = 80;
+static const RoomID kMarsMaze027 = 81;
+static const RoomID kMarsMaze028 = 82;
+static const RoomID kMarsMaze031 = 83;
+static const RoomID kMarsMaze032 = 84;
+static const RoomID kMarsMaze033 = 85;
+static const RoomID kMarsMaze034 = 86;
+static const RoomID kMarsMaze035 = 87;
+static const RoomID kMarsMaze036 = 88;
+static const RoomID kMarsMaze037 = 89;
+static const RoomID kMarsMaze038 = 90;
+static const RoomID kMarsMaze039 = 91;
+static const RoomID kMarsMaze042 = 92;
+static const RoomID kMarsMaze043 = 93;
+static const RoomID kMarsMaze044 = 94;
+static const RoomID kMarsMaze045 = 95;
+static const RoomID kMarsMaze046 = 96;
+static const RoomID kMarsMaze047 = 97;
+static const RoomID kMarsMaze049 = 98;
+static const RoomID kMarsMaze050 = 99;
+static const RoomID kMarsMaze051 = 100;
+static const RoomID kMarsMaze052 = 101;
+static const RoomID kMarsMaze053 = 102;
+static const RoomID kMarsMaze054 = 103;
+static const RoomID kMarsMaze055 = 104;
+static const RoomID kMarsMaze056 = 105;
+static const RoomID kMarsMaze057 = 106;
+static const RoomID kMarsMaze058 = 107;
+static const RoomID kMarsMaze059 = 108;
+static const RoomID kMarsMaze060 = 109;
+static const RoomID kMarsMaze061 = 110;
+static const RoomID kMarsMaze063 = 111;
+static const RoomID kMarsMaze064 = 112;
+static const RoomID kMarsMaze065 = 113;
+static const RoomID kMarsMaze066 = 114;
+static const RoomID kMarsMaze067 = 115;
+static const RoomID kMarsMaze068 = 116;
+static const RoomID kMarsMaze069 = 117;
+static const RoomID kMarsMaze070 = 118;
+static const RoomID kMarsMaze071 = 119;
+static const RoomID kMarsMaze072 = 120;
+static const RoomID kMarsMaze074 = 121;
+static const RoomID kMarsMaze076 = 122;
+static const RoomID kMarsMaze078 = 123;
+static const RoomID kMarsMaze079 = 124;
+static const RoomID kMarsMaze081 = 125;
+static const RoomID kMarsMaze083 = 126;
+static const RoomID kMarsMaze084 = 127;
+static const RoomID kMarsMaze085 = 128;
+static const RoomID kMarsMaze086 = 129;
+static const RoomID kMarsMaze087 = 130;
+static const RoomID kMarsMaze088 = 131;
+static const RoomID kMarsMaze089 = 132;
+static const RoomID kMarsMaze090 = 133;
+static const RoomID kMarsMaze091 = 134;
+static const RoomID kMarsMaze092 = 135;
+static const RoomID kMarsMaze093 = 136;
+static const RoomID kMarsMaze098 = 137;
+static const RoomID kMarsMaze099 = 138;
+static const RoomID kMarsMaze100 = 139;
+static const RoomID kMarsMaze101 = 140;
+static const RoomID kMarsMaze104 = 141;
+static const RoomID kMarsMaze105 = 142;
+static const RoomID kMarsMaze106 = 143;
+static const RoomID kMarsMaze107 = 144;
+static const RoomID kMarsMaze108 = 145;
+static const RoomID kMarsMaze111 = 146;
+static const RoomID kMarsMaze113 = 147;
+static const RoomID kMarsMaze114 = 148;
+static const RoomID kMarsMaze115 = 149;
+static const RoomID kMarsMaze116 = 150;
+static const RoomID kMarsMaze117 = 151;
+static const RoomID kMarsMaze118 = 152;
+static const RoomID kMarsMaze119 = 153;
+static const RoomID kMarsMaze120 = 154;
+static const RoomID kMarsMaze121 = 155;
+static const RoomID kMarsMaze122 = 156;
+static const RoomID kMarsMaze123 = 157;
+static const RoomID kMarsMaze124 = 158;
+static const RoomID kMarsMaze125 = 159;
+static const RoomID kMarsMaze126 = 160;
+static const RoomID kMarsMaze127 = 161;
+static const RoomID kMarsMaze128 = 162;
+static const RoomID kMarsMaze129 = 163;
+static const RoomID kMarsMaze130 = 164;
+static const RoomID kMarsMaze131 = 165;
+static const RoomID kMarsMaze132 = 166;
+static const RoomID kMarsMaze133 = 167;
+static const RoomID kMarsMaze136 = 168;
+static const RoomID kMarsMaze137 = 169;
+static const RoomID kMarsMaze138 = 170;
+static const RoomID kMarsMaze139 = 171;
+static const RoomID kMarsMaze140 = 172;
+static const RoomID kMarsMaze141 = 173;
+static const RoomID kMarsMaze142 = 174;
+static const RoomID kMarsMaze143 = 175;
+static const RoomID kMarsMaze144 = 176;
+static const RoomID kMarsMaze145 = 177;
+static const RoomID kMarsMaze146 = 178;
+static const RoomID kMarsMaze147 = 179;
+static const RoomID kMarsMaze148 = 180;
+static const RoomID kMarsMaze149 = 181;
+static const RoomID kMarsMaze152 = 182;
+static const RoomID kMarsMaze153 = 183;
+static const RoomID kMarsMaze154 = 184;
+static const RoomID kMarsMaze155 = 185;
+static const RoomID kMarsMaze156 = 186;
+static const RoomID kMarsMaze157 = 187;
+static const RoomID kMarsMaze159 = 188;
+static const RoomID kMarsMaze160 = 189;
+static const RoomID kMarsMaze161 = 190;
+static const RoomID kMarsMaze162 = 191;
+static const RoomID kMarsMaze163 = 192;
+static const RoomID kMarsMaze164 = 193;
+static const RoomID kMarsMaze165 = 194;
+static const RoomID kMarsMaze166 = 195;
+static const RoomID kMarsMaze167 = 196;
+static const RoomID kMarsMaze168 = 197;
+static const RoomID kMarsMaze169 = 198;
+static const RoomID kMarsMaze170 = 199;
+static const RoomID kMarsMaze171 = 200;
+static const RoomID kMarsMaze172 = 201;
+static const RoomID kMarsMaze173 = 202;
+static const RoomID kMarsMaze174 = 203;
+static const RoomID kMarsMaze175 = 204;
+static const RoomID kMarsMaze177 = 205;
+static const RoomID kMarsMaze178 = 206;
+static const RoomID kMarsMaze179 = 207;
+static const RoomID kMarsMaze180 = 208;
+static const RoomID kMarsMaze181 = 209;
+static const RoomID kMarsMaze182 = 210;
+static const RoomID kMarsMaze183 = 211;
+static const RoomID kMarsMaze184 = 212;
+static const RoomID kMarsMaze187 = 213;
+static const RoomID kMarsMaze188 = 214;
+static const RoomID kMarsMaze189 = 215;
+static const RoomID kMarsMaze190 = 216;
+static const RoomID kMarsMaze191 = 217;
+static const RoomID kMarsMaze192 = 218;
+static const RoomID kMarsMaze193 = 219;
+static const RoomID kMarsMaze194 = 220;
+static const RoomID kMarsMaze195 = 221;
+static const RoomID kMarsMaze198 = 222;
+static const RoomID kMarsMaze199 = 223;
+static const RoomID kMarsMaze200 = 224;
+static const RoomID kMarsDeathRoom = 225;
 
 //	Hot Spot Activation IDs.
 
-const HotSpotActivationID kActivationReadyForKiosk = 1;
-const HotSpotActivationID kActivationKioskChoice = 2;
-const HotSpotActivationID kActivationTunnelMapReady = 3;
-const HotSpotActivationID kActivateMarsPodClosed = 4;
-const HotSpotActivationID kActivateMarsPodOpen = 5;
-const HotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
-const HotSpotActivationID kActivateAirlockPressurized = 7;
-const HotSpotActivationID kActivateMaskOnHolder = 8;
-const HotSpotActivationID kActivateMaskOnFiller = 9;
-const HotSpotActivationID kActivateReactorPlatformOut = 10;
-const HotSpotActivationID kActivateReactorPlatformIn = 11;
-const HotSpotActivationID kActivateReactorAskLowerScreen = 12;
-const HotSpotActivationID kActivateReactorReadyForNitrogen = 13;
-const HotSpotActivationID kActivateReactorReadyForCrowBar = 14;
-const HotSpotActivationID kActivateReactorAskOperation = 15;
-const HotSpotActivationID kActivateReactorRanEvaluation = 16;
-const HotSpotActivationID kActivateReactorRanDiagnostics = 17;
-const HotSpotActivationID kActivateReactorAnalyzed = 18;
-const HotSpotActivationID kActivateReactorInstructions = 19;
-const HotSpotActivationID kActivateReactorInGame = 20;
-const HotSpotActivationID kActivateReactorBombSafe = 21;
-const HotSpotActivationID kActivateReactorBombExposed = 22;
-const HotSpotActivationID kActivationRobotHeadClosed = 23;
-const HotSpotActivationID kActivationRobotHeadOpen = 24;
+static const HotSpotActivationID kActivationReadyForKiosk = 1;
+static const HotSpotActivationID kActivationKioskChoice = 2;
+static const HotSpotActivationID kActivationTunnelMapReady = 3;
+static const HotSpotActivationID kActivateMarsPodClosed = 4;
+static const HotSpotActivationID kActivateMarsPodOpen = 5;
+static const HotSpotActivationID kActivateReadyToPressurizeAirlock = 6;
+static const HotSpotActivationID kActivateAirlockPressurized = 7;
+static const HotSpotActivationID kActivateMaskOnHolder = 8;
+static const HotSpotActivationID kActivateMaskOnFiller = 9;
+static const HotSpotActivationID kActivateReactorPlatformOut = 10;
+static const HotSpotActivationID kActivateReactorPlatformIn = 11;
+static const HotSpotActivationID kActivateReactorAskLowerScreen = 12;
+static const HotSpotActivationID kActivateReactorReadyForNitrogen = 13;
+static const HotSpotActivationID kActivateReactorReadyForCrowBar = 14;
+static const HotSpotActivationID kActivateReactorAskOperation = 15;
+static const HotSpotActivationID kActivateReactorRanEvaluation = 16;
+static const HotSpotActivationID kActivateReactorRanDiagnostics = 17;
+static const HotSpotActivationID kActivateReactorAnalyzed = 18;
+static const HotSpotActivationID kActivateReactorInstructions = 19;
+static const HotSpotActivationID kActivateReactorInGame = 20;
+static const HotSpotActivationID kActivateReactorBombSafe = 21;
+static const HotSpotActivationID kActivateReactorBombExposed = 22;
+static const HotSpotActivationID kActivationRobotHeadClosed = 23;
+static const HotSpotActivationID kActivationRobotHeadOpen = 24;
 
 //	Hot Spot IDs.
 
-const HotSpotID kMars11NorthKioskSpotID = 5000;
-const HotSpotID kMars11NorthKioskSightsSpotID = 5001;
-const HotSpotID kMars11NorthKioskColonySpotID = 5002;
-const HotSpotID kMars12NorthKioskSpotID = 5003;
-const HotSpotID kMars12NorthKioskSightsSpotID = 5004;
-const HotSpotID kMars12NorthKioskColonySpotID = 5005;
-const HotSpotID kMars31SouthSpotID = 5006;
-const HotSpotID kMars31SouthOutSpotID = 5007;
-const HotSpotID kMars31SouthCardSpotID = 5008;
-const HotSpotID kMars33NorthSpotID = 5009;
-const HotSpotID kMars33NorthOutSpotID = 5010;
-const HotSpotID kMars33NorthMonitorSpotID = 5011;
-const HotSpotID kMars34NorthCardDropSpotID = 5012;
-const HotSpotID kMars34SouthOpenStorageSpotID = 5013;
-const HotSpotID kMars34SouthCloseStorageSpotID = 5014;
-const HotSpotID kMars34SouthCrowbarSpotID = 5015;
-const HotSpotID kMars35EastPressurizeSpotID = 5016;
-const HotSpotID kMars35EastSpinSpotID = 5017;
-const HotSpotID kMars35WestPressurizeSpotID = 5018;
-const HotSpotID kMars35WestSpinSpotID = 5019;
-const HotSpotID kMars45NorthOpenStorageSpotID = 5020;
-const HotSpotID kMars45NorthCloseStorageSpotID = 5021;
-const HotSpotID kMars45NorthCrowbarSpotID = 5022;
-const HotSpotID kAttackRobotHotSpotID = 5023;
-const HotSpotID kMars49AirMaskSpotID = 5024;
-const HotSpotID kMars49AirMaskFilledSpotID = 5025;
-const HotSpotID kMars49AirFillingDropSpotID = 5026;
-const HotSpotID kMars52MoveLeftSpotID = 5027;
-const HotSpotID kMars52MoveRightSpotID = 5028;
-const HotSpotID kMars52ExtractSpotID = 5029;
-const HotSpotID kMars53RetractSpotID = 5030;
-const HotSpotID kMars54MoveLeftSpotID = 5031;
-const HotSpotID kMars54MoveRightSpotID = 5032;
-const HotSpotID kMars54ExtractSpotID = 5033;
-const HotSpotID kMars55RetractSpotID = 5034;
-const HotSpotID kMars56MoveLeftSpotID = 5035;
-const HotSpotID kMars56MoveRightSpotID = 5036;
-const HotSpotID kMars56ExtractSpotID = 5037;
-const HotSpotID kMars57RetractSpotID = 5038;
-const HotSpotID kMars57LowerScreenSpotID = 5039;
-const HotSpotID kMars57Retract2SpotID = 5040;
-const HotSpotID kMars57DropNitrogenSpotID = 5041;
-const HotSpotID kMars57DropCrowBarSpotID = 5042;
-const HotSpotID kMars57CantOpenPanelSpotID = 5043;
-const HotSpotID kMars57ShieldEvaluationSpotID = 5044;
-const HotSpotID kMars57MeasureOutputSpotID = 5045;
-const HotSpotID kMars57RunDiagnosticsSpotID = 5046;
-const HotSpotID kMars57BackToOperationMenuSpotID = 5047;
-const HotSpotID kMars57AnalyzeObjectSpotID = 5048;
-const HotSpotID kMars57RemoveObjectMenuSpotID = 5049;
-const HotSpotID kMars57CircuitLinkSpotID = 5050;
-const HotSpotID kMars57CancelCircuitLinkSpotID = 5051;
-const HotSpotID kMars57GameInstructionsSpotID = 5052;
-const HotSpotID kMars57UndoMoveSpotID = 5053;
-const HotSpotID kMars57RedMoveSpotID = 5054;
-const HotSpotID kMars57YellowMoveSpotID = 5055;
-const HotSpotID kMars57GreenMoveSpotID = 5056;
-const HotSpotID kMars57BlueMoveSpotID = 5057;
-const HotSpotID kMars57PurpleMoveSpotID = 5058;
-const HotSpotID kMars57LowerScreenSafelySpotID = 5059;
-const HotSpotID kMars57GrabBombSpotID = 5060;
-const HotSpotID kMars58MoveLeftSpotID = 5061;
-const HotSpotID kMars58MoveRightSpotID = 5062;
-const HotSpotID kMars58ExtractSpotID = 5063;
-const HotSpotID kMars59RetractSpotID = 5064;
-const HotSpotID kMars60EastPressurizeSpotID = 5065;
-const HotSpotID kMars60EastSpinSpotID = 5066;
-const HotSpotID kMars60WestPressurizeSpotID = 5067;
-const HotSpotID kMars60WestSpinSpotID = 5068;
-const HotSpotID kRobotShuttleOpenHeadSpotID = 5069;
-const HotSpotID kRobotShuttleMapChipSpotID = 5070;
-const HotSpotID kRobotShuttleOpticalChipSpotID = 5071;
-const HotSpotID kRobotShuttleShieldChipSpotID = 5072;
+static const HotSpotID kMars11NorthKioskSpotID = 5000;
+static const HotSpotID kMars11NorthKioskSightsSpotID = 5001;
+static const HotSpotID kMars11NorthKioskColonySpotID = 5002;
+static const HotSpotID kMars12NorthKioskSpotID = 5003;
+static const HotSpotID kMars12NorthKioskSightsSpotID = 5004;
+static const HotSpotID kMars12NorthKioskColonySpotID = 5005;
+static const HotSpotID kMars31SouthSpotID = 5006;
+static const HotSpotID kMars31SouthOutSpotID = 5007;
+static const HotSpotID kMars31SouthCardSpotID = 5008;
+static const HotSpotID kMars33NorthSpotID = 5009;
+static const HotSpotID kMars33NorthOutSpotID = 5010;
+static const HotSpotID kMars33NorthMonitorSpotID = 5011;
+static const HotSpotID kMars34NorthCardDropSpotID = 5012;
+static const HotSpotID kMars34SouthOpenStorageSpotID = 5013;
+static const HotSpotID kMars34SouthCloseStorageSpotID = 5014;
+static const HotSpotID kMars34SouthCrowbarSpotID = 5015;
+static const HotSpotID kMars35EastPressurizeSpotID = 5016;
+static const HotSpotID kMars35EastSpinSpotID = 5017;
+static const HotSpotID kMars35WestPressurizeSpotID = 5018;
+static const HotSpotID kMars35WestSpinSpotID = 5019;
+static const HotSpotID kMars45NorthOpenStorageSpotID = 5020;
+static const HotSpotID kMars45NorthCloseStorageSpotID = 5021;
+static const HotSpotID kMars45NorthCrowbarSpotID = 5022;
+static const HotSpotID kAttackRobotHotSpotID = 5023;
+static const HotSpotID kMars49AirMaskSpotID = 5024;
+static const HotSpotID kMars49AirMaskFilledSpotID = 5025;
+static const HotSpotID kMars49AirFillingDropSpotID = 5026;
+static const HotSpotID kMars52MoveLeftSpotID = 5027;
+static const HotSpotID kMars52MoveRightSpotID = 5028;
+static const HotSpotID kMars52ExtractSpotID = 5029;
+static const HotSpotID kMars53RetractSpotID = 5030;
+static const HotSpotID kMars54MoveLeftSpotID = 5031;
+static const HotSpotID kMars54MoveRightSpotID = 5032;
+static const HotSpotID kMars54ExtractSpotID = 5033;
+static const HotSpotID kMars55RetractSpotID = 5034;
+static const HotSpotID kMars56MoveLeftSpotID = 5035;
+static const HotSpotID kMars56MoveRightSpotID = 5036;
+static const HotSpotID kMars56ExtractSpotID = 5037;
+static const HotSpotID kMars57RetractSpotID = 5038;
+static const HotSpotID kMars57LowerScreenSpotID = 5039;
+static const HotSpotID kMars57Retract2SpotID = 5040;
+static const HotSpotID kMars57DropNitrogenSpotID = 5041;
+static const HotSpotID kMars57DropCrowBarSpotID = 5042;
+static const HotSpotID kMars57CantOpenPanelSpotID = 5043;
+static const HotSpotID kMars57ShieldEvaluationSpotID = 5044;
+static const HotSpotID kMars57MeasureOutputSpotID = 5045;
+static const HotSpotID kMars57RunDiagnosticsSpotID = 5046;
+static const HotSpotID kMars57BackToOperationMenuSpotID = 5047;
+static const HotSpotID kMars57AnalyzeObjectSpotID = 5048;
+static const HotSpotID kMars57RemoveObjectMenuSpotID = 5049;
+static const HotSpotID kMars57CircuitLinkSpotID = 5050;
+static const HotSpotID kMars57CancelCircuitLinkSpotID = 5051;
+static const HotSpotID kMars57GameInstructionsSpotID = 5052;
+static const HotSpotID kMars57UndoMoveSpotID = 5053;
+static const HotSpotID kMars57RedMoveSpotID = 5054;
+static const HotSpotID kMars57YellowMoveSpotID = 5055;
+static const HotSpotID kMars57GreenMoveSpotID = 5056;
+static const HotSpotID kMars57BlueMoveSpotID = 5057;
+static const HotSpotID kMars57PurpleMoveSpotID = 5058;
+static const HotSpotID kMars57LowerScreenSafelySpotID = 5059;
+static const HotSpotID kMars57GrabBombSpotID = 5060;
+static const HotSpotID kMars58MoveLeftSpotID = 5061;
+static const HotSpotID kMars58MoveRightSpotID = 5062;
+static const HotSpotID kMars58ExtractSpotID = 5063;
+static const HotSpotID kMars59RetractSpotID = 5064;
+static const HotSpotID kMars60EastPressurizeSpotID = 5065;
+static const HotSpotID kMars60EastSpinSpotID = 5066;
+static const HotSpotID kMars60WestPressurizeSpotID = 5067;
+static const HotSpotID kMars60WestSpinSpotID = 5068;
+static const HotSpotID kRobotShuttleOpenHeadSpotID = 5069;
+static const HotSpotID kRobotShuttleMapChipSpotID = 5070;
+static const HotSpotID kRobotShuttleOpticalChipSpotID = 5071;
+static const HotSpotID kRobotShuttleShieldChipSpotID = 5072;
 
 //	Extra sequence IDs.
 
-const ExtraID kMarsArrivalFromTSA = 0;
-const ExtraID kMars0AWatchShuttleDepart = 1;
-const ExtraID kRobotThrowsPlayer = 2;
-const ExtraID kMarsInfoKioskIntro = 3;
-const ExtraID kMarsColonyInfo = 4;
-const ExtraID kMarsSightsInfo = 5;
-const ExtraID kRobotOnWayToShuttle = 6;
-const ExtraID kMars31SouthZoomInNoCard = 7;
-const ExtraID kMars31SouthViewNoCard = 8;
-const ExtraID kMars31SouthZoomOutNoCard = 9;
-const ExtraID kMars31SouthZoomViewNoCard = 10;
-const ExtraID kMars33SlideShow1 = 11;
-const ExtraID kMars33SlideShow2 = 12;
-const ExtraID kMars33SlideShow3 = 13;
-const ExtraID kMars33SlideShow4 = 14;
-const ExtraID kMars34SpotOpenWithBar = 15;
-const ExtraID kMars34SpotCloseWithBar = 16;
-const ExtraID kMars34SpotOpenNoBar = 17;
-const ExtraID kMars34SpotCloseNoBar = 18;
-const ExtraID kMars34ViewOpenWithBar = 19;
-const ExtraID kMars34ViewOpenNoBar = 20;
-const ExtraID kMars34NorthPodGreeting = 21;
-const ExtraID kMarsTurnOnPod = 22;
-const ExtraID kMarsTakePodToMars45 = 23;
-const ExtraID kMars35WestSpinAirlockToEast = 24;
-const ExtraID kMars35EastSpinAirlockToWest = 25;
-const ExtraID kMars45SpotOpenWithBar = 26;
-const ExtraID kMars45SpotCloseWithBar = 27;
-const ExtraID kMars45SpotOpenNoBar = 28;
-const ExtraID kMars45SpotCloseNoBar = 29;
-const ExtraID kMars45ViewOpenWithBar = 30;
-const ExtraID kMars45ViewOpenNoBar = 31;
-const ExtraID kMars48RobotApproaches = 32;
-const ExtraID kMars48RobotKillsPlayer = 33;
-const ExtraID kMars48RobotLoops = 34;
-const ExtraID kMars48RobotView = 35;
-const ExtraID kMars48RobotDefends = 36;
-const ExtraID kMars49SouthViewMaskFilling = 37;
-const ExtraID kMars52SpinLeft = 38;
-const ExtraID kMars52SpinRight = 39;
-const ExtraID kMars52Extend = 40;
-const ExtraID kMars53Retract = 41;
-const ExtraID kMars54SpinLeft = 42;
-const ExtraID kMars54SpinRight = 43;
-const ExtraID kMars54Extend = 44;
-const ExtraID kMars55Retract = 45;
-const ExtraID kMars56SpinLeft = 46;
-const ExtraID kMars56SpinRight = 47;
-const ExtraID kMars56ExtendWithBomb = 48;
-const ExtraID kMars56ExtendNoBomb = 49;
-const ExtraID kMars57RetractWithBomb = 50;
-const ExtraID kMars57RetractNoBomb = 51;
-const ExtraID kMars57LowerScreenClosed = 52;
-const ExtraID kMars57CantOpenPanel = 53;
-const ExtraID kMars57FreezeLock = 54;
-const ExtraID kMars57BreakLock = 55;
-const ExtraID kMars57LockFrozenView = 56;
-const ExtraID kMars57ThawLock = 57;
-const ExtraID kMars57OpenPanel = 58;
-const ExtraID kMars57OpenPanelChoices = 59;
-const ExtraID kMars57ShieldEvaluation = 60;
-const ExtraID kMars57MeasureOutput = 61;
-const ExtraID kMars57ShieldOkayLoop = 62;
-const ExtraID kMars57RunDiagnostics = 63;
-const ExtraID kMars57BombExplodes = 64;
-const ExtraID kMars57BombAnalysis = 65;
-const ExtraID kMars57DontLink = 66;
-const ExtraID kMars57CircuitLink = 67;
-const ExtraID kMars57GameLevel1 = 68;
-const ExtraID kMars57GameLevel2 = 69;
-const ExtraID kMars57GameLevel3 = 70;
-const ExtraID kMars57BombExplodesInGame = 71;
-const ExtraID kMars57GameSolved = 72;
-const ExtraID kMars57ExposeBomb = 73;
-const ExtraID kMars57BackToNormal = 74;
-const ExtraID kMars57ViewOpenNoBomb = 75;
-const ExtraID kMars58SpinLeft = 76;
-const ExtraID kMars58SpinRight = 77;
-const ExtraID kMars58Extend = 78;
-const ExtraID kMars59Retract = 79;
-const ExtraID kMars60WestSpinAirlockToEast = 80;
-const ExtraID kMars60EastSpinAirlockToWest = 81;
-const ExtraID kMarsRobotHeadOpen = 82;
-const ExtraID kMarsRobotHeadClose = 83;
-const ExtraID kMarsRobotHead000 = 84;
-const ExtraID kMarsRobotHead001 = 85;
-const ExtraID kMarsRobotHead010 = 86;
-const ExtraID kMarsRobotHead011 = 87;
-const ExtraID kMarsRobotHead100 = 88;
-const ExtraID kMarsRobotHead101 = 89;
-const ExtraID kMarsRobotHead110 = 90;
-const ExtraID kMarsRobotHead111 = 91;
-const ExtraID kMarsMaze007RobotApproach = 92;
-const ExtraID kMarsMaze007RobotLoop = 93;
-const ExtraID kMarsMaze007RobotDeath = 94;
-const ExtraID kMarsMaze015SouthRobotApproach = 95;
-const ExtraID kMarsMaze015SouthRobotLoop = 96;
-const ExtraID kMarsMaze015SouthRobotDeath = 97;
-const ExtraID kMarsMaze101EastRobotApproach = 98;
-const ExtraID kMarsMaze101EastRobotLoop = 99;
-const ExtraID kMarsMaze101EastRobotDeath = 100;
-const ExtraID kMarsMaze104WestLoop = 101;
-const ExtraID kMarsMaze104WestDeath = 102;
-const ExtraID kMarsMaze133SouthApproach = 103;
-const ExtraID kMarsMaze133SouthLoop = 104;
-const ExtraID kMarsMaze133SouthDeath = 105;
-const ExtraID kMarsMaze136NorthApproach = 106;
-const ExtraID kMarsMaze136NorthLoop = 107;
-const ExtraID kMarsMaze136NorthDeath = 108;
-const ExtraID kMarsMaze184WestLoop = 109;
-const ExtraID kMarsMaze184WestDeath = 110;
-const ExtraID kMars200DeathInBucket = 111;
-
-const ResIDType kReactorUndoHilitePICTID = 900;
-
-const int16 kMars52Compass = 90;
-const int16 kMars54Compass = 180;
-const int16 kMars56Compass = 270;
-const int16 kMars58Compass = 0;
+static const ExtraID kMarsArrivalFromTSA = 0;
+static const ExtraID kMars0AWatchShuttleDepart = 1;
+static const ExtraID kRobotThrowsPlayer = 2;
+static const ExtraID kMarsInfoKioskIntro = 3;
+static const ExtraID kMarsColonyInfo = 4;
+static const ExtraID kMarsSightsInfo = 5;
+static const ExtraID kRobotOnWayToShuttle = 6;
+static const ExtraID kMars31SouthZoomInNoCard = 7;
+static const ExtraID kMars31SouthViewNoCard = 8;
+static const ExtraID kMars31SouthZoomOutNoCard = 9;
+static const ExtraID kMars31SouthZoomViewNoCard = 10;
+static const ExtraID kMars33SlideShow1 = 11;
+static const ExtraID kMars33SlideShow2 = 12;
+static const ExtraID kMars33SlideShow3 = 13;
+static const ExtraID kMars33SlideShow4 = 14;
+static const ExtraID kMars34SpotOpenWithBar = 15;
+static const ExtraID kMars34SpotCloseWithBar = 16;
+static const ExtraID kMars34SpotOpenNoBar = 17;
+static const ExtraID kMars34SpotCloseNoBar = 18;
+static const ExtraID kMars34ViewOpenWithBar = 19;
+static const ExtraID kMars34ViewOpenNoBar = 20;
+static const ExtraID kMars34NorthPodGreeting = 21;
+static const ExtraID kMarsTurnOnPod = 22;
+static const ExtraID kMarsTakePodToMars45 = 23;
+static const ExtraID kMars35WestSpinAirlockToEast = 24;
+static const ExtraID kMars35EastSpinAirlockToWest = 25;
+static const ExtraID kMars45SpotOpenWithBar = 26;
+static const ExtraID kMars45SpotCloseWithBar = 27;
+static const ExtraID kMars45SpotOpenNoBar = 28;
+static const ExtraID kMars45SpotCloseNoBar = 29;
+static const ExtraID kMars45ViewOpenWithBar = 30;
+static const ExtraID kMars45ViewOpenNoBar = 31;
+static const ExtraID kMars48RobotApproaches = 32;
+static const ExtraID kMars48RobotKillsPlayer = 33;
+static const ExtraID kMars48RobotLoops = 34;
+static const ExtraID kMars48RobotView = 35;
+static const ExtraID kMars48RobotDefends = 36;
+static const ExtraID kMars49SouthViewMaskFilling = 37;
+static const ExtraID kMars52SpinLeft = 38;
+static const ExtraID kMars52SpinRight = 39;
+static const ExtraID kMars52Extend = 40;
+static const ExtraID kMars53Retract = 41;
+static const ExtraID kMars54SpinLeft = 42;
+static const ExtraID kMars54SpinRight = 43;
+static const ExtraID kMars54Extend = 44;
+static const ExtraID kMars55Retract = 45;
+static const ExtraID kMars56SpinLeft = 46;
+static const ExtraID kMars56SpinRight = 47;
+static const ExtraID kMars56ExtendWithBomb = 48;
+static const ExtraID kMars56ExtendNoBomb = 49;
+static const ExtraID kMars57RetractWithBomb = 50;
+static const ExtraID kMars57RetractNoBomb = 51;
+static const ExtraID kMars57LowerScreenClosed = 52;
+static const ExtraID kMars57CantOpenPanel = 53;
+static const ExtraID kMars57FreezeLock = 54;
+static const ExtraID kMars57BreakLock = 55;
+static const ExtraID kMars57LockFrozenView = 56;
+static const ExtraID kMars57ThawLock = 57;
+static const ExtraID kMars57OpenPanel = 58;
+static const ExtraID kMars57OpenPanelChoices = 59;
+static const ExtraID kMars57ShieldEvaluation = 60;
+static const ExtraID kMars57MeasureOutput = 61;
+static const ExtraID kMars57ShieldOkayLoop = 62;
+static const ExtraID kMars57RunDiagnostics = 63;
+static const ExtraID kMars57BombExplodes = 64;
+static const ExtraID kMars57BombAnalysis = 65;
+static const ExtraID kMars57DontLink = 66;
+static const ExtraID kMars57CircuitLink = 67;
+static const ExtraID kMars57GameLevel1 = 68;
+static const ExtraID kMars57GameLevel2 = 69;
+static const ExtraID kMars57GameLevel3 = 70;
+static const ExtraID kMars57BombExplodesInGame = 71;
+static const ExtraID kMars57GameSolved = 72;
+static const ExtraID kMars57ExposeBomb = 73;
+static const ExtraID kMars57BackToNormal = 74;
+static const ExtraID kMars57ViewOpenNoBomb = 75;
+static const ExtraID kMars58SpinLeft = 76;
+static const ExtraID kMars58SpinRight = 77;
+static const ExtraID kMars58Extend = 78;
+static const ExtraID kMars59Retract = 79;
+static const ExtraID kMars60WestSpinAirlockToEast = 80;
+static const ExtraID kMars60EastSpinAirlockToWest = 81;
+static const ExtraID kMarsRobotHeadOpen = 82;
+static const ExtraID kMarsRobotHeadClose = 83;
+static const ExtraID kMarsRobotHead000 = 84;
+static const ExtraID kMarsRobotHead001 = 85;
+static const ExtraID kMarsRobotHead010 = 86;
+static const ExtraID kMarsRobotHead011 = 87;
+static const ExtraID kMarsRobotHead100 = 88;
+static const ExtraID kMarsRobotHead101 = 89;
+static const ExtraID kMarsRobotHead110 = 90;
+static const ExtraID kMarsRobotHead111 = 91;
+static const ExtraID kMarsMaze007RobotApproach = 92;
+static const ExtraID kMarsMaze007RobotLoop = 93;
+static const ExtraID kMarsMaze007RobotDeath = 94;
+static const ExtraID kMarsMaze015SouthRobotApproach = 95;
+static const ExtraID kMarsMaze015SouthRobotLoop = 96;
+static const ExtraID kMarsMaze015SouthRobotDeath = 97;
+static const ExtraID kMarsMaze101EastRobotApproach = 98;
+static const ExtraID kMarsMaze101EastRobotLoop = 99;
+static const ExtraID kMarsMaze101EastRobotDeath = 100;
+static const ExtraID kMarsMaze104WestLoop = 101;
+static const ExtraID kMarsMaze104WestDeath = 102;
+static const ExtraID kMarsMaze133SouthApproach = 103;
+static const ExtraID kMarsMaze133SouthLoop = 104;
+static const ExtraID kMarsMaze133SouthDeath = 105;
+static const ExtraID kMarsMaze136NorthApproach = 106;
+static const ExtraID kMarsMaze136NorthLoop = 107;
+static const ExtraID kMarsMaze136NorthDeath = 108;
+static const ExtraID kMarsMaze184WestLoop = 109;
+static const ExtraID kMarsMaze184WestDeath = 110;
+static const ExtraID kMars200DeathInBucket = 111;
+
+static const ResIDType kReactorUndoHilitePICTID = 900;
+
+static const int16 kMars52Compass = 90;
+static const int16 kMars54Compass = 180;
+static const int16 kMars56Compass = 270;
+static const int16 kMars58Compass = 0;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/neighborhood/mars/energybeam.cpp b/engines/pegasus/neighborhood/mars/energybeam.cpp
index 85a1596..964c8ba 100755
--- a/engines/pegasus/neighborhood/mars/energybeam.cpp
+++ b/engines/pegasus/neighborhood/mars/energybeam.cpp
@@ -28,14 +28,14 @@
 
 namespace Pegasus {
 
-const TimeValue kEnergyBeamTime = kOneSecond * kShuttleWeaponScale / 2;
+static const TimeValue kEnergyBeamTime = kOneSecond * kShuttleWeaponScale / 2;
 
-const CoordType kEnergyBeamOriginH = kShuttleWindowMidH;
-const CoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
+static const CoordType kEnergyBeamOriginH = kShuttleWindowMidH;
+static const CoordType kEnergyBeamOriginV = kShuttleWindowTop + kShuttleWindowHeight;
 
-const float kBeamXOrigin = convertScreenHToSpaceX(kEnergyBeamOriginH, kEnergyBeamMinDistance);
-const float kBeamYOrigin = convertScreenVToSpaceY(kEnergyBeamOriginV, kEnergyBeamMinDistance);
-const float kBeamZOrigin = kEnergyBeamMinDistance;
+static const float kBeamXOrigin = convertScreenHToSpaceX(kEnergyBeamOriginH, kEnergyBeamMinDistance);
+static const float kBeamYOrigin = convertScreenVToSpaceY(kEnergyBeamOriginV, kEnergyBeamMinDistance);
+static const float kBeamZOrigin = kEnergyBeamMinDistance;
 
 EnergyBeam::EnergyBeam() {
 	_weaponDuration = kEnergyBeamTime;
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
index d383cc3..140bd12 100755
--- a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
@@ -29,22 +29,22 @@
 
 namespace Pegasus {
 
-const TimeValue kGravitonTime = kOneSecond * kShuttleWeaponScale;
+static const TimeValue kGravitonTime = kOneSecond * kShuttleWeaponScale;
 
-const CoordType kGravitonOriginH = kShuttleWindowLeft - 1;
-const CoordType kGravitonOriginV = kShuttleWindowMidV;
+static const CoordType kGravitonOriginH = kShuttleWindowLeft - 1;
+static const CoordType kGravitonOriginV = kShuttleWindowMidV;
 
-const float kGravitonXOrigin = convertScreenHToSpaceX(kGravitonOriginH, kGravitonMinDistance);
-const float kGravitonYOrigin = convertScreenVToSpaceY(kGravitonOriginV, kGravitonMinDistance);
-const float kGravitonZOrigin = kGravitonMinDistance;
+static const float kGravitonXOrigin = convertScreenHToSpaceX(kGravitonOriginH, kGravitonMinDistance);
+static const float kGravitonYOrigin = convertScreenVToSpaceY(kGravitonOriginV, kGravitonMinDistance);
+static const float kGravitonZOrigin = kGravitonMinDistance;
 
 //	Width of graviton sprite...
-const CoordType kGravitonMaxScreenWidth = 78;
-const CoordType kGravitonMaxScreenHeight = 46;
+static const CoordType kGravitonMaxScreenWidth = 78;
+static const CoordType kGravitonMaxScreenHeight = 46;
 
-const float kGravitonWidth = convertScreenHToSpaceX(kShuttleWindowMidH + kGravitonMaxScreenWidth / 2, kGravitonMinDistance)
+static const float kGravitonWidth = convertScreenHToSpaceX(kShuttleWindowMidH + kGravitonMaxScreenWidth / 2, kGravitonMinDistance)
 		- convertScreenHToSpaceX(kShuttleWindowMidH - kGravitonMaxScreenWidth / 2, kGravitonMinDistance);
-const float kGravitonHeight = convertScreenVToSpaceY(kShuttleWindowMidV - kGravitonMaxScreenHeight / 2, kGravitonMinDistance)
+static const float kGravitonHeight = convertScreenVToSpaceY(kShuttleWindowMidV - kGravitonMaxScreenHeight / 2, kGravitonMinDistance)
 		- convertScreenVToSpaceY(kShuttleWindowMidV + kGravitonMaxScreenHeight / 2, kGravitonMinDistance);
 
 GravitonCannon::GravitonCannon() {
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 93f9990..c950a85 100755
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -40,23 +40,23 @@ namespace Pegasus {
 
 // This should really be 22.5.
 // Probably no one will know the difference.
-const int16 kMarsShieldPanelOffsetAngle = 22;
+static const int16 kMarsShieldPanelOffsetAngle = 22;
 
-const CanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
+static const CanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
 
-const NotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
-const NotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
-const NotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
+static const NotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
+static const NotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
+static const NotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
 
-const NotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
+static const NotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
 													kExplosionFinishedFlag |
 													kTimeToTransportFlag;
 
-const TimeValue kLittleExplosionStart = 0 * 40;
-const TimeValue kLittleExplosionStop = 24 * 40;
+static const TimeValue kLittleExplosionStart = 0 * 40;
+static const TimeValue kLittleExplosionStop = 24 * 40;
 
-const TimeValue kBigExplosionStart = 24 * 40;
-const TimeValue kBigExplosionStop = 62 * 40;
+static const TimeValue kBigExplosionStart = 24 * 40;
+static const TimeValue kBigExplosionStop = 62 * 40;
 
 enum {
 	kMaze007RobotLoopingEvent,
diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
index 7a43c18..ef26a7b 100755
--- a/engines/pegasus/neighborhood/mars/planetmover.cpp
+++ b/engines/pegasus/neighborhood/mars/planetmover.cpp
@@ -32,11 +32,11 @@
 
 namespace Pegasus {
 
-const TimeScale kRovingScale = kTractorBeamScale;
-const TimeValue kRovingTime = kTenSeconds * kRovingScale;
-const TimeValue kRovingSlop = kTwoSeconds * kRovingScale;
+static const TimeScale kRovingScale = kTractorBeamScale;
+static const TimeValue kRovingTime = kTenSeconds * kRovingScale;
+static const TimeValue kRovingSlop = kTwoSeconds * kRovingScale;
 
-const CoordType kMaxVelocity = 20;
+static const CoordType kMaxVelocity = 20;
 
 PlanetMover::PlanetMover() {
 	setScale(kRovingScale);
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
index b1ecdde..9776027 100755
--- a/engines/pegasus/neighborhood/mars/robotship.cpp
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -33,25 +33,25 @@
 
 namespace Pegasus {
 
-const TimeScale kRovingScale = kTractorBeamScale;
-const TimeValue kRovingTime = kSixSeconds * kRovingScale;
-const TimeValue kRovingSlop = kThreeSeconds * kRovingScale;
+static const TimeScale kRovingScale = kTractorBeamScale;
+static const TimeValue kRovingTime = kSixSeconds * kRovingScale;
+static const TimeValue kRovingSlop = kThreeSeconds * kRovingScale;
 
-const int kNumSpriteColumns = 15;
-const int kNumSpriteRows = 16;
+static const int kNumSpriteColumns = 15;
+static const int kNumSpriteRows = 16;
 
-const CoordType kInitialLocationLeft = kShuttleWindowLeft - 50;
-const CoordType kInitialLocationTop = kShuttleWindowTop - 50;
-const CoordType kInitialLocationWidth = kShuttleWindowWidth + 100;
-const CoordType kInitialLocationHeight = kShuttleWindowHeight + 100;
+static const CoordType kInitialLocationLeft = kShuttleWindowLeft - 50;
+static const CoordType kInitialLocationTop = kShuttleWindowTop - 50;
+static const CoordType kInitialLocationWidth = kShuttleWindowWidth + 100;
+static const CoordType kInitialLocationHeight = kShuttleWindowHeight + 100;
 
-const CoordType kVelocityVectorLength = 100;
-const CoordType kVelocityVectorSlop = 50;
+static const CoordType kVelocityVectorLength = 100;
+static const CoordType kVelocityVectorSlop = 50;
 
-const CoordType kRovingLeft = kShuttleWindowLeft + 20;
-const CoordType kRovingTop = kShuttleWindowTop + 20;
-const CoordType kRovingWidth = kShuttleWindowMidH - kRovingLeft;
-const CoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
+static const CoordType kRovingLeft = kShuttleWindowLeft + 20;
+static const CoordType kRovingTop = kShuttleWindowTop + 20;
+static const CoordType kRovingWidth = kShuttleWindowMidH - kRovingLeft;
+static const CoordType kRovingHeight = kShuttleWindowMidV - kRovingTop;
 
 RobotShip* g_robotShip = 0;
 
diff --git a/engines/pegasus/neighborhood/mars/robotship.h b/engines/pegasus/neighborhood/mars/robotship.h
index 7921198..b668e8f 100755
--- a/engines/pegasus/neighborhood/mars/robotship.h
+++ b/engines/pegasus/neighborhood/mars/robotship.h
@@ -30,8 +30,8 @@
 
 namespace Pegasus {
 
-const CoordType kShuttleMovieWidth = 114;
-const CoordType kShuttleMovieHeight = 42;
+static const CoordType kShuttleMovieWidth = 114;
+static const CoordType kShuttleMovieHeight = 42;
 
 class RobotShip : IdlerTimeBase {
 friend void timeToDropJunkFunction(FunctionPtr *, void *);
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.h b/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
index 169a0f6..51161e0 100755
--- a/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
+++ b/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
@@ -31,16 +31,16 @@
 
 namespace Pegasus {
 
-const int32 kFullShuttleEnergy = 100;
+static const int32 kFullShuttleEnergy = 100;
 // Low is 20 percent
-const int32 kLowShuttleEnergy = kFullShuttleEnergy * 20 / 100;
+static const int32 kLowShuttleEnergy = kFullShuttleEnergy * 20 / 100;
 
-const int32 kMinDampingEnergy = 15;
-const int32 kMinGravitonEnergy = 63;
+static const int32 kMinDampingEnergy = 15;
+static const int32 kMinGravitonEnergy = 63;
 
-const TimeScale kTractorBeamScale = kFifteenTicksPerSecond;
-const TimeValue kTractorBeamTime = kFiveSeconds * kTractorBeamScale;
-const int32 kTractorBeamEnergy = kLowShuttleEnergy;
+static const TimeScale kTractorBeamScale = kFifteenTicksPerSecond;
+static const TimeValue kTractorBeamTime = kFiveSeconds * kTractorBeamScale;
+static const int32 kTractorBeamEnergy = kLowShuttleEnergy;
 
 class ShuttleEnergyMeter : public FaderAnimation {
 public:
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
index cac188e..14f5b88 100755
--- a/engines/pegasus/neighborhood/mars/shuttlehud.cpp
+++ b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
@@ -30,26 +30,26 @@
 
 namespace Pegasus {
 
-const CoordType kHUDTargetGridLeft = kShuttleWindowLeft + 16;
-const CoordType kHUDTargetGridTop = kShuttleWindowTop + 8;
-const CoordType kHUDTargetGridWidth = 328;
-const CoordType kHUDTargetGridHeight = 206;
-
-const CoordType kHUDRS232Left = kHUDTargetGridLeft + 264;
-const CoordType kHUDRS232Top = kHUDTargetGridTop + 2;
-
-const CoordType kHUDLockLeft = kShuttleWindowLeft + 101;
-const CoordType kHUDLockTop = kShuttleWindowTop + 49;
-const CoordType kHUDLockWidth = 145;
-const CoordType kHUDLockHeight = 124;
-
-const CoordType kTractorLockWidth = 50;
-const CoordType kTractorLockHeight = 30;
-
-const CoordType kTractorLockLeft = kShuttleWindowMidH - kTractorLockWidth / 2;
-const CoordType kTractorLockTop = kShuttleWindowMidV - kTractorLockHeight / 2;
-const CoordType kTractorLockRight = kTractorLockLeft + kTractorLockWidth;
-const CoordType kTractorLockBottom = kTractorLockTop + kTractorLockHeight;
+static const CoordType kHUDTargetGridLeft = kShuttleWindowLeft + 16;
+static const CoordType kHUDTargetGridTop = kShuttleWindowTop + 8;
+static const CoordType kHUDTargetGridWidth = 328;
+static const CoordType kHUDTargetGridHeight = 206;
+
+static const CoordType kHUDRS232Left = kHUDTargetGridLeft + 264;
+static const CoordType kHUDRS232Top = kHUDTargetGridTop + 2;
+
+static const CoordType kHUDLockLeft = kShuttleWindowLeft + 101;
+static const CoordType kHUDLockTop = kShuttleWindowTop + 49;
+static const CoordType kHUDLockWidth = 145;
+static const CoordType kHUDLockHeight = 124;
+
+static const CoordType kTractorLockWidth = 50;
+static const CoordType kTractorLockHeight = 30;
+
+static const CoordType kTractorLockLeft = kShuttleWindowMidH - kTractorLockWidth / 2;
+static const CoordType kTractorLockTop = kShuttleWindowMidV - kTractorLockHeight / 2;
+static const CoordType kTractorLockRight = kTractorLockLeft + kTractorLockWidth;
+static const CoordType kTractorLockBottom = kTractorLockTop + kTractorLockHeight;
 
 static const uint16 s_RS232Data[] = {
 	0xF0E1, 0xCE70,
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.h b/engines/pegasus/neighborhood/mars/shuttleweapon.h
index 30e42fa..38529c8 100755
--- a/engines/pegasus/neighborhood/mars/shuttleweapon.h
+++ b/engines/pegasus/neighborhood/mars/shuttleweapon.h
@@ -35,7 +35,7 @@ namespace Pegasus {
 // For now, no...
 // clone2727 adds: And now forever
 
-const TimeScale kShuttleWeaponScale = kFifteenTicksPerSecond;
+static const TimeScale kShuttleWeaponScale = kFifteenTicksPerSecond;
 
 class ShuttleWeapon : public IdlerAnimation {
 public:
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.h b/engines/pegasus/neighborhood/mars/spacechase3d.h
index 1e145a1..f6815e6 100755
--- a/engines/pegasus/neighborhood/mars/spacechase3d.h
+++ b/engines/pegasus/neighborhood/mars/spacechase3d.h
@@ -32,8 +32,8 @@ namespace Pegasus {
 
 // This is approximately right for a field of view of 72 degrees
 // (Should be set to the tangent of FOV).
-//const float kTangentFOV = 0.76254;
-const float kTangentFOV = 1.0;
+//static const float kTangentFOV = 0.76254;
+static const float kTangentFOV = 1.0;
 
 // Define these as macros and they can be used to define constants...
 #define convertSpaceXToScreenH(x, z) \
@@ -63,7 +63,7 @@ struct Point3D {
 	}
 };
 
-const int kScreenWidth = kShuttleWindowWidth;
+static const int kScreenWidth = kShuttleWindowWidth;
 
 bool isNegative(int a);
 bool isPositive(int a);
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index 2884713..9f34c21 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -29,15 +29,13 @@
 
 namespace Pegasus {
 
-//const TimeValue kWeaponReboundTime = kTwoSeconds * kJunkTimeScale;
-//const TimeValue kCollisionReboundTime = kOneSecond * kJunkTimeScale;
-const CoordType kMaxBounceSize = 90;
-const CoordType kBounceTargetHRange = 640 - kMaxBounceSize - 2;
-const CoordType kBounceTargetVRange = 480 - kMaxBounceSize - 2;
-
-const float kJunkXTarget = 0;
-const float kJunkYTarget = 0;
-const float kJunkZTarget = kJunkMinDistance;
+static const CoordType kMaxBounceSize = 90;
+static const CoordType kBounceTargetHRange = 640 - kMaxBounceSize - 2;
+static const CoordType kBounceTargetVRange = 480 - kMaxBounceSize - 2;
+
+static const float kJunkXTarget = 0;
+static const float kJunkYTarget = 0;
+static const float kJunkZTarget = kJunkMinDistance;
 
 SpaceJunk *g_spaceJunk = 0;
 
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.h b/engines/pegasus/neighborhood/mars/spacejunk.h
index 03943b9..f2dbf9a 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.h
+++ b/engines/pegasus/neighborhood/mars/spacejunk.h
@@ -32,9 +32,9 @@
 
 namespace Pegasus {
 
-const CoordType kJunkMaxScreenSize = 250;
+static const CoordType kJunkMaxScreenSize = 250;
 
-const float kJunkSize = convertScreenVToSpaceY(kShuttleWindowMidV - kJunkMaxScreenSize / 2, kJunkMinDistance) -
+static const float kJunkSize = convertScreenVToSpaceY(kShuttleWindowMidV - kJunkMaxScreenSize / 2, kJunkMinDistance) -
 		convertScreenVToSpaceY(kShuttleWindowMidV + kJunkMaxScreenSize / 2, kJunkMinDistance);
 
 class SpaceJunk : public ScalingMovie, public Idler {
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.cpp b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
index 5ea63a0..81c9629 100755
--- a/engines/pegasus/neighborhood/mars/tractorbeam.cpp
+++ b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
@@ -36,19 +36,19 @@ TractorBeam::TractorBeam() : DisplayElement(kNoDisplayElement) {
 
 }
 
-const int kHalfWidth = kShuttleTractorWidth >> 1;
-const int kHalfHeight = kShuttleTractorHeight >> 1;
+static const int kHalfWidth = kShuttleTractorWidth >> 1;
+static const int kHalfHeight = kShuttleTractorHeight >> 1;
 
-const int kW3Vert = kHalfHeight * kHalfHeight * kHalfHeight;
-const int kW3Div2Vert = kW3Vert >> 1;
+static const int kW3Vert = kHalfHeight * kHalfHeight * kHalfHeight;
+static const int kW3Div2Vert = kW3Vert >> 1;
 
-const int kW3Horiz = kHalfWidth * kHalfWidth * kHalfWidth;
-const int kW3Div2Horiz = kW3Horiz >> 1;
+static const int kW3Horiz = kHalfWidth * kHalfWidth * kHalfWidth;
+static const int kW3Div2Horiz = kW3Horiz >> 1;
 
-const int kMaxLevel = 50;
+static const int kMaxLevel = 50;
 
-const int kAVert = -2 * kMaxLevel;
-const int kBVert = 3 * kMaxLevel * kHalfHeight;
+static const int kAVert = -2 * kMaxLevel;
+static const int kBVert = 3 * kMaxLevel * kHalfHeight;
 
 #define READ_PIXEL(ptr) \
 	if (screen->format.bytesPerPixel == 2) \
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 7b1f867..93d29b6 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -52,22 +52,22 @@ namespace Pegasus {
 class PegasusEngine;
 
 // Pegasus Prime neighborhood id's
-const NeighborhoodID kCaldoriaID = 0;
-const NeighborhoodID kFullTSAID = 1;
-const NeighborhoodID kFinalTSAID = 2;
-const NeighborhoodID kTinyTSAID = 3;
-const NeighborhoodID kPrehistoricID = 4;
-const NeighborhoodID kMarsID = 5;
-const NeighborhoodID kWSCID = 6;
-const NeighborhoodID kNoradAlphaID = 7;
-const NeighborhoodID kNoradDeltaID = 8;
+static const NeighborhoodID kCaldoriaID = 0;
+static const NeighborhoodID kFullTSAID = 1;
+static const NeighborhoodID kFinalTSAID = 2;
+static const NeighborhoodID kTinyTSAID = 3;
+static const NeighborhoodID kPrehistoricID = 4;
+static const NeighborhoodID kMarsID = 5;
+static const NeighborhoodID kWSCID = 6;
+static const NeighborhoodID kNoradAlphaID = 7;
+static const NeighborhoodID kNoradDeltaID = 8;
 // The sub chase is not really a neighborhood, but we define a constant that is used
 // to allow an easy transition out of Norad Alpha.
-const NeighborhoodID kNoradSubChaseID = 1000;
+static const NeighborhoodID kNoradSubChaseID = 1000;
 
-const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
-const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
-const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
+static const TimeScale kDefaultLoopFadeScale = kThirtyTicksPerSecond;
+static const TimeValue kDefaultLoopFadeOut = kHalfSecondPerThirtyTicks;
+static const TimeValue kDefaultLoopFadeIn = kHalfSecondPerThirtyTicks;
 
 enum QueueRequestType {
 	kNavExtraRequest,
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
index 00cfe71..61d77bf 100755
--- a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
@@ -32,18 +32,18 @@
 
 namespace Pegasus {
 
-const NotificationFlags kFSPowerUpFinishedFlag = 1;
-const NotificationFlags kFSSplashFinishedFlag = kFSPowerUpFinishedFlag << 1;
-const NotificationFlags kFSIntakeWarningFinishedFlag = kFSSplashFinishedFlag << 1;
-const NotificationFlags kFSIntakeHiliteFinishedFlag = kFSIntakeWarningFinishedFlag << 1;
-const NotificationFlags kFSDispenseHiliteFinishedFlag = kFSIntakeHiliteFinishedFlag << 1;
-const NotificationFlags kFSArHiliteFinishedFlag = kFSDispenseHiliteFinishedFlag << 1;
-const NotificationFlags kFSCO2HiliteFinishedFlag = kFSArHiliteFinishedFlag << 1;
-const NotificationFlags kFSHeHiliteFinishedFlag = kFSCO2HiliteFinishedFlag << 1;
-const NotificationFlags kFSOHiliteFinishedFlag = kFSHeHiliteFinishedFlag << 1;
-const NotificationFlags kFSNHiliteFinishedFlag = kFSOHiliteFinishedFlag << 1;
-
-const NotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
+static const NotificationFlags kFSPowerUpFinishedFlag = 1;
+static const NotificationFlags kFSSplashFinishedFlag = kFSPowerUpFinishedFlag << 1;
+static const NotificationFlags kFSIntakeWarningFinishedFlag = kFSSplashFinishedFlag << 1;
+static const NotificationFlags kFSIntakeHiliteFinishedFlag = kFSIntakeWarningFinishedFlag << 1;
+static const NotificationFlags kFSDispenseHiliteFinishedFlag = kFSIntakeHiliteFinishedFlag << 1;
+static const NotificationFlags kFSArHiliteFinishedFlag = kFSDispenseHiliteFinishedFlag << 1;
+static const NotificationFlags kFSCO2HiliteFinishedFlag = kFSArHiliteFinishedFlag << 1;
+static const NotificationFlags kFSHeHiliteFinishedFlag = kFSCO2HiliteFinishedFlag << 1;
+static const NotificationFlags kFSOHiliteFinishedFlag = kFSHeHiliteFinishedFlag << 1;
+static const NotificationFlags kFSNHiliteFinishedFlag = kFSOHiliteFinishedFlag << 1;
+
+static const NotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
 												kFSSplashFinishedFlag |
 												kFSIntakeWarningFinishedFlag |
 												kFSIntakeHiliteFinishedFlag |
@@ -54,75 +54,75 @@ const NotificationFlags kFSNotificationFlags = kFSPowerUpFinishedFlag |
 												kFSOHiliteFinishedFlag |
 												kFSNHiliteFinishedFlag;
 
-const int16 kNoState = 0;
-const int16 kMainMenu = 1;
-const int16 kWaitingForAttach = 2;
-const int16 kDispenseMenu = 3;
-const int16 kWaitingForDispense = 4;
+static const int16 kNoState = 0;
+static const int16 kMainMenu = 1;
+static const int16 kWaitingForAttach = 2;
+static const int16 kDispenseMenu = 3;
+static const int16 kWaitingForDispense = 4;
 
 // Dummy itemIDs
-const ItemID kCO2Item = 10000;
-const ItemID kHeItem = 10001;
+static const ItemID kCO2Item = 10000;
+static const ItemID kHeItem = 10001;
 
 // Interactive points.
-const TimeValue kFSPowerUpStartStart = 0;
-const TimeValue kFSPowerUpStartStop = 600;
-const TimeValue kFSSplashStart = 600;
-const TimeValue kFSSplashStop = 7800;
-const TimeValue kFSSplashIntakeStart = 7800;
-const TimeValue kFSSplashIntakeStop = 18600;
-
-const TimeValue kFSMainMenu = 18600;
-const TimeValue kFSIntakeHiliteStart = 19200;
-const TimeValue kFSIntakeHiliteStop = 19800;
-const TimeValue kFSDispenseHiliteStart = 19800;
-const TimeValue kFSDispenseHiliteStop = 20400;
-
-const TimeValue kFSDispenseMenu = 20400;
-
-const TimeValue kFSArHiliteStart = 21000;
-const TimeValue kFSArHiliteStop = 21600;
-const TimeValue kFSArAttach = 21600;
-const TimeValue kFSArFilledStart = 22200;
-const TimeValue kFSArFilledStop = 25200;
-const TimeValue kFSArIncompatibleStart = 25200;
-const TimeValue kFSArIncompatibleStop = 30000;
-
-const TimeValue kFSCO2HiliteStart = 30000;
-const TimeValue kFSCO2HiliteStop = 30600;
-const TimeValue kFSCO2Attach = 30600;
-const TimeValue kFSCO2FilledStart = 31200;
-const TimeValue kFSCO2FilledStop = 34200;
-const TimeValue kFSCO2IncompatibleStart = 34200;
-const TimeValue kFSCO2IncompatibleStop = 39000;
-
-const TimeValue kFSHeHiliteStart = 39000;
-const TimeValue kFSHeHiliteStop = 39600;
-const TimeValue kFSHeAttach = 39600;
-const TimeValue kFSHeFilledStart = 40200;
-const TimeValue kFSHeFilledStop = 43200;
-const TimeValue kFSHeIncompatibleStart = 43200;
-const TimeValue kFSHeIncompatibleStop = 48000;
-
-const TimeValue kFSOHiliteStart = 48000;
-const TimeValue kFSOHiliteStop = 48600;
-const TimeValue kFSOAttach = 48600;
-const TimeValue kFSOFilledStart = 49200;
-const TimeValue kFSOFilledStop = 52200;
-const TimeValue kFSOIncompatibleStart = 52200;
-const TimeValue kFSOIncompatibleStop = 57000;
-
-const TimeValue kFSNHiliteStart = 57000;
-const TimeValue kFSNHiliteStop = 57600;
-const TimeValue kFSNAttach = 57600;
-const TimeValue kFSNFilledStart = 58200;
-const TimeValue kFSNFilledStop = 61200;
-const TimeValue kFSNIncompatibleStart = 61200;
-const TimeValue kFSNIncompatibleStop = 66000;
-
-const TimeValue kFSIntakeMenu = 66000;
-const TimeValue kFSIntakeInProgressStart = 66600;
-const TimeValue kFSIntakeInProgressStop = 69600;
+static const TimeValue kFSPowerUpStartStart = 0;
+static const TimeValue kFSPowerUpStartStop = 600;
+static const TimeValue kFSSplashStart = 600;
+static const TimeValue kFSSplashStop = 7800;
+static const TimeValue kFSSplashIntakeStart = 7800;
+static const TimeValue kFSSplashIntakeStop = 18600;
+
+static const TimeValue kFSMainMenu = 18600;
+static const TimeValue kFSIntakeHiliteStart = 19200;
+static const TimeValue kFSIntakeHiliteStop = 19800;
+static const TimeValue kFSDispenseHiliteStart = 19800;
+static const TimeValue kFSDispenseHiliteStop = 20400;
+
+static const TimeValue kFSDispenseMenu = 20400;
+
+static const TimeValue kFSArHiliteStart = 21000;
+static const TimeValue kFSArHiliteStop = 21600;
+static const TimeValue kFSArAttach = 21600;
+static const TimeValue kFSArFilledStart = 22200;
+static const TimeValue kFSArFilledStop = 25200;
+static const TimeValue kFSArIncompatibleStart = 25200;
+static const TimeValue kFSArIncompatibleStop = 30000;
+
+static const TimeValue kFSCO2HiliteStart = 30000;
+static const TimeValue kFSCO2HiliteStop = 30600;
+static const TimeValue kFSCO2Attach = 30600;
+static const TimeValue kFSCO2FilledStart = 31200;
+static const TimeValue kFSCO2FilledStop = 34200;
+static const TimeValue kFSCO2IncompatibleStart = 34200;
+static const TimeValue kFSCO2IncompatibleStop = 39000;
+
+static const TimeValue kFSHeHiliteStart = 39000;
+static const TimeValue kFSHeHiliteStop = 39600;
+static const TimeValue kFSHeAttach = 39600;
+static const TimeValue kFSHeFilledStart = 40200;
+static const TimeValue kFSHeFilledStop = 43200;
+static const TimeValue kFSHeIncompatibleStart = 43200;
+static const TimeValue kFSHeIncompatibleStop = 48000;
+
+static const TimeValue kFSOHiliteStart = 48000;
+static const TimeValue kFSOHiliteStop = 48600;
+static const TimeValue kFSOAttach = 48600;
+static const TimeValue kFSOFilledStart = 49200;
+static const TimeValue kFSOFilledStop = 52200;
+static const TimeValue kFSOIncompatibleStart = 52200;
+static const TimeValue kFSOIncompatibleStop = 57000;
+
+static const TimeValue kFSNHiliteStart = 57000;
+static const TimeValue kFSNHiliteStop = 57600;
+static const TimeValue kFSNAttach = 57600;
+static const TimeValue kFSNFilledStart = 58200;
+static const TimeValue kFSNFilledStop = 61200;
+static const TimeValue kFSNIncompatibleStart = 61200;
+static const TimeValue kFSNIncompatibleStop = 66000;
+
+static const TimeValue kFSIntakeMenu = 66000;
+static const TimeValue kFSIntakeInProgressStart = 66600;
+static const TimeValue kFSIntakeInProgressStop = 69600;
 
 NoradAlphaFillingStation::NoradAlphaFillingStation(Neighborhood *owner) : GameInteraction(kNoradFillingStationInteractionID, owner),
 		_rightSideMovie(kN01RightSideID), _rightSideNotification(kNoradFillingStationNotificationID, ((PegasusEngine *)g_engine)) {
diff --git a/engines/pegasus/neighborhood/norad/constants.h b/engines/pegasus/neighborhood/norad/constants.h
index 92319b8..e86422a 100755
--- a/engines/pegasus/neighborhood/norad/constants.h
+++ b/engines/pegasus/neighborhood/norad/constants.h
@@ -32,723 +32,723 @@ namespace Pegasus {
 
 // Norad Alpha spot constants
 
-const TimeValue kAlphaBumpIntoWallIn = 0;
-const TimeValue kAlphaBumpIntoWallOut = 303;
+static const TimeValue kAlphaBumpIntoWallIn = 0;
+static const TimeValue kAlphaBumpIntoWallOut = 303;
 
-const TimeValue kAlphaAccessDeniedIn = 303;
-const TimeValue kAlphaAccessDeniedOut = 3045;
+static const TimeValue kAlphaAccessDeniedIn = 303;
+static const TimeValue kAlphaAccessDeniedOut = 3045;
 
-const TimeValue kAlphaRegDoorCloseIn = 3045;
-const TimeValue kAlphaRegDoorCloseOut = 4476;
+static const TimeValue kAlphaRegDoorCloseIn = 3045;
+static const TimeValue kAlphaRegDoorCloseOut = 4476;
 
-const TimeValue kAlphaElevatorDoorCloseIn = 4476;
-const TimeValue kAlphaElevatorDoorCloseOut = 5071;
+static const TimeValue kAlphaElevatorDoorCloseIn = 4476;
+static const TimeValue kAlphaElevatorDoorCloseOut = 5071;
 
-const TimeValue kAlphaCantTransportIn = 5071;
-const TimeValue kAlphaCantTransportOut = 9348;
+static const TimeValue kAlphaCantTransportIn = 5071;
+static const TimeValue kAlphaCantTransportOut = 9348;
 
-const TimeValue kAlphaPressureDoorIntro1In = 9348;
-const TimeValue kAlphaPressureDoorIntro1Out = 11061;
+static const TimeValue kAlphaPressureDoorIntro1In = 9348;
+static const TimeValue kAlphaPressureDoorIntro1Out = 11061;
 
-const TimeValue kAlphaPressureDoorIntro2In = 11061;
-const TimeValue kAlphaPressureDoorIntro2Out = 14098;
+static const TimeValue kAlphaPressureDoorIntro2In = 11061;
+static const TimeValue kAlphaPressureDoorIntro2Out = 14098;
 
-const TimeValue kN22ReplyIn = 14098;
-const TimeValue kN22ReplyOut = 18442;
+static const TimeValue kN22ReplyIn = 14098;
+static const TimeValue kN22ReplyOut = 18442;
 
-const TimeValue kAlphaLoadClawIntroIn = 18442;
-const TimeValue kAlphaLoadClawIntroOut = 20698;
+static const TimeValue kAlphaLoadClawIntroIn = 18442;
+static const TimeValue kAlphaLoadClawIntroOut = 20698;
 
 // Norad Delta spot constants
 
-const TimeValue kDeltaBumpIntoWallIn = 0;
-const TimeValue kDeltaBumpIntoWallOut = 303;
+static const TimeValue kDeltaBumpIntoWallIn = 0;
+static const TimeValue kDeltaBumpIntoWallOut = 303;
 
-const TimeValue kDeltaAccessDeniedIn = 303;
-const TimeValue kDeltaAccessDeniedOut = 3045;
+static const TimeValue kDeltaAccessDeniedIn = 303;
+static const TimeValue kDeltaAccessDeniedOut = 3045;
 
-const TimeValue kDeltaRegDoorCloseIn = 3045;
-const TimeValue kDeltaRegDoorCloseOut = 4476;
+static const TimeValue kDeltaRegDoorCloseIn = 3045;
+static const TimeValue kDeltaRegDoorCloseOut = 4476;
 
-const TimeValue kDeltaElevatorDoorCloseIn = 4476;
-const TimeValue kDeltaElevatorDoorCloseOut = 5071;
+static const TimeValue kDeltaElevatorDoorCloseIn = 4476;
+static const TimeValue kDeltaElevatorDoorCloseOut = 5071;
 
-const TimeValue kPressureDoorIntro1In = 5071;
-const TimeValue kPressureDoorIntro1Out = 6784;
+static const TimeValue kPressureDoorIntro1In = 5071;
+static const TimeValue kPressureDoorIntro1Out = 6784;
 
-const TimeValue kPressureDoorIntro2In = 6784;
-const TimeValue kPressureDoorIntro2Out = 9821;
+static const TimeValue kPressureDoorIntro2In = 6784;
+static const TimeValue kPressureDoorIntro2Out = 9821;
 
-const TimeValue kLoadClawIntroIn = 9821;
-const TimeValue kLoadClawIntroOut = 12077;
+static const TimeValue kLoadClawIntroIn = 9821;
+static const TimeValue kLoadClawIntroOut = 12077;
 
-const TimeValue kHoldForRetinalIn = 12077;
-const TimeValue kHoldForRetinalOut = 14104;
+static const TimeValue kHoldForRetinalIn = 12077;
+static const TimeValue kHoldForRetinalOut = 14104;
 
-const TimeValue kRetinalScanFailedIn = 14104;
-const TimeValue kRetinalScanFailedOut = 17538;
+static const TimeValue kRetinalScanFailedIn = 14104;
+static const TimeValue kRetinalScanFailedOut = 17538;
 
-const TimeValue kAddisAbabaIn = 17538;
-const TimeValue kAddisAbabaOut = 19263;
+static const TimeValue kAddisAbabaIn = 17538;
+static const TimeValue kAddisAbabaOut = 19263;
 
-const TimeValue kBangkokIn = 19263;
-const TimeValue kBangkokOut = 20201;
+static const TimeValue kBangkokIn = 19263;
+static const TimeValue kBangkokOut = 20201;
 
-const TimeValue kBonnIn = 20201;
-const TimeValue kBonnOut = 20915;
+static const TimeValue kBonnIn = 20201;
+static const TimeValue kBonnOut = 20915;
 
-const TimeValue kDublinIn = 20915;
-const TimeValue kDublinOut = 21660;
+static const TimeValue kDublinIn = 20915;
+static const TimeValue kDublinOut = 21660;
 
-const TimeValue kHonoluluIn = 21660;
-const TimeValue kHonoluluOut = 22498;
+static const TimeValue kHonoluluIn = 21660;
+static const TimeValue kHonoluluOut = 22498;
 
-const TimeValue kMadridIn = 22498;
-const TimeValue kMadridOut = 23474;
+static const TimeValue kMadridIn = 22498;
+static const TimeValue kMadridOut = 23474;
 
-const TimeValue kReykjavikIn = 23474;
-const TimeValue kReykjavikOut = 24488;
+static const TimeValue kReykjavikIn = 23474;
+static const TimeValue kReykjavikOut = 24488;
 
-const TimeValue kSanAntonioIn = 24488;
-const TimeValue kSanAntonioOut = 25561;
+static const TimeValue kSanAntonioIn = 24488;
+static const TimeValue kSanAntonioOut = 25561;
 
-const TimeValue kSeoulIn = 25561;
-const TimeValue kSeoulOut = 26461;
+static const TimeValue kSeoulIn = 25561;
+static const TimeValue kSeoulOut = 26461;
 
-const TimeValue kSvortalskIn = 26461;
-const TimeValue kSvortalskOut = 27582;
+static const TimeValue kSvortalskIn = 26461;
+static const TimeValue kSvortalskOut = 27582;
 
-const TimeValue kSiloBeepIn = 27582;
-const TimeValue kSiloBeepOut = 27721;
+static const TimeValue kSiloBeepIn = 27582;
+static const TimeValue kSiloBeepOut = 27721;
 
-const TimeValue kAllSilosDeactivatedIn = 27721;
-const TimeValue kAllSilosDeactivatedOut = 28928;
+static const TimeValue kAllSilosDeactivatedIn = 27721;
+static const TimeValue kAllSilosDeactivatedOut = 28928;
 
-const TimeValue kGlobalLaunchOverrideIn = 28928;
-const TimeValue kGlobalLaunchOverrideOut = 30736;
+static const TimeValue kGlobalLaunchOverrideIn = 28928;
+static const TimeValue kGlobalLaunchOverrideOut = 30736;
 
-const TimeValue kLaunchSiloSelectedIn = 30736;
-const TimeValue kLaunchSiloSelectedOut = 31660;
+static const TimeValue kLaunchSiloSelectedIn = 30736;
+static const TimeValue kLaunchSiloSelectedOut = 31660;
 
-const TimeValue kLaunchToProceedIn = 31660;
-const TimeValue kLaunchToProceedOut = 32536;
+static const TimeValue kLaunchToProceedIn = 31660;
+static const TimeValue kLaunchToProceedOut = 32536;
 
-const TimeValue kMaximumDeactivationIn = 32536;
-const TimeValue kMaximumDeactivationOut = 34337;
+static const TimeValue kMaximumDeactivationIn = 32536;
+static const TimeValue kMaximumDeactivationOut = 34337;
 
-const TimeValue kMissileLaunchedIn = 34337;
-const TimeValue kMissileLaunchedOut = 35082;
+static const TimeValue kMissileLaunchedIn = 34337;
+static const TimeValue kMissileLaunchedOut = 35082;
 
-const TimeValue kNewLaunchSiloIn = 35082;
-const TimeValue kNewLaunchSiloOut = 36320;
+static const TimeValue kNewLaunchSiloIn = 35082;
+static const TimeValue kNewLaunchSiloOut = 36320;
 
-const TimeValue kStrikeAuthorizedIn = 36320;
-const TimeValue kStrikeAuthorizedOut = 37393;
+static const TimeValue kStrikeAuthorizedIn = 36320;
+static const TimeValue kStrikeAuthorizedOut = 37393;
 
-const TimeValue kPrimaryTargetIn = 37393;
-const TimeValue kPrimaryTargetOut = 38628;
+static const TimeValue kPrimaryTargetIn = 37393;
+static const TimeValue kPrimaryTargetOut = 38628;
 
-const TimeValue kSiloDeactivatedIn = 38628;
-const TimeValue kSiloDeactivatedOut = 39566;
+static const TimeValue kSiloDeactivatedIn = 38628;
+static const TimeValue kSiloDeactivatedOut = 39566;
 
-const TimeValue kStrikeCodeRejectedIn = 39566;
-const TimeValue kStrikeCodeRejectedOut = 41056;
+static const TimeValue kStrikeCodeRejectedIn = 39566;
+static const TimeValue kStrikeCodeRejectedOut = 41056;
 
-const TimeValue kToDeactivateIn = 41056;
-const TimeValue kToDeactivateOut = 46494;
+static const TimeValue kToDeactivateIn = 41056;
+static const TimeValue kToDeactivateOut = 46494;
 
-const TimeValue kTwoMinutesIn = 46494;
-const TimeValue kTwoMinutesOut = 47166;
+static const TimeValue kTwoMinutesIn = 46494;
+static const TimeValue kTwoMinutesOut = 47166;
 
-const TimeValue kOneMinuteIn = 47166;
-const TimeValue kOneMinuteOut = 47856;
+static const TimeValue kOneMinuteIn = 47166;
+static const TimeValue kOneMinuteOut = 47856;
 
-const TimeValue kFiftySecondsIn = 47856;
-const TimeValue kFiftySecondsOut = 48691;
+static const TimeValue kFiftySecondsIn = 47856;
+static const TimeValue kFiftySecondsOut = 48691;
 
-const TimeValue kFortySecondsIn = 48691;
-const TimeValue kFortySecondsOut = 49500;
+static const TimeValue kFortySecondsIn = 48691;
+static const TimeValue kFortySecondsOut = 49500;
 
-const TimeValue kThirtySecondsIn = 49500;
-const TimeValue kThirtySecondsOut = 50362;
+static const TimeValue kThirtySecondsIn = 49500;
+static const TimeValue kThirtySecondsOut = 50362;
 
-const TimeValue kTwentySecondsIn = 50362;
-const TimeValue kTwentySecondsOut = 51245;
+static const TimeValue kTwentySecondsIn = 50362;
+static const TimeValue kTwentySecondsOut = 51245;
 
-const TimeValue kTenSecondsIn = 51245;
-const TimeValue kTenSecondsOut = 52069;
+static const TimeValue kTenSecondsIn = 51245;
+static const TimeValue kTenSecondsOut = 52069;
 
-const TimeValue kGiveUpHumanIn = 52069;
-const TimeValue kGiveUpHumanOut = 55023;
+static const TimeValue kGiveUpHumanIn = 52069;
+static const TimeValue kGiveUpHumanOut = 55023;
 
-const TimeValue kIJustBrokeIn = 55023;
-const TimeValue kIJustBrokeOut = 59191;
+static const TimeValue kIJustBrokeIn = 55023;
+static const TimeValue kIJustBrokeOut = 59191;
 
-const TimeValue kTheOnlyGoodHumanIn = 59191;
-const TimeValue kTheOnlyGoodHumanOut = 62379;
+static const TimeValue kTheOnlyGoodHumanIn = 59191;
+static const TimeValue kTheOnlyGoodHumanOut = 62379;
 
-const TimeValue kYouAreRunningIn = 62379;
-const TimeValue kYouAreRunningOut = 64201;
+static const TimeValue kYouAreRunningIn = 62379;
+static const TimeValue kYouAreRunningOut = 64201;
 
-const TimeValue kYouCannotPossiblyIn = 64201;
-const TimeValue kYouCannotPossiblyOut = 65740;
+static const TimeValue kYouCannotPossiblyIn = 64201;
+static const TimeValue kYouCannotPossiblyOut = 65740;
 
-const TimeValue kYouWillFailIn = 65740;
-const TimeValue kYouWillFailOut = 67217;
+static const TimeValue kYouWillFailIn = 65740;
+static const TimeValue kYouWillFailOut = 67217;
 
-const CanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
+static const CanOpenDoorReason kCantOpenBadPressure = kCantOpenLastReason + 1;
 
-const NotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
+static const NotificationFlags kAirTimerExpiredFlag = kLastNeighborhoodNotificationFlag << 1;
 
-const uint16 kNoradWarningVolume = 0x100 / 3;
-const uint16 kNoradSuckWindVolume = 0x100 / 2;
+static const uint16 kNoradWarningVolume = 0x100 / 3;
+static const uint16 kNoradSuckWindVolume = 0x100 / 2;
 
-const int16 kElevatorCompassAngle = -40;
-const int16 kSubPlatformCompassAngle = 45;
-const int16 kSubControlCompassAngle = -10;
+static const int16 kElevatorCompassAngle = -40;
+static const int16 kSubPlatformCompassAngle = 45;
+static const int16 kSubControlCompassAngle = -10;
 
 //	Norad interactions.
 
-const InteractionID kNoradGlobeGameInteractionID = 0;
-const InteractionID kNoradECRMonitorInteractionID = 1;
-const InteractionID kNoradFillingStationInteractionID = 2;
-const InteractionID kNoradElevatorInteractionID = 3;
-const InteractionID kNoradPressureDoorInteractionID = 4;
-const InteractionID kNoradSubControlRoomInteractionID = 5;
-const InteractionID kNoradSubPlatformInteractionID = 6;
+static const InteractionID kNoradGlobeGameInteractionID = 0;
+static const InteractionID kNoradECRMonitorInteractionID = 1;
+static const InteractionID kNoradFillingStationInteractionID = 2;
+static const InteractionID kNoradElevatorInteractionID = 3;
+static const InteractionID kNoradPressureDoorInteractionID = 4;
+static const InteractionID kNoradSubControlRoomInteractionID = 5;
+static const InteractionID kNoradSubPlatformInteractionID = 6;
 
 /////////////////////////////////////////////
 //
 //	Norad Alpha
 
-const CoordType kECRSlideShowLeft = kNavAreaLeft + 78;
-const CoordType kECRSlideShowTop = kNavAreaTop + 1;
+static const CoordType kECRSlideShowLeft = kNavAreaLeft + 78;
+static const CoordType kECRSlideShowTop = kNavAreaTop + 1;
 
-const CoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
-const CoordType kECRPanTop = kNavAreaTop + 1 + 4;
-const CoordType kECRPanRight = kECRPanLeft + 213;
-const CoordType kECRPanBottom = kECRPanTop + 241;
+static const CoordType kECRPanLeft = kNavAreaLeft + 78 + 5;
+static const CoordType kECRPanTop = kNavAreaTop + 1 + 4;
+static const CoordType kECRPanRight = kECRPanLeft + 213;
+static const CoordType kECRPanBottom = kECRPanTop + 241;
 
-const CoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
-const CoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
+static const CoordType kNoradAlphaElevatorControlsLeft = kNavAreaLeft + 332;
+static const CoordType kNoradAlphaElevatorControlsTop = kNavAreaTop + 127;
 
-const CoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
-const CoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
+static const CoordType kNoradAlpha01LeftSideLeft = kNavAreaLeft + 0;
+static const CoordType kNoradAlpha01LeftSideTop = kNavAreaTop + 0;
 
-const CoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
-const CoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
+static const CoordType kNoradAlpha01RightSideLeft = kNavAreaLeft + 240;
+static const CoordType kNoradAlpha01RightSideTop = kNavAreaTop + 12;
 
-const CoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
-const CoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
+static const CoordType kNoradUpperLevelsLeft = kNavAreaLeft + 98;
+static const CoordType kNoradUpperLevelsTop = kNavAreaTop + 31;
 
-const CoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
-const CoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
+static const CoordType kNoradUpperTypeLeft = kNoradUpperLevelsLeft + 114;
+static const CoordType kNoradUpperTypeTop = kNoradUpperLevelsTop + 8;
 
-const CoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
-const CoordType kNoradUpperUpTop = kNavAreaTop + 32;
+static const CoordType kNoradUpperUpLeft = kNavAreaLeft + 361;
+static const CoordType kNoradUpperUpTop = kNavAreaTop + 32;
 
-const CoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
-const CoordType kNoradUpperDownTop = kNavAreaTop + 66;
+static const CoordType kNoradUpperDownLeft = kNavAreaLeft + 367;
+static const CoordType kNoradUpperDownTop = kNavAreaTop + 66;
 
-const CoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
-const CoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
+static const CoordType kNoradLowerLevelsLeft = kNavAreaLeft + 74;
+static const CoordType kNoradLowerLevelsTop = kNavAreaTop + 157;
 
-const CoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
-const CoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
+static const CoordType kNoradLowerTypeLeft = kNoradLowerLevelsLeft + 144;
+static const CoordType kNoradLowerTypeTop = kNoradLowerLevelsTop + 9;
 
-const CoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
-const CoordType kNoradLowerUpTop = kNavAreaTop + 164;
+static const CoordType kNoradLowerUpLeft = kNavAreaLeft + 380;
+static const CoordType kNoradLowerUpTop = kNavAreaTop + 164;
 
-const CoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
-const CoordType kNoradLowerDownTop = kNavAreaTop + 212;
+static const CoordType kNoradLowerDownLeft = kNavAreaLeft + 388;
+static const CoordType kNoradLowerDownTop = kNavAreaTop + 212;
 
-const CoordType kNoradPlatformLeft = kNavAreaLeft + 36;
-const CoordType kNoradPlatformTop = kNavAreaTop + 87;
+static const CoordType kNoradPlatformLeft = kNavAreaLeft + 36;
+static const CoordType kNoradPlatformTop = kNavAreaTop + 87;
 
-const CoordType kNoradSubControlLeft = kNavAreaLeft + 0;
-const CoordType kNoradSubControlTop = kNavAreaTop + 84;
+static const CoordType kNoradSubControlLeft = kNavAreaLeft + 0;
+static const CoordType kNoradSubControlTop = kNavAreaTop + 84;
 
-const CoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
-const CoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
+static const CoordType kNoradSubControlPinchLeft = kNoradSubControlLeft + 106;
+static const CoordType kNoradSubControlPinchTop = kNoradSubControlTop + 86;
 
-const CoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
-const CoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
+static const CoordType kNoradSubControlDownLeft = kNoradSubControlLeft + 66;
+static const CoordType kNoradSubControlDownTop = kNoradSubControlTop + 106;
 
-const CoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
-const CoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
+static const CoordType kNoradSubControlRightLeft = kNoradSubControlLeft + 83;
+static const CoordType kNoradSubControlRightTop = kNoradSubControlTop + 90;
 
-const CoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
-const CoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
+static const CoordType kNoradSubControlLeftLeft = kNoradSubControlLeft + 56;
+static const CoordType kNoradSubControlLeftTop = kNoradSubControlTop + 91;
 
-const CoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
-const CoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
+static const CoordType kNoradSubControlUpLeft = kNoradSubControlLeft + 66;
+static const CoordType kNoradSubControlUpTop = kNoradSubControlTop + 81;
 
-const CoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
-const CoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
+static const CoordType kNoradSubControlCCWLeft = kNoradSubControlLeft + 29;
+static const CoordType kNoradSubControlCCWTop = kNoradSubControlTop + 88;
 
-const CoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
-const CoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
+static const CoordType kNoradSubControlCWLeft = kNoradSubControlLeft + 0;
+static const CoordType kNoradSubControlCWTop = kNoradSubControlTop + 89;
 
-const CoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
-const CoordType kNoradClawMonitorTop = kNavAreaTop + 97;
+static const CoordType kNoradClawMonitorLeft = kNavAreaLeft + 288;
+static const CoordType kNoradClawMonitorTop = kNavAreaTop + 97;
 
-const CoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
-const CoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
+static const CoordType kNoradGreenBallAtALeft = kNoradClawMonitorLeft + 179;
+static const CoordType kNoradGreenBallAtATop = kNoradClawMonitorTop + 82;
 
-const CoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
-const CoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
+static const CoordType kNoradGreenBallAtBLeft = kNoradClawMonitorLeft + 130;
+static const CoordType kNoradGreenBallAtBTop = kNoradClawMonitorTop + 73;
 
-const CoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
-const CoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
+static const CoordType kNoradGreenBallAtCLeft = kNoradClawMonitorLeft + 110;
+static const CoordType kNoradGreenBallAtCTop = kNoradClawMonitorTop + 26;
 
-const CoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
-const CoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
+static const CoordType kNoradGreenBallAtDLeft = kNoradClawMonitorLeft + 21;
+static const CoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
 
 /////////////////////////////////////////////
 //
 //	Norad Delta
 
-const CoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
-const CoordType kGlobeMonitorTop = kNavAreaTop + 144;
+static const CoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
+static const CoordType kGlobeMonitorTop = kNavAreaTop + 144;
 
-const CoordType kGlobeLeft = kNavAreaLeft + 172;
-const CoordType kGlobeTop = kNavAreaTop;
+static const CoordType kGlobeLeft = kNavAreaLeft + 172;
+static const CoordType kGlobeTop = kNavAreaTop;
 
-const CoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
-const CoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
+static const CoordType kGlobeCircleLeftLeft = kNavAreaLeft + 186;
+static const CoordType kGlobeCircleLeftTop = kNavAreaTop + 41;
 
-const CoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
-const CoordType kGlobeCircleRightTop = kNavAreaTop + 41;
+static const CoordType kGlobeCircleRightLeft = kNavAreaLeft + 321;
+static const CoordType kGlobeCircleRightTop = kNavAreaTop + 41;
 
-const CoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
-const CoordType kGlobeCircleUpTop = kNavAreaTop + 7;
+static const CoordType kGlobeCircleUpLeft = kNavAreaLeft + 220;
+static const CoordType kGlobeCircleUpTop = kNavAreaTop + 7;
 
-const CoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
-const CoordType kGlobeCircleDownTop = kNavAreaTop + 142;
+static const CoordType kGlobeCircleDownLeft = kNavAreaLeft + 220;
+static const CoordType kGlobeCircleDownTop = kNavAreaTop + 142;
 
-const CoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
-const CoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
+static const CoordType kGlobeUpperLeftHiliteLeft = kNavAreaLeft + 207;
+static const CoordType kGlobeUpperLeftHiliteTop = kNavAreaTop + 28;
 
-const CoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
-const CoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
+static const CoordType kGlobeUpperRightHiliteLeft = kNavAreaLeft + 307;
+static const CoordType kGlobeUpperRightHiliteTop = kNavAreaTop + 28;
 
-const CoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
-const CoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
+static const CoordType kGlobeLowerLeftHiliteLeft = kNavAreaLeft + 207;
+static const CoordType kGlobeLowerLeftHiliteTop = kNavAreaTop + 128;
 
-const CoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
-const CoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
+static const CoordType kGlobeLowerRightHiliteLeft = kNavAreaLeft + 307;
+static const CoordType kGlobeLowerRightHiliteTop = kNavAreaTop + 128;
 
-const CoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
-const CoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
+static const CoordType kGlobeLeftMotionHiliteLeft = kNavAreaLeft + 182;
+static const CoordType kGlobeLeftMotionHiliteTop = kNavAreaTop + 60;
 
-const CoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
-const CoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
+static const CoordType kGlobeRightMotionHiliteLeft = kNavAreaLeft + 331;
+static const CoordType kGlobeRightMotionHiliteTop = kNavAreaTop + 60;
 
-const CoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
-const CoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
+static const CoordType kGlobeUpMotionHiliteLeft = kNavAreaLeft + 239;
+static const CoordType kGlobeUpMotionHiliteTop = kNavAreaTop + 3;
 
-const CoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
-const CoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
+static const CoordType kGlobeDownMotionHiliteLeft = kNavAreaLeft + 239;
+static const CoordType kGlobeDownMotionHiliteTop = kNavAreaTop + 152;
 
-const CoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
-const CoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
+static const CoordType kGlobeUpperNamesLeft = kNavAreaLeft + 368;
+static const CoordType kGlobeUpperNamesTop = kNavAreaTop + 188;
 
-const CoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
-const CoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
+static const CoordType kGlobeLowerNamesLeft = kNavAreaLeft + 368;
+static const CoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
 
-const CoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
-const CoordType kGlobeCountdownTop = kNavAreaTop + 164;
+static const CoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
+static const CoordType kGlobeCountdownTop = kNavAreaTop + 164;
 
 //	Norad Alpha display IDs.
 
-const DisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
-const DisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
-const DisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
-const DisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
-const DisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
-const DisplayElementID kN01RightSideID = kN01LeftSideID + 1;
-const DisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
-const DisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
-const DisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
-const DisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
-const DisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
-const DisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
-const DisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
-const DisplayElementID kSubControlPinchID = kClawMonitorID + 1;
-const DisplayElementID kSubControlDownID = kSubControlPinchID + 1;
-const DisplayElementID kSubControlRightID = kSubControlDownID + 1;
-const DisplayElementID kSubControlLeftID = kSubControlRightID + 1;
-const DisplayElementID kSubControlUpID = kSubControlLeftID + 1;
-const DisplayElementID kSubControlCCWID = kSubControlUpID + 1;
-const DisplayElementID kSubControlCWID = kSubControlCCWID + 1;
-const DisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
+static const DisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
+static const DisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
+static const DisplayElementID kNoradAlphaDeathMovieID = kECRPanID + 1;
+static const DisplayElementID kNoradElevatorControlsID = kNoradAlphaDeathMovieID + 1;
+static const DisplayElementID kN01LeftSideID = kNoradElevatorControlsID + 1;
+static const DisplayElementID kN01RightSideID = kN01LeftSideID + 1;
+static const DisplayElementID kPressureDoorLevelsID = kN01RightSideID + 1;
+static const DisplayElementID kPressureDoorTypeID = kPressureDoorLevelsID + 1;
+static const DisplayElementID kPressureDoorUpButtonID = kPressureDoorTypeID + 1;
+static const DisplayElementID kPressureDoorDownButtonID = kPressureDoorUpButtonID + 1;
+static const DisplayElementID kPlatformMonitorID = kPressureDoorDownButtonID + 1;
+static const DisplayElementID kSubControlMonitorID = kPlatformMonitorID + 1;
+static const DisplayElementID kClawMonitorID = kSubControlMonitorID + 1;
+static const DisplayElementID kSubControlPinchID = kClawMonitorID + 1;
+static const DisplayElementID kSubControlDownID = kSubControlPinchID + 1;
+static const DisplayElementID kSubControlRightID = kSubControlDownID + 1;
+static const DisplayElementID kSubControlLeftID = kSubControlRightID + 1;
+static const DisplayElementID kSubControlUpID = kSubControlLeftID + 1;
+static const DisplayElementID kSubControlCCWID = kSubControlUpID + 1;
+static const DisplayElementID kSubControlCWID = kSubControlCCWID + 1;
+static const DisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
 
 //	Norad Delta display IDs.
 
-const DisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
-const DisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
-const DisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
-const DisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
-const DisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
-const DisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
-const DisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
-const DisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
-const DisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
-const DisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
-const DisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
-const DisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
-const DisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
-const DisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
-const DisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
-const DisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
-const DisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
+static const DisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
+static const DisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
+static const DisplayElementID kGlobeCircleLeftID = kGlobeMovieID + 1;
+static const DisplayElementID kGlobeCircleRightID = kGlobeCircleLeftID + 1;
+static const DisplayElementID kGlobeCircleUpID = kGlobeCircleRightID + 1;
+static const DisplayElementID kGlobeCircleDownID = kGlobeCircleUpID + 1;
+static const DisplayElementID kMotionHiliteLeftID = kGlobeCircleDownID + 1;
+static const DisplayElementID kMotionHiliteRightID = kMotionHiliteLeftID + 1;
+static const DisplayElementID kMotionHiliteUpID = kMotionHiliteRightID + 1;
+static const DisplayElementID kMotionHiliteDownID = kMotionHiliteUpID + 1;
+static const DisplayElementID kTargetHiliteUpperLeftID = kMotionHiliteDownID + 1;
+static const DisplayElementID kTargetHiliteUpperRightID = kTargetHiliteUpperLeftID + 1;
+static const DisplayElementID kTargetHiliteLowerLeftID = kTargetHiliteUpperRightID + 1;
+static const DisplayElementID kTargetHiliteLowerRightID = kTargetHiliteLowerLeftID + 1;
+static const DisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1;
+static const DisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
+static const DisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
 
 //	Norad Alpha:
 
-const DisplayOrder kECRMonitorOrder = kMonitorLayer;
-const DisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
+static const DisplayOrder kECRMonitorOrder = kMonitorLayer;
+static const DisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
 
-const DisplayOrder kN01LeftSideOrder = kMonitorLayer;
-const DisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
+static const DisplayOrder kN01LeftSideOrder = kMonitorLayer;
+static const DisplayOrder kN01RightSideOrder = kN01LeftSideOrder + 1;
 
-const DisplayOrder kElevatorControlsOrder = kMonitorLayer;
+static const DisplayOrder kElevatorControlsOrder = kMonitorLayer;
 
-const DisplayOrder kPressureLevelsOrder = kMonitorLayer;
-const DisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
-const DisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
-const DisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
+static const DisplayOrder kPressureLevelsOrder = kMonitorLayer;
+static const DisplayOrder kPressureTypeOrder = kPressureLevelsOrder + 1;
+static const DisplayOrder kPressureUpOrder = kPressureTypeOrder + 1;
+static const DisplayOrder kPressureDownOrder = kPressureUpOrder + 1;
 
-const DisplayOrder kPlatformOrder = kMonitorLayer;
+static const DisplayOrder kPlatformOrder = kMonitorLayer;
 
-const DisplayOrder kSubControlOrder = kMonitorLayer;
-const DisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
-const DisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
-const DisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
-const DisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
-const DisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
-const DisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
-const DisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
-const DisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
-const DisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
+static const DisplayOrder kSubControlOrder = kMonitorLayer;
+static const DisplayOrder kClawMonitorOrder = kSubControlOrder + 1;
+static const DisplayOrder kSubControlPinchOrder = kClawMonitorOrder + 1;
+static const DisplayOrder kSubControlDownOrder = kSubControlPinchOrder + 1;
+static const DisplayOrder kSubControlRightOrder = kSubControlDownOrder + 1;
+static const DisplayOrder kSubControlLeftOrder = kSubControlRightOrder + 1;
+static const DisplayOrder kSubControlUpOrder = kSubControlLeftOrder + 1;
+static const DisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
+static const DisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
+static const DisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
 
 //	Norad Delta:
 
-const DisplayOrder kGlobeMonitorLayer = kMonitorLayer;
-const DisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
-const DisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
-const DisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
-const DisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
-const DisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
-const DisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
+static const DisplayOrder kGlobeMonitorLayer = kMonitorLayer;
+static const DisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
+static const DisplayOrder kGlobeCircleLayer = kGlobeMovieLayer + 1;
+static const DisplayOrder kGlobeHilitesLayer = kGlobeCircleLayer + 1;
+static const DisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
+static const DisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
+static const DisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
 
 //	Norad Alpha Tables
 
-const TimeScale kNoradAlphaMovieScale = 600;
-const TimeScale kNoradAlphaFramesPerSecond = 15;
-const TimeScale kNoradAlphaFrameDuration = 40;
+static const TimeScale kNoradAlphaMovieScale = 600;
+static const TimeScale kNoradAlphaFramesPerSecond = 15;
+static const TimeScale kNoradAlphaFrameDuration = 40;
 
 //	Alternate IDs.
 
-const AlternateID kAltNoradAlphaNormal = 0;
+static const AlternateID kAltNoradAlphaNormal = 0;
 
 //	Room IDs.
 
-const RoomID kNorad01 = 0;
-const RoomID kNorad01East = 1;
-const RoomID kNorad01West = 2;
-const RoomID kNorad02 = 3;
-const RoomID kNorad03 = 4;
-const RoomID kNorad04 = 5;
-const RoomID kNorad05 = 6;
-const RoomID kNorad06 = 7;
-const RoomID kNorad07 = 8;
-const RoomID kNorad07North = 9;
-const RoomID kNorad08 = 10;
-const RoomID kNorad09 = 11;
-const RoomID kNorad10 = 12;
-const RoomID kNorad10East = 13;
-const RoomID kNorad11 = 14;
-const RoomID kNorad11South = 15;
-const RoomID kNorad12 = 16;
-const RoomID kNorad12South = 17;
-const RoomID kNorad13 = 18;
-const RoomID kNorad14 = 19;
-const RoomID kNorad15 = 20;
-const RoomID kNorad16 = 21;
-const RoomID kNorad17 = 22;
-const RoomID kNorad18 = 23;
-const RoomID kNorad19 = 24;
-const RoomID kNorad19West = 25;
-const RoomID kNorad21 = 26;
-const RoomID kNorad21West = 27;
-const RoomID kNorad22 = 28;
-const RoomID kNorad22West = 29;
+static const RoomID kNorad01 = 0;
+static const RoomID kNorad01East = 1;
+static const RoomID kNorad01West = 2;
+static const RoomID kNorad02 = 3;
+static const RoomID kNorad03 = 4;
+static const RoomID kNorad04 = 5;
+static const RoomID kNorad05 = 6;
+static const RoomID kNorad06 = 7;
+static const RoomID kNorad07 = 8;
+static const RoomID kNorad07North = 9;
+static const RoomID kNorad08 = 10;
+static const RoomID kNorad09 = 11;
+static const RoomID kNorad10 = 12;
+static const RoomID kNorad10East = 13;
+static const RoomID kNorad11 = 14;
+static const RoomID kNorad11South = 15;
+static const RoomID kNorad12 = 16;
+static const RoomID kNorad12South = 17;
+static const RoomID kNorad13 = 18;
+static const RoomID kNorad14 = 19;
+static const RoomID kNorad15 = 20;
+static const RoomID kNorad16 = 21;
+static const RoomID kNorad17 = 22;
+static const RoomID kNorad18 = 23;
+static const RoomID kNorad19 = 24;
+static const RoomID kNorad19West = 25;
+static const RoomID kNorad21 = 26;
+static const RoomID kNorad21West = 27;
+static const RoomID kNorad22 = 28;
+static const RoomID kNorad22West = 29;
 
 //	Hot Spot Activation IDs.
 
 
 //	Hot Spot IDs.
 
-const HotSpotID kNorad01ECRSpotID = 5000;
-const HotSpotID kNorad01GasSpotID = 5001;
-const HotSpotID kNorad01ECROutSpotID = 5002;
-const HotSpotID kNorad01GasOutSpotID = 5003;
-const HotSpotID kNorad01MonitorSpotID = 5004;
-const HotSpotID kNorad01IntakeSpotID = 5005;
-const HotSpotID kNorad01DispenseSpotID = 5006;
-const HotSpotID kNorad01ArSpotID = 5007;
-const HotSpotID kNorad01CO2SpotID = 5008;
-const HotSpotID kNorad01HeSpotID = 5009;
-const HotSpotID kNorad01OSpotID = 5010;
-const HotSpotID kNorad01NSpotID = 5011;
-const HotSpotID kN01GasCanisterSpotID = 5012;
-const HotSpotID kN01ArgonCanisterSpotID = 5013;
-const HotSpotID kN01AirMaskSpotID = 5014;
-const HotSpotID kN01NitrogenCanisterSpotID = 5015;
-const HotSpotID kN01GasOutletSpotID = 5016;
-const HotSpotID kNorad07DoorSpotID = 5017;
-const HotSpotID kNorad07DoorOutSpotID = 5018;
-const HotSpotID kNorad10DoorSpotID = 5019;
-const HotSpotID kNorad10EastOutSpotID = 5020;
-const HotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
-const HotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
-const HotSpotID kNorad11ElevatorSpotID = 5023;
-const HotSpotID kNorad11ElevatorOutSpotID = 5024;
-const HotSpotID kNorad11ElevatorDownSpotID = 5025;
-const HotSpotID kNorad12ElevatorSpotID = 5026;
-const HotSpotID kNorad12ElevatorOutSpotID = 5027;
-const HotSpotID kNorad12ElevatorUpSpotID = 5028;
-const HotSpotID kNorad19MonitorSpotID = 5029;
-const HotSpotID kNorad19MonitorOutSpotID = 5030;
-const HotSpotID kNorad19ActivateMonitorSpotID = 5031;
-const HotSpotID kNorad21WestSpotID = 5032;
-const HotSpotID kNorad21WestOutSpotID = 5033;
-const HotSpotID kAlphaLowerPressureDoorUpSpotID = 5034;
-const HotSpotID kAlphaLowerPressureDoorDownSpotID = 5035;
-const HotSpotID kNorad22MonitorSpotID = 5036;
-const HotSpotID kNorad22MonitorOutSpotID = 5037;
-const HotSpotID kNorad22LaunchPrepSpotID = 5038;
-const HotSpotID kNorad22ClawControlSpotID = 5039;
-const HotSpotID kNorad22ClawPinchSpotID = 5040;
-const HotSpotID kNorad22ClawDownSpotID = 5041;
-const HotSpotID kNorad22ClawRightSpotID = 5042;
-const HotSpotID kNorad22ClawLeftSpotID = 5043;
-const HotSpotID kNorad22ClawUpSpotID = 5044;
-const HotSpotID kNorad22ClawCCWSpotID = 5045;
-const HotSpotID kNorad22ClawCWSpotID = 5046;
+static const HotSpotID kNorad01ECRSpotID = 5000;
+static const HotSpotID kNorad01GasSpotID = 5001;
+static const HotSpotID kNorad01ECROutSpotID = 5002;
+static const HotSpotID kNorad01GasOutSpotID = 5003;
+static const HotSpotID kNorad01MonitorSpotID = 5004;
+static const HotSpotID kNorad01IntakeSpotID = 5005;
+static const HotSpotID kNorad01DispenseSpotID = 5006;
+static const HotSpotID kNorad01ArSpotID = 5007;
+static const HotSpotID kNorad01CO2SpotID = 5008;
+static const HotSpotID kNorad01HeSpotID = 5009;
+static const HotSpotID kNorad01OSpotID = 5010;
+static const HotSpotID kNorad01NSpotID = 5011;
+static const HotSpotID kN01GasCanisterSpotID = 5012;
+static const HotSpotID kN01ArgonCanisterSpotID = 5013;
+static const HotSpotID kN01AirMaskSpotID = 5014;
+static const HotSpotID kN01NitrogenCanisterSpotID = 5015;
+static const HotSpotID kN01GasOutletSpotID = 5016;
+static const HotSpotID kNorad07DoorSpotID = 5017;
+static const HotSpotID kNorad07DoorOutSpotID = 5018;
+static const HotSpotID kNorad10DoorSpotID = 5019;
+static const HotSpotID kNorad10EastOutSpotID = 5020;
+static const HotSpotID kAlphaUpperPressureDoorUpSpotID = 5021;
+static const HotSpotID kAlphaUpperPressureDoorDownSpotID = 5022;
+static const HotSpotID kNorad11ElevatorSpotID = 5023;
+static const HotSpotID kNorad11ElevatorOutSpotID = 5024;
+static const HotSpotID kNorad11ElevatorDownSpotID = 5025;
+static const HotSpotID kNorad12ElevatorSpotID = 5026;
+static const HotSpotID kNorad12ElevatorOutSpotID = 5027;
+static const HotSpotID kNorad12ElevatorUpSpotID = 5028;
+static const HotSpotID kNorad19MonitorSpotID = 5029;
+static const HotSpotID kNorad19MonitorOutSpotID = 5030;
+static const HotSpotID kNorad19ActivateMonitorSpotID = 5031;
+static const HotSpotID kNorad21WestSpotID = 5032;
+static const HotSpotID kNorad21WestOutSpotID = 5033;
+static const HotSpotID kAlphaLowerPressureDoorUpSpotID = 5034;
+static const HotSpotID kAlphaLowerPressureDoorDownSpotID = 5035;
+static const HotSpotID kNorad22MonitorSpotID = 5036;
+static const HotSpotID kNorad22MonitorOutSpotID = 5037;
+static const HotSpotID kNorad22LaunchPrepSpotID = 5038;
+static const HotSpotID kNorad22ClawControlSpotID = 5039;
+static const HotSpotID kNorad22ClawPinchSpotID = 5040;
+static const HotSpotID kNorad22ClawDownSpotID = 5041;
+static const HotSpotID kNorad22ClawRightSpotID = 5042;
+static const HotSpotID kNorad22ClawLeftSpotID = 5043;
+static const HotSpotID kNorad22ClawUpSpotID = 5044;
+static const HotSpotID kNorad22ClawCCWSpotID = 5045;
+static const HotSpotID kNorad22ClawCWSpotID = 5046;
 
 //	Extra sequence IDs.
 
-const ExtraID kNoradArriveFromTSA = 0;
-const ExtraID kNorad01RobotTaunt = 1;
-const ExtraID kNorad01ZoomInWithGasCanister = 2;
-const ExtraID kN01WGasCanister = 3;
-const ExtraID kNorad01ZoomOutWithGasCanister = 4;
-const ExtraID kN01WZEmptyLit = 5;
-const ExtraID kN01WZGasCanisterDim = 6;
-const ExtraID kN01WZGasCanisterLit = 7;
-const ExtraID kN01WZArgonCanisterDim = 8;
-const ExtraID kN01WZArgonCanisterLit = 9;
-const ExtraID kN01WZAirMaskDim = 10;
-const ExtraID kN01WZAirMaskLit = 11;
-const ExtraID kN01WZNitrogenCanisterDim = 12;
-const ExtraID kN01WZNitrogenCanisterLit = 13;
-const ExtraID kNorad04EastDeath = 14;
-const ExtraID kNorad19PrepSub = 15;
-const ExtraID kNorad19ExitToSub = 16;
-const ExtraID kNorad22SouthIntro = 17;
-const ExtraID kNorad22SouthReply = 18;
-const ExtraID kNorad22SouthFinish = 19;
-const ExtraID kN22ClawFromAToB = 20;
-const ExtraID kN22ClawALoop = 21;
-const ExtraID kN22ClawAPinch = 22;
-const ExtraID kN22ClawACounterclockwise = 23;
-const ExtraID kN22ClawAClockwise = 24;
-const ExtraID kN22ClawFromBToA = 25;
-const ExtraID kN22ClawFromBToC = 26;
-const ExtraID kN22ClawFromBToD = 27;
-const ExtraID kN22ClawBLoop = 28;
-const ExtraID kN22ClawBPinch = 29;
-const ExtraID kN22ClawBCounterclockwise = 30;
-const ExtraID kN22ClawBClockwise = 31;
-const ExtraID kN22ClawFromCToB = 32;
-const ExtraID kN22ClawCLoop = 33;
-const ExtraID kN22ClawCPinch = 34;
-const ExtraID kN22ClawCCounterclockwise = 35;
-const ExtraID kN22ClawCClockwise = 36;
-const ExtraID kN22ClawFromDToB = 37;
-const ExtraID kN22ClawDLoop = 38;
-const ExtraID kN22ClawDPinch = 39;
-const ExtraID kN22ClawDCounterclockwise = 40;
-const ExtraID kN22ClawDClockwise = 41;
+static const ExtraID kNoradArriveFromTSA = 0;
+static const ExtraID kNorad01RobotTaunt = 1;
+static const ExtraID kNorad01ZoomInWithGasCanister = 2;
+static const ExtraID kN01WGasCanister = 3;
+static const ExtraID kNorad01ZoomOutWithGasCanister = 4;
+static const ExtraID kN01WZEmptyLit = 5;
+static const ExtraID kN01WZGasCanisterDim = 6;
+static const ExtraID kN01WZGasCanisterLit = 7;
+static const ExtraID kN01WZArgonCanisterDim = 8;
+static const ExtraID kN01WZArgonCanisterLit = 9;
+static const ExtraID kN01WZAirMaskDim = 10;
+static const ExtraID kN01WZAirMaskLit = 11;
+static const ExtraID kN01WZNitrogenCanisterDim = 12;
+static const ExtraID kN01WZNitrogenCanisterLit = 13;
+static const ExtraID kNorad04EastDeath = 14;
+static const ExtraID kNorad19PrepSub = 15;
+static const ExtraID kNorad19ExitToSub = 16;
+static const ExtraID kNorad22SouthIntro = 17;
+static const ExtraID kNorad22SouthReply = 18;
+static const ExtraID kNorad22SouthFinish = 19;
+static const ExtraID kN22ClawFromAToB = 20;
+static const ExtraID kN22ClawALoop = 21;
+static const ExtraID kN22ClawAPinch = 22;
+static const ExtraID kN22ClawACounterclockwise = 23;
+static const ExtraID kN22ClawAClockwise = 24;
+static const ExtraID kN22ClawFromBToA = 25;
+static const ExtraID kN22ClawFromBToC = 26;
+static const ExtraID kN22ClawFromBToD = 27;
+static const ExtraID kN22ClawBLoop = 28;
+static const ExtraID kN22ClawBPinch = 29;
+static const ExtraID kN22ClawBCounterclockwise = 30;
+static const ExtraID kN22ClawBClockwise = 31;
+static const ExtraID kN22ClawFromCToB = 32;
+static const ExtraID kN22ClawCLoop = 33;
+static const ExtraID kN22ClawCPinch = 34;
+static const ExtraID kN22ClawCCounterclockwise = 35;
+static const ExtraID kN22ClawCClockwise = 36;
+static const ExtraID kN22ClawFromDToB = 37;
+static const ExtraID kN22ClawDLoop = 38;
+static const ExtraID kN22ClawDPinch = 39;
+static const ExtraID kN22ClawDCounterclockwise = 40;
+static const ExtraID kN22ClawDClockwise = 41;
 
 
 //	Norad Delta Extra sequence IDs.
 
-const ExtraID kArriveFromSubChase = 0;
-const ExtraID kN59ZoomWithRobot = 1;
-const ExtraID kN59RobotApproaches = 2;
-const ExtraID kN59RobotPunchLoop = 3;
-const ExtraID kN59PlayerWins1 = 4;
-const ExtraID kN59PlayerWins2 = 5;
-const ExtraID kN59RobotWins = 6;
-const ExtraID kN59RobotHeadOpens = 7;
-const ExtraID kN59Biochips111 = 8;
-const ExtraID kN59Biochips011 = 9;
-const ExtraID kN59Biochips101 = 10;
-const ExtraID kN59Biochips001 = 11;
-const ExtraID kN59Biochips110 = 12;
-const ExtraID kN59Biochips010 = 13;
-const ExtraID kN59Biochips100 = 14;
-const ExtraID kN59Biochips000 = 15;
-const ExtraID kN59RobotDisappears = 16;
-const ExtraID kN60ClawFromAToB = 17;
-const ExtraID kN60ClawALoop = 18;
-const ExtraID kN60ClawAPinch = 19;
-const ExtraID kN60ClawACounterclockwise = 20;
-const ExtraID kN60ClawAClockwise = 21;
-const ExtraID kN60ClawFromBToA = 22;
-const ExtraID kN60ClawFromBToC = 23;
-const ExtraID kN60ClawFromBToD = 24;
-const ExtraID kN60ClawBLoop = 25;
-const ExtraID kN60ClawBPinch = 26;
-const ExtraID kN60ClawBCounterclockwise = 27;
-const ExtraID kN60ClawBClockwise = 28;
-const ExtraID kN60ClawFromCToB = 29;
-const ExtraID kN60ClawCLoop = 30;
-const ExtraID kN60ClawCPinch = 31;
-const ExtraID kN60ClawCCounterclockwise = 32;
-const ExtraID kN60ClawCClockwise = 33;
-const ExtraID kN60ClawFromDToB = 34;
-const ExtraID kN60ClawDLoop = 35;
-const ExtraID kN60ClawDPinch = 36;
-const ExtraID kN60ClawDCounterclockwise = 37;
-const ExtraID kN60ClawDClockwise = 38;
-const ExtraID kN60RobotApproaches = 39;
-const ExtraID kN60FirstMistake = 40;
-const ExtraID kN60ArmActivated = 41;
-const ExtraID kN60SecondMistake = 42;
-const ExtraID kN60ArmToPositionB = 43;
-const ExtraID kN60ThirdMistake = 44;
-const ExtraID kN60ArmGrabsRobot = 45;
-const ExtraID kN60FourthMistake = 46;
-const ExtraID kN60ArmCarriesRobotToPositionA = 47;
-const ExtraID kN60PlayerFollowsRobotToDoor = 48;
-const ExtraID kN60RobotHeadOpens = 49;
-const ExtraID kN60Biochips111 = 50;
-const ExtraID kN60Biochips011 = 51;
-const ExtraID kN60Biochips101 = 52;
-const ExtraID kN60Biochips001 = 53;
-const ExtraID kN60Biochips110 = 54;
-const ExtraID kN60Biochips010 = 55;
-const ExtraID kN60Biochips100 = 56;
-const ExtraID kN60Biochips000 = 57;
-const ExtraID kN60RobotDisappears = 58;
-const ExtraID kNoradDeltaRetinalScanBad = 59;
-const ExtraID kNoradDeltaRetinalScanGood = 60;
-const ExtraID kN79BrightView = 61;
+static const ExtraID kArriveFromSubChase = 0;
+static const ExtraID kN59ZoomWithRobot = 1;
+static const ExtraID kN59RobotApproaches = 2;
+static const ExtraID kN59RobotPunchLoop = 3;
+static const ExtraID kN59PlayerWins1 = 4;
+static const ExtraID kN59PlayerWins2 = 5;
+static const ExtraID kN59RobotWins = 6;
+static const ExtraID kN59RobotHeadOpens = 7;
+static const ExtraID kN59Biochips111 = 8;
+static const ExtraID kN59Biochips011 = 9;
+static const ExtraID kN59Biochips101 = 10;
+static const ExtraID kN59Biochips001 = 11;
+static const ExtraID kN59Biochips110 = 12;
+static const ExtraID kN59Biochips010 = 13;
+static const ExtraID kN59Biochips100 = 14;
+static const ExtraID kN59Biochips000 = 15;
+static const ExtraID kN59RobotDisappears = 16;
+static const ExtraID kN60ClawFromAToB = 17;
+static const ExtraID kN60ClawALoop = 18;
+static const ExtraID kN60ClawAPinch = 19;
+static const ExtraID kN60ClawACounterclockwise = 20;
+static const ExtraID kN60ClawAClockwise = 21;
+static const ExtraID kN60ClawFromBToA = 22;
+static const ExtraID kN60ClawFromBToC = 23;
+static const ExtraID kN60ClawFromBToD = 24;
+static const ExtraID kN60ClawBLoop = 25;
+static const ExtraID kN60ClawBPinch = 26;
+static const ExtraID kN60ClawBCounterclockwise = 27;
+static const ExtraID kN60ClawBClockwise = 28;
+static const ExtraID kN60ClawFromCToB = 29;
+static const ExtraID kN60ClawCLoop = 30;
+static const ExtraID kN60ClawCPinch = 31;
+static const ExtraID kN60ClawCCounterclockwise = 32;
+static const ExtraID kN60ClawCClockwise = 33;
+static const ExtraID kN60ClawFromDToB = 34;
+static const ExtraID kN60ClawDLoop = 35;
+static const ExtraID kN60ClawDPinch = 36;
+static const ExtraID kN60ClawDCounterclockwise = 37;
+static const ExtraID kN60ClawDClockwise = 38;
+static const ExtraID kN60RobotApproaches = 39;
+static const ExtraID kN60FirstMistake = 40;
+static const ExtraID kN60ArmActivated = 41;
+static const ExtraID kN60SecondMistake = 42;
+static const ExtraID kN60ArmToPositionB = 43;
+static const ExtraID kN60ThirdMistake = 44;
+static const ExtraID kN60ArmGrabsRobot = 45;
+static const ExtraID kN60FourthMistake = 46;
+static const ExtraID kN60ArmCarriesRobotToPositionA = 47;
+static const ExtraID kN60PlayerFollowsRobotToDoor = 48;
+static const ExtraID kN60RobotHeadOpens = 49;
+static const ExtraID kN60Biochips111 = 50;
+static const ExtraID kN60Biochips011 = 51;
+static const ExtraID kN60Biochips101 = 52;
+static const ExtraID kN60Biochips001 = 53;
+static const ExtraID kN60Biochips110 = 54;
+static const ExtraID kN60Biochips010 = 55;
+static const ExtraID kN60Biochips100 = 56;
+static const ExtraID kN60Biochips000 = 57;
+static const ExtraID kN60RobotDisappears = 58;
+static const ExtraID kNoradDeltaRetinalScanBad = 59;
+static const ExtraID kNoradDeltaRetinalScanGood = 60;
+static const ExtraID kN79BrightView = 61;
 
 // Norad Delta Tables
 
-const TimeScale kNoradDeltaMovieScale = 600;
-const TimeScale kNoradDeltaFramesPerSecond = 15;
-const TimeScale kNoradDeltaFrameDuration = 40;
+static const TimeScale kNoradDeltaMovieScale = 600;
+static const TimeScale kNoradDeltaFramesPerSecond = 15;
+static const TimeScale kNoradDeltaFrameDuration = 40;
 
 //	Alternate IDs.
 
-const AlternateID kAltNoradDeltaNormal = 0;
+static const AlternateID kAltNoradDeltaNormal = 0;
 
 //	Room IDs.
 
-const RoomID kNorad41 = 0;
-const RoomID kNorad42 = 1;
-const RoomID kNorad43 = 2;
-const RoomID kNorad44 = 3;
-const RoomID kNorad45 = 4;
-const RoomID kNorad46 = 5;
-const RoomID kNorad47 = 6;
-const RoomID kNorad48 = 7;
-const RoomID kNorad48South = 8;
-const RoomID kNorad49 = 9;
-const RoomID kNorad49South = 10;
-const RoomID kNorad50 = 11;
-const RoomID kNorad50East = 12;
-const RoomID kNorad51 = 13;
-const RoomID kNorad52 = 14;
-const RoomID kNorad53 = 15;
-const RoomID kNorad54 = 16;
-const RoomID kNorad54North = 17;
-const RoomID kNorad55 = 18;
-const RoomID kNorad56 = 19;
-const RoomID kNorad57 = 20;
-const RoomID kNorad58 = 21;
-const RoomID kNorad59 = 22;
-const RoomID kNorad59West = 23;
-const RoomID kNorad60 = 24;
-const RoomID kNorad60West = 25;
-const RoomID kNorad61 = 26;
-const RoomID kNorad62 = 27;
-const RoomID kNorad63 = 28;
-const RoomID kNorad64 = 29;
-const RoomID kNorad65 = 30;
-const RoomID kNorad66 = 31;
-const RoomID kNorad67 = 32;
-const RoomID kNorad68 = 33;
-const RoomID kNorad68West = 34;
-const RoomID kNorad69 = 35;
-const RoomID kNorad78 = 36;
-const RoomID kNorad79 = 37;
-const RoomID kNorad79West = 38;
+static const RoomID kNorad41 = 0;
+static const RoomID kNorad42 = 1;
+static const RoomID kNorad43 = 2;
+static const RoomID kNorad44 = 3;
+static const RoomID kNorad45 = 4;
+static const RoomID kNorad46 = 5;
+static const RoomID kNorad47 = 6;
+static const RoomID kNorad48 = 7;
+static const RoomID kNorad48South = 8;
+static const RoomID kNorad49 = 9;
+static const RoomID kNorad49South = 10;
+static const RoomID kNorad50 = 11;
+static const RoomID kNorad50East = 12;
+static const RoomID kNorad51 = 13;
+static const RoomID kNorad52 = 14;
+static const RoomID kNorad53 = 15;
+static const RoomID kNorad54 = 16;
+static const RoomID kNorad54North = 17;
+static const RoomID kNorad55 = 18;
+static const RoomID kNorad56 = 19;
+static const RoomID kNorad57 = 20;
+static const RoomID kNorad58 = 21;
+static const RoomID kNorad59 = 22;
+static const RoomID kNorad59West = 23;
+static const RoomID kNorad60 = 24;
+static const RoomID kNorad60West = 25;
+static const RoomID kNorad61 = 26;
+static const RoomID kNorad62 = 27;
+static const RoomID kNorad63 = 28;
+static const RoomID kNorad64 = 29;
+static const RoomID kNorad65 = 30;
+static const RoomID kNorad66 = 31;
+static const RoomID kNorad67 = 32;
+static const RoomID kNorad68 = 33;
+static const RoomID kNorad68West = 34;
+static const RoomID kNorad69 = 35;
+static const RoomID kNorad78 = 36;
+static const RoomID kNorad79 = 37;
+static const RoomID kNorad79West = 38;
 
 //	Hot Spot Activation IDs.
 
 
 //	Hot Spot IDs.
 
-const HotSpotID kNorad48ElevatorSpotID = 5000;
-const HotSpotID kNorad48ElevatorOutSpotID = 5001;
-const HotSpotID kNorad48ElevatorUpSpotID = 5002;
-const HotSpotID kNorad49ElevatorSpotID = 5003;
-const HotSpotID kNorad49ElevatorOutSpotID = 5004;
-const HotSpotID kNorad49ElevatorDownSpotID = 5005;
-const HotSpotID kNorad50DoorSpotID = 5006;
-const HotSpotID kNorad50DoorOutSpotID = 5007;
-const HotSpotID kDeltaUpperPressureDoorUpSpotID = 5008;
-const HotSpotID kDeltaUpperPressureDoorDownSpotID = 5009;
-const HotSpotID kNorad54DoorSpotID = 5010;
-const HotSpotID kNorad54DoorOutSpotID = 5011;
-const HotSpotID kNorad59WestSpotID = 5012;
-const HotSpotID kNorad59WestOutSpotID = 5013;
-const HotSpotID kDeltaLowerPressureDoorUpSpotID = 5014;
-const HotSpotID kDeltaLowerPressureDoorDownSpotID = 5015;
-const HotSpotID kDelta59RobotHeadSpotID = 5016;
-const HotSpotID kDelta59RobotShieldBiochipSpotID = 5017;
-const HotSpotID kDelta59RobotOpMemBiochipSpotID = 5018;
-const HotSpotID kDelta59RobotRetinalBiochipSpotID = 5019;
-const HotSpotID kNorad60MonitorSpotID = 5020;
-const HotSpotID kNorad60MonitorOutSpotID = 5021;
-const HotSpotID kNorad60LaunchPrepSpotID = 5022;
-const HotSpotID kNorad60ClawControlSpotID = 5023;
-const HotSpotID kNorad60ClawPinchSpotID = 5024;
-const HotSpotID kNorad60ClawDownSpotID = 5025;
-const HotSpotID kNorad60ClawRightSpotID = 5026;
-const HotSpotID kNorad60ClawLeftSpotID = 5027;
-const HotSpotID kNorad60ClawUpSpotID = 5028;
-const HotSpotID kNorad60ClawCCWSpotID = 5029;
-const HotSpotID kNorad60ClawCWSpotID = 5030;
-const HotSpotID kDelta60RobotHeadSpotID = 5031;
-const HotSpotID kDelta60RobotShieldBiochipSpotID = 5032;
-const HotSpotID kDelta60RobotOpMemBiochipSpotID = 5033;
-const HotSpotID kDelta60RobotRetinalBiochipSpotID = 5034;
-const HotSpotID kNorad68WestSpotID = 5035;
-const HotSpotID kNorad68WestOutSpotID = 5036;
-const HotSpotID kNorad79WestSpotID = 5037;
-const HotSpotID kNorad79WestOutSpotID = 5038;
-const HotSpotID kNorad79SpinLeftSpotID = 5039;
-const HotSpotID kNorad79SpinRightSpotID = 5040;
-const HotSpotID kNorad79SpinUpSpotID = 5041;
-const HotSpotID kNorad79SpinDownSpotID = 5042;
-const HotSpotID kNorad79SiloAreaSpotID = 5043;
+static const HotSpotID kNorad48ElevatorSpotID = 5000;
+static const HotSpotID kNorad48ElevatorOutSpotID = 5001;
+static const HotSpotID kNorad48ElevatorUpSpotID = 5002;
+static const HotSpotID kNorad49ElevatorSpotID = 5003;
+static const HotSpotID kNorad49ElevatorOutSpotID = 5004;
+static const HotSpotID kNorad49ElevatorDownSpotID = 5005;
+static const HotSpotID kNorad50DoorSpotID = 5006;
+static const HotSpotID kNorad50DoorOutSpotID = 5007;
+static const HotSpotID kDeltaUpperPressureDoorUpSpotID = 5008;
+static const HotSpotID kDeltaUpperPressureDoorDownSpotID = 5009;
+static const HotSpotID kNorad54DoorSpotID = 5010;
+static const HotSpotID kNorad54DoorOutSpotID = 5011;
+static const HotSpotID kNorad59WestSpotID = 5012;
+static const HotSpotID kNorad59WestOutSpotID = 5013;
+static const HotSpotID kDeltaLowerPressureDoorUpSpotID = 5014;
+static const HotSpotID kDeltaLowerPressureDoorDownSpotID = 5015;
+static const HotSpotID kDelta59RobotHeadSpotID = 5016;
+static const HotSpotID kDelta59RobotShieldBiochipSpotID = 5017;
+static const HotSpotID kDelta59RobotOpMemBiochipSpotID = 5018;
+static const HotSpotID kDelta59RobotRetinalBiochipSpotID = 5019;
+static const HotSpotID kNorad60MonitorSpotID = 5020;
+static const HotSpotID kNorad60MonitorOutSpotID = 5021;
+static const HotSpotID kNorad60LaunchPrepSpotID = 5022;
+static const HotSpotID kNorad60ClawControlSpotID = 5023;
+static const HotSpotID kNorad60ClawPinchSpotID = 5024;
+static const HotSpotID kNorad60ClawDownSpotID = 5025;
+static const HotSpotID kNorad60ClawRightSpotID = 5026;
+static const HotSpotID kNorad60ClawLeftSpotID = 5027;
+static const HotSpotID kNorad60ClawUpSpotID = 5028;
+static const HotSpotID kNorad60ClawCCWSpotID = 5029;
+static const HotSpotID kNorad60ClawCWSpotID = 5030;
+static const HotSpotID kDelta60RobotHeadSpotID = 5031;
+static const HotSpotID kDelta60RobotShieldBiochipSpotID = 5032;
+static const HotSpotID kDelta60RobotOpMemBiochipSpotID = 5033;
+static const HotSpotID kDelta60RobotRetinalBiochipSpotID = 5034;
+static const HotSpotID kNorad68WestSpotID = 5035;
+static const HotSpotID kNorad68WestOutSpotID = 5036;
+static const HotSpotID kNorad79WestSpotID = 5037;
+static const HotSpotID kNorad79WestOutSpotID = 5038;
+static const HotSpotID kNorad79SpinLeftSpotID = 5039;
+static const HotSpotID kNorad79SpinRightSpotID = 5040;
+static const HotSpotID kNorad79SpinUpSpotID = 5041;
+static const HotSpotID kNorad79SpinDownSpotID = 5042;
+static const HotSpotID kNorad79SiloAreaSpotID = 5043;
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.cpp b/engines/pegasus/neighborhood/norad/noradelevator.cpp
index f3f1e1c..4279e23 100755
--- a/engines/pegasus/neighborhood/norad/noradelevator.cpp
+++ b/engines/pegasus/neighborhood/norad/noradelevator.cpp
@@ -32,10 +32,10 @@
 namespace Pegasus {
 
 // Norad elevator PICTs:
-const ResIDType kElevatorLabelID = 200;
-const ResIDType kElevatorButtonsID = 201;
-const ResIDType kElevatorDownOnID = 202;
-const ResIDType kElevatorUpOnID = 203;
+static const ResIDType kElevatorLabelID = 200;
+static const ResIDType kElevatorButtonsID = 201;
+static const ResIDType kElevatorDownOnID = 202;
+static const ResIDType kElevatorUpOnID = 203;
 
 NoradElevator::NoradElevator(Neighborhood *handler, const RoomID upRoom, const RoomID downRoom,
 		const HotSpotID upHotspot, const HotSpotID downHotspot) : GameInteraction(kNoradElevatorInteractionID, handler),
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
index 3675f43..520d568 100755
--- a/engines/pegasus/neighborhood/norad/pressuredoor.cpp
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
@@ -33,32 +33,32 @@
 
 namespace Pegasus {
 
-const TimeValue kLevelsSplashStart = 0;
-const TimeValue kLevelsSplashStop = 1;
-const TimeValue kPressureBase = 1;
-
-const TimeValue kDoorSealedTime = 0;
-const TimeValue kEqualizeTime = 1;
-const TimeValue kMaxPressureLoopStart = 2;
-const TimeValue kMaxPressureLoopStop = 3;
-const TimeValue kOpeningDoorLoopStart = 3;
-const TimeValue kOpeningDoorLoopStop = 4;
-const TimeValue kIncreasingPressureTime = 4;
-const TimeValue kDecreasingPressureTime = 5;
-const TimeValue kCautionLoopStart = 6;
-const TimeValue kCautionLoopStop = 7;
-
-const NotificationFlags kSplashFinished = 1;
-const NotificationFlags kPressureDroppingFlag = kSplashFinished << 1;
-
-const NotificationFlags kPressureNotificationFlags = kSplashFinished |
+static const TimeValue kLevelsSplashStart = 0;
+static const TimeValue kLevelsSplashStop = 1;
+static const TimeValue kPressureBase = 1;
+
+static const TimeValue kDoorSealedTime = 0;
+static const TimeValue kEqualizeTime = 1;
+static const TimeValue kMaxPressureLoopStart = 2;
+static const TimeValue kMaxPressureLoopStop = 3;
+static const TimeValue kOpeningDoorLoopStart = 3;
+static const TimeValue kOpeningDoorLoopStop = 4;
+static const TimeValue kIncreasingPressureTime = 4;
+static const TimeValue kDecreasingPressureTime = 5;
+static const TimeValue kCautionLoopStart = 6;
+static const TimeValue kCautionLoopStop = 7;
+
+static const NotificationFlags kSplashFinished = 1;
+static const NotificationFlags kPressureDroppingFlag = kSplashFinished << 1;
+
+static const NotificationFlags kPressureNotificationFlags = kSplashFinished |
 														kPressureDroppingFlag;
 
-const NotificationFlags kDoorJumpsUpFlag = 1;
-const NotificationFlags kDoorJumpsBackFlag = kDoorJumpsUpFlag << 1;
-const NotificationFlags kDoorCrushedFlag = kDoorJumpsBackFlag << 1;
+static const NotificationFlags kDoorJumpsUpFlag = 1;
+static const NotificationFlags kDoorJumpsBackFlag = kDoorJumpsUpFlag << 1;
+static const NotificationFlags kDoorCrushedFlag = kDoorJumpsBackFlag << 1;
 
-const NotificationFlags kUtilityNotificationFlags = kDoorJumpsUpFlag |
+static const NotificationFlags kUtilityNotificationFlags = kDoorJumpsUpFlag |
 														kDoorJumpsBackFlag |
 														kDoorCrushedFlag;
 
@@ -82,27 +82,27 @@ enum {
 };
 
 // Pressure values range from 0 to 11.
-const short kMinPressure = 0;
-const short kMaxPressure = 11;
+static const short kMinPressure = 0;
+static const short kMaxPressure = 11;
 
-const TimeScale kNavTimeScale = 600;
-const TimeValue kNavFrameRate = 15;
-const TimeValue kNavTimePerFrame = kNavTimeScale / kNavFrameRate;
+static const TimeScale kNavTimeScale = 600;
+static const TimeValue kNavFrameRate = 15;
+static const TimeValue kNavTimePerFrame = kNavTimeScale / kNavFrameRate;
 
-const TimeValue kApproachPunchInTime = 122 * kNavTimePerFrame;
-const TimeValue kLoopPunchInTime = 38 * kNavTimePerFrame;
-const TimeValue kPunchThroughTime = 38 * kNavTimePerFrame;
+static const TimeValue kApproachPunchInTime = 122 * kNavTimePerFrame;
+static const TimeValue kLoopPunchInTime = 38 * kNavTimePerFrame;
+static const TimeValue kPunchThroughTime = 38 * kNavTimePerFrame;
 
 // Pressure door PICTs:
-const ResIDType kUpperPressureUpOffPICTID = 400;
-const ResIDType kUpperPressureUpOnPICTID = 401;
-const ResIDType kUpperPressureDownOffPICTID = 402;
-const ResIDType kUpperPressureDownOnPICTID = 403;
-
-const ResIDType kLowerPressureUpOffPICTID = 404;
-const ResIDType kLowerPressureUpOnPICTID = 405;
-const ResIDType kLowerPressureDownOffPICTID = 406;
-const ResIDType kLowerPressureDownOnPICTID = 407;
+static const ResIDType kUpperPressureUpOffPICTID = 400;
+static const ResIDType kUpperPressureUpOnPICTID = 401;
+static const ResIDType kUpperPressureDownOffPICTID = 402;
+static const ResIDType kUpperPressureDownOnPICTID = 403;
+
+static const ResIDType kLowerPressureUpOffPICTID = 404;
+static const ResIDType kLowerPressureUpOnPICTID = 405;
+static const ResIDType kLowerPressureDownOffPICTID = 406;
+static const ResIDType kLowerPressureDownOnPICTID = 407;
 
 PressureDoor::PressureDoor(Neighborhood *handler, bool isUpperDoor, const HotSpotID upSpotID, const HotSpotID downSpotID,
 		const HotSpotID outSpotID, TimeValue pressureSoundIn, TimeValue pressureSoundOut, TimeValue equalizeSoundIn,
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.h b/engines/pegasus/neighborhood/norad/pressuredoor.h
index 5ae8c9b..7ef1518 100755
--- a/engines/pegasus/neighborhood/norad/pressuredoor.h
+++ b/engines/pegasus/neighborhood/norad/pressuredoor.h
@@ -33,7 +33,7 @@
 
 namespace Pegasus {
 
-const short kNormalSubRoomPressure = 2;
+static const short kNormalSubRoomPressure = 2;
 
 class PressureDoor : public GameInteraction, public NotificationReceiver {
 public:
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.h b/engines/pegasus/neighborhood/norad/pressuretracker.h
index 39ce1c1..7d57259 100755
--- a/engines/pegasus/neighborhood/norad/pressuretracker.h
+++ b/engines/pegasus/neighborhood/norad/pressuretracker.h
@@ -33,12 +33,12 @@ namespace Pegasus {
 // This class assumes that the globe movie is built at 15 frames per second with a
 // time scale of 600, yielding 40 time unit per frame.
 
-typedef enum {
+enum PressureTrackDirection {
 	kTrackPressureUp,
 	kTrackPressureDown
-} tPressureTrackDirection;
+};
 
-const int kPressureDoorTrackInterval = 45;
+static const int kPressureDoorTrackInterval = 45;
 
 class PressureDoor;
 class Sprite;
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index 476dd92..8a306fe 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -34,122 +34,122 @@ namespace Pegasus {
 
 // Right Monitor times
 
-const TimeValue kAlphaClawSplashStart = 0;
-const TimeValue kAlphaClawSplashStop = 4000;
-
-const TimeValue kDeltaClawSplashStart = 4000;
-const TimeValue kDeltaClawSplashStop = 8000;
-
-const TimeValue kClawAtATime = 8000;
-const TimeValue kClawAtAPinchedTime = 8600;
-const TimeValue kClawAtATurnedTime = 9200;
-const TimeValue kClawAtAWithRobotPinchedTime = 9800;
-
-const TimeValue kClawAtBTime = 10400;
-const TimeValue kClawAtBPinchedTime = 11000;
-const TimeValue kClawAtBTurnedTime = 11600;
-const TimeValue kClawAtBWithRobotTime = 12200;
-const TimeValue kClawAtBWithRobotPinchedTime = 12800;
-
-const TimeValue kClawAtCTime = 13400;
-const TimeValue kClawAtCPinchedTime = 14000;
-const TimeValue kClawAtCTurnedTime = 14600;
-
-const TimeValue kClawAtDTime = 15200;
-const TimeValue kClawAtDPinchedTime = 15800;
-const TimeValue kClawAtDTurnedTime = 16400;
-
-const TimeValue kAToBStart = 17000;
-const TimeValue kAToBStop = 18680;
-const TimeValue kAPinchStart = 18680;
-const TimeValue kAPinchStop = 20200;
-const TimeValue kACCWStart = 20200;
-const TimeValue kACCWStop = 21600;
-const TimeValue kACWStart = 21600;
-const TimeValue kACWStop = 23000;
-
-const TimeValue kBToAStart = 23000;
-const TimeValue kBToAStop = 24680;
-const TimeValue kBToCStart = 24680;
-const TimeValue kBToCStop = 26520;
-const TimeValue kBToDStart = 26520;
-const TimeValue kBToDStop = 28320;
-const TimeValue kBPinchStart = 28320;
-const TimeValue kBPinchStop = 29680;
-const TimeValue kBCCWStart = 29680;
-const TimeValue kBCCWStop = 31200;
-const TimeValue kBCWStart = 31200;
-const TimeValue kBCWStop = 32720;
-
-const TimeValue kCToBStart = 32720;
-const TimeValue kCToBStop = 34560;
-const TimeValue kCPinchStart = 34560;
-const TimeValue kCPinchStop = 36400;
-const TimeValue kCCCWStart = 36400;
-const TimeValue kCCCWStop = 37840;
-const TimeValue kCCWStart = 37840;
-const TimeValue kCCWStop = 39280;
-
-const TimeValue kDToBStart = 39280;
-const TimeValue kDToBStop = 41080;
-const TimeValue kDPinchStart = 41080;
-const TimeValue kDPinchStop = 42600;
-const TimeValue kDCCWStart = 42600;
-const TimeValue kDCCWStop = 44000;
-const TimeValue kDCWStart = 44000;
-const TimeValue kDCWStop = 45400;
-
-const TimeValue kRobotApproachStart = 45400;
-const TimeValue kRobotApproachStop = 56800;
-
-const TimeValue kCToBWithRobotStart = 56800;
-const TimeValue kCToBWithRobotStop = 58600;
-
-const TimeValue kBPinchWithRobotStart = 58600;
-const TimeValue kBPinchWithRobotStop = 60400;
-const TimeValue kBToAWithRobotStart = 60400;
-const TimeValue kBToAWithRobotStop = 62240;
+static const TimeValue kAlphaClawSplashStart = 0;
+static const TimeValue kAlphaClawSplashStop = 4000;
+
+static const TimeValue kDeltaClawSplashStart = 4000;
+static const TimeValue kDeltaClawSplashStop = 8000;
+
+static const TimeValue kClawAtATime = 8000;
+static const TimeValue kClawAtAPinchedTime = 8600;
+static const TimeValue kClawAtATurnedTime = 9200;
+static const TimeValue kClawAtAWithRobotPinchedTime = 9800;
+
+static const TimeValue kClawAtBTime = 10400;
+static const TimeValue kClawAtBPinchedTime = 11000;
+static const TimeValue kClawAtBTurnedTime = 11600;
+static const TimeValue kClawAtBWithRobotTime = 12200;
+static const TimeValue kClawAtBWithRobotPinchedTime = 12800;
+
+static const TimeValue kClawAtCTime = 13400;
+static const TimeValue kClawAtCPinchedTime = 14000;
+static const TimeValue kClawAtCTurnedTime = 14600;
+
+static const TimeValue kClawAtDTime = 15200;
+static const TimeValue kClawAtDPinchedTime = 15800;
+static const TimeValue kClawAtDTurnedTime = 16400;
+
+static const TimeValue kAToBStart = 17000;
+static const TimeValue kAToBStop = 18680;
+static const TimeValue kAPinchStart = 18680;
+static const TimeValue kAPinchStop = 20200;
+static const TimeValue kACCWStart = 20200;
+static const TimeValue kACCWStop = 21600;
+static const TimeValue kACWStart = 21600;
+static const TimeValue kACWStop = 23000;
+
+static const TimeValue kBToAStart = 23000;
+static const TimeValue kBToAStop = 24680;
+static const TimeValue kBToCStart = 24680;
+static const TimeValue kBToCStop = 26520;
+static const TimeValue kBToDStart = 26520;
+static const TimeValue kBToDStop = 28320;
+static const TimeValue kBPinchStart = 28320;
+static const TimeValue kBPinchStop = 29680;
+static const TimeValue kBCCWStart = 29680;
+static const TimeValue kBCCWStop = 31200;
+static const TimeValue kBCWStart = 31200;
+static const TimeValue kBCWStop = 32720;
+
+static const TimeValue kCToBStart = 32720;
+static const TimeValue kCToBStop = 34560;
+static const TimeValue kCPinchStart = 34560;
+static const TimeValue kCPinchStop = 36400;
+static const TimeValue kCCCWStart = 36400;
+static const TimeValue kCCCWStop = 37840;
+static const TimeValue kCCWStart = 37840;
+static const TimeValue kCCWStop = 39280;
+
+static const TimeValue kDToBStart = 39280;
+static const TimeValue kDToBStop = 41080;
+static const TimeValue kDPinchStart = 41080;
+static const TimeValue kDPinchStop = 42600;
+static const TimeValue kDCCWStart = 42600;
+static const TimeValue kDCCWStop = 44000;
+static const TimeValue kDCWStart = 44000;
+static const TimeValue kDCWStop = 45400;
+
+static const TimeValue kRobotApproachStart = 45400;
+static const TimeValue kRobotApproachStop = 56800;
+
+static const TimeValue kCToBWithRobotStart = 56800;
+static const TimeValue kCToBWithRobotStop = 58600;
+
+static const TimeValue kBPinchWithRobotStart = 58600;
+static const TimeValue kBPinchWithRobotStop = 60400;
+static const TimeValue kBToAWithRobotStart = 60400;
+static const TimeValue kBToAWithRobotStop = 62240;
 
 // As usual, times here are in seconds.
 
 // Left monitor times.
 
-const TimeValue kAlphaSplashStart = 0;
-const TimeValue kAlphaSplashStop = 2;
+static const TimeValue kAlphaSplashStart = 0;
+static const TimeValue kAlphaSplashStop = 2;
 
-const TimeValue kMainMenuTime = 2;
-const TimeValue kLaunchPrepRolloverTime = 3;
-const TimeValue kLaunchPrepHighlightStart = 4;
-const TimeValue kLaunchPrepHighlightStop = 5;
-const TimeValue kClawControlRolloverTime = 5;
-const TimeValue kClawControlHighlightStart = 6;
-const TimeValue kClawControlHighlightStop = 7;
+static const TimeValue kMainMenuTime = 2;
+static const TimeValue kLaunchPrepRolloverTime = 3;
+static const TimeValue kLaunchPrepHighlightStart = 4;
+static const TimeValue kLaunchPrepHighlightStop = 5;
+static const TimeValue kClawControlRolloverTime = 5;
+static const TimeValue kClawControlHighlightStart = 6;
+static const TimeValue kClawControlHighlightStop = 7;
 
-const TimeValue kAlphaLaunchPrepStart = 7;
-const TimeValue kAlphaLaunchPrepStop = 17;
+static const TimeValue kAlphaLaunchPrepStart = 7;
+static const TimeValue kAlphaLaunchPrepStop = 17;
 
-const TimeValue kClawMenuStart = 17;
-const TimeValue kClawMenuStop = 18;
+static const TimeValue kClawMenuStart = 17;
+static const TimeValue kClawMenuStop = 18;
 
-const TimeValue kClawMenuTime = 18;
+static const TimeValue kClawMenuTime = 18;
 
-const TimeValue kDeltaSplashStart = 19;
-const TimeValue kDeltaSplashStop = 21;
+static const TimeValue kDeltaSplashStart = 19;
+static const TimeValue kDeltaSplashStop = 21;
 
-const TimeValue kDeltaLaunchPrepStart = 21;
-const TimeValue kDeltaLaunchPrepStop = 30;
+static const TimeValue kDeltaLaunchPrepStart = 21;
+static const TimeValue kDeltaLaunchPrepStop = 30;
 
 // Right monitor times.
 
-const NotificationFlags kAlphaSplashFinished = 1;
-const NotificationFlags kAlphaPrepFinished = kAlphaSplashFinished << 1;
-const NotificationFlags kPrepHighlightFinished = kAlphaPrepFinished << 1;
-const NotificationFlags kClawHighlightFinished = kPrepHighlightFinished << 1;
-const NotificationFlags kClawMenuFinished = kClawHighlightFinished << 1;
-const NotificationFlags kDeltaSplashFinished = kClawMenuFinished << 1;
-const NotificationFlags kDeltaPrepFinished = kDeltaSplashFinished << 1;
+static const NotificationFlags kAlphaSplashFinished = 1;
+static const NotificationFlags kAlphaPrepFinished = kAlphaSplashFinished << 1;
+static const NotificationFlags kPrepHighlightFinished = kAlphaPrepFinished << 1;
+static const NotificationFlags kClawHighlightFinished = kPrepHighlightFinished << 1;
+static const NotificationFlags kClawMenuFinished = kClawHighlightFinished << 1;
+static const NotificationFlags kDeltaSplashFinished = kClawMenuFinished << 1;
+static const NotificationFlags kDeltaPrepFinished = kDeltaSplashFinished << 1;
 
-const NotificationFlags kSubControlNotificationFlags = kAlphaSplashFinished |
+static const NotificationFlags kSubControlNotificationFlags = kAlphaSplashFinished |
 														kAlphaPrepFinished |
 														kPrepHighlightFinished |
 														kClawHighlightFinished |
@@ -157,9 +157,9 @@ const NotificationFlags kSubControlNotificationFlags = kAlphaSplashFinished |
 														kDeltaSplashFinished |
 														kDeltaPrepFinished;
 
-const NotificationFlags kOneSecondOfMoveFinished = 1;
+static const NotificationFlags kOneSecondOfMoveFinished = 1;
 
-const NotificationFlags kGreenBallNotificationFlags = kOneSecondOfMoveFinished;
+static const NotificationFlags kGreenBallNotificationFlags = kOneSecondOfMoveFinished;
 
 enum {
 	kButtonDimFrame,
@@ -307,7 +307,7 @@ enum {
 	kMoveClawUp
 };
 
-const int kClawNowhere = -1;
+static const int kClawNowhere = -1;
 
 // Array indexed by [claw position] [move direction]
 // array yields new claw position or -1.
@@ -415,8 +415,8 @@ enum {
 };
 
 // Sub Control Room button PICTs:
-const ResIDType kSubControlButtonBaseID = 500;
-const ResIDType kClawMonitorGreenBallBaseID = 600;
+static const ResIDType kSubControlButtonBaseID = 500;
+static const ResIDType kClawMonitorGreenBallBaseID = 600;
 
 // Constructor
 SubControlRoom::SubControlRoom(Neighborhood *handler) : GameInteraction(kNoradSubControlRoomInteractionID, handler),
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.h b/engines/pegasus/neighborhood/norad/subcontrolroom.h
index e7ee849..3ee729b 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.h
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.h
@@ -31,12 +31,12 @@
 
 namespace Pegasus {
 
-const uint32 kClawAtA = 0;
-const uint32 kClawAtB = 1;
-const uint32 kClawAtC = 2;
-const uint32 kClawAtD = 3;
+static const uint32 kClawAtA = 0;
+static const uint32 kClawAtB = 1;
+static const uint32 kClawAtC = 2;
+static const uint32 kClawAtD = 3;
 
-const int kNumClawButtons = 7;
+static const int kNumClawButtons = 7;
 
 class Norad;
 
diff --git a/engines/pegasus/neighborhood/norad/subplatform.cpp b/engines/pegasus/neighborhood/norad/subplatform.cpp
index 7f1df53..bfe93ea 100755
--- a/engines/pegasus/neighborhood/norad/subplatform.cpp
+++ b/engines/pegasus/neighborhood/norad/subplatform.cpp
@@ -35,30 +35,30 @@ namespace Pegasus {
 
 // As usual, times here are in seconds.
 
-const TimeValue kNormalSplashStart = 0;
-const TimeValue kNormalSplashStop = 5;
+static const TimeValue kNormalSplashStart = 0;
+static const TimeValue kNormalSplashStop = 5;
 
-const TimeValue kPrepSubStart = 5;
-const TimeValue kPrepSubStop = 15;
+static const TimeValue kPrepSubStart = 5;
+static const TimeValue kPrepSubStop = 15;
 
-const TimeValue kPrepIncompleteStart = 15;
-const TimeValue kPrepIncompleteStop = 19;
+static const TimeValue kPrepIncompleteStart = 15;
+static const TimeValue kPrepIncompleteStop = 19;
 
-const TimeValue kDamagedStart = 19;
-const TimeValue kDamagedStop = 28;
+static const TimeValue kDamagedStart = 19;
+static const TimeValue kDamagedStop = 28;
 
-const NotificationFlags kNormalSplashFinished = 1;
-const NotificationFlags kPrepSubFinished = kNormalSplashFinished << 1;
-const NotificationFlags kPrepIncompleteFinished = kPrepSubFinished << 1;
-const NotificationFlags kDamagedFinished = kPrepIncompleteFinished << 1;
+static const NotificationFlags kNormalSplashFinished = 1;
+static const NotificationFlags kPrepSubFinished = kNormalSplashFinished << 1;
+static const NotificationFlags kPrepIncompleteFinished = kPrepSubFinished << 1;
+static const NotificationFlags kDamagedFinished = kPrepIncompleteFinished << 1;
 
-const NotificationFlags kPlatformNotificationFlags = kNormalSplashFinished |
+static const NotificationFlags kPlatformNotificationFlags = kNormalSplashFinished |
 														kPrepSubFinished |
 														kPrepIncompleteFinished |
 														kDamagedFinished;
 
-const uint16 kSubPreppedBit = (1 << 0);
-const uint16 kWaitingForPlayerBit = (1 << 1);
+static const uint16 kSubPreppedBit = (1 << 0);
+static const uint16 kWaitingForPlayerBit = (1 << 1);
 
 SubPlatform::SubPlatform(Neighborhood *handler) : GameInteraction(kNoradSubPlatformInteractionID, handler),
 		_platformMovie(kPlatformMonitorID), _platformNotification(kNoradSubPlatformNotificationID, (PegasusEngine *)g_engine) {
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.h b/engines/pegasus/neighborhood/prehistoric/prehistoric.h
index 786a7f7..2750fc0 100755
--- a/engines/pegasus/neighborhood/prehistoric/prehistoric.h
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.h
@@ -30,73 +30,73 @@
 
 namespace Pegasus {
 
-const TimeScale kPrehistoricMovieScale = 600;
-const TimeScale kPrehistoricFramesPerSecond = 15;
-const TimeScale kPrehistoricFrameDuration = 40;
+static const TimeScale kPrehistoricMovieScale = 600;
+static const TimeScale kPrehistoricFramesPerSecond = 15;
+static const TimeScale kPrehistoricFrameDuration = 40;
 
 //	Alternate IDs.
 
-const AlternateID kAltPrehistoricNormal = 0;
-const AlternateID kAltPrehistoricBridgeSet = 1;
+static const AlternateID kAltPrehistoricNormal = 0;
+static const AlternateID kAltPrehistoricBridgeSet = 1;
 
 //	Room IDs.
 
-const RoomID kPrehistoric01 = 0;
-const RoomID kPrehistoric02 = 1;
-const RoomID kPrehistoric03 = 2;
-const RoomID kPrehistoric04 = 3;
-const RoomID kPrehistoric05 = 4;
-const RoomID kPrehistoric06 = 5;
-const RoomID kPrehistoric07 = 6;
-const RoomID kPrehistoric08 = 7;
-const RoomID kPrehistoric09 = 8;
-const RoomID kPrehistoric10 = 9;
-const RoomID kPrehistoric11 = 10;
-const RoomID kPrehistoric12 = 11;
-const RoomID kPrehistoric13 = 12;
-const RoomID kPrehistoric14 = 13;
-const RoomID kPrehistoric15 = 14;
-const RoomID kPrehistoric16 = 15;
-const RoomID kPrehistoric17 = 16;
-const RoomID kPrehistoric18 = 17;
-const RoomID kPrehistoric19 = 18;
-const RoomID kPrehistoric20 = 19;
-const RoomID kPrehistoric21 = 20;
-const RoomID kPrehistoric22 = 21;
-const RoomID kPrehistoric22North = 22;
-const RoomID kPrehistoric23 = 23;
-const RoomID kPrehistoric24 = 24;
-const RoomID kPrehistoric25 = 25;
-const RoomID kPrehistoricDeath = 26;
+static const RoomID kPrehistoric01 = 0;
+static const RoomID kPrehistoric02 = 1;
+static const RoomID kPrehistoric03 = 2;
+static const RoomID kPrehistoric04 = 3;
+static const RoomID kPrehistoric05 = 4;
+static const RoomID kPrehistoric06 = 5;
+static const RoomID kPrehistoric07 = 6;
+static const RoomID kPrehistoric08 = 7;
+static const RoomID kPrehistoric09 = 8;
+static const RoomID kPrehistoric10 = 9;
+static const RoomID kPrehistoric11 = 10;
+static const RoomID kPrehistoric12 = 11;
+static const RoomID kPrehistoric13 = 12;
+static const RoomID kPrehistoric14 = 13;
+static const RoomID kPrehistoric15 = 14;
+static const RoomID kPrehistoric16 = 15;
+static const RoomID kPrehistoric17 = 16;
+static const RoomID kPrehistoric18 = 17;
+static const RoomID kPrehistoric19 = 18;
+static const RoomID kPrehistoric20 = 19;
+static const RoomID kPrehistoric21 = 20;
+static const RoomID kPrehistoric22 = 21;
+static const RoomID kPrehistoric22North = 22;
+static const RoomID kPrehistoric23 = 23;
+static const RoomID kPrehistoric24 = 24;
+static const RoomID kPrehistoric25 = 25;
+static const RoomID kPrehistoricDeath = 26;
 
 //	Hot Spot Activation IDs.
 
-const HotSpotActivationID kActivationVaultClosed = 1;
-const HotSpotActivationID kActivationVaultOpen = 2;
+static const HotSpotActivationID kActivationVaultClosed = 1;
+static const HotSpotActivationID kActivationVaultOpen = 2;
 
 //	Hot Spot IDs.
 
-const HotSpotID kPre18EastSpotID = 5000;
-const HotSpotID kPre22NorthSpotID = 5001;
-const HotSpotID kPre22NorthOutSpotID = 5002;
-const HotSpotID kPre22NorthBreakerSpotID = 5003;
-const HotSpotID kPrehistoricKeyDropSpotID = 5004;
-const HotSpotID kPrehistoricHistoricalLogSpotID = 5005;
+static const HotSpotID kPre18EastSpotID = 5000;
+static const HotSpotID kPre22NorthSpotID = 5001;
+static const HotSpotID kPre22NorthOutSpotID = 5002;
+static const HotSpotID kPre22NorthBreakerSpotID = 5003;
+static const HotSpotID kPrehistoricKeyDropSpotID = 5004;
+static const HotSpotID kPrehistoricHistoricalLogSpotID = 5005;
 
 //	Extra sequence IDs.
 
-const ExtraID kPreArrivalFromTSA = 0;
-const ExtraID kPre18EastBridgeOut = 1;
-const ExtraID kPre18EastBridgeOn = 2;
-const ExtraID kPre18EastZoom = 3;
-const ExtraID kPre18EastZoomOut = 4;
-const ExtraID kPre22ThrowBreaker = 5;
-const ExtraID kPre25EastUnlockingVaultWithLog = 6;
-const ExtraID kPre25EastVaultOpenWithLog = 7;
-const ExtraID kPre25EastViewWithLog = 8;
-const ExtraID kPre25EastUnlockingVaultNoLog = 9;
-const ExtraID kPre25EastVaultOpenNoLog = 10;
-const ExtraID kPre25EastViewNoLog = 11;
+static const ExtraID kPreArrivalFromTSA = 0;
+static const ExtraID kPre18EastBridgeOut = 1;
+static const ExtraID kPre18EastBridgeOn = 2;
+static const ExtraID kPre18EastZoom = 3;
+static const ExtraID kPre18EastZoomOut = 4;
+static const ExtraID kPre22ThrowBreaker = 5;
+static const ExtraID kPre25EastUnlockingVaultWithLog = 6;
+static const ExtraID kPre25EastVaultOpenWithLog = 7;
+static const ExtraID kPre25EastViewWithLog = 8;
+static const ExtraID kPre25EastUnlockingVaultNoLog = 9;
+static const ExtraID kPre25EastVaultOpenNoLog = 10;
+static const ExtraID kPre25EastViewNoLog = 11;
 
 class PegasusEngine;
 
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 5ee8fe4..c54e252 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -41,357 +41,357 @@ namespace Pegasus {
 
 // TSA PICTs:
 
-const ResIDType kTBPCloseBoxPICTID = 800;
-const ResIDType kTBPRewindPICTID = 801;
-const ResIDType kUnresolvedPICTID = 802;
-const ResIDType kResolvedPICTID = 803;
-const ResIDType kJumpMenuPICTID = 804;
-const ResIDType kJumpMenuHilitedPICTID = 805;
-const ResIDType kExitPICTID = 806;
-const ResIDType kExitHilitedPICTID = 807;
-const ResIDType kLeftRipPICTID = 808;
-const ResIDType kComparisonCloseBoxPICTID = 809;
-const ResIDType kComparisonLeftRewindPICTID = 810;
-const ResIDType kComparisonRightRewindPICTID = 811;
-const ResIDType kComparisonHiliteNoradPICTID = 812;
-const ResIDType kComparisonHiliteMarsPICTID = 813;
-const ResIDType kComparisonHiliteCaldoriaPICTID = 814;
-const ResIDType kComparisonHiliteWSCPICTID = 815;
-const ResIDType kComparisonChancesNoradPICTID = 816;
-const ResIDType kComparisonChancesMarsPICTID = 817;
-const ResIDType kComparisonChancesCaldoriaPICTID = 818;
-const ResIDType kComparisonChancesWSCPICTID = 819;
-const ResIDType kRedirectionCCRolloverPICTID = 820;
-const ResIDType kRedirectionRRRolloverPICTID = 821;
-const ResIDType kRedirectionFDRolloverPICTID = 822;
-const ResIDType kRedirectionCCDoorPICTID = 823;
-const ResIDType kRedirectionRRDoorPICTID = 824;
-const ResIDType kRedirectionFDDoorPICTID = 825;
-const ResIDType kRedirectionSecuredPICTID = 826;
-const ResIDType kRedirectionNewTargetPICTID = 827;
-const ResIDType kRedirectionClosePICTID = 828;
-
-const short kCompassShift = 15;
-
-const TimeScale kFullTSAMovieScale = 600;
-const TimeScale kFullTSAFramesPerSecond = 15;
-const TimeScale kFullTSAFrameDuration = 40;
+static const ResIDType kTBPCloseBoxPICTID = 800;
+static const ResIDType kTBPRewindPICTID = 801;
+static const ResIDType kUnresolvedPICTID = 802;
+static const ResIDType kResolvedPICTID = 803;
+static const ResIDType kJumpMenuPICTID = 804;
+static const ResIDType kJumpMenuHilitedPICTID = 805;
+static const ResIDType kExitPICTID = 806;
+static const ResIDType kExitHilitedPICTID = 807;
+static const ResIDType kLeftRipPICTID = 808;
+static const ResIDType kComparisonCloseBoxPICTID = 809;
+static const ResIDType kComparisonLeftRewindPICTID = 810;
+static const ResIDType kComparisonRightRewindPICTID = 811;
+static const ResIDType kComparisonHiliteNoradPICTID = 812;
+static const ResIDType kComparisonHiliteMarsPICTID = 813;
+static const ResIDType kComparisonHiliteCaldoriaPICTID = 814;
+static const ResIDType kComparisonHiliteWSCPICTID = 815;
+static const ResIDType kComparisonChancesNoradPICTID = 816;
+static const ResIDType kComparisonChancesMarsPICTID = 817;
+static const ResIDType kComparisonChancesCaldoriaPICTID = 818;
+static const ResIDType kComparisonChancesWSCPICTID = 819;
+static const ResIDType kRedirectionCCRolloverPICTID = 820;
+static const ResIDType kRedirectionRRRolloverPICTID = 821;
+static const ResIDType kRedirectionFDRolloverPICTID = 822;
+static const ResIDType kRedirectionCCDoorPICTID = 823;
+static const ResIDType kRedirectionRRDoorPICTID = 824;
+static const ResIDType kRedirectionFDDoorPICTID = 825;
+static const ResIDType kRedirectionSecuredPICTID = 826;
+static const ResIDType kRedirectionNewTargetPICTID = 827;
+static const ResIDType kRedirectionClosePICTID = 828;
+
+static const int16 kCompassShift = 15;
+
+static const TimeScale kFullTSAMovieScale = 600;
+static const TimeScale kFullTSAFramesPerSecond = 15;
+static const TimeScale kFullTSAFrameDuration = 40;
 
 // Alternate IDs.
-const AlternateID kAltTSANormal = 0;
-const AlternateID kAltTSARobotsAtReadyRoom = 1;
-const AlternateID kAltTSARobotsAtFrontDoor = 2;
-const AlternateID kAltTSARedAlert = 3;
+static const AlternateID kAltTSANormal = 0;
+static const AlternateID kAltTSARobotsAtReadyRoom = 1;
+static const AlternateID kAltTSARobotsAtFrontDoor = 2;
+static const AlternateID kAltTSARedAlert = 3;
 
 // Room IDs.
-const RoomID kTSA01 = 1;
-const RoomID kTSA02 = 2;
-const RoomID kTSA03 = 3;
-const RoomID kTSA04 = 4;
-const RoomID kTSA05 = 5;
-const RoomID kTSA0A = 6;
-const RoomID kTSA06 = 7;
-const RoomID kTSA07 = 8;
-const RoomID kTSA08 = 9;
-const RoomID kTSA09 = 10;
-const RoomID kTSA10 = 11;
-const RoomID kTSA11 = 12;
-const RoomID kTSA12 = 13;
-const RoomID kTSA13 = 14;
-const RoomID kTSA14 = 15;
-const RoomID kTSA15 = 16;
-const RoomID kTSA16 = 17;
-const RoomID kTSA17 = 18;
-const RoomID kTSA18 = 19;
-const RoomID kTSA19 = 20;
-const RoomID kTSA0B = 21;
-const RoomID kTSA21Cyan = 22;
-const RoomID kTSA22Cyan = 23;
-const RoomID kTSA23Cyan = 24;
-const RoomID kTSA24Cyan = 25;
-const RoomID kTSA25Cyan = 26;
-const RoomID kTSA21Red = 27;
-const RoomID kTSA23Red = 29;
-const RoomID kTSA24Red = 30;
-const RoomID kTSA25Red = 31;
-const RoomID kTSA26 = 32;
-const RoomID kTSA27 = 33;
-const RoomID kTSA28 = 34;
-const RoomID kTSA29 = 35;
-const RoomID kTSA30 = 36;
-const RoomID kTSA31 = 37;
-const RoomID kTSA32 = 38;
-const RoomID kTSA33 = 39;
-const RoomID kTSA34 = 40;
-const RoomID kTSA35 = 41;
-const RoomID kTSADeathRoom = 43;
+static const RoomID kTSA01 = 1;
+static const RoomID kTSA02 = 2;
+static const RoomID kTSA03 = 3;
+static const RoomID kTSA04 = 4;
+static const RoomID kTSA05 = 5;
+static const RoomID kTSA0A = 6;
+static const RoomID kTSA06 = 7;
+static const RoomID kTSA07 = 8;
+static const RoomID kTSA08 = 9;
+static const RoomID kTSA09 = 10;
+static const RoomID kTSA10 = 11;
+static const RoomID kTSA11 = 12;
+static const RoomID kTSA12 = 13;
+static const RoomID kTSA13 = 14;
+static const RoomID kTSA14 = 15;
+static const RoomID kTSA15 = 16;
+static const RoomID kTSA16 = 17;
+static const RoomID kTSA17 = 18;
+static const RoomID kTSA18 = 19;
+static const RoomID kTSA19 = 20;
+static const RoomID kTSA0B = 21;
+static const RoomID kTSA21Cyan = 22;
+static const RoomID kTSA22Cyan = 23;
+static const RoomID kTSA23Cyan = 24;
+static const RoomID kTSA24Cyan = 25;
+static const RoomID kTSA25Cyan = 26;
+static const RoomID kTSA21Red = 27;
+static const RoomID kTSA23Red = 29;
+static const RoomID kTSA24Red = 30;
+static const RoomID kTSA25Red = 31;
+static const RoomID kTSA26 = 32;
+static const RoomID kTSA27 = 33;
+static const RoomID kTSA28 = 34;
+static const RoomID kTSA29 = 35;
+static const RoomID kTSA30 = 36;
+static const RoomID kTSA31 = 37;
+static const RoomID kTSA32 = 38;
+static const RoomID kTSA33 = 39;
+static const RoomID kTSA34 = 40;
+static const RoomID kTSA35 = 41;
+static const RoomID kTSADeathRoom = 43;
 
 // Hot Spot Activation IDs.
-const HotSpotActivationID kActivateTSAReadyForCard = 1;
-const HotSpotActivationID kActivateTSAReadyToTransport = 2;
-const HotSpotActivationID kActivateTSARobotsAwake = 3;
-const HotSpotActivationID kActivateTSA0BZoomedOut = 4;
-const HotSpotActivationID kActivateTSA0BZoomedIn = 5;
-const HotSpotActivationID kActivateTSA0BComparisonVideo = 6;
-const HotSpotActivationID kActivationLogReaderOpen = 7;
-const HotSpotActivationID kActivateTSA0BTBPVideo = 8;
-const HotSpotActivationID kActivationDoesntHaveKey = 9;
-const HotSpotActivationID kActivationKeyVaultOpen = 10;
-const HotSpotActivationID kActivationDoesntHaveChips = 11;
-const HotSpotActivationID kActivationChipVaultOpen = 12;
-const HotSpotActivationID kActivationJumpToPrehistoric = 13;
-const HotSpotActivationID kActivationJumpToNorad = 14;
-const HotSpotActivationID kActivationJumpToMars = 15;
-const HotSpotActivationID kActivationJumpToWSC = 16;
-const HotSpotActivationID kActivationReadyToExit = 17;
-const HotSpotActivationID kActivationReadyForJumpMenu = 18;
-const HotSpotActivationID kActivationMainJumpMenu = 19;
+static const HotSpotActivationID kActivateTSAReadyForCard = 1;
+static const HotSpotActivationID kActivateTSAReadyToTransport = 2;
+static const HotSpotActivationID kActivateTSARobotsAwake = 3;
+static const HotSpotActivationID kActivateTSA0BZoomedOut = 4;
+static const HotSpotActivationID kActivateTSA0BZoomedIn = 5;
+static const HotSpotActivationID kActivateTSA0BComparisonVideo = 6;
+static const HotSpotActivationID kActivationLogReaderOpen = 7;
+static const HotSpotActivationID kActivateTSA0BTBPVideo = 8;
+static const HotSpotActivationID kActivationDoesntHaveKey = 9;
+static const HotSpotActivationID kActivationKeyVaultOpen = 10;
+static const HotSpotActivationID kActivationDoesntHaveChips = 11;
+static const HotSpotActivationID kActivationChipVaultOpen = 12;
+static const HotSpotActivationID kActivationJumpToPrehistoric = 13;
+static const HotSpotActivationID kActivationJumpToNorad = 14;
+static const HotSpotActivationID kActivationJumpToMars = 15;
+static const HotSpotActivationID kActivationJumpToWSC = 16;
+static const HotSpotActivationID kActivationReadyToExit = 17;
+static const HotSpotActivationID kActivationReadyForJumpMenu = 18;
+static const HotSpotActivationID kActivationMainJumpMenu = 19;
 
 // Hot Spot IDs.
-const HotSpotID kTSAGTCardDropSpotID = 5000;
-const HotSpotID kTSAGTTokyoSpotID = 5001;
-const HotSpotID kTSAGTCaldoriaSpotID = 5002;
-const HotSpotID kTSAGTBeachSpotID = 5003;
-const HotSpotID kTSAGTOtherSpotID = 5004;
-const HotSpotID kTSA02DoorSpotID = 5005;
-const HotSpotID kTSA03EastJimenezSpotID = 5006;
-const HotSpotID kTSA03WestCrenshawSpotID = 5007;
-const HotSpotID kTSA04EastMatsumotoSpotID = 5008;
-const HotSpotID kTSA04WestCastilleSpotID = 5009;
-const HotSpotID kTSA05EastSinclairSpotID = 5010;
-const HotSpotID kTSA05WestWhiteSpotID = 5011;
-const HotSpotID kTSA0AEastSpotID = 5012;
-const HotSpotID kTSA0AWastSpotID = 5013;
-const HotSpotID kTSA0BEastMonitorSpotID = 5014;
-const HotSpotID kTSA0BEastMonitorOutSpotID = 5015;
-const HotSpotID kTSA0BEastCompareNoradSpotID = 5016;
-const HotSpotID kTSA0BEastCompareMarsSpotID = 5017;
-const HotSpotID kTSA0BEastCompareCaldoriaSpotID = 5018;
-const HotSpotID kTSA0BEastCompareWSCSpotID = 5019;
-const HotSpotID kTSA0BEastLeftRewindSpotID = 5020;
-const HotSpotID kTSA0BEastLeftPlaySpotID = 5021;
-const HotSpotID kTSA0BEastRightRewindSpotID = 5022;
-const HotSpotID kTSA0BEastRightPlaySpotID = 5023;
-const HotSpotID kTSA0BEastCloseVideoSpotID = 5024;
-const HotSpotID kTSA0BNorthMonitorSpotID = 5025;
-const HotSpotID kTSA0BNorthMonitorOutSpotID = 5026;
-const HotSpotID kTSA0BNorthHistLogSpotID = 5027;
-const HotSpotID kTSA0BNorthRobotsToCommandCenterSpotID = 5028;
-const HotSpotID kTSA0BNorthRobotsToReadyRoomSpotID = 5029;
-const HotSpotID kTSA0BNorthRobotsToFrontDoorSpotID = 5030;
-const HotSpotID kTSA0BWestMonitorSpotID = 5031;
-const HotSpotID kTSA0BWestMonitorOutSpotID = 5032;
-const HotSpotID kTSA0BWestTheorySpotID = 5033;
-const HotSpotID kTSA0BWestBackgroundSpotID = 5034;
-const HotSpotID kTSA0BWestProcedureSpotID = 5035;
-const HotSpotID kTSA0BWestCloseVideoSpotID = 5036;
-const HotSpotID kTSA0BWestPlayVideoSpotID = 5037;
-const HotSpotID kTSA0BWestRewindVideoSpotID = 5038;
-const HotSpotID kTSA22EastMonitorSpotID = 5039;
-const HotSpotID kTSA22EastKeySpotID = 5040;
-const HotSpotID kTSA23WestMonitorSpotID = 5041;
-const HotSpotID kTSA23WestChipsSpotID = 5042;
-const HotSpotID kTSA34NorthDoorSpotID = 5043;
-const HotSpotID kTSA37NorthJumpToPrehistoricSpotID = 5044;
-const HotSpotID kTSA37NorthJumpToNoradSpotID = 5045;
-const HotSpotID kTSA37NorthCancelNoradSpotID = 5046;
-const HotSpotID kTSA37NorthJumpToMarsSpotID = 5047;
-const HotSpotID kTSA37NorthCancelMarsSpotID = 5048;
-const HotSpotID kTSA37NorthJumpToWSCSpotID = 5049;
-const HotSpotID kTSA37NorthCancelWSCSpotID = 5050;
-const HotSpotID kTSA37NorthExitSpotID = 5051;
-const HotSpotID kTSA37NorthJumpMenuSpotID = 5052;
-const HotSpotID kTSA37NorthNoradMenuSpotID = 5053;
-const HotSpotID kTSA37NorthMarsMenuSpotID = 5054;
-const HotSpotID kTSA37NorthWSCMenuSpotID = 5055;
+static const HotSpotID kTSAGTCardDropSpotID = 5000;
+static const HotSpotID kTSAGTTokyoSpotID = 5001;
+static const HotSpotID kTSAGTCaldoriaSpotID = 5002;
+static const HotSpotID kTSAGTBeachSpotID = 5003;
+static const HotSpotID kTSAGTOtherSpotID = 5004;
+static const HotSpotID kTSA02DoorSpotID = 5005;
+static const HotSpotID kTSA03EastJimenezSpotID = 5006;
+static const HotSpotID kTSA03WestCrenshawSpotID = 5007;
+static const HotSpotID kTSA04EastMatsumotoSpotID = 5008;
+static const HotSpotID kTSA04WestCastilleSpotID = 5009;
+static const HotSpotID kTSA05EastSinclairSpotID = 5010;
+static const HotSpotID kTSA05WestWhiteSpotID = 5011;
+static const HotSpotID kTSA0AEastSpotID = 5012;
+static const HotSpotID kTSA0AWastSpotID = 5013;
+static const HotSpotID kTSA0BEastMonitorSpotID = 5014;
+static const HotSpotID kTSA0BEastMonitorOutSpotID = 5015;
+static const HotSpotID kTSA0BEastCompareNoradSpotID = 5016;
+static const HotSpotID kTSA0BEastCompareMarsSpotID = 5017;
+static const HotSpotID kTSA0BEastCompareCaldoriaSpotID = 5018;
+static const HotSpotID kTSA0BEastCompareWSCSpotID = 5019;
+static const HotSpotID kTSA0BEastLeftRewindSpotID = 5020;
+static const HotSpotID kTSA0BEastLeftPlaySpotID = 5021;
+static const HotSpotID kTSA0BEastRightRewindSpotID = 5022;
+static const HotSpotID kTSA0BEastRightPlaySpotID = 5023;
+static const HotSpotID kTSA0BEastCloseVideoSpotID = 5024;
+static const HotSpotID kTSA0BNorthMonitorSpotID = 5025;
+static const HotSpotID kTSA0BNorthMonitorOutSpotID = 5026;
+static const HotSpotID kTSA0BNorthHistLogSpotID = 5027;
+static const HotSpotID kTSA0BNorthRobotsToCommandCenterSpotID = 5028;
+static const HotSpotID kTSA0BNorthRobotsToReadyRoomSpotID = 5029;
+static const HotSpotID kTSA0BNorthRobotsToFrontDoorSpotID = 5030;
+static const HotSpotID kTSA0BWestMonitorSpotID = 5031;
+static const HotSpotID kTSA0BWestMonitorOutSpotID = 5032;
+static const HotSpotID kTSA0BWestTheorySpotID = 5033;
+static const HotSpotID kTSA0BWestBackgroundSpotID = 5034;
+static const HotSpotID kTSA0BWestProcedureSpotID = 5035;
+static const HotSpotID kTSA0BWestCloseVideoSpotID = 5036;
+static const HotSpotID kTSA0BWestPlayVideoSpotID = 5037;
+static const HotSpotID kTSA0BWestRewindVideoSpotID = 5038;
+static const HotSpotID kTSA22EastMonitorSpotID = 5039;
+static const HotSpotID kTSA22EastKeySpotID = 5040;
+static const HotSpotID kTSA23WestMonitorSpotID = 5041;
+static const HotSpotID kTSA23WestChipsSpotID = 5042;
+static const HotSpotID kTSA34NorthDoorSpotID = 5043;
+static const HotSpotID kTSA37NorthJumpToPrehistoricSpotID = 5044;
+static const HotSpotID kTSA37NorthJumpToNoradSpotID = 5045;
+static const HotSpotID kTSA37NorthCancelNoradSpotID = 5046;
+static const HotSpotID kTSA37NorthJumpToMarsSpotID = 5047;
+static const HotSpotID kTSA37NorthCancelMarsSpotID = 5048;
+static const HotSpotID kTSA37NorthJumpToWSCSpotID = 5049;
+static const HotSpotID kTSA37NorthCancelWSCSpotID = 5050;
+static const HotSpotID kTSA37NorthExitSpotID = 5051;
+static const HotSpotID kTSA37NorthJumpMenuSpotID = 5052;
+static const HotSpotID kTSA37NorthNoradMenuSpotID = 5053;
+static const HotSpotID kTSA37NorthMarsMenuSpotID = 5054;
+static const HotSpotID kTSA37NorthWSCMenuSpotID = 5055;
 
 // Extra sequence IDs.
-const ExtraID kTSATransporterArrowLoop = 0;
-const ExtraID kTSAArriveFromCaldoria = 1;
-const ExtraID kTSAGTOtherChoice = 2;
-const ExtraID kTSAGTCardSwipe = 3;
-const ExtraID kTSAGTSelectCaldoria = 4;
-const ExtraID kTSAGTGoToCaldoria = 5;
-const ExtraID kTSAGTSelectBeach = 6;
-const ExtraID kTSAGTGoToBeach = 7;
-const ExtraID kTSAGTArriveAtBeach = 8;
-const ExtraID kTSAGTSelectTokyo = 9;
-const ExtraID kTSAGTGoToTokyo = 10;
-const ExtraID kTSAGTArriveAtTokyo = 11;
-const ExtraID kTSA02NorthZoomIn = 12;
-const ExtraID kTSA02NorthTenSecondDoor = 13;
-const ExtraID kTSA02NorthZoomOut = 14;
-const ExtraID kTSA02NorthDoorWithAgent3 = 15;
-const ExtraID kTSA03JimenezZoomIn = 16;
-const ExtraID kTSA03JimenezSpeech = 17;
-const ExtraID kTSA03JimenezZoomOut = 18;
-const ExtraID kTSA03CrenshawZoomIn = 19;
-const ExtraID kTSA03CrenshawSpeech = 20;
-const ExtraID kTSA03CrenshawZoomOut = 21;
-const ExtraID kTSA03SouthRobotDeath = 22;
-const ExtraID kTSA04NorthRobotGreeting = 23;
-const ExtraID kTSA04MatsumotoZoomIn = 24;
-const ExtraID kTSA04MatsumotoSpeech = 25;
-const ExtraID kTSA04MatsumotoZoomOut = 26;
-const ExtraID kTSA04CastilleZoomIn = 27;
-const ExtraID kTSA04CastilleSpeech = 28;
-const ExtraID kTSA04CastilleZoomOut = 29;
-const ExtraID kTSA05SinclairZoomIn = 30;
-const ExtraID kTSA05SinclairSpeech = 31;
-const ExtraID kTSA05SinclairZoomOut = 32;
-const ExtraID kTSA05WhiteZoomIn = 33;
-const ExtraID kTSA05WhiteSpeech = 34;
-const ExtraID kTSA05WhiteZoomOut = 35;
-const ExtraID kTSA0AEastRobot = 36;
-const ExtraID kTSA0AWestRobot = 37;
-const ExtraID kTSA16NorthRobotDeath = 38;
-const ExtraID kTSA0BEastZoomIn = 39;
-const ExtraID kTSA0BEastZoomedView = 40;
-const ExtraID kTSA0BEastZoomOut = 41;
-const ExtraID kTSA0BEastTurnLeft = 42;
-const ExtraID kTSA0BComparisonStartup = 43;
-const ExtraID kTSA0BComparisonView0000 = 44;
-const ExtraID kTSA0BComparisonView0002 = 45;
-const ExtraID kTSA0BComparisonView0020 = 46;
-const ExtraID kTSA0BComparisonView0022 = 47;
-const ExtraID kTSA0BComparisonView0200 = 48;
-const ExtraID kTSA0BComparisonView0202 = 49;
-const ExtraID kTSA0BComparisonView0220 = 50;
-const ExtraID kTSA0BComparisonView0222 = 51;
-const ExtraID kTSA0BComparisonView2000 = 52;
-const ExtraID kTSA0BComparisonView2002 = 53;
-const ExtraID kTSA0BComparisonView2020 = 54;
-const ExtraID kTSA0BComparisonView2022 = 55;
-const ExtraID kTSA0BComparisonView2200 = 56;
-const ExtraID kTSA0BComparisonView2202 = 57;
-const ExtraID kTSA0BComparisonView2220 = 58;
-const ExtraID kTSA0BComparisonView2222 = 59;
-const ExtraID kTSA0BNoradComparisonView = 60;
-const ExtraID kTSA0BNoradUnaltered = 61;
-const ExtraID kTSA0BNoradAltered = 62;
-const ExtraID kTSA0BMarsComparisonView = 63;
-const ExtraID kTSA0BMarsUnaltered = 64;
-const ExtraID kTSA0BMarsAltered = 65;
-const ExtraID kTSA0BWSCComparisonView = 66;
-const ExtraID kTSA0BWSCUnaltered = 67;
-const ExtraID kTSA0BWSCAltered = 68;
-const ExtraID kTSA0BCaldoriaComparisonView = 69;
-const ExtraID kTSA0BCaldoriaUnaltered = 70;
-const ExtraID kTSA0BCaldoriaAltered = 71;
-const ExtraID kTSA0BNorthZoomIn = 72;
-const ExtraID kTSA0BNorthZoomedView = 73;
-const ExtraID kTSA0BNorthZoomOut = 74;
-const ExtraID kTSA0BNorthTurnLeft = 75;
-const ExtraID kTSA0BNorthTurnRight = 76;
-const ExtraID kTSA0BNorthHistLogOpen = 77;
-const ExtraID kTSA0BNorthHistLogClose = 78;
-const ExtraID kTSA0BNorthHistLogCloseWithLog = 79;
-const ExtraID kTSA0BNorthCantChangeHistory = 80;
-const ExtraID kTSA0BNorthYoureBusted = 81;
-const ExtraID kTSA0BNorthFinallyHappened = 82;
-const ExtraID kTSA0BShowRip1 = 83;
-const ExtraID kTSA0BNorthRipView1 = 84;
-const ExtraID kTSA0BShowRip2 = 85;
-const ExtraID kTSA0BShowGuardRobots = 86;
-const ExtraID kTSA0BAIInterruption = 87;
-const ExtraID kTSA0BRobotsToCommandCenter = 88;
-const ExtraID kTSA0BNorthRobotsAtCCView = 89;
-const ExtraID kTSA0BNorthRobotsAtRRView = 90;
-const ExtraID kTSA0BNorthRobotsAtFDView = 91;
-const ExtraID kTSA0BRobotsFromCommandCenterToReadyRoom = 92;
-const ExtraID kTSA0BRobotsFromReadyRoomToCommandCenter = 93;
-const ExtraID kTSA0BRobotsFromCommandCenterToFrontDoor = 94;
-const ExtraID kTSA0BRobotsFromFrontDoorToCommandCenter = 95;
-const ExtraID kTSA0BRobotsFromFrontDoorToReadyRoom = 96;
-const ExtraID kTSA0BRobotsFromReadyRoomToFrontDoor = 97;
-const ExtraID kTSA0BWestZoomIn = 98;
-const ExtraID kTSA0BWestZoomedView = 99;
-const ExtraID kTSA0BWestZoomOut = 100;
-const ExtraID kTSA0BWestTurnRight = 101;
-const ExtraID kTSA0BTBPTheoryHighlight = 102;
-const ExtraID kTSA0BTBPBackgroundHighlight = 103;
-const ExtraID kTSA0BTBPProcedureHighlight = 104;
-const ExtraID kTSA0BTBPTheory = 105;
-const ExtraID kTSA0BTBPBackground = 106;
-const ExtraID kTSA0BTBPProcedure = 107;
-const ExtraID kTSA0BRipAlarmScreen = 108;
-const ExtraID kTSA22RedEastZoomInSequence = 109;
-const ExtraID kTSA22RedEastVaultViewWithKey = 110;
-const ExtraID kTSA22RedEastVaultViewNoKey = 111;
-const ExtraID kTSA23RedWestVaultZoomInSequence = 112;
-const ExtraID kTSA23RedWestVaultViewWithChips = 113;
-const ExtraID kTSA23RedWestVaultViewNoChips = 114;
-const ExtraID kTSA25NorthDeniedNoKey = 115;
-const ExtraID kTSA25NorthDeniedNoChip = 116;
-const ExtraID kTSA25NorthPutOnSuit = 117;
-const ExtraID kTSA25NorthAlreadyHaveSuit = 118;
-const ExtraID kTSA25NorthDescending1 = 119;
-const ExtraID kTSA25NorthDescending2 = 120;
-const ExtraID kTSA37HorseToAI1 = 121;
-const ExtraID kTSA37PegasusAI1 = 122;
-const ExtraID kTSA37AI1ToCommissioner1 = 123;
-const ExtraID kTSA37Commissioner1 = 124;
-const ExtraID kTSA37Commissioner1ToZoom = 125;
-const ExtraID kTSA37ZoomToPrehistoric = 126;
-const ExtraID kTSA37PrehistoricToAI2 = 127;
-const ExtraID kTSA37PegasusAI2 = 128;
-const ExtraID kTSA37AI2ToPrehistoric = 129;
-const ExtraID kTSA37PrehistoricToDepart = 130;
-const ExtraID kTSA37PegasusDepart = 131;
-const ExtraID kTSA37TimeJumpToPegasus = 132;
-const ExtraID kTSA37RecallToDownload = 133;
-const ExtraID kTSA37DownloadToColonel1 = 134;
-const ExtraID kTSA37Colonel1 = 135;
-const ExtraID kTSA37Colonel1ToReviewRequired = 136;
-const ExtraID kTSA37ReviewRequiredToExit = 137;
-const ExtraID kTSA37ExitHilited = 138;
-const ExtraID kTSA37ExitToHorse = 139;
-const ExtraID kTSA37HorseToColonel2 = 140;
-const ExtraID kTSA37Colonel2 = 141;
-const ExtraID kTSA37PegasusAI3 = 142;
-const ExtraID kTSA37AI3ToHorse = 143;
-const ExtraID kTSA37HorseToZoom = 144;
-const ExtraID kTSA37ZoomToMainMenu = 145;
-const ExtraID kTSA37MainMenuToAI4 = 146;
-const ExtraID kTSA37PegasusAI4 = 147;
-const ExtraID kTSA37AI4ToMainMenu = 148;
-const ExtraID kTSA37JumpMenu000 = 149;
-const ExtraID kTSA37JumpMenu001 = 150;
-const ExtraID kTSA37JumpMenu010 = 151;
-const ExtraID kTSA37JumpMenu011 = 152;
-const ExtraID kTSA37JumpMenu100 = 153;
-const ExtraID kTSA37JumpMenu101 = 154;
-const ExtraID kTSA37JumpMenu110 = 155;
-const ExtraID kTSA37JumpMenu111 = 156;
-const ExtraID kTSA37JumpToWSCMenu = 157;
-const ExtraID kTSA37CancelWSC = 158;
-const ExtraID kTSA37JumpToWSC = 159;
-const ExtraID kTSA37WSCToAI5 = 160;
-const ExtraID kTSA37PegasusAI5 = 161;
-const ExtraID kTSA37AI5ToWSC = 162;
-const ExtraID kTSA37WSCToDepart = 163;
-const ExtraID kTSA37JumpToMarsMenu = 164;
-const ExtraID kTSA37CancelMars = 165;
-const ExtraID kTSA37JumpToMars = 166;
-const ExtraID kTSA37MarsToAI6 = 167;
-const ExtraID kTSA37PegasusAI6 = 168;
-const ExtraID kTSA37AI6ToMars = 169;
-const ExtraID kTSA37MarsToDepart = 170;
-const ExtraID kTSA37JumpToNoradMenu = 171;
-const ExtraID kTSA37CancelNorad = 172;
-const ExtraID kTSA37JumpToNorad = 173;
-const ExtraID kTSA37NoradToAI7 = 174;
-const ExtraID kTSA37PegasusAI7 = 175;
-const ExtraID kTSA37AI7ToNorad = 176;
-const ExtraID kTSA37NoradToDepart = 177;
-const ExtraID kTSA37EnvironmentalScan = 178;
-const ExtraID kTSA37DownloadToMainMenu = 179;
-const ExtraID kTSA37DownloadToOpMemReview = 180;
-const ExtraID kTSA37OpMemReviewToMainMenu = 181;
-const ExtraID kTSA37OpMemReviewToAllClear = 182;
-const ExtraID kTSA37AllClearToCongratulations = 183;
-const ExtraID kTSA37Congratulations = 184;
-const ExtraID kTSA37CongratulationsToExit = 185;
+static const ExtraID kTSATransporterArrowLoop = 0;
+static const ExtraID kTSAArriveFromCaldoria = 1;
+static const ExtraID kTSAGTOtherChoice = 2;
+static const ExtraID kTSAGTCardSwipe = 3;
+static const ExtraID kTSAGTSelectCaldoria = 4;
+static const ExtraID kTSAGTGoToCaldoria = 5;
+static const ExtraID kTSAGTSelectBeach = 6;
+static const ExtraID kTSAGTGoToBeach = 7;
+static const ExtraID kTSAGTArriveAtBeach = 8;
+static const ExtraID kTSAGTSelectTokyo = 9;
+static const ExtraID kTSAGTGoToTokyo = 10;
+static const ExtraID kTSAGTArriveAtTokyo = 11;
+static const ExtraID kTSA02NorthZoomIn = 12;
+static const ExtraID kTSA02NorthTenSecondDoor = 13;
+static const ExtraID kTSA02NorthZoomOut = 14;
+static const ExtraID kTSA02NorthDoorWithAgent3 = 15;
+static const ExtraID kTSA03JimenezZoomIn = 16;
+static const ExtraID kTSA03JimenezSpeech = 17;
+static const ExtraID kTSA03JimenezZoomOut = 18;
+static const ExtraID kTSA03CrenshawZoomIn = 19;
+static const ExtraID kTSA03CrenshawSpeech = 20;
+static const ExtraID kTSA03CrenshawZoomOut = 21;
+static const ExtraID kTSA03SouthRobotDeath = 22;
+static const ExtraID kTSA04NorthRobotGreeting = 23;
+static const ExtraID kTSA04MatsumotoZoomIn = 24;
+static const ExtraID kTSA04MatsumotoSpeech = 25;
+static const ExtraID kTSA04MatsumotoZoomOut = 26;
+static const ExtraID kTSA04CastilleZoomIn = 27;
+static const ExtraID kTSA04CastilleSpeech = 28;
+static const ExtraID kTSA04CastilleZoomOut = 29;
+static const ExtraID kTSA05SinclairZoomIn = 30;
+static const ExtraID kTSA05SinclairSpeech = 31;
+static const ExtraID kTSA05SinclairZoomOut = 32;
+static const ExtraID kTSA05WhiteZoomIn = 33;
+static const ExtraID kTSA05WhiteSpeech = 34;
+static const ExtraID kTSA05WhiteZoomOut = 35;
+static const ExtraID kTSA0AEastRobot = 36;
+static const ExtraID kTSA0AWestRobot = 37;
+static const ExtraID kTSA16NorthRobotDeath = 38;
+static const ExtraID kTSA0BEastZoomIn = 39;
+static const ExtraID kTSA0BEastZoomedView = 40;
+static const ExtraID kTSA0BEastZoomOut = 41;
+static const ExtraID kTSA0BEastTurnLeft = 42;
+static const ExtraID kTSA0BComparisonStartup = 43;
+static const ExtraID kTSA0BComparisonView0000 = 44;
+static const ExtraID kTSA0BComparisonView0002 = 45;
+static const ExtraID kTSA0BComparisonView0020 = 46;
+static const ExtraID kTSA0BComparisonView0022 = 47;
+static const ExtraID kTSA0BComparisonView0200 = 48;
+static const ExtraID kTSA0BComparisonView0202 = 49;
+static const ExtraID kTSA0BComparisonView0220 = 50;
+static const ExtraID kTSA0BComparisonView0222 = 51;
+static const ExtraID kTSA0BComparisonView2000 = 52;
+static const ExtraID kTSA0BComparisonView2002 = 53;
+static const ExtraID kTSA0BComparisonView2020 = 54;
+static const ExtraID kTSA0BComparisonView2022 = 55;
+static const ExtraID kTSA0BComparisonView2200 = 56;
+static const ExtraID kTSA0BComparisonView2202 = 57;
+static const ExtraID kTSA0BComparisonView2220 = 58;
+static const ExtraID kTSA0BComparisonView2222 = 59;
+static const ExtraID kTSA0BNoradComparisonView = 60;
+static const ExtraID kTSA0BNoradUnaltered = 61;
+static const ExtraID kTSA0BNoradAltered = 62;
+static const ExtraID kTSA0BMarsComparisonView = 63;
+static const ExtraID kTSA0BMarsUnaltered = 64;
+static const ExtraID kTSA0BMarsAltered = 65;
+static const ExtraID kTSA0BWSCComparisonView = 66;
+static const ExtraID kTSA0BWSCUnaltered = 67;
+static const ExtraID kTSA0BWSCAltered = 68;
+static const ExtraID kTSA0BCaldoriaComparisonView = 69;
+static const ExtraID kTSA0BCaldoriaUnaltered = 70;
+static const ExtraID kTSA0BCaldoriaAltered = 71;
+static const ExtraID kTSA0BNorthZoomIn = 72;
+static const ExtraID kTSA0BNorthZoomedView = 73;
+static const ExtraID kTSA0BNorthZoomOut = 74;
+static const ExtraID kTSA0BNorthTurnLeft = 75;
+static const ExtraID kTSA0BNorthTurnRight = 76;
+static const ExtraID kTSA0BNorthHistLogOpen = 77;
+static const ExtraID kTSA0BNorthHistLogClose = 78;
+static const ExtraID kTSA0BNorthHistLogCloseWithLog = 79;
+static const ExtraID kTSA0BNorthCantChangeHistory = 80;
+static const ExtraID kTSA0BNorthYoureBusted = 81;
+static const ExtraID kTSA0BNorthFinallyHappened = 82;
+static const ExtraID kTSA0BShowRip1 = 83;
+static const ExtraID kTSA0BNorthRipView1 = 84;
+static const ExtraID kTSA0BShowRip2 = 85;
+static const ExtraID kTSA0BShowGuardRobots = 86;
+static const ExtraID kTSA0BAIInterruption = 87;
+static const ExtraID kTSA0BRobotsToCommandCenter = 88;
+static const ExtraID kTSA0BNorthRobotsAtCCView = 89;
+static const ExtraID kTSA0BNorthRobotsAtRRView = 90;
+static const ExtraID kTSA0BNorthRobotsAtFDView = 91;
+static const ExtraID kTSA0BRobotsFromCommandCenterToReadyRoom = 92;
+static const ExtraID kTSA0BRobotsFromReadyRoomToCommandCenter = 93;
+static const ExtraID kTSA0BRobotsFromCommandCenterToFrontDoor = 94;
+static const ExtraID kTSA0BRobotsFromFrontDoorToCommandCenter = 95;
+static const ExtraID kTSA0BRobotsFromFrontDoorToReadyRoom = 96;
+static const ExtraID kTSA0BRobotsFromReadyRoomToFrontDoor = 97;
+static const ExtraID kTSA0BWestZoomIn = 98;
+static const ExtraID kTSA0BWestZoomedView = 99;
+static const ExtraID kTSA0BWestZoomOut = 100;
+static const ExtraID kTSA0BWestTurnRight = 101;
+static const ExtraID kTSA0BTBPTheoryHighlight = 102;
+static const ExtraID kTSA0BTBPBackgroundHighlight = 103;
+static const ExtraID kTSA0BTBPProcedureHighlight = 104;
+static const ExtraID kTSA0BTBPTheory = 105;
+static const ExtraID kTSA0BTBPBackground = 106;
+static const ExtraID kTSA0BTBPProcedure = 107;
+static const ExtraID kTSA0BRipAlarmScreen = 108;
+static const ExtraID kTSA22RedEastZoomInSequence = 109;
+static const ExtraID kTSA22RedEastVaultViewWithKey = 110;
+static const ExtraID kTSA22RedEastVaultViewNoKey = 111;
+static const ExtraID kTSA23RedWestVaultZoomInSequence = 112;
+static const ExtraID kTSA23RedWestVaultViewWithChips = 113;
+static const ExtraID kTSA23RedWestVaultViewNoChips = 114;
+static const ExtraID kTSA25NorthDeniedNoKey = 115;
+static const ExtraID kTSA25NorthDeniedNoChip = 116;
+static const ExtraID kTSA25NorthPutOnSuit = 117;
+static const ExtraID kTSA25NorthAlreadyHaveSuit = 118;
+static const ExtraID kTSA25NorthDescending1 = 119;
+static const ExtraID kTSA25NorthDescending2 = 120;
+static const ExtraID kTSA37HorseToAI1 = 121;
+static const ExtraID kTSA37PegasusAI1 = 122;
+static const ExtraID kTSA37AI1ToCommissioner1 = 123;
+static const ExtraID kTSA37Commissioner1 = 124;
+static const ExtraID kTSA37Commissioner1ToZoom = 125;
+static const ExtraID kTSA37ZoomToPrehistoric = 126;
+static const ExtraID kTSA37PrehistoricToAI2 = 127;
+static const ExtraID kTSA37PegasusAI2 = 128;
+static const ExtraID kTSA37AI2ToPrehistoric = 129;
+static const ExtraID kTSA37PrehistoricToDepart = 130;
+static const ExtraID kTSA37PegasusDepart = 131;
+static const ExtraID kTSA37TimeJumpToPegasus = 132;
+static const ExtraID kTSA37RecallToDownload = 133;
+static const ExtraID kTSA37DownloadToColonel1 = 134;
+static const ExtraID kTSA37Colonel1 = 135;
+static const ExtraID kTSA37Colonel1ToReviewRequired = 136;
+static const ExtraID kTSA37ReviewRequiredToExit = 137;
+static const ExtraID kTSA37ExitHilited = 138;
+static const ExtraID kTSA37ExitToHorse = 139;
+static const ExtraID kTSA37HorseToColonel2 = 140;
+static const ExtraID kTSA37Colonel2 = 141;
+static const ExtraID kTSA37PegasusAI3 = 142;
+static const ExtraID kTSA37AI3ToHorse = 143;
+static const ExtraID kTSA37HorseToZoom = 144;
+static const ExtraID kTSA37ZoomToMainMenu = 145;
+static const ExtraID kTSA37MainMenuToAI4 = 146;
+static const ExtraID kTSA37PegasusAI4 = 147;
+static const ExtraID kTSA37AI4ToMainMenu = 148;
+static const ExtraID kTSA37JumpMenu000 = 149;
+static const ExtraID kTSA37JumpMenu001 = 150;
+static const ExtraID kTSA37JumpMenu010 = 151;
+static const ExtraID kTSA37JumpMenu011 = 152;
+static const ExtraID kTSA37JumpMenu100 = 153;
+static const ExtraID kTSA37JumpMenu101 = 154;
+static const ExtraID kTSA37JumpMenu110 = 155;
+static const ExtraID kTSA37JumpMenu111 = 156;
+static const ExtraID kTSA37JumpToWSCMenu = 157;
+static const ExtraID kTSA37CancelWSC = 158;
+static const ExtraID kTSA37JumpToWSC = 159;
+static const ExtraID kTSA37WSCToAI5 = 160;
+static const ExtraID kTSA37PegasusAI5 = 161;
+static const ExtraID kTSA37AI5ToWSC = 162;
+static const ExtraID kTSA37WSCToDepart = 163;
+static const ExtraID kTSA37JumpToMarsMenu = 164;
+static const ExtraID kTSA37CancelMars = 165;
+static const ExtraID kTSA37JumpToMars = 166;
+static const ExtraID kTSA37MarsToAI6 = 167;
+static const ExtraID kTSA37PegasusAI6 = 168;
+static const ExtraID kTSA37AI6ToMars = 169;
+static const ExtraID kTSA37MarsToDepart = 170;
+static const ExtraID kTSA37JumpToNoradMenu = 171;
+static const ExtraID kTSA37CancelNorad = 172;
+static const ExtraID kTSA37JumpToNorad = 173;
+static const ExtraID kTSA37NoradToAI7 = 174;
+static const ExtraID kTSA37PegasusAI7 = 175;
+static const ExtraID kTSA37AI7ToNorad = 176;
+static const ExtraID kTSA37NoradToDepart = 177;
+static const ExtraID kTSA37EnvironmentalScan = 178;
+static const ExtraID kTSA37DownloadToMainMenu = 179;
+static const ExtraID kTSA37DownloadToOpMemReview = 180;
+static const ExtraID kTSA37OpMemReviewToMainMenu = 181;
+static const ExtraID kTSA37OpMemReviewToAllClear = 182;
+static const ExtraID kTSA37AllClearToCongratulations = 183;
+static const ExtraID kTSA37Congratulations = 184;
+static const ExtraID kTSA37CongratulationsToExit = 185;
 
 const DisplayOrder kRipTimerOrder = kMonitorLayer;
 
@@ -495,31 +495,31 @@ const CoordType kRedirectionNewTargetTop = kNavAreaTop + 166;
 const CoordType kRedirectionCloseLeft = kNavAreaLeft + 56;
 const CoordType kRedirectionCloseTop = kNavAreaTop + 220;
 
-const TimeValue kTSABumpIntoWallIn = 0;
-const TimeValue kTSABumpIntoWallOut = 148;
+static const TimeValue kTSABumpIntoWallIn = 0;
+static const TimeValue kTSABumpIntoWallOut = 148;
 
-const TimeValue kTSAGTDoorCloseIn = 148;
-const TimeValue kTSAGTDoorCloseOut = 1570;
+static const TimeValue kTSAGTDoorCloseIn = 148;
+static const TimeValue kTSAGTDoorCloseOut = 1570;
 
-const TimeValue kTSANoOtherDestinationIn = 1570;
-const TimeValue kTSANoOtherDestinationOut = 3601;
+static const TimeValue kTSANoOtherDestinationIn = 1570;
+static const TimeValue kTSANoOtherDestinationOut = 3601;
 
-const TimeValue kTSAEntryDoorCloseIn = 3601;
-const TimeValue kTSAEntryDoorCloseOut = 4200;
+static const TimeValue kTSAEntryDoorCloseIn = 3601;
+static const TimeValue kTSAEntryDoorCloseOut = 4200;
 
-const TimeValue kTSAInsideDoorCloseIn = 4200;
-const TimeValue kTSAInsideDoorCloseOut = 4800;
+static const TimeValue kTSAInsideDoorCloseIn = 4200;
+static const TimeValue kTSAInsideDoorCloseOut = 4800;
 
-const TimeValue kTSAVaultCloseIn = 4800;
-const TimeValue kTSAVaultCloseOut = 5388;
+static const TimeValue kTSAVaultCloseIn = 4800;
+static const TimeValue kTSAVaultCloseOut = 5388;
 
-const TimeValue kTSAPegasusDoorCloseIn = 5388;
-const TimeValue kTSAPegasusDoorCloseOut = 6457;
+static const TimeValue kTSAPegasusDoorCloseIn = 5388;
+static const TimeValue kTSAPegasusDoorCloseOut = 6457;
 
-const bool kPegasusUnresolved = false;
-const bool kPegasusResolved = true;
-const bool kPegasusCantExit = false;
-const bool kPegasusCanExit = true;
+static const bool kPegasusUnresolved = false;
+static const bool kPegasusResolved = true;
+static const bool kPegasusCantExit = false;
+static const bool kPegasusCanExit = true;
 
 // Monitor modes
 enum {
@@ -582,15 +582,15 @@ static const ExtraID s_historicalLogViews[16] = {
 	kTSA0BComparisonView2222
 };
 
-const long kRedirectionCCRolloverSprite = 0;
-const long kRedirectionRRRolloverSprite = 1;
-const long kRedirectionFDRolloverSprite = 2;
-const long kRedirectionCCDoorSprite = 3;
-const long kRedirectionRRDoorSprite = 4;
-const long kRedirectionFDDoorSprite = 5;
-const long kRedirectionCloseSprite = 6;
-const long kRedirectionSecuredSprite = 0;
-const long kRedirectionNewTargetSprite = 1;
+static const int kRedirectionCCRolloverSprite = 0;
+static const int kRedirectionRRRolloverSprite = 1;
+static const int kRedirectionFDRolloverSprite = 2;
+static const int kRedirectionCCDoorSprite = 3;
+static const int kRedirectionRRDoorSprite = 4;
+static const int kRedirectionFDDoorSprite = 5;
+static const int kRedirectionCloseSprite = 6;
+static const int kRedirectionSecuredSprite = 0;
+static const int kRedirectionNewTargetSprite = 1;
 
 void RipTimer::initImage() {
 	_middle = -1;
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
index cc0ce62..0a3f8a2 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.h
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.h
@@ -49,9 +49,9 @@ protected:
 
 //	Room IDs.
 
-const RoomID kTSA00 = 0;
-const RoomID kTSA22Red = 28;
-const RoomID kTSA37 = 42;
+static const RoomID kTSA00 = 0;
+static const RoomID kTSA22Red = 28;
+static const RoomID kTSA37 = 42;
 
 class FullTSA : public Neighborhood {
 friend void uncreatedInTSAFunction(FunctionPtr *, void *tsa);
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
index 823aa17..2fa6c53 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
@@ -36,73 +36,73 @@
 
 namespace Pegasus {
 
-const short kCompassShift = 30;
+static const int16 kCompassShift = 30;
 
-const TimeScale kTinyTSAMovieScale = 600;
-const TimeScale kTinyTSAFramesPerSecond = 15;
-const TimeScale kTinyTSAFrameDuration = 40;
+static const TimeScale kTinyTSAMovieScale = 600;
+static const TimeScale kTinyTSAFramesPerSecond = 15;
+static const TimeScale kTinyTSAFrameDuration = 40;
 
 // Alternate IDs.
-const AlternateID kAltTinyTSANormal = 0;
+static const AlternateID kAltTinyTSANormal = 0;
 
 // Hot Spot Activation IDs.
-const HotSpotActivationID kActivationTinyTSAJumpToNorad = 1;
-const HotSpotActivationID kActivationTinyTSAJumpToMars = 2;
-const HotSpotActivationID kActivationTinyTSAJumpToWSC = 3;
-const HotSpotActivationID kActivationTinyTSAReadyForJumpMenu = 4;
-const HotSpotActivationID kActivationTinyTSAMainJumpMenu = 5;
+static const HotSpotActivationID kActivationTinyTSAJumpToNorad = 1;
+static const HotSpotActivationID kActivationTinyTSAJumpToMars = 2;
+static const HotSpotActivationID kActivationTinyTSAJumpToWSC = 3;
+static const HotSpotActivationID kActivationTinyTSAReadyForJumpMenu = 4;
+static const HotSpotActivationID kActivationTinyTSAMainJumpMenu = 5;
 
 // Hot Spot IDs.
-const HotSpotID kTinyTSA37NorthJumpToNoradSpotID = 5000;
-const HotSpotID kTinyTSA37NorthCancelNoradSpotID = 5001;
-const HotSpotID kTinyTSA37NorthJumpToMarsSpotID = 5002;
-const HotSpotID kTinyTSA37NorthCancelMarsSpotID = 5003;
-const HotSpotID kTinyTSA37NorthJumpToWSCSpotID = 5004;
-const HotSpotID kTinyTSA37NorthCancelWSCSpotID = 5005;
-const HotSpotID kTinyTSA37NorthJumpMenuSpotID = 5006;
-const HotSpotID kTinyTSA37NorthNoradMenuSpotID = 5007;
-const HotSpotID kTinyTSA37NorthMarsMenuSpotID = 5008;
-const HotSpotID kTinyTSA37NorthWSCMenuSpotID = 5009;
+static const HotSpotID kTinyTSA37NorthJumpToNoradSpotID = 5000;
+static const HotSpotID kTinyTSA37NorthCancelNoradSpotID = 5001;
+static const HotSpotID kTinyTSA37NorthJumpToMarsSpotID = 5002;
+static const HotSpotID kTinyTSA37NorthCancelMarsSpotID = 5003;
+static const HotSpotID kTinyTSA37NorthJumpToWSCSpotID = 5004;
+static const HotSpotID kTinyTSA37NorthCancelWSCSpotID = 5005;
+static const HotSpotID kTinyTSA37NorthJumpMenuSpotID = 5006;
+static const HotSpotID kTinyTSA37NorthNoradMenuSpotID = 5007;
+static const HotSpotID kTinyTSA37NorthMarsMenuSpotID = 5008;
+static const HotSpotID kTinyTSA37NorthWSCMenuSpotID = 5009;
 
 // Extra sequence IDs.
-const ExtraID kTinyTSA37PegasusDepart = 0;
-const ExtraID kTinyTSA37TimeJumpToPegasus = 1;
-const ExtraID kTinyTSA37RecallToDownload = 2;
-const ExtraID kTinyTSA37ExitHilited = 3;
-const ExtraID kTinyTSA37ExitToHorse = 4;
-const ExtraID kTinyTSA37JumpMenu000 = 5;
-const ExtraID kTinyTSA37JumpMenu001 = 6;
-const ExtraID kTinyTSA37JumpMenu010 = 7;
-const ExtraID kTinyTSA37JumpMenu011 = 8;
-const ExtraID kTinyTSA37JumpMenu100 = 9;
-const ExtraID kTinyTSA37JumpMenu101 = 10;
-const ExtraID kTinyTSA37JumpMenu110 = 11;
-const ExtraID kTinyTSA37JumpMenu111 = 12;
-const ExtraID kTinyTSA37JumpToWSCMenu = 13;
-const ExtraID kTinyTSA37CancelWSC = 14;
-const ExtraID kTinyTSA37JumpToWSC = 15;
-const ExtraID kTinyTSA37WSCToAI5 = 16;
-const ExtraID kTinyTSA37PegasusAI5 = 17;
-const ExtraID kTinyTSA37AI5ToWSC = 18;
-const ExtraID kTinyTSA37WSCToDepart = 19;
-const ExtraID kTinyTSA37JumpToMarsMenu = 20;
-const ExtraID kTinyTSA37CancelMars = 21;
-const ExtraID kTinyTSA37JumpToMars = 22;
-const ExtraID kTinyTSA37MarsToAI6 = 23;
-const ExtraID kTinyTSA37PegasusAI6 = 24;
-const ExtraID kTinyTSA37AI6ToMars = 25;
-const ExtraID kTinyTSA37MarsToDepart = 26;
-const ExtraID kTinyTSA37JumpToNoradMenu = 27;
-const ExtraID kTinyTSA37CancelNorad = 28;
-const ExtraID kTinyTSA37JumpToNorad = 29;
-const ExtraID kTinyTSA37NoradToAI7 = 30;
-const ExtraID kTinyTSA37PegasusAI7 = 31;
-const ExtraID kTinyTSA37AI7ToNorad = 32;
-const ExtraID kTinyTSA37NoradToDepart = 33;
-const ExtraID kTinyTSA37EnvironmentalScan = 34;
-const ExtraID kTinyTSA37DownloadToMainMenu = 35;
-const ExtraID kTinyTSA37DownloadToOpMemReview = 36;
-const ExtraID kTinyTSA37OpMemReviewToMainMenu = 37;
+static const ExtraID kTinyTSA37PegasusDepart = 0;
+static const ExtraID kTinyTSA37TimeJumpToPegasus = 1;
+static const ExtraID kTinyTSA37RecallToDownload = 2;
+static const ExtraID kTinyTSA37ExitHilited = 3;
+static const ExtraID kTinyTSA37ExitToHorse = 4;
+static const ExtraID kTinyTSA37JumpMenu000 = 5;
+static const ExtraID kTinyTSA37JumpMenu001 = 6;
+static const ExtraID kTinyTSA37JumpMenu010 = 7;
+static const ExtraID kTinyTSA37JumpMenu011 = 8;
+static const ExtraID kTinyTSA37JumpMenu100 = 9;
+static const ExtraID kTinyTSA37JumpMenu101 = 10;
+static const ExtraID kTinyTSA37JumpMenu110 = 11;
+static const ExtraID kTinyTSA37JumpMenu111 = 12;
+static const ExtraID kTinyTSA37JumpToWSCMenu = 13;
+static const ExtraID kTinyTSA37CancelWSC = 14;
+static const ExtraID kTinyTSA37JumpToWSC = 15;
+static const ExtraID kTinyTSA37WSCToAI5 = 16;
+static const ExtraID kTinyTSA37PegasusAI5 = 17;
+static const ExtraID kTinyTSA37AI5ToWSC = 18;
+static const ExtraID kTinyTSA37WSCToDepart = 19;
+static const ExtraID kTinyTSA37JumpToMarsMenu = 20;
+static const ExtraID kTinyTSA37CancelMars = 21;
+static const ExtraID kTinyTSA37JumpToMars = 22;
+static const ExtraID kTinyTSA37MarsToAI6 = 23;
+static const ExtraID kTinyTSA37PegasusAI6 = 24;
+static const ExtraID kTinyTSA37AI6ToMars = 25;
+static const ExtraID kTinyTSA37MarsToDepart = 26;
+static const ExtraID kTinyTSA37JumpToNoradMenu = 27;
+static const ExtraID kTinyTSA37CancelNorad = 28;
+static const ExtraID kTinyTSA37JumpToNorad = 29;
+static const ExtraID kTinyTSA37NoradToAI7 = 30;
+static const ExtraID kTinyTSA37PegasusAI7 = 31;
+static const ExtraID kTinyTSA37AI7ToNorad = 32;
+static const ExtraID kTinyTSA37NoradToDepart = 33;
+static const ExtraID kTinyTSA37EnvironmentalScan = 34;
+static const ExtraID kTinyTSA37DownloadToMainMenu = 35;
+static const ExtraID kTinyTSA37DownloadToOpMemReview = 36;
+static const ExtraID kTinyTSA37OpMemReviewToMainMenu = 37;
 
 TinyTSA::TinyTSA(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Tiny TSA", kTinyTSAID) {
 }
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.h b/engines/pegasus/neighborhood/tsa/tinytsa.h
index d7dee7f..db74206 100755
--- a/engines/pegasus/neighborhood/tsa/tinytsa.h
+++ b/engines/pegasus/neighborhood/tsa/tinytsa.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 //	Room IDs.
 
-const RoomID kTinyTSA37 = 0;
+static const RoomID kTinyTSA37 = 0;
 
 class TinyTSA : public Neighborhood {
 public:
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index 6bc3a85..1f00999 100755
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -33,15 +33,15 @@
 
 namespace Pegasus {
 
-const CanMoveForwardReason kCantMoveWatchingDiagnosis = kCantMoveLastReason + 1;
+static const CanMoveForwardReason kCantMoveWatchingDiagnosis = kCantMoveLastReason + 1;
 
-const CanTurnReason kCantTurnWatchingDiagnosis = kCantTurnLastReason + 1;
-const CanTurnReason kCantTurnWatchingAnalysis = kCantTurnWatchingDiagnosis + 1;
-const CanTurnReason kCantTurnInMoleculeGame = kCantTurnWatchingAnalysis + 1;
+static const CanTurnReason kCantTurnWatchingDiagnosis = kCantTurnLastReason + 1;
+static const CanTurnReason kCantTurnWatchingAnalysis = kCantTurnWatchingDiagnosis + 1;
+static const CanTurnReason kCantTurnInMoleculeGame = kCantTurnWatchingAnalysis + 1;
 
-const TimeScale kMoleculesMovieScale = 600;
-const TimeValue kMoleculeLoopTime = 4 * kMoleculesMovieScale;
-const TimeValue kMoleculeFailTime = 2 * kMoleculesMovieScale;
+static const TimeScale kMoleculesMovieScale = 600;
+static const TimeValue kMoleculeLoopTime = 4 * kMoleculesMovieScale;
+static const TimeValue kMoleculeFailTime = 2 * kMoleculesMovieScale;
 
 enum {
 	kMoleculeLoop0Time = 0,
@@ -59,7 +59,7 @@ enum {
 	kMoleculeLoop6Time = kMoleculeFail5Time + kMoleculeFailTime
 };
 
-const TimeValue s_moleculeLoopTimes[] = {
+static const TimeValue s_moleculeLoopTimes[] = {
 	kMoleculeLoop0Time,
 	kMoleculeLoop1Time,
 	kMoleculeLoop2Time,
@@ -69,7 +69,7 @@ const TimeValue s_moleculeLoopTimes[] = {
 	kMoleculeLoop6Time
 };
 
-const TimeValue s_moleculeFailTimes[] = {
+static const TimeValue s_moleculeFailTimes[] = {
 	kMoleculeFail0Time,
 	kMoleculeFail1Time,
 	kMoleculeFail2Time,
@@ -78,399 +78,399 @@ const TimeValue s_moleculeFailTimes[] = {
 	kMoleculeFail5Time
 };
 
-const short kAuditoriumAngleOffset = 5;
+static const int16 kAuditoriumAngleOffset = 5;
 
-const long kPlasmaEnergyWithShield = kMaxJMPEnergy * 10 / 100;
-const long kPlasmaEnergyNoShield = kMaxJMPEnergy * 20 / 100;
+static const int kPlasmaEnergyWithShield = kMaxJMPEnergy * 10 / 100;
+static const int kPlasmaEnergyNoShield = kMaxJMPEnergy * 20 / 100;
 
-const long kTimerEventPlasmaHit = 0;
-const long kTimerEventPlayerGawkingAtRobot = 1;
-const long kTimerEventPlayerGawkingAtRobot2 = 2;
+static const int kTimerEventPlasmaHit = 0;
+static const int kTimerEventPlayerGawkingAtRobot = 1;
+static const int kTimerEventPlayerGawkingAtRobot2 = 2;
 
-const TimeValue kWSCMolecule1In = 0;
-const TimeValue kWSCMolecule1Out = 937;
+static const TimeValue kWSCMolecule1In = 0;
+static const TimeValue kWSCMolecule1Out = 937;
 
-const TimeValue kWSCMolecule2In = 937;
-const TimeValue kWSCMolecule2Out = 1864;
+static const TimeValue kWSCMolecule2In = 937;
+static const TimeValue kWSCMolecule2Out = 1864;
 
-const TimeValue kWSCMolecule3In = 1864;
-const TimeValue kWSCMolecule3Out = 2790;
+static const TimeValue kWSCMolecule3In = 1864;
+static const TimeValue kWSCMolecule3Out = 2790;
 
-const TimeValue kWSCClick1In = 2790;
-const TimeValue kWSCClick1Out = 2890;
+static const TimeValue kWSCClick1In = 2790;
+static const TimeValue kWSCClick1Out = 2890;
 
-const TimeValue kWSCClick2In = 2890;
-const TimeValue kWSCClick2Out = 3059;
+static const TimeValue kWSCClick2In = 2890;
+static const TimeValue kWSCClick2Out = 3059;
 
-const TimeValue kWSCClick3In = 3059;
-const TimeValue kWSCClick3Out = 3156;
+static const TimeValue kWSCClick3In = 3059;
+static const TimeValue kWSCClick3Out = 3156;
 
-const TimeValue kWSCFlashlightClickIn = 3156;
-const TimeValue kWSCFlashlightClickOut = 3211;
+static const TimeValue kWSCFlashlightClickIn = 3156;
+static const TimeValue kWSCFlashlightClickOut = 3211;
 
-const TimeValue kWSCBumpIntoWallIn = 3211;
-const TimeValue kWSCBumpIntoWallOut = 3514;
+static const TimeValue kWSCBumpIntoWallIn = 3211;
+static const TimeValue kWSCBumpIntoWallOut = 3514;
 
-const TimeValue kWSCCantTransportIn = 3514;
-const TimeValue kWSCCantTransportOut = 7791;
+static const TimeValue kWSCCantTransportIn = 3514;
+static const TimeValue kWSCCantTransportOut = 7791;
 
-const TimeValue kHernandezNotHomeIn = 7791;
-const TimeValue kHernandezNotHomeOut = 10199;
+static const TimeValue kHernandezNotHomeIn = 7791;
+static const TimeValue kHernandezNotHomeOut = 10199;
 
-const TimeValue kWashingtonNotHomeIn = 10199;
-const TimeValue kWashingtonNotHomeOut = 12649;
+static const TimeValue kWashingtonNotHomeIn = 10199;
+static const TimeValue kWashingtonNotHomeOut = 12649;
 
-const TimeValue kSullivanNotHomeIn = 12649;
-const TimeValue kSullivanNotHomeOut = 15031;
+static const TimeValue kSullivanNotHomeIn = 12649;
+static const TimeValue kSullivanNotHomeOut = 15031;
 
-const TimeValue kNakamuraNotHomeIn = 15031;
-const TimeValue kNakamuraNotHomeOut = 17545;
+static const TimeValue kNakamuraNotHomeIn = 15031;
+static const TimeValue kNakamuraNotHomeOut = 17545;
 
-const TimeValue kGrailisNotHomeIn = 17545;
-const TimeValue kGrailisNotHomeOut = 19937;
+static const TimeValue kGrailisNotHomeIn = 17545;
+static const TimeValue kGrailisNotHomeOut = 19937;
 
-const TimeValue kTheriaultNotHomeIn = 19937;
-const TimeValue kTheriaultNotHomeOut = 22395;
+static const TimeValue kTheriaultNotHomeIn = 19937;
+static const TimeValue kTheriaultNotHomeOut = 22395;
 
-const TimeValue kGlennerNotHomeIn = 22395;
-const TimeValue kGlennerNotHomeOut = 24770;
+static const TimeValue kGlennerNotHomeIn = 22395;
+static const TimeValue kGlennerNotHomeOut = 24770;
 
-const TimeValue kSinclairNotHomeIn = 24770;
-const TimeValue kSinclairNotHomeOut = 27328;
+static const TimeValue kSinclairNotHomeIn = 24770;
+static const TimeValue kSinclairNotHomeOut = 27328;
 
-const TimeValue kWSCLabClosedIn = 27328;
-const TimeValue kWSCLabClosedOut = 28904;
+static const TimeValue kWSCLabClosedIn = 27328;
+static const TimeValue kWSCLabClosedOut = 28904;
 
-const TimeValue kSlidingDoorCloseIn = 28904;
-const TimeValue kSlidingDoorCloseOut = 29295;
+static const TimeValue kSlidingDoorCloseIn = 28904;
+static const TimeValue kSlidingDoorCloseOut = 29295;
 
-const TimeValue kSlimyDoorCloseIn = 29295;
-const TimeValue kSlimyDoorCloseOut = 29788;
+static const TimeValue kSlimyDoorCloseIn = 29295;
+static const TimeValue kSlimyDoorCloseOut = 29788;
 
-const TimeValue kPaging1In = 29788;
-const TimeValue kPaging1Out = 32501;
+static const TimeValue kPaging1In = 29788;
+static const TimeValue kPaging1Out = 32501;
 
-const TimeValue kPaging2In = 32501;
-const TimeValue kPaging2Out = 34892;
+static const TimeValue kPaging2In = 32501;
+static const TimeValue kPaging2Out = 34892;
 
-const TimeValue kCheckInIn = 34892;
-const TimeValue kCheckInOut = 37789;
+static const TimeValue kCheckInIn = 34892;
+static const TimeValue kCheckInOut = 37789;
 
-const TimeValue kDrinkAntidoteIn = 37789;
-const TimeValue kDrinkAntidoteOut = 39725;
+static const TimeValue kDrinkAntidoteIn = 37789;
+static const TimeValue kDrinkAntidoteOut = 39725;
 
-const TimeScale kWSCMovieScale = 600;
-const TimeScale kWSCFramesPerSecond = 15;
-const TimeScale kWSCFrameDuration = 40;
+static const TimeScale kWSCMovieScale = 600;
+static const TimeScale kWSCFramesPerSecond = 15;
+static const TimeScale kWSCFrameDuration = 40;
 
 // Alternate IDs.
-const AlternateID kAltWSCNormal = 0;
-const AlternateID kAltWSCTookMachineGun = 1;
-const AlternateID kAltWSCW0ZDoorOpen = 2;
-const AlternateID kAltWSCPeopleAtW19North = 3;
+static const AlternateID kAltWSCNormal = 0;
+static const AlternateID kAltWSCTookMachineGun = 1;
+static const AlternateID kAltWSCW0ZDoorOpen = 2;
+static const AlternateID kAltWSCPeopleAtW19North = 3;
 
 // Room IDs.
-const RoomID kWSC02 = 1;
-const RoomID kWSC03 = 4;
-const RoomID kWSC04 = 5;
-const RoomID kWSC06 = 6;
-const RoomID kWSC07 = 7;
-const RoomID kWSC08 = 8;
-const RoomID kWSC09 = 9;
-const RoomID kWSC10 = 10;
-const RoomID kWSC11 = 11;
-const RoomID kWSC13 = 12;
-const RoomID kWSC14 = 13;
-const RoomID kWSC15 = 14;
-const RoomID kWSC16 = 15;
-const RoomID kWSC17 = 16;
-const RoomID kWSC18 = 17;
-const RoomID kWSC19 = 18;
-const RoomID kWSC20 = 19;
-const RoomID kWSC21 = 20;
-const RoomID kWSC22 = 21;
-const RoomID kWSC23 = 22;
-const RoomID kWSC24 = 23;
-const RoomID kWSC25 = 24;
-const RoomID kWSC26 = 25;
-const RoomID kWSC27 = 26;
-const RoomID kWSC28 = 27;
-const RoomID kWSC29 = 28;
-const RoomID kWSC31 = 29;
-const RoomID kWSC32 = 30;
-const RoomID kWSC33 = 31;
-const RoomID kWSC34 = 32;
-const RoomID kWSC35 = 33;
-const RoomID kWSC36 = 34;
-const RoomID kWSC37 = 35;
-const RoomID kWSC38 = 36;
-const RoomID kWSC39 = 37;
-const RoomID kWSC40 = 38;
-const RoomID kWSC41 = 39;
-const RoomID kWSC42 = 40;
-const RoomID kWSC43 = 41;
-const RoomID kWSC44 = 42;
-const RoomID kWSC45 = 43;
-const RoomID kWSC46 = 44;
-const RoomID kWSC47 = 45;
-const RoomID kWSC48 = 46;
-const RoomID kWSC49 = 47;
-const RoomID kWSC50 = 48;
-const RoomID kWSC52 = 49;
-const RoomID kWSC53 = 50;
-const RoomID kWSC54 = 51;
-const RoomID kWSC55 = 52;
-const RoomID kWSC56 = 53;
-const RoomID kWSC57 = 54;
-const RoomID kWSC58 = 55;
-const RoomID kWSC60 = 56;
-const RoomID kWSC60East = 57;
-const RoomID kWSC60North = 58;
-const RoomID kWSC61 = 59;
-const RoomID kWSC61South = 60;
-const RoomID kWSC61West = 61;
-const RoomID kWSC63 = 63;
-const RoomID kWSC64 = 64;
-const RoomID kWSC65 = 65;
-const RoomID kWSC65Screen = 66;
-const RoomID kWSC66 = 67;
-const RoomID kWSC67 = 68;
-const RoomID kWSC68 = 69;
-const RoomID kWSC69 = 70;
-const RoomID kWSC70 = 71;
-const RoomID kWSC71 = 72;
-const RoomID kWSC72 = 73;
-const RoomID kWSC73 = 74;
-const RoomID kWSC74 = 75;
-const RoomID kWSC75 = 76;
-const RoomID kWSC0Z = 77;
-const RoomID kWSC76 = 78;
-const RoomID kWSC77 = 79;
-const RoomID kWSC78 = 80;
-const RoomID kWSC79 = 81;
-const RoomID kWSC80 = 82;
-const RoomID kWSC81 = 83;
-const RoomID kWSC82 = 84;
-const RoomID kWSC83 = 85;
-const RoomID kWSC84 = 86;
-const RoomID kWSC85 = 87;
-const RoomID kWSC86 = 88;
-const RoomID kWSC87 = 89;
-const RoomID kWSC88 = 90;
-const RoomID kWSC89 = 91;
-const RoomID kWSC90 = 92;
-const RoomID kWSC91 = 93;
-const RoomID kWSC92 = 94;
-const RoomID kWSC93 = 95;
-const RoomID kWSC94 = 96;
-const RoomID kWSC95 = 97;
-const RoomID kWSC96 = 98;
-const RoomID kWSC97 = 99;
-const RoomID kWSC98 = 100;
-const RoomID kWSCDeathRoom = 101;
+static const RoomID kWSC02 = 1;
+static const RoomID kWSC03 = 4;
+static const RoomID kWSC04 = 5;
+static const RoomID kWSC06 = 6;
+static const RoomID kWSC07 = 7;
+static const RoomID kWSC08 = 8;
+static const RoomID kWSC09 = 9;
+static const RoomID kWSC10 = 10;
+static const RoomID kWSC11 = 11;
+static const RoomID kWSC13 = 12;
+static const RoomID kWSC14 = 13;
+static const RoomID kWSC15 = 14;
+static const RoomID kWSC16 = 15;
+static const RoomID kWSC17 = 16;
+static const RoomID kWSC18 = 17;
+static const RoomID kWSC19 = 18;
+static const RoomID kWSC20 = 19;
+static const RoomID kWSC21 = 20;
+static const RoomID kWSC22 = 21;
+static const RoomID kWSC23 = 22;
+static const RoomID kWSC24 = 23;
+static const RoomID kWSC25 = 24;
+static const RoomID kWSC26 = 25;
+static const RoomID kWSC27 = 26;
+static const RoomID kWSC28 = 27;
+static const RoomID kWSC29 = 28;
+static const RoomID kWSC31 = 29;
+static const RoomID kWSC32 = 30;
+static const RoomID kWSC33 = 31;
+static const RoomID kWSC34 = 32;
+static const RoomID kWSC35 = 33;
+static const RoomID kWSC36 = 34;
+static const RoomID kWSC37 = 35;
+static const RoomID kWSC38 = 36;
+static const RoomID kWSC39 = 37;
+static const RoomID kWSC40 = 38;
+static const RoomID kWSC41 = 39;
+static const RoomID kWSC42 = 40;
+static const RoomID kWSC43 = 41;
+static const RoomID kWSC44 = 42;
+static const RoomID kWSC45 = 43;
+static const RoomID kWSC46 = 44;
+static const RoomID kWSC47 = 45;
+static const RoomID kWSC48 = 46;
+static const RoomID kWSC49 = 47;
+static const RoomID kWSC50 = 48;
+static const RoomID kWSC52 = 49;
+static const RoomID kWSC53 = 50;
+static const RoomID kWSC54 = 51;
+static const RoomID kWSC55 = 52;
+static const RoomID kWSC56 = 53;
+static const RoomID kWSC57 = 54;
+static const RoomID kWSC58 = 55;
+static const RoomID kWSC60 = 56;
+static const RoomID kWSC60East = 57;
+static const RoomID kWSC60North = 58;
+static const RoomID kWSC61 = 59;
+static const RoomID kWSC61South = 60;
+static const RoomID kWSC61West = 61;
+static const RoomID kWSC63 = 63;
+static const RoomID kWSC64 = 64;
+static const RoomID kWSC65 = 65;
+static const RoomID kWSC65Screen = 66;
+static const RoomID kWSC66 = 67;
+static const RoomID kWSC67 = 68;
+static const RoomID kWSC68 = 69;
+static const RoomID kWSC69 = 70;
+static const RoomID kWSC70 = 71;
+static const RoomID kWSC71 = 72;
+static const RoomID kWSC72 = 73;
+static const RoomID kWSC73 = 74;
+static const RoomID kWSC74 = 75;
+static const RoomID kWSC75 = 76;
+static const RoomID kWSC0Z = 77;
+static const RoomID kWSC76 = 78;
+static const RoomID kWSC77 = 79;
+static const RoomID kWSC78 = 80;
+static const RoomID kWSC79 = 81;
+static const RoomID kWSC80 = 82;
+static const RoomID kWSC81 = 83;
+static const RoomID kWSC82 = 84;
+static const RoomID kWSC83 = 85;
+static const RoomID kWSC84 = 86;
+static const RoomID kWSC85 = 87;
+static const RoomID kWSC86 = 88;
+static const RoomID kWSC87 = 89;
+static const RoomID kWSC88 = 90;
+static const RoomID kWSC89 = 91;
+static const RoomID kWSC90 = 92;
+static const RoomID kWSC91 = 93;
+static const RoomID kWSC92 = 94;
+static const RoomID kWSC93 = 95;
+static const RoomID kWSC94 = 96;
+static const RoomID kWSC95 = 97;
+static const RoomID kWSC96 = 98;
+static const RoomID kWSC97 = 99;
+static const RoomID kWSC98 = 100;
+static const RoomID kWSCDeathRoom = 101;
 
 // Hot Spot Activation IDs.
-const HotSpotActivationID kActivationZoomedInToAnalyzer = 1;
-const HotSpotActivationID kActivationShotByRobot = 2;
-const HotSpotActivationID kActivationWarnedAboutPoison = 3;
-const HotSpotActivationID kActivationMorphScreenOff = 4;
-const HotSpotActivationID kActivationReadyForMorph = 5;
-const HotSpotActivationID kActivationMorphLooping = 6;
-const HotSpotActivationID kActivationMorphInterrupted = 7;
-const HotSpotActivationID kActivationW03NorthOff = 8;
-const HotSpotActivationID kActivationW03NorthReadyForInstructions = 9;
-const HotSpotActivationID kActivationW03NorthSawInstructions = 10;
-const HotSpotActivationID kActivationW03NorthInGame = 11;
-const HotSpotActivationID kActivationReadyForSynthesis = 12;
-const HotSpotActivationID kActivationSynthesizerLooping = 13;
-const HotSpotActivationID kActivationReadyForMap = 14;
-const HotSpotActivationID kActivationSinclairOfficeLocked = 15;
-const HotSpotActivationID kActivationW58SouthDoorLocked = 16;
-const HotSpotActivationID kActivationW61SouthOff = 17;
-const HotSpotActivationID kActivationW61SouthOn = 18;
-const HotSpotActivationID kActivationW61MessagesOff = 19;
-const HotSpotActivationID kActivationW61MessagesOn = 20;
-const HotSpotActivationID kActivationWSCRobotHeadOpen = 21;
-const HotSpotActivationID kActivationRobotTurning = 22;
-const HotSpotActivationID kActivationRobotDead = 23;
-const HotSpotActivationID kActivationRobotGone = 24;
+static const HotSpotActivationID kActivationZoomedInToAnalyzer = 1;
+static const HotSpotActivationID kActivationShotByRobot = 2;
+static const HotSpotActivationID kActivationWarnedAboutPoison = 3;
+static const HotSpotActivationID kActivationMorphScreenOff = 4;
+static const HotSpotActivationID kActivationReadyForMorph = 5;
+static const HotSpotActivationID kActivationMorphLooping = 6;
+static const HotSpotActivationID kActivationMorphInterrupted = 7;
+static const HotSpotActivationID kActivationW03NorthOff = 8;
+static const HotSpotActivationID kActivationW03NorthReadyForInstructions = 9;
+static const HotSpotActivationID kActivationW03NorthSawInstructions = 10;
+static const HotSpotActivationID kActivationW03NorthInGame = 11;
+static const HotSpotActivationID kActivationReadyForSynthesis = 12;
+static const HotSpotActivationID kActivationSynthesizerLooping = 13;
+static const HotSpotActivationID kActivationReadyForMap = 14;
+static const HotSpotActivationID kActivationSinclairOfficeLocked = 15;
+static const HotSpotActivationID kActivationW58SouthDoorLocked = 16;
+static const HotSpotActivationID kActivationW61SouthOff = 17;
+static const HotSpotActivationID kActivationW61SouthOn = 18;
+static const HotSpotActivationID kActivationW61MessagesOff = 19;
+static const HotSpotActivationID kActivationW61MessagesOn = 20;
+static const HotSpotActivationID kActivationWSCRobotHeadOpen = 21;
+static const HotSpotActivationID kActivationRobotTurning = 22;
+static const HotSpotActivationID kActivationRobotDead = 23;
+static const HotSpotActivationID kActivationRobotGone = 24;
 
 // Hot Spot IDs.
-const HotSpotID kWSCDropDartSpotID = 5000;
-const HotSpotID kWSCTurnOnAnalyzerSpotID = 5001;
-const HotSpotID kWSCAnalyzerScreenSpotID = 5002;
-const HotSpotID kWSCSpinRobotSpotID = 5003;
-const HotSpotID kWSC01YesSpotID = 5004;
-const HotSpotID kWSC01NoSpotID = 5005;
-const HotSpotID kWSC01AcknowledgeWarningSpotID = 5006;
-const HotSpotID kWSC02SouthMorphSpotID = 5007;
-const HotSpotID kWSC02SouthMessagesSpotID = 5008;
-const HotSpotID kWSC02SouthMorphOutSpotID = 5009;
-const HotSpotID kWSC02ActivateMorphScreenSpotID = 5010;
-const HotSpotID kWSC02SouthStartMorphSpotID = 5011;
-const HotSpotID kWSC02SouthInterruptMorphSpotID = 5012;
-const HotSpotID kWSC02SouthMorphFinishedSpotID = 5013;
-const HotSpotID kWSC02SouthTakeArgonSpotID = 5014;
-const HotSpotID kWSC02SouthMessagesOutSpotID = 5015;
-const HotSpotID kWSC02SouthTakeNitrogenSpotID = 5016;
-const HotSpotID kWSC02SouthPlayMessagesSpotID = 5017;
-const HotSpotID kWSC03NorthActivateScreenSpotID = 5018;
-const HotSpotID kWSC03NorthBuildMoleculeSpotID = 5019;
-const HotSpotID kWSC03NorthProceedSpotID = 5020;
-const HotSpotID kWSC03NorthMolecule1SpotID = 5021;
-const HotSpotID kWSC03NorthMolecule2SpotID = 5022;
-const HotSpotID kWSC03NorthMolecule3SpotID = 5023;
-const HotSpotID kWSC03NorthMolecule4SpotID = 5024;
-const HotSpotID kWSC03NorthMolecule5SpotID = 5025;
-const HotSpotID kWSC03NorthMolecule6SpotID = 5026;
-const HotSpotID kWSC03SouthActivateSynthesizerSpotID = 5027;
-const HotSpotID kWSC03SouthPickUpAntidoteSpotID = 5028;
-const HotSpotID kWSC07SouthMapSpotID = 5029;
-const HotSpotID kW42EastUnlockDoorSpotID = 5030;
-const HotSpotID kW56NorthMapSpotID = 5031;
-const HotSpotID kW58SouthPryDoorSpotID = 5032;
-const HotSpotID kWSC60EastSpotID = 5033;
-const HotSpotID kWSC60NorthSpotID = 5034;
-const HotSpotID kWSC60EastOutSpotID = 5035;
-const HotSpotID kWSC60NorthOutSpotID = 5036;
-const HotSpotID kWSC61EastSpotID = 5037;
-const HotSpotID kWSC61SouthSpotID = 5038;
-const HotSpotID kW61SouthMachineGunSpotID = 5039;
-const HotSpotID kW61SouthDropMachineGunSpotID = 5040;
-const HotSpotID kWSC61WestSpotID = 5041;
-const HotSpotID kWSC61SouthOutSpotID = 5042;
-const HotSpotID kW61SouthActivateSpotID = 5043;
-const HotSpotID kW61SmartAlloysSpotID = 5044;
-const HotSpotID kW61MorphingSpotID = 5045;
-const HotSpotID kW61TimeBendingSpotID = 5046;
-const HotSpotID kWSC61WestOutSpotID = 5047;
-const HotSpotID kW61TurnOnMessagesSpotID = 5048;
-const HotSpotID kW61WhiteMessageSpotID = 5049;
-const HotSpotID kW61WalchekMessageSpotID = 5050;
-const HotSpotID kWSC65SouthScreenSpotID = 5051;
-const HotSpotID kWSC65SouthScreenOutSpotID = 5052;
-const HotSpotID kW98RetinalChipSpotID = 5053;
-const HotSpotID kW98MapChipSpotID = 5054;
-const HotSpotID kW98OpticalChipSpotID = 5055;
-const HotSpotID kW98DropArgonSpotID = 5056;
-const HotSpotID kW98GrabCableSpotID = 5057;
-const HotSpotID kW98OpenRobotSpotID = 5058;
-const HotSpotID kW98StunGunSpotID = 5059;
+static const HotSpotID kWSCDropDartSpotID = 5000;
+static const HotSpotID kWSCTurnOnAnalyzerSpotID = 5001;
+static const HotSpotID kWSCAnalyzerScreenSpotID = 5002;
+static const HotSpotID kWSCSpinRobotSpotID = 5003;
+static const HotSpotID kWSC01YesSpotID = 5004;
+static const HotSpotID kWSC01NoSpotID = 5005;
+static const HotSpotID kWSC01AcknowledgeWarningSpotID = 5006;
+static const HotSpotID kWSC02SouthMorphSpotID = 5007;
+static const HotSpotID kWSC02SouthMessagesSpotID = 5008;
+static const HotSpotID kWSC02SouthMorphOutSpotID = 5009;
+static const HotSpotID kWSC02ActivateMorphScreenSpotID = 5010;
+static const HotSpotID kWSC02SouthStartMorphSpotID = 5011;
+static const HotSpotID kWSC02SouthInterruptMorphSpotID = 5012;
+static const HotSpotID kWSC02SouthMorphFinishedSpotID = 5013;
+static const HotSpotID kWSC02SouthTakeArgonSpotID = 5014;
+static const HotSpotID kWSC02SouthMessagesOutSpotID = 5015;
+static const HotSpotID kWSC02SouthTakeNitrogenSpotID = 5016;
+static const HotSpotID kWSC02SouthPlayMessagesSpotID = 5017;
+static const HotSpotID kWSC03NorthActivateScreenSpotID = 5018;
+static const HotSpotID kWSC03NorthBuildMoleculeSpotID = 5019;
+static const HotSpotID kWSC03NorthProceedSpotID = 5020;
+static const HotSpotID kWSC03NorthMolecule1SpotID = 5021;
+static const HotSpotID kWSC03NorthMolecule2SpotID = 5022;
+static const HotSpotID kWSC03NorthMolecule3SpotID = 5023;
+static const HotSpotID kWSC03NorthMolecule4SpotID = 5024;
+static const HotSpotID kWSC03NorthMolecule5SpotID = 5025;
+static const HotSpotID kWSC03NorthMolecule6SpotID = 5026;
+static const HotSpotID kWSC03SouthActivateSynthesizerSpotID = 5027;
+static const HotSpotID kWSC03SouthPickUpAntidoteSpotID = 5028;
+static const HotSpotID kWSC07SouthMapSpotID = 5029;
+static const HotSpotID kW42EastUnlockDoorSpotID = 5030;
+static const HotSpotID kW56NorthMapSpotID = 5031;
+static const HotSpotID kW58SouthPryDoorSpotID = 5032;
+static const HotSpotID kWSC60EastSpotID = 5033;
+static const HotSpotID kWSC60NorthSpotID = 5034;
+static const HotSpotID kWSC60EastOutSpotID = 5035;
+static const HotSpotID kWSC60NorthOutSpotID = 5036;
+static const HotSpotID kWSC61EastSpotID = 5037;
+static const HotSpotID kWSC61SouthSpotID = 5038;
+static const HotSpotID kW61SouthMachineGunSpotID = 5039;
+static const HotSpotID kW61SouthDropMachineGunSpotID = 5040;
+static const HotSpotID kWSC61WestSpotID = 5041;
+static const HotSpotID kWSC61SouthOutSpotID = 5042;
+static const HotSpotID kW61SouthActivateSpotID = 5043;
+static const HotSpotID kW61SmartAlloysSpotID = 5044;
+static const HotSpotID kW61MorphingSpotID = 5045;
+static const HotSpotID kW61TimeBendingSpotID = 5046;
+static const HotSpotID kWSC61WestOutSpotID = 5047;
+static const HotSpotID kW61TurnOnMessagesSpotID = 5048;
+static const HotSpotID kW61WhiteMessageSpotID = 5049;
+static const HotSpotID kW61WalchekMessageSpotID = 5050;
+static const HotSpotID kWSC65SouthScreenSpotID = 5051;
+static const HotSpotID kWSC65SouthScreenOutSpotID = 5052;
+static const HotSpotID kW98RetinalChipSpotID = 5053;
+static const HotSpotID kW98MapChipSpotID = 5054;
+static const HotSpotID kW98OpticalChipSpotID = 5055;
+static const HotSpotID kW98DropArgonSpotID = 5056;
+static const HotSpotID kW98GrabCableSpotID = 5057;
+static const HotSpotID kW98OpenRobotSpotID = 5058;
+static const HotSpotID kW98StunGunSpotID = 5059;
 
 // Extra sequence IDs.
-const ExtraID kWSCArrivalFromTSA = 0;
-const ExtraID kWSCShotByRobot = 1;
-const ExtraID kWSCDartScan1 = 2;
-const ExtraID kWSCDartScan2 = 3;
-const ExtraID kWSCDartScanNo = 4;
-const ExtraID kWSCDartScan3 = 5;
-const ExtraID kWSCAnalyzerPowerUp = 6;
-const ExtraID kWSCAnalyzerPowerUpWithDart = 7;
-const ExtraID kWSCDropDartIntoAnalyzer = 8;
-const ExtraID kWSCAnalyzeDart = 9;
-const ExtraID kWSCZoomOutFromAnalyzer = 10;
-const ExtraID kWSCSpinRobot = 11;
-const ExtraID kWSC02MorphZoomNoArgon = 12;
-const ExtraID kWSC02MessagesZoomNoNitrogen = 13;
-const ExtraID kWSC02ZoomOutNoArgon = 14;
-const ExtraID kWSC02TurnOnMorphScreen = 15;
-const ExtraID kWSC02DropToMorphExperiment = 16;
-const ExtraID kWSC02MorphLoop = 17;
-const ExtraID kWSC02MorphInterruption = 18;
-const ExtraID kWSC02MorphFinished = 19;
-const ExtraID kWSC02TurnOffMorphScreen = 20;
-const ExtraID kWSC02SouthViewNoArgon = 21;
-const ExtraID kMessagesMovedToOffice = 22;
-const ExtraID kMessagesOff = 23;
-const ExtraID kMessagesZoomOutNoNitrogen = 24;
-const ExtraID kMessagesMovedToOfficeNoNitrogen = 25;
-const ExtraID kMessagesOffNoNitrogen = 26;
-const ExtraID kMessagesViewNoNitrogen = 27;
-const ExtraID kMessagesViewMachineOnNoNitrogen = 28;
-const ExtraID kW03NorthActivate = 29;
-const ExtraID kW03NorthGetData = 30;
-const ExtraID kW03NorthInstructions = 31;
-const ExtraID kW03NorthPrepMolecule1 = 32;
-const ExtraID kW03NorthPrepMolecule2 = 33;
-const ExtraID kW03NorthPrepMolecule3 = 34;
-const ExtraID kW03NorthFinishSynthesis = 35;
-const ExtraID kW03SouthCreateAntidote = 36;
-const ExtraID kW03SouthAntidoteLoop = 37;
-const ExtraID kW03SouthDeactivate = 38;
-const ExtraID kW03SouthViewNoAntidote = 39;
-const ExtraID kWSC07SouthMap = 40;
-const ExtraID kW17WestPeopleCrossing = 41;
-const ExtraID kW17WestPeopleCrossingView = 42;
-const ExtraID kW21SouthPeopleCrossing = 43;
-const ExtraID kW24SouthPeopleCrossing = 44;
-const ExtraID kW34EastPeopleCrossing = 45;
-const ExtraID kW36WestPeopleCrossing = 46;
-const ExtraID kW38NorthPeopleCrossing = 47;
-const ExtraID kW46SouthPeopleCrossing = 48;
-const ExtraID kW49NorthPeopleCrossing = 49;
-const ExtraID kW49NorthPeopleCrossingView = 50;
-const ExtraID kWSC56SouthMap = 51;
-const ExtraID kNerdAtTheDoor1 = 52;
-const ExtraID kNerdAtTheDoor2 = 53;
-const ExtraID kW61SouthZoomInNoGun = 54;
-const ExtraID kW61Brochure = 55;
-const ExtraID kW61SouthScreenOnWithGun = 56;
-const ExtraID kW61SouthScreenOffWithGun = 57;
-const ExtraID kW61SouthSmartAlloysWithGun = 58;
-const ExtraID kW61SouthMorphingWithGun = 59;
-const ExtraID kW61SouthTimeBendingWithGun = 60;
-const ExtraID kW61SouthZoomOutNoGun = 61;
-const ExtraID kW61SouthScreenOnNoGun = 62;
-const ExtraID kW61SouthScreenOffNoGun = 63;
-const ExtraID kW61SouthSmartAlloysNoGun = 64;
-const ExtraID kW61SouthMorphingNoGun = 65;
-const ExtraID kW61SouthTimeBendingNoGun = 66;
-const ExtraID kW61MessagesOn = 67;
-const ExtraID kW61MessagesOff = 68;
-const ExtraID kW61WhiteMessage = 69;
-const ExtraID kW61WalchekMessage = 70;
-const ExtraID kW61WalchekEasterEgg1 = 71;
-const ExtraID kW62SouthPlasmaRobotAppears = 72;
-const ExtraID kW62ZoomToRobot = 73;
-const ExtraID kW62ZoomOutFromRobot = 74;
-const ExtraID kW62PlasmaDodgeSurvive = 75;
-const ExtraID kW62PlasmaDodgeDie = 76;
-const ExtraID kW65SouthSinclairLecture = 77;
-const ExtraID kW73WestPeopleCrossing = 78;
-const ExtraID kW73WestPeopleCrossingView = 79;
-const ExtraID kW0ZSpottedByWomen = 80;
-const ExtraID kW95RobotShoots = 81;
-const ExtraID kW98MorphsToRobot = 82;
-const ExtraID kW98RobotShoots = 83;
-const ExtraID kW98RobotShocked = 84;
-const ExtraID kW98RobotGassed = 85;
-const ExtraID kW98RobotHeadOpensDark = 86;
-const ExtraID kW98RobotHead000Dark = 87;
-const ExtraID kW98RobotHead001Dark = 88;
-const ExtraID kW98RobotHead010Dark = 89;
-const ExtraID kW98RobotHead011Dark = 90;
-const ExtraID kW98RobotHead100Dark = 91;
-const ExtraID kW98RobotHead101Dark = 92;
-const ExtraID kW98RobotHead110Dark = 93;
-const ExtraID kW98RobotHead111Dark = 94;
-const ExtraID kW98RobotHeadClosesDark = 95;
-const ExtraID kW98WestViewWithGunDark = 96;
-const ExtraID kW98WestViewNoGunDark = 97;
-const ExtraID kW98RobotHeadOpensLight = 98;
-const ExtraID kW98RobotHead000Light = 99;
-const ExtraID kW98RobotHead001Light = 100;
-const ExtraID kW98RobotHead010Light = 101;
-const ExtraID kW98RobotHead011Light = 102;
-const ExtraID kW98RobotHead100Light = 103;
-const ExtraID kW98RobotHead101Light = 104;
-const ExtraID kW98RobotHead110Light = 105;
-const ExtraID kW98RobotHead111Light = 106;
-const ExtraID kW98RobotHeadClosesLight = 107;
-const ExtraID kW98WestViewWithGunLight = 108;
-const ExtraID kW98WestViewNoGunLight = 109;
-
-const CoordType kMoleculesMovieLeft = kNavAreaLeft + 112;
-const CoordType kMoleculesMovieTop = kNavAreaTop + 40;
+static const ExtraID kWSCArrivalFromTSA = 0;
+static const ExtraID kWSCShotByRobot = 1;
+static const ExtraID kWSCDartScan1 = 2;
+static const ExtraID kWSCDartScan2 = 3;
+static const ExtraID kWSCDartScanNo = 4;
+static const ExtraID kWSCDartScan3 = 5;
+static const ExtraID kWSCAnalyzerPowerUp = 6;
+static const ExtraID kWSCAnalyzerPowerUpWithDart = 7;
+static const ExtraID kWSCDropDartIntoAnalyzer = 8;
+static const ExtraID kWSCAnalyzeDart = 9;
+static const ExtraID kWSCZoomOutFromAnalyzer = 10;
+static const ExtraID kWSCSpinRobot = 11;
+static const ExtraID kWSC02MorphZoomNoArgon = 12;
+static const ExtraID kWSC02MessagesZoomNoNitrogen = 13;
+static const ExtraID kWSC02ZoomOutNoArgon = 14;
+static const ExtraID kWSC02TurnOnMorphScreen = 15;
+static const ExtraID kWSC02DropToMorphExperiment = 16;
+static const ExtraID kWSC02MorphLoop = 17;
+static const ExtraID kWSC02MorphInterruption = 18;
+static const ExtraID kWSC02MorphFinished = 19;
+static const ExtraID kWSC02TurnOffMorphScreen = 20;
+static const ExtraID kWSC02SouthViewNoArgon = 21;
+static const ExtraID kMessagesMovedToOffice = 22;
+static const ExtraID kMessagesOff = 23;
+static const ExtraID kMessagesZoomOutNoNitrogen = 24;
+static const ExtraID kMessagesMovedToOfficeNoNitrogen = 25;
+static const ExtraID kMessagesOffNoNitrogen = 26;
+static const ExtraID kMessagesViewNoNitrogen = 27;
+static const ExtraID kMessagesViewMachineOnNoNitrogen = 28;
+static const ExtraID kW03NorthActivate = 29;
+static const ExtraID kW03NorthGetData = 30;
+static const ExtraID kW03NorthInstructions = 31;
+static const ExtraID kW03NorthPrepMolecule1 = 32;
+static const ExtraID kW03NorthPrepMolecule2 = 33;
+static const ExtraID kW03NorthPrepMolecule3 = 34;
+static const ExtraID kW03NorthFinishSynthesis = 35;
+static const ExtraID kW03SouthCreateAntidote = 36;
+static const ExtraID kW03SouthAntidoteLoop = 37;
+static const ExtraID kW03SouthDeactivate = 38;
+static const ExtraID kW03SouthViewNoAntidote = 39;
+static const ExtraID kWSC07SouthMap = 40;
+static const ExtraID kW17WestPeopleCrossing = 41;
+static const ExtraID kW17WestPeopleCrossingView = 42;
+static const ExtraID kW21SouthPeopleCrossing = 43;
+static const ExtraID kW24SouthPeopleCrossing = 44;
+static const ExtraID kW34EastPeopleCrossing = 45;
+static const ExtraID kW36WestPeopleCrossing = 46;
+static const ExtraID kW38NorthPeopleCrossing = 47;
+static const ExtraID kW46SouthPeopleCrossing = 48;
+static const ExtraID kW49NorthPeopleCrossing = 49;
+static const ExtraID kW49NorthPeopleCrossingView = 50;
+static const ExtraID kWSC56SouthMap = 51;
+static const ExtraID kNerdAtTheDoor1 = 52;
+static const ExtraID kNerdAtTheDoor2 = 53;
+static const ExtraID kW61SouthZoomInNoGun = 54;
+static const ExtraID kW61Brochure = 55;
+static const ExtraID kW61SouthScreenOnWithGun = 56;
+static const ExtraID kW61SouthScreenOffWithGun = 57;
+static const ExtraID kW61SouthSmartAlloysWithGun = 58;
+static const ExtraID kW61SouthMorphingWithGun = 59;
+static const ExtraID kW61SouthTimeBendingWithGun = 60;
+static const ExtraID kW61SouthZoomOutNoGun = 61;
+static const ExtraID kW61SouthScreenOnNoGun = 62;
+static const ExtraID kW61SouthScreenOffNoGun = 63;
+static const ExtraID kW61SouthSmartAlloysNoGun = 64;
+static const ExtraID kW61SouthMorphingNoGun = 65;
+static const ExtraID kW61SouthTimeBendingNoGun = 66;
+static const ExtraID kW61MessagesOn = 67;
+static const ExtraID kW61MessagesOff = 68;
+static const ExtraID kW61WhiteMessage = 69;
+static const ExtraID kW61WalchekMessage = 70;
+static const ExtraID kW61WalchekEasterEgg1 = 71;
+static const ExtraID kW62SouthPlasmaRobotAppears = 72;
+static const ExtraID kW62ZoomToRobot = 73;
+static const ExtraID kW62ZoomOutFromRobot = 74;
+static const ExtraID kW62PlasmaDodgeSurvive = 75;
+static const ExtraID kW62PlasmaDodgeDie = 76;
+static const ExtraID kW65SouthSinclairLecture = 77;
+static const ExtraID kW73WestPeopleCrossing = 78;
+static const ExtraID kW73WestPeopleCrossingView = 79;
+static const ExtraID kW0ZSpottedByWomen = 80;
+static const ExtraID kW95RobotShoots = 81;
+static const ExtraID kW98MorphsToRobot = 82;
+static const ExtraID kW98RobotShoots = 83;
+static const ExtraID kW98RobotShocked = 84;
+static const ExtraID kW98RobotGassed = 85;
+static const ExtraID kW98RobotHeadOpensDark = 86;
+static const ExtraID kW98RobotHead000Dark = 87;
+static const ExtraID kW98RobotHead001Dark = 88;
+static const ExtraID kW98RobotHead010Dark = 89;
+static const ExtraID kW98RobotHead011Dark = 90;
+static const ExtraID kW98RobotHead100Dark = 91;
+static const ExtraID kW98RobotHead101Dark = 92;
+static const ExtraID kW98RobotHead110Dark = 93;
+static const ExtraID kW98RobotHead111Dark = 94;
+static const ExtraID kW98RobotHeadClosesDark = 95;
+static const ExtraID kW98WestViewWithGunDark = 96;
+static const ExtraID kW98WestViewNoGunDark = 97;
+static const ExtraID kW98RobotHeadOpensLight = 98;
+static const ExtraID kW98RobotHead000Light = 99;
+static const ExtraID kW98RobotHead001Light = 100;
+static const ExtraID kW98RobotHead010Light = 101;
+static const ExtraID kW98RobotHead011Light = 102;
+static const ExtraID kW98RobotHead100Light = 103;
+static const ExtraID kW98RobotHead101Light = 104;
+static const ExtraID kW98RobotHead110Light = 105;
+static const ExtraID kW98RobotHead111Light = 106;
+static const ExtraID kW98RobotHeadClosesLight = 107;
+static const ExtraID kW98WestViewWithGunLight = 108;
+static const ExtraID kW98WestViewNoGunLight = 109;
+
+static const CoordType kMoleculesMovieLeft = kNavAreaLeft + 112;
+static const CoordType kMoleculesMovieTop = kNavAreaTop + 40;
 
 WSC::WSC(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "WSC", kWSCID),
 		_moleculesMovie(kNoDisplayElement) {
diff --git a/engines/pegasus/neighborhood/wsc/wsc.h b/engines/pegasus/neighborhood/wsc/wsc.h
index 845b587..e2e931e 100755
--- a/engines/pegasus/neighborhood/wsc/wsc.h
+++ b/engines/pegasus/neighborhood/wsc/wsc.h
@@ -31,13 +31,13 @@
 
 namespace Pegasus {
 
-const DisplayOrder kWSCMoleculeBinOrder = kMonitorLayer;
-const DisplayOrder kWSCMoleculesMovieOrder = kWSCMoleculeBinOrder + 1;
+static const DisplayOrder kWSCMoleculeBinOrder = kMonitorLayer;
+static const DisplayOrder kWSCMoleculesMovieOrder = kWSCMoleculeBinOrder + 1;
 
-const RoomID kWSC01 = 0;
-const RoomID kWSC02Morph = 2;
-const RoomID kWSC02Messages = 3;
-const RoomID kWSC62 = 62;
+static const RoomID kWSC01 = 0;
+static const RoomID kWSC02Morph = 2;
+static const RoomID kWSC02Messages = 3;
+static const RoomID kWSC62 = 62;
 
 class WSC : public Neighborhood {
 public:
diff --git a/engines/pegasus/scoring.h b/engines/pegasus/scoring.h
index 41dcb4b..efae17c 100755
--- a/engines/pegasus/scoring.h
+++ b/engines/pegasus/scoring.h
@@ -34,55 +34,55 @@ namespace Pegasus {
 //
 //	Scoring.
 
-const CoordType kDeathScreenScoreLeft = 151;
-const CoordType kDeathScreenScoreTop = 212;
-const CoordType kDeathScreenScoreWidth = 124;
-const CoordType kDeathScreenScoreHeight = 12;
-const CoordType kDeathScreenScoreSkipVert = -16;
+static const CoordType kDeathScreenScoreLeft = 151;
+static const CoordType kDeathScreenScoreTop = 212;
+static const CoordType kDeathScreenScoreWidth = 124;
+static const CoordType kDeathScreenScoreHeight = 12;
+static const CoordType kDeathScreenScoreSkipVert = -16;
 
 //	Caldoria & TSA
 
-const GameScoreType kSawINNScore					= 5;
-const GameScoreType kTookShowerScore				= 2;
-const GameScoreType kFixedHairScore				= 2;
-const GameScoreType kGotKeyCardScore				= 5;
-const GameScoreType kReadPaperScore				= 2;
-const GameScoreType kLookThroughTelescopeScore		= 2;
-const GameScoreType kSawCaldoriaKioskScore			= 2;
-const GameScoreType kGoToTSAScore					= 3;
+static const GameScoreType kSawINNScore					= 5;
+static const GameScoreType kTookShowerScore				= 2;
+static const GameScoreType kFixedHairScore				= 2;
+static const GameScoreType kGotKeyCardScore				= 5;
+static const GameScoreType kReadPaperScore				= 2;
+static const GameScoreType kLookThroughTelescopeScore		= 2;
+static const GameScoreType kSawCaldoriaKioskScore			= 2;
+static const GameScoreType kGoToTSAScore					= 3;
 
-const GameScoreType kEnterTSAScore					= 2;
-const GameScoreType kSawBust1Score					= 2;
-const GameScoreType kSawBust2Score					= 2;
-const GameScoreType kSawBust3Score					= 2;
-const GameScoreType kSawBust4Score					= 2;
-const GameScoreType kSawBust5Score					= 2;
-const GameScoreType kSawBust6Score					= 2;
-const GameScoreType kSawTheoryScore				= 4;
-const GameScoreType kSawBackgroundScore			= 4;
-const GameScoreType kSawProcedureScore				= 4;
-const GameScoreType kGotJourneymanKeyScore			= 5;
-const GameScoreType kGotPegasusBiochipScore		= 5;
-const GameScoreType kGotBiosuitScore				= 5;
-const GameScoreType kGoToPrehistoricScore			= 5;
+static const GameScoreType kEnterTSAScore					= 2;
+static const GameScoreType kSawBust1Score					= 2;
+static const GameScoreType kSawBust2Score					= 2;
+static const GameScoreType kSawBust3Score					= 2;
+static const GameScoreType kSawBust4Score					= 2;
+static const GameScoreType kSawBust5Score					= 2;
+static const GameScoreType kSawBust6Score					= 2;
+static const GameScoreType kSawTheoryScore				= 4;
+static const GameScoreType kSawBackgroundScore			= 4;
+static const GameScoreType kSawProcedureScore				= 4;
+static const GameScoreType kGotJourneymanKeyScore			= 5;
+static const GameScoreType kGotPegasusBiochipScore		= 5;
+static const GameScoreType kGotBiosuitScore				= 5;
+static const GameScoreType kGoToPrehistoricScore			= 5;
 
-const GameScoreType kPutLogInReaderScore			= 5;
-const GameScoreType kSawCaldoriaNormalScore		= 2;
-const GameScoreType kSawCaldoriaAlteredScore		= 2;
-const GameScoreType kSawNoradNormalScore			= 2;
-const GameScoreType kSawNoradAlteredScore			= 2;
-const GameScoreType kSawMarsNormalScore			= 2;
-const GameScoreType kSawMarsAlteredScore			= 2;
-const GameScoreType kSawWSCNormalScore				= 2;
-const GameScoreType kSawWSCAlteredScore			= 2;
-const GameScoreType kWentToReadyRoom2Score			= 5;
-const GameScoreType kWentAfterSinclairScore		= 5;
-const GameScoreType kUsedCardBombScore				= 10;
-const GameScoreType kShieldedCardBombScore			= 5;
-const GameScoreType kStunnedSinclairScore			= 10;
-const GameScoreType kDisarmedNukeScore				= 10;
+static const GameScoreType kPutLogInReaderScore			= 5;
+static const GameScoreType kSawCaldoriaNormalScore		= 2;
+static const GameScoreType kSawCaldoriaAlteredScore		= 2;
+static const GameScoreType kSawNoradNormalScore			= 2;
+static const GameScoreType kSawNoradAlteredScore			= 2;
+static const GameScoreType kSawMarsNormalScore			= 2;
+static const GameScoreType kSawMarsAlteredScore			= 2;
+static const GameScoreType kSawWSCNormalScore				= 2;
+static const GameScoreType kSawWSCAlteredScore			= 2;
+static const GameScoreType kWentToReadyRoom2Score			= 5;
+static const GameScoreType kWentAfterSinclairScore		= 5;
+static const GameScoreType kUsedCardBombScore				= 10;
+static const GameScoreType kShieldedCardBombScore			= 5;
+static const GameScoreType kStunnedSinclairScore			= 10;
+static const GameScoreType kDisarmedNukeScore				= 10;
 
-const GameScoreType kMaxCaldoriaTSAScoreBefore		=	kSawINNScore +
+static const GameScoreType kMaxCaldoriaTSAScoreBefore		=	kSawINNScore +
 														kTookShowerScore +
 														kFixedHairScore +
 														kGotKeyCardScore +
@@ -115,52 +115,52 @@ const GameScoreType kMaxCaldoriaTSAScoreBefore		=	kSawINNScore +
 														kSawWSCAlteredScore +
 														kWentToReadyRoom2Score;
 
-const GameScoreType kMaxCaldoriaTSAScoreAfter		=	kWentAfterSinclairScore +
+static const GameScoreType kMaxCaldoriaTSAScoreAfter		=	kWentAfterSinclairScore +
 														kUsedCardBombScore +
 														kShieldedCardBombScore +
 														kStunnedSinclairScore +
 														kDisarmedNukeScore;
 
-const GameScoreType kMaxCaldoriaTSAScore			=	kMaxCaldoriaTSAScoreBefore +
+static const GameScoreType kMaxCaldoriaTSAScore			=	kMaxCaldoriaTSAScoreBefore +
 														kMaxCaldoriaTSAScoreAfter;
 
 //	Prehistoric
 
-const GameScoreType kThrewBreakerScore				= 10;
-const GameScoreType kExtendedBridgeScore			= 10;
-const GameScoreType kGotHistoricalLogScore			= 5;
-const GameScoreType kFinishedPrehistoricScore		= 10;
+static const GameScoreType kThrewBreakerScore				= 10;
+static const GameScoreType kExtendedBridgeScore			= 10;
+static const GameScoreType kGotHistoricalLogScore			= 5;
+static const GameScoreType kFinishedPrehistoricScore		= 10;
 
-const GameScoreType kMaxPrehistoricScore			=	kThrewBreakerScore +
+static const GameScoreType kMaxPrehistoricScore			=	kThrewBreakerScore +
 														kExtendedBridgeScore +
 														kGotHistoricalLogScore +
 														kFinishedPrehistoricScore;
 
 //	Mars
 
-const GameScoreType kThrownByRobotScore			= 3;
-const GameScoreType kGotMarsCardScore				= 5;
-const GameScoreType kSawMarsKioskScore				= 2;
-const GameScoreType kSawTransportMapScore			= 2;
-const GameScoreType kGotCrowBarScore				= 5;
-const GameScoreType kTurnedOnTransportScore		= 5;
-const GameScoreType kGotOxygenMaskScore			= 5;
-const GameScoreType kAvoidedRobotScore				= 5;
-const GameScoreType kActivatedPlatformScore		= 2;
-const GameScoreType kUsedLiquidNitrogenScore		= 3;
-const GameScoreType kUsedCrowBarScore				= 3;
-const GameScoreType kFoundCardBombScore			= 4;
-const GameScoreType kDisarmedCardBombScore			= 8;
-const GameScoreType kGotCardBombScore				= 5;
-const GameScoreType kThreadedMazeScore				= 5;
-const GameScoreType kThreadedGearRoomScore			= 2;
-const GameScoreType kEnteredShuttleScore			= 2;
-const GameScoreType kEnteredLaunchTubeScore		= 4;
-const GameScoreType kStoppedRobotsShuttleScore		= 10;
-const GameScoreType kGotMarsOpMemChipScore			= 10;
-const GameScoreType kFinishedMarsScore				= 10;
+static const GameScoreType kThrownByRobotScore			= 3;
+static const GameScoreType kGotMarsCardScore				= 5;
+static const GameScoreType kSawMarsKioskScore				= 2;
+static const GameScoreType kSawTransportMapScore			= 2;
+static const GameScoreType kGotCrowBarScore				= 5;
+static const GameScoreType kTurnedOnTransportScore		= 5;
+static const GameScoreType kGotOxygenMaskScore			= 5;
+static const GameScoreType kAvoidedRobotScore				= 5;
+static const GameScoreType kActivatedPlatformScore		= 2;
+static const GameScoreType kUsedLiquidNitrogenScore		= 3;
+static const GameScoreType kUsedCrowBarScore				= 3;
+static const GameScoreType kFoundCardBombScore			= 4;
+static const GameScoreType kDisarmedCardBombScore			= 8;
+static const GameScoreType kGotCardBombScore				= 5;
+static const GameScoreType kThreadedMazeScore				= 5;
+static const GameScoreType kThreadedGearRoomScore			= 2;
+static const GameScoreType kEnteredShuttleScore			= 2;
+static const GameScoreType kEnteredLaunchTubeScore		= 4;
+static const GameScoreType kStoppedRobotsShuttleScore		= 10;
+static const GameScoreType kGotMarsOpMemChipScore			= 10;
+static const GameScoreType kFinishedMarsScore				= 10;
 
-const GameScoreType kMaxMarsScore					=	kThrownByRobotScore +
+static const GameScoreType kMaxMarsScore					=	kThrownByRobotScore +
 														kGotMarsCardScore +
 														kSawMarsKioskScore +
 														kSawTransportMapScore +
@@ -184,23 +184,23 @@ const GameScoreType kMaxMarsScore					=	kThrownByRobotScore +
 
 //	Norad
 
-const GameScoreType kSawSecurityMonitorScore		= 5;
-const GameScoreType kFilledOxygenCanisterScore		= 5;
-const GameScoreType kFilledArgonCanisterScore		= 5;
-const GameScoreType kSawUnconsciousOperatorScore	= 5;
-const GameScoreType kWentThroughPressureDoorScore	= 5;
-const GameScoreType kPreppedSubScore				= 5;
-const GameScoreType kEnteredSubScore				= 5;
-const GameScoreType kExitedSubScore				= 10;
-const GameScoreType kSawRobotAt54NorthScore		= 5;
-const GameScoreType kPlayedWithClawScore			= 5;
-const GameScoreType kUsedRetinalChipScore			= 5;
-const GameScoreType kFinishedGlobeGameScore		= 10;
-const GameScoreType kStoppedNoradRobotScore		= 10;
-const GameScoreType kGotNoradOpMemChipScore		= 10;
-const GameScoreType kFinishedNoradScore			= 10;
+static const GameScoreType kSawSecurityMonitorScore		= 5;
+static const GameScoreType kFilledOxygenCanisterScore		= 5;
+static const GameScoreType kFilledArgonCanisterScore		= 5;
+static const GameScoreType kSawUnconsciousOperatorScore	= 5;
+static const GameScoreType kWentThroughPressureDoorScore	= 5;
+static const GameScoreType kPreppedSubScore				= 5;
+static const GameScoreType kEnteredSubScore				= 5;
+static const GameScoreType kExitedSubScore				= 10;
+static const GameScoreType kSawRobotAt54NorthScore		= 5;
+static const GameScoreType kPlayedWithClawScore			= 5;
+static const GameScoreType kUsedRetinalChipScore			= 5;
+static const GameScoreType kFinishedGlobeGameScore		= 10;
+static const GameScoreType kStoppedNoradRobotScore		= 10;
+static const GameScoreType kGotNoradOpMemChipScore		= 10;
+static const GameScoreType kFinishedNoradScore			= 10;
 
-const GameScoreType kMaxNoradScore					=	kSawSecurityMonitorScore +
+static const GameScoreType kMaxNoradScore					=	kSawSecurityMonitorScore +
 														kFilledOxygenCanisterScore +
 														kFilledArgonCanisterScore +
 														kSawUnconsciousOperatorScore +
@@ -218,28 +218,28 @@ const GameScoreType kMaxNoradScore					=	kSawSecurityMonitorScore +
 
 //	WSC
 
-const GameScoreType kRemovedDartScore				= 5;
-const GameScoreType kAnalyzedDartScore				= 5;
-const GameScoreType kBuiltAntidoteScore			= 5;
-const GameScoreType kGotSinclairKeyScore			= 5;
-const GameScoreType kGotArgonCanisterScore 		= 5;
-const GameScoreType kGotNitrogenCanisterScore		= 5;
-const GameScoreType kPlayedWithMessagesScore		= 2;
-const GameScoreType kSawMorphExperimentScore		= 3;
-const GameScoreType kEnteredSinclairOfficeScore	= 2;
-const GameScoreType kSawBrochureScore				= 3;
-const GameScoreType kSawSinclairEntry1Score		= 3;
-const GameScoreType kSawSinclairEntry2Score		= 3;
-const GameScoreType kSawSinclairEntry3Score		= 3;
-const GameScoreType kSawWSCDirectoryScore			= 3;
-const GameScoreType kUsedCrowBarInWSCScore			= 5;
-const GameScoreType kFinishedPlasmaDodgeScore		= 10;
-const GameScoreType kOpenedCatwalkScore			= 3;
-const GameScoreType kStoppedWSCRobotScore			= 10;
-const GameScoreType kGotWSCOpMemChipScore			= 10;
-const GameScoreType kFinishedWSCScore				= 10;
+static const GameScoreType kRemovedDartScore				= 5;
+static const GameScoreType kAnalyzedDartScore				= 5;
+static const GameScoreType kBuiltAntidoteScore			= 5;
+static const GameScoreType kGotSinclairKeyScore			= 5;
+static const GameScoreType kGotArgonCanisterScore 		= 5;
+static const GameScoreType kGotNitrogenCanisterScore		= 5;
+static const GameScoreType kPlayedWithMessagesScore		= 2;
+static const GameScoreType kSawMorphExperimentScore		= 3;
+static const GameScoreType kEnteredSinclairOfficeScore	= 2;
+static const GameScoreType kSawBrochureScore				= 3;
+static const GameScoreType kSawSinclairEntry1Score		= 3;
+static const GameScoreType kSawSinclairEntry2Score		= 3;
+static const GameScoreType kSawSinclairEntry3Score		= 3;
+static const GameScoreType kSawWSCDirectoryScore			= 3;
+static const GameScoreType kUsedCrowBarInWSCScore			= 5;
+static const GameScoreType kFinishedPlasmaDodgeScore		= 10;
+static const GameScoreType kOpenedCatwalkScore			= 3;
+static const GameScoreType kStoppedWSCRobotScore			= 10;
+static const GameScoreType kGotWSCOpMemChipScore			= 10;
+static const GameScoreType kFinishedWSCScore				= 10;
 
-const GameScoreType kMaxWSCScore					=	kRemovedDartScore +
+static const GameScoreType kMaxWSCScore					=	kRemovedDartScore +
 														kAnalyzedDartScore +
 														kBuiltAntidoteScore +
 														kGotSinclairKeyScore +
@@ -262,15 +262,15 @@ const GameScoreType kMaxWSCScore					=	kRemovedDartScore +
 
 //	Gandhi
 
-const GameScoreType kMarsGandhiScore				= 10;
-const GameScoreType kNoradGandhiScore				= 10;
-const GameScoreType kWSCGandhiScore				= 10;
+static const GameScoreType kMarsGandhiScore				= 10;
+static const GameScoreType kNoradGandhiScore				= 10;
+static const GameScoreType kWSCGandhiScore				= 10;
 
-const GameScoreType kMaxGandhiScore				=	kMarsGandhiScore +
+static const GameScoreType kMaxGandhiScore				=	kMarsGandhiScore +
 														kNoradGandhiScore +
 														kWSCGandhiScore;
 
-const GameScoreType kMaxTotalScore					=	kMaxCaldoriaTSAScore +
+static const GameScoreType kMaxTotalScore					=	kMaxCaldoriaTSAScore +
 														kMaxPrehistoricScore +
 														kMaxMarsScore +
 														kMaxNoradScore +
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index 8be095a..dcd68e4 100755
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -50,10 +50,10 @@ private:
 //	Transitions are faders that range over [0,1000], which makes their
 //	"resolution" one tenth of a percent
 
-const long kTransitionBottom = 0;
-const long kTransitionTop = 1000;
+static const int kTransitionBottom = 0;
+static const int kTransitionTop = 1000;
 
-const long kTransitionRange = kTransitionTop - kTransitionBottom;
+static const int kTransitionRange = kTransitionTop - kTransitionBottom;
 
 class Transition : public FaderAnimation {
 public:


Commit: fa92148098c2ea5302e6b324e289fed118d6ace3
    https://github.com/scummvm/scummvm/commit/fa92148098c2ea5302e6b324e289fed118d6ace3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-19T15:06:56-08:00

Commit Message:
PEGASUS: Fix timers starting when paused

TimeBase now has its own pause time adjustment instead of using getTotalPlayTime()

Changed paths:
    engines/pegasus/timers.cpp
    engines/pegasus/timers.h



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index a5cfa44..49071a2 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -67,6 +67,7 @@ TimeBase::TimeBase(const TimeScale preferredScale) {
 	_stopScale = 1;
 	_master = 0;
 	_pausedRate = 0;
+	_pauseStart = 0;
 	
 	((PegasusEngine *)g_engine)->addTimeBase(this);
 }
@@ -118,6 +119,7 @@ void TimeBase::pause() {
 		_pausedRate = getRate();
 		stop();
 		_paused = true;
+		_pauseStart = g_system->getMillis();
 	}
 }
 
@@ -125,6 +127,9 @@ void TimeBase::resume() {
 	if (_paused) {
 		setRate(_pausedRate);
 		_paused = false;
+
+		if (isRunning())
+			_lastMillis += g_system->getMillis() - _pauseStart;
 	}
 }
 
@@ -200,9 +205,9 @@ void TimeBase::setMasterTimeBase(TimeBase *tb) {
 
 void TimeBase::updateTime() {
 	if (_lastMillis == 0) {
-		_lastMillis = g_engine->getTotalPlayTime();
+		_lastMillis = g_system->getMillis();
 	} else {
-		uint32 curTime = g_engine->getTotalPlayTime();
+		uint32 curTime = g_system->getMillis();
 		if (_lastMillis == curTime) // No change
 			return;
 
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
index 5c96b6d..1dd32de 100755
--- a/engines/pegasus/timers.h
+++ b/engines/pegasus/timers.h
@@ -120,7 +120,7 @@ protected:
 	uint32 _flags;
 
 	Common::Rational _time;
-	uint32 _lastMillis;
+	uint32 _lastMillis, _pauseStart;
 
 private:
 	Common::Rational getEffectiveRate() const;


Commit: 924e0b32ad80cefb81d1cadc55d389a14430a5a7
    https://github.com/scummvm/scummvm/commit/924e0b32ad80cefb81d1cadc55d389a14430a5a7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-19T15:55:08-08:00

Commit Message:
PEGASUS: Implement saving/loading from the in-game pause menu

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 5e7d188..da2f09e 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -306,7 +306,7 @@ void PegasusEngine::runIntro() {
 	delete video;
 }
 
-void PegasusEngine::showLoadDialog() {
+Common::Error PegasusEngine::showLoadDialog() {
 	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
 	slc.setSaveMode(false);
 
@@ -317,10 +317,47 @@ void PegasusEngine::showLoadDialog() {
 
 	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 
-	if (slot >= 0)
-		loadGameState(slot);
+	Common::Error result;
+
+	if (slot >= 0) {
+		if (loadGameState(slot).getCode() == Common::kNoError)
+			result = Common::kNoError;
+		else
+			result = Common::kUnknownError;
+	} else {
+		result = Common::kUserCanceled;
+	}
 
 	slc.close();
+
+	return result;
+}
+
+Common::Error PegasusEngine::showSaveDialog() {
+	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"));
+	slc.setSaveMode(true);
+
+	Common::String gameId = ConfMan.get("gameid");
+
+	const EnginePlugin *plugin = 0;
+	EngineMan.findGame(gameId, &plugin);
+
+	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
+
+	Common::Error result;
+
+	if (slot >= 0) {
+		if (saveGameState(slot, slc.getResultString()).getCode() == Common::kNoError)
+			result = Common::kNoError;
+		else
+			result = Common::kUnknownError;
+	} else {
+		result = Common::kUserCanceled;
+	}
+
+	slc.close();
+
+	return result;
 }
 
 GUI::Debugger *PegasusEngine::getDebugger() {
@@ -640,6 +677,8 @@ bool PegasusEngine::checkGameMenu() {
 }
 
 void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
+	Common::Error result;
+
 	switch (command) {
 	case kMenuCmdStartAdventure:
 		GameState.setWalkthroughMode(false);
@@ -734,13 +773,23 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 			resetIntroTimer();
 		break;
 	case kMenuCmdPauseSave:
-		error("Save game");
+		if (showSaveDialog().getCode() != Common::kUserCanceled)
+			pauseMenu(false);
 		break;
 	case kMenuCmdPauseContinue:
 		pauseMenu(false);
 		break;
 	case kMenuCmdPauseRestore:
-		error("Load game");
+		makeContinuePoint();
+		result = showLoadDialog();
+
+		if (result.getCode() == Common::kNoError) {
+			// Successfully loaded, unpause the game
+			pauseMenu(false);
+		} else if (result.getCode() != Common::kUserCanceled) {
+			// Try to get us back to a sane state
+			loadFromContinuePoint();
+		}
 		break;
 	case kMenuCmdPauseQuit:
 		_gfx->doFadeOutSync();
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 86ba267..bd8f04b 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -236,11 +236,12 @@ private:
 	void loadFromContinuePoint();
 	Common::ReadStream *_continuePoint;
 	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
+	Common::Error showLoadDialog();
+	Common::Error showSaveDialog();
 
 	// Misc.
 	Hotspot _returnHotspot;
 	InputHandler *_savedHandler;
-	void showLoadDialog();
 	void showTempScreen(const Common::String &fileName);
 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
 	void throwAwayEverything();


Commit: 5fe762e7cdfd2ca72129abe2eac181ae5402aaff
    https://github.com/scummvm/scummvm/commit/5fe762e7cdfd2ca72129abe2eac181ae5402aaff
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-19T18:13:54-08:00

Commit Message:
PEGASUS: Fix typo in the save code

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index da2f09e..f5efbc0 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -541,7 +541,7 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	byte biochipCount = _biochips.getNumItems();
 	stream->writeByte(biochipCount);
 
-	if (itemCount > 0) {
+	if (biochipCount > 0) {
 		for (uint32 i = 0; i < biochipCount; i++)
 			stream->writeUint16BE(_biochips.getItemIDAt(i));
 


Commit: a600dcb56a9633ebfae0d726480352b6f2e9b3ba
    https://github.com/scummvm/scummvm/commit/a600dcb56a9633ebfae0d726480352b6f2e9b3ba
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-20T15:26:25-08:00

Commit Message:
PEGASUS: Some space/misc cleanup

Changed paths:
    engines/pegasus/ai/ai_action.h
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/ai/ai_condition.h
    engines/pegasus/constants.h
    engines/pegasus/elements.cpp
    engines/pegasus/elements.h
    engines/pegasus/energymonitor.cpp
    engines/pegasus/energymonitor.h
    engines/pegasus/gamestate.cpp
    engines/pegasus/gamestate.h
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/items/inventory.cpp
    engines/pegasus/items/inventory.h
    engines/pegasus/items/inventorypicture.cpp
    engines/pegasus/items/item.cpp
    engines/pegasus/items/item.h
    engines/pegasus/menu.cpp
    engines/pegasus/movie.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.h
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/exit.h
    engines/pegasus/neighborhood/hotspotinfo.h
    engines/pegasus/neighborhood/mars/constants.h
    engines/pegasus/neighborhood/mars/gravitoncannon.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/norad/constants.h
    engines/pegasus/neighborhood/norad/delta/globegame.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp
    engines/pegasus/neighborhood/spot.cpp
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/notification.cpp
    engines/pegasus/notification.h
    engines/pegasus/pegasus.cpp
    engines/pegasus/scoring.h
    engines/pegasus/sound.h
    engines/pegasus/timers.cpp
    engines/pegasus/transition.h
    engines/pegasus/types.h



diff --git a/engines/pegasus/ai/ai_action.h b/engines/pegasus/ai/ai_action.h
index 9ac3078..6eac976 100755
--- a/engines/pegasus/ai/ai_action.h
+++ b/engines/pegasus/ai/ai_action.h
@@ -38,7 +38,7 @@ class AITimerCondition;
 
 /////////////////////////////////////////////
 //
-//	AIAction
+// AIAction
 
 class AIAction {
 friend class AIRule;
@@ -58,7 +58,7 @@ typedef Common::List<AIAction *> AIActionList;
 
 /////////////////////////////////////////////
 //
-//	AICompoundAction
+// AICompoundAction
 
 class AICompoundAction : public AIAction {
 public:
@@ -75,7 +75,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIPlayMessageAction
+// AIPlayMessageAction
 
 class AIPlayMessageAction : public AIAction {
 public:
@@ -91,7 +91,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIStartTimerAction
+// AIStartTimerAction
 
 class AIStartTimerAction : public AIAction {
 public:
@@ -105,7 +105,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIActivateRuleAction
+// AIActivateRuleAction
 
 class AIActivateRuleAction : public AIAction {
 public:
@@ -119,7 +119,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIDeactivateRuleAction
+// AIDeactivateRuleAction
 
 class AIDeactivateRuleAction : public AIAction {
 public:
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 6203843..b0836ab 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -70,7 +70,7 @@ AIArea::~AIArea() {
 	g_AIArea = 0;
 }
 
-//	Save last state of AI rules...
+// Save last state of AI rules...
 void AIArea::saveAIState() {
 	// TODO
 }
@@ -188,16 +188,16 @@ void AIArea::setAIAreaToTime(const LowerClientSignature client, const LowerAreaS
 	}
 }
 
-//	Plays a sequence on an area. When the sequence ends, the previous image
-//	is restored.
-//	Also, is input disabled or not?
-//	Easy answer: yes.
+// Plays a sequence on an area. When the sequence ends, the previous image
+// is restored.
+// Also, is input disabled or not?
+// Easy answer: yes.
 
-//	There are only so many legal combinations of client/area.
-//	Here is the list of supported pairs:
-//		kBiochipSignature		kMiddleAreaSignature
-//		kBiochipSignature		kRightAreaSignature
-//		kInventorySignature		kMiddleAreaSignature
+// There are only so many legal combinations of client/area.
+// Here is the list of supported pairs:
+//     kBiochipSignature        kMiddleAreaSignature
+// 	   kBiochipSignature        kRightAreaSignature
+// 	   kInventorySignature      kMiddleAreaSignature
 
 void AIArea::playAIAreaSequence(const LowerClientSignature, const LowerAreaSignature area, const TimeValue start, const TimeValue stop) {
 	PegasusEngine *vm = (PegasusEngine *)g_engine;
@@ -336,7 +336,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo
 	return result;
 }
 
-//	Only implemented for kMiddleAreaSignature, kInventorySignature
+// Only implemented for kMiddleAreaSignature, kInventorySignature
 void AIArea::loopAIAreaSequence(const LowerClientSignature owner, const LowerAreaSignature area, const TimeValue start, const TimeValue stop) {
 	if (area == kMiddleAreaSignature && owner == kInventorySignature && owner == _middleAreaOwner) {
 		_middleAreaMovie.stop();
@@ -387,7 +387,7 @@ void AIArea::setMiddleMovieTime(const LowerClientSignature client, const TimeVal
 	_middleAreaOwner = client;
 }
 
-//	Only called by kBiochipSignature.
+// Only called by kBiochipSignature.
 void AIArea::setRightMovieTime(const TimeValue time) {
 	if (!_AIMovie.isSurfaceValid()) {
 		// Can't do it when the AI movie is up...
diff --git a/engines/pegasus/ai/ai_condition.h b/engines/pegasus/ai/ai_condition.h
index ba4f411..2d93a52 100755
--- a/engines/pegasus/ai/ai_condition.h
+++ b/engines/pegasus/ai/ai_condition.h
@@ -37,7 +37,7 @@ namespace Pegasus {
 
 /////////////////////////////////////////////
 //
-//	AICondition
+// AICondition
 
 class AICondition {
 public:
@@ -56,7 +56,7 @@ public:
 
 /////////////////////////////////////////////
 //
-//	AIOneChildCondition
+// AIOneChildCondition
 
 class AIOneChildCondition : public AICondition {
 public:
@@ -72,7 +72,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AITwoChildrenCondition
+// AITwoChildrenCondition
 
 class AITwoChildrenCondition : public AICondition {
 public:
@@ -88,7 +88,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AINotCondition
+// AINotCondition
 
 class AINotCondition : public AIOneChildCondition {
 public:
@@ -99,7 +99,7 @@ public:
 
 /////////////////////////////////////////////
 //
-//	AIAndCondition
+// AIAndCondition
 
 class AIAndCondition : public AITwoChildrenCondition {
 public:
@@ -110,7 +110,7 @@ public:
 
 /////////////////////////////////////////////
 //
-//	AIOrCondition
+// AIOrCondition
 
 class AIOrCondition : public AITwoChildrenCondition {
 public:
@@ -121,7 +121,7 @@ public:
 
 /////////////////////////////////////////////
 //
-//	AITimerCondition
+// AITimerCondition
 
 class AITimerCondition : public AICondition {
 public:
@@ -144,7 +144,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AILocationCondition
+// AILocationCondition
 
 class AILocationCondition : public AICondition {
 public:
@@ -164,7 +164,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIDoorOpenedCondition
+// AIDoorOpenedCondition
 
 class AIDoorOpenedCondition : public AICondition {
 public:
@@ -179,7 +179,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIHasItemCondition
+// AIHasItemCondition
 
 class AIHasItemCondition : public AICondition {
 public:
@@ -193,7 +193,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIDoesntHaveItemCondition
+// AIDoesntHaveItemCondition
 
 class AIDoesntHaveItemCondition : public AICondition {
 public:
@@ -207,7 +207,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AICurrentItemCondition
+// AICurrentItemCondition
 
 class AICurrentItemCondition : public AICondition {
 public:
@@ -221,7 +221,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AICurrentBiochipCondition
+// AICurrentBiochipCondition
 
 class AICurrentBiochipCondition : public AICondition {
 public:
@@ -235,7 +235,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIItemStateCondition
+// AIItemStateCondition
 
 class AIItemStateCondition : public AICondition {
 public:
@@ -250,7 +250,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AIEnergyMonitorCondition
+// AIEnergyMonitorCondition
 
 class AIEnergyMonitorCondition : public AICondition {
 public:
@@ -264,7 +264,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	AILastExtraCondition
+// AILastExtraCondition
 
 class AILastExtraCondition : public AICondition {
 public:
@@ -278,7 +278,7 @@ protected:
 
 /////////////////////////////////////////////
 //
-//	Helper functions
+// Helper functions
 
 AICondition *makeLocationAndDoesntHaveItemCondition(const RoomID room, const DirectionConstant direction, const ItemID item);
 
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
index eb9a8ab..77a8025 100755
--- a/engines/pegasus/constants.h
+++ b/engines/pegasus/constants.h
@@ -105,7 +105,7 @@ static const DisplayElementID kCurrentDragSpriteID = 1000;
 
 static const TimeScale kDefaultTimeScale = 600;
 
-//	Ticks per second.
+// Ticks per second.
 
 static const TimeScale kOneTickPerSecond = 1;
 static const TimeScale kTwoTicksPerSecond = 2;
@@ -114,7 +114,7 @@ static const TimeScale kThirtyTicksPerSecond = 30;
 static const TimeScale kSixtyTicksPerSecond = 60;
 static const TimeScale kMovieTicksPerSecond = 600;
 
-//	These times are in seconds.
+// These times are in seconds.
 
 static const TimeValue kOneSecond = 1;
 static const TimeValue kTwoSeconds = 2;
@@ -166,7 +166,7 @@ static const TimeValue kFiftyMinutes = kOneMinute * 50;
 static const TimeValue kOneHour = kOneMinute * 60;
 static const TimeValue kTwoHours = kOneHour * 2;
 
-//	Common times.
+// Common times.
 
 static const TimeValue kHalfSecondPerTwoTicks = kTwoTicksPerSecond / 2;
 static const TimeValue kHalfSecondPerThirtyTicks = kThirtyTicksPerSecond / 2;
@@ -188,7 +188,7 @@ static const TimeValue kOneMinutePerSixtyTicks = kOneMinute * kSixtyTicksPerSeco
 static const TimeValue kFiveMinutesPerSixtyTicks = kFiveMinutes * kSixtyTicksPerSecond;
 static const TimeValue kTenMinutesPerSixtyTicks = kTenMinutes * kSixtyTicksPerSecond;
 
-//	Time in seconds you can hang around Caldoria without going to work...
+// Time in seconds you can hang around Caldoria without going to work...
 static const TimeValue kLateWarning2TimeLimit = kFiveMinutes;
 static const TimeValue kLateWarning3TimeLimit = kTenMinutes;
 
@@ -264,14 +264,14 @@ static const uint32 kPegasusPrimeVersion = 0x00009019;
 static const char kNormalSave = 0;
 static const char kContinueSave = 1;
 
-//	Display IDs.
+// Display IDs.
 
 static const DisplayElementID kNavMovieID = 1;
 static const DisplayElementID kTurnPushID = 2;
 
 static const DisplayElementID kMaxGameShellDisplayID = kTurnPushID;
 
-//	Display ordering.
+// Display ordering.
 
 static const DisplayOrder kNavLayer = 10000;
 static const DisplayOrder kNavMovieOrder = kNavLayer;
@@ -279,7 +279,7 @@ static const DisplayOrder kTurnPushOrder = kNavMovieOrder + 1;
 
 /////////////////////////////////////////////
 //
-//	Display IDs.
+// Display IDs.
 
 static const DisplayElementID kScreenDimmerID = kMaxGameShellDisplayID + 1;
 static const DisplayElementID kInterface1ID = kScreenDimmerID + 1;
@@ -367,7 +367,7 @@ static const CoordType kFinalMessageTop = kInventoryPushTop + 24;
 
 /////////////////////////////////////////////
 //
-//	Notifications.
+// Notifications.
 
 static const NotificationID kJMPDCShellNotificationID = kLastNeighborhoodNotificationID + 1;
 static const NotificationID kInterfaceNotificationID = kJMPDCShellNotificationID + 1;
@@ -386,7 +386,7 @@ static const NotificationID kCaldoriaVidPhoneNotificationID = kNoradGlobeNotific
 static const NotificationID kCaldoriaMessagesNotificationID = kCaldoriaVidPhoneNotificationID + 1;
 static const NotificationID kCaldoriaBombTimerNotificationID = kCaldoriaMessagesNotificationID + 1;
 
-//	Sent to the shell by fShellNotification.
+// Sent to the shell by fShellNotification.
 static const NotificationFlags kGameStartingFlag = 1;
 static const NotificationFlags kNeedNewJumpFlag = kGameStartingFlag << 1;
 static const NotificationFlags kPlayerDiedFlag = kNeedNewJumpFlag << 1;
@@ -395,7 +395,7 @@ static const NotificationFlags kJMPShellNotificationFlags = kGameStartingFlag |
 														kNeedNewJumpFlag |
 														kPlayerDiedFlag;
 
-//	Sent to the interface.
+// Sent to the interface.
 static const NotificationFlags kInventoryLidOpenFlag = 1;
 static const NotificationFlags kInventoryLidClosedFlag = kInventoryLidOpenFlag << 1;
 static const NotificationFlags kInventoryDrawerUpFlag = kInventoryLidClosedFlag << 1;
@@ -414,21 +414,21 @@ static const NotificationFlags kInterfaceNotificationFlags =	kInventoryLidOpenFl
 														kBiochipDrawerUpFlag |
 														kBiochipDrawerDownFlag;
 
-//	Hot spots.
+// Hot spots.
 
-//	Neighborhood hot spots.
+// Neighborhood hot spots.
 
 static const HotSpotID kFirstNeighborhoodSpotID = 5000;
 
-//	kShellSpotFlag is a flag which marks all hot spots which belong to the shell, like
-//	the current item and current biochip spots.
+// kShellSpotFlag is a flag which marks all hot spots which belong to the shell, like
+// the current item and current biochip spots.
 static const HotSpotFlags kShellSpotFlag = 1;
-//	kNeighborhoodSpotFlag is a flag which marks all hot spots which belong to a
-//	neighborhood, like buttons on walls and so on.
+// kNeighborhoodSpotFlag is a flag which marks all hot spots which belong to a
+// neighborhood, like buttons on walls and so on.
 static const HotSpotFlags kNeighborhoodSpotFlag = kShellSpotFlag << 1;
-//	kZoomInSpotFlag is a flag which marks all hot spots which indicate a zoom.
+// kZoomInSpotFlag is a flag which marks all hot spots which indicate a zoom.
 static const HotSpotFlags kZoomInSpotFlag = kNeighborhoodSpotFlag << 1;
-//	kZoomOutSpotFlag is a flag which marks all hot spots which indicate a zoom.
+// kZoomOutSpotFlag is a flag which marks all hot spots which indicate a zoom.
 static const HotSpotFlags kZoomOutSpotFlag = kZoomInSpotFlag << 1;
 
 static const HotSpotFlags kClickSpotFlag = kZoomOutSpotFlag << 1;
@@ -443,10 +443,10 @@ static const HotSpotFlags kHighestGameShellSpotFlag = kOpenDoorSpotFlag;
 
 /////////////////////////////////////////////
 //
-//	Hot spots.
+// Hot spots.
 
-//	Shell hot spots.
-//	The shell reserves all hot spot IDs from 0 to 999
+// Shell hot spots.
+// The shell reserves all hot spot IDs from 0 to 999
 
 static const HotSpotID kCurrentItemSpotID = 0;
 static const HotSpotID kCurrentBiochipSpotID = kCurrentItemSpotID + 1;
@@ -477,28 +477,28 @@ static const HotSpotID kShuttleTractorSpotID = kShuttleGravitonSpotID + 1;
 static const HotSpotID kShuttleViewSpotID = kShuttleTractorSpotID + 1;
 static const HotSpotID kShuttleTransportSpotID = kShuttleViewSpotID + 1;
 
-//	Most of these are obsolete:
+// Most of these are obsolete:
 
-//	kInventoryDropSpotFlag is a flag which marks hot spots which are valid drop spots
-//	for inventory items.
-//	static const HotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
+// kInventoryDropSpotFlag is a flag which marks hot spots which are valid drop spots
+// for inventory items.
+// static const HotSpotFlags kInventoryDropSpotFlag = kHighestGameShellSpotFlag << 1;
 
-//	kBiochipDropSpotFlag is a flag which marks hot spots which are valid drop spots
-//	for biochips.
-//	static const HotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
+// kBiochipDropSpotFlag is a flag which marks hot spots which are valid drop spots
+// for biochips.
+// static const HotSpotFlags kBiochipDropSpotFlag = kInventoryDropSpotFlag << 1;
 
-//	kInventorySpotFlag is a flag which marks hot spots which indicate inventory items
-//	in the environment.
-//	static const HotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
+// kInventorySpotFlag is a flag which marks hot spots which indicate inventory items
+// in the environment.
+// static const HotSpotFlags kInventorySpotFlag = kBiochipDropSpotFlag << 1;
 
-//	kBiochipSpotFlag is a flag which marks hot spots which indicate biochips
-//	in the environment.
+// kBiochipSpotFlag is a flag which marks hot spots which indicate biochips
+// in the environment.
 static const HotSpotFlags kPickUpBiochipSpotFlag = kHighestGameShellSpotFlag << 1;
 static const HotSpotFlags kDropBiochipSpotFlag = kPickUpBiochipSpotFlag << 1;
 
 static const HotSpotFlags kInfoReturnSpotFlag = kDropBiochipSpotFlag << 1;
 
-//	Biochip and inventory hot spot flags...
+// Biochip and inventory hot spot flags...
 
 static const HotSpotFlags kAIBiochipSpotFlag = kInfoReturnSpotFlag << 1;
 static const HotSpotFlags kPegasusBiochipSpotFlag = kAIBiochipSpotFlag << 1;
@@ -521,7 +521,7 @@ static const int32 kDeathMenuID = 4;
 
 /////////////////////////////////////////////
 //
-//	Menu commands.
+// Menu commands.
 
 static const GameMenuCommand kMenuCmdOverview = kMenuCmdNoCommand + 1;
 static const GameMenuCommand kMenuCmdStartAdventure = kMenuCmdOverview + 1;
@@ -551,16 +551,16 @@ static const GameMenuCommand kMenuCmdEjectRestart = kMenuCmdCancelRestart + 1;
 static const TimeValue kMenuButtonHiliteTime = 20;
 static const TimeScale kMenuButtonHiliteScale = kSixtyTicksPerSecond;
 
-//	PICT resources:
+// PICT resources:
 
-//	Warning light PICTs:
+// Warning light PICTs:
 
 static const ResIDType kLightOffID = 128;
 static const ResIDType kLightYellowID = 129;
 static const ResIDType kLightOrangeID = 130;
 static const ResIDType kLightRedID = 131;
 
-//	Date PICTs:
+// Date PICTs:
 
 static const ResIDType kDatePrehistoricID = 138;
 static const ResIDType kDate2112ID = 139;
@@ -570,7 +570,7 @@ static const ResIDType kDate2318ID = 142;
 
 /////////////////////////////////////////////
 //
-//	Display Order
+// Display Order
 
 static const DisplayOrder kCroppedMovieLayer = 11000;
 
@@ -626,7 +626,7 @@ static const DisplayOrder kPauseSmallHiliteOrder = kPauseLargeHiliteOrder + 1;
 
 /////////////////////////////////////////////
 //
-//	Death reasons.
+// Death reasons.
 enum {
 	// Caldoria
 	kDeathUncreatedInCaldoria = 1,
@@ -697,10 +697,10 @@ static const CoordType kAIRightAreaWidth = 96;
 static const CoordType kAIRightAreaHeight = 96;
 
 enum {
-	kTSAPlayerNotArrived,				//	initial state, must be zero
-	kTSAPlayerForcedReview,				//	Player must watch TBP before rip occurs.
-	kTSAPlayerDetectedRip,				//	Player finished TBP, rip alarm just went off.
-	kTSAPlayerNeedsHistoricalLog,		//	Player is instructed to get historical log
+	kTSAPlayerNotArrived,				// initial state, must be zero
+	kTSAPlayerForcedReview,				// Player must watch TBP before rip occurs.
+	kTSAPlayerDetectedRip,				// Player finished TBP, rip alarm just went off.
+	kTSAPlayerNeedsHistoricalLog,		// Player is instructed to get historical log
 	kTSAPlayerGotHistoricalLog,
 	kTSAPlayerInstalledHistoricalLog,
 	kTSABossSawHistoricalLog,
@@ -718,7 +718,7 @@ enum {
 
 /////////////////////////////////////////////
 //
-//	Mode static constants.
+// Mode static constants.
 
 static const GameMode kModeInventoryPick = kLastGameShellMode + 1;
 static const GameMode kModeBiochipPick = kModeInventoryPick + 1;
diff --git a/engines/pegasus/elements.cpp b/engines/pegasus/elements.cpp
index 850b9cb..0310d26 100644
--- a/engines/pegasus/elements.cpp
+++ b/engines/pegasus/elements.cpp
@@ -135,11 +135,11 @@ void DisplayElement::show() {
 	}
 }
 
-//	Only invalidates this element's bounding rectangle if all these conditions are true:
-//	--	The triggered element is this element.
-//	--	The element is displaying on the display list.
-//	--	The element is visible.
-//	--	The element is part of the active layer OR is one of the reserved items.
+// Only invalidates this element's bounding rectangle if all these conditions are true:
+// -- The triggered element is this element.
+// -- The element is displaying on the display list.
+// -- The element is visible.
+// -- The element is part of the active layer OR is one of the reserved items.
 void DisplayElement::triggerRedraw() {
 	GraphicsManager *gfx = ((PegasusEngine *)g_engine)->_gfx;
 
diff --git a/engines/pegasus/elements.h b/engines/pegasus/elements.h
index 009cb3a..6a465d1 100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@ -131,10 +131,10 @@ protected:
 	TimeValue _lastTime;
 };
 
-//	This class reads PICT resources and plays them like a movie.
-//	Assumes there is a resource of type 'PFrm' describing the time values for each
-//	PICT frame, as well as the total time in the movie.
-//	Assumes that PICT frames begin at PICT 128
+// This class reads PICT resources and plays them like a movie.
+// Assumes there is a resource of type 'PFrm' describing the time values for each
+// PICT frame, as well as the total time in the movie.
+// Assumes that PICT frames begin at PICT 128
 
 class FrameSequence : public IdlerAnimation {
 public:
diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
index 5f12bf4..7a9ca78 100755
--- a/engines/pegasus/energymonitor.cpp
+++ b/engines/pegasus/energymonitor.cpp
@@ -266,7 +266,7 @@ void EnergyMonitor::calibrateEnergyBar() {
 	setEnergyValue(0);
 	setEnergyDrainRate(-(int32)kMaxJMPEnergy / 2);
 
-	//	Make sure warning light is hidden...
+	// Make sure warning light is hidden...
 	_energyLight.hide();
 	while (getCurrentEnergy() != (int32)kMaxJMPEnergy) {
 		vm->checkCallBacks();
diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
index 4c111af..02377d5 100755
--- a/engines/pegasus/energymonitor.h
+++ b/engines/pegasus/energymonitor.h
@@ -49,10 +49,10 @@ protected:
 	TimeValue _blinkDuration;
 };
 
-//	Energy monitor constants.
+// Energy monitor constants.
 
-//	These are in seconds.
-//	Max is two hours
+// These are in seconds.
+// Max is two hours
 static const uint32 kMaxJMPEnergy = 7200;
 
 static const uint32 kCasualEnergy = kMaxJMPEnergy * 100 / 100;      // 100%
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
index 0a8597d..601960e 100755
--- a/engines/pegasus/gamestate.cpp
+++ b/engines/pegasus/gamestate.cpp
@@ -41,7 +41,7 @@ Common::Error GameStateManager::writeGameState(Common::WriteStream *stream) {
 	stream->writeUint16BE(_currentRoom);
 	stream->writeByte(_currentDirection);
 	stream->writeUint16BE(_nexNeighborhoodID);
-	stream->writeUint16BE(_nexRoomID);
+	stream->writeUint16BE(_nextRoomID);
 	stream->writeByte(_nextDirection);
 	stream->writeUint16BE(_lastNeighborhood);
 	stream->writeUint16BE(_lastRoom);
@@ -71,7 +71,7 @@ Common::Error GameStateManager::readGameState(Common::ReadStream *stream) {
 	_currentRoom = stream->readUint16BE();
 	_currentDirection = stream->readByte();
 	_nexNeighborhoodID = stream->readUint16BE();
-	_nexRoomID = stream->readUint16BE();
+	_nextRoomID = stream->readUint16BE();
 	_nextDirection = stream->readByte();
 	_lastNeighborhood = stream->readUint16BE();
 	_lastRoom = stream->readUint16BE();
@@ -101,7 +101,7 @@ void GameStateManager::resetGameState() {
 	_currentRoom = kNoRoomID;
 	_currentDirection = kNoDirection;
 	_nexNeighborhoodID = kNoNeighborhoodID;
-	_nexRoomID = kNoRoomID;
+	_nextRoomID = kNoRoomID;
 	_nextDirection = kNoDirection;
 	_lastNeighborhood = kNoNeighborhoodID;
 	_lastRoom = kNoRoomID;
@@ -169,13 +169,13 @@ RoomViewID GameStateManager::getCurrentRoomAndView() {
 
 void GameStateManager::getNextLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction) {
 	neighborhood = _nexNeighborhoodID;
-	room = _nexRoomID;
+	room = _nextRoomID;
 	direction = _nextDirection;
 }
 
 void GameStateManager::setNextLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 	_nexNeighborhoodID = neighborhood;
-	_nexRoomID = room;
+	_nextRoomID = room;
 	_nextDirection = direction;
 }
 
@@ -188,11 +188,11 @@ void GameStateManager::setNextNeighborhood(const NeighborhoodID neighborhood) {
 }
 
 RoomID GameStateManager::getNextRoom() {
-	return _nexRoomID;
+	return _nextRoomID;
 }
 
 void GameStateManager::setNextRoom(const RoomID room) {
-	_nexRoomID = room;
+	_nextRoomID = room;
 }
 
 DirectionConstant GameStateManager::getNextDirection() {
@@ -530,7 +530,7 @@ GameScoreType GameStateManager::getTotalScore() {
 
 /////////////////////////////////////////////
 //
-//	Caldoria data
+// Caldoria data
 	
 void GameStateManager::writeCaldoriaState(Common::WriteStream *stream) {
 	_caldoriaFlags.writeToStream(stream);
@@ -549,7 +549,7 @@ void GameStateManager::resetCaldoriaState() {
 
 /////////////////////////////////////////////
 //
-//	TSA data
+// TSA data
 
 void GameStateManager::writeTSAState(Common::WriteStream *stream) {
 	_TSAFlags.writeToStream(stream);
@@ -580,7 +580,7 @@ void GameStateManager::resetTSAState() {
 
 /////////////////////////////////////////////
 //
-//	Prehistoric data
+// Prehistoric data
 
 void GameStateManager::writePrehistoricState(Common::WriteStream *stream) {
 	_prehistoricFlags.writeToStream(stream);
@@ -596,7 +596,7 @@ void GameStateManager::resetPrehistoricState() {
 
 /////////////////////////////////////////////
 //
-//	Norad data
+// Norad data
 
 void GameStateManager::writeNoradState(Common::WriteStream *stream) {
 	_noradFlags.writeToStream(stream);
@@ -618,7 +618,7 @@ void GameStateManager::resetNoradState() {
 
 /////////////////////////////////////////////
 //
-//	Mars data
+// Mars data
 
 void GameStateManager::writeMarsState(Common::WriteStream *stream) {
 	_marsFlags.writeToStream(stream);
@@ -634,7 +634,7 @@ void GameStateManager::resetMarsState() {
 
 /////////////////////////////////////////////
 //
-//	WSC data
+// WSC data
 
 void GameStateManager::writeWSCState(Common::WriteStream *stream) {
 	_WSCFlags.writeToStream(stream);
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index 5eab093..7812003 100755
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -41,7 +41,7 @@ namespace Common {
 
 namespace Pegasus {
 
-//	The only things saved in here are things which get written out to a saved game file...
+// The only things saved in here are things which get written out to a saved game file...
 
 enum {
 	kGlobalWalkthroughFlag,
@@ -347,494 +347,494 @@ public:
 
 	// Pegasus Prime
 	
-	//	Scoring...
-	//	Scoring "Set" functions.
-	//	Caldoria/TSA scoring
+	// Scoring...
+	// Scoring "Set" functions.
+	// Caldoria/TSA scoring
 	void setScoringSawINN(const bool = true);
 	void setScoringTookShower(const bool = true);
 	void setScoringFixedHair(const bool = true);
 	void setScoringGotKeyCard(const bool = true);
 	void setScoringReadPaper(const bool = true);
 	void setScoringLookThroughTelescope(const bool = true);
-	void						setScoringSawCaldoriaKiosk(const bool = true);
-	void						setScoringGoToTSA(const bool = true);
-	void						setScoringEnterTSA(const bool = true);
-	void						setScoringSawBust1(const bool = true);
-	void						setScoringSawBust2(const bool = true);
-	void						setScoringSawBust3(const bool = true);
-	void						setScoringSawBust4(const bool = true);
-	void						setScoringSawBust5(const bool = true);
-	void						setScoringSawBust6(const bool = true);
-	void						setScoringSawTheory(const bool = true);
-	void						setScoringSawBackground(const bool = true);
-	void						setScoringSawProcedure(const bool = true);
-	void						setScoringGotJourneymanKey(const bool = true);
-	void						setScoringGotPegasusBiochip(const bool = true);
-	void						setScoringGotBiosuit(const bool = true);
-	void						setScoringGoToPrehistoric(const bool = true);
-	void						setScoringPutLogInReader(const bool = true);
-	void						setScoringSawCaldoriaNormal(const bool = true);
-	void						setScoringSawCaldoriaAltered(const bool = true);
-	void						setScoringSawNoradNormal(const bool = true);
-	void						setScoringSawNoradAltered(const bool = true);
-	void						setScoringSawMarsNormal(const bool = true);
-	void						setScoringSawMarsAltered(const bool = true);
-	void						setScoringSawWSCNormal(const bool = true);
-	void						setScoringSawWSCAltered(const bool = true);
-	void						setScoringWentToReadyRoom2(const bool = true);
-	void						setScoringWentAfterSinclair(const bool = true);
-	void						setScoringUsedCardBomb(const bool = true);
-	void						setScoringShieldedCardBomb(const bool = true);
-	void						setScoringStunnedSinclair(const bool = true);
-	void						setScoringDisarmedNuke(const bool = true);
-
-	//	Prehistoric scoring
-	void						setScoringThrewBreaker(const bool = true);
-	void						setScoringExtendedBridge(const bool = true);
-	void						setScoringGotHistoricalLog(const bool = true);
-	void						setScoringFinishedPrehistoric(const bool = true);
-
-	//	Mars scoring
-	void						setScoringThrownByRobot(const bool = true);
-	void						setScoringGotMarsCard(const bool = true);
-	void						setScoringSawMarsKiosk(const bool = true);
-	void						setScoringSawTransportMap(const bool = true);
-	void						setScoringGotCrowBar(const bool = true);
-	void						setScoringTurnedOnTransport(const bool = true);
-	void						setScoringGotOxygenMask(const bool = true);
-	void						setScoringAvoidedRobot(const bool = true);
-	void						setScoringActivatedPlatform(const bool = true);
-	void						setScoringUsedLiquidNitrogen(const bool = true);
-	void						setScoringUsedCrowBar(const bool = true);
-	void						setScoringFoundCardBomb(const bool = true);
-	void						setScoringDisarmedCardBomb(const bool = true);
-	void						setScoringGotCardBomb(const bool = true);
-	void						setScoringThreadedMaze(const bool = true);
-	void						setScoringThreadedGearRoom(const bool = true);
-	void						setScoringEnteredShuttle(const bool = true);
-	void						setScoringEnteredLaunchTube(const bool = true);
-	void						setScoringStoppedRobotsShuttle(const bool = true);
-	void						setScoringGotMarsOpMemChip(const bool = true);
-	void						setScoringFinishedMars(const bool = true);
-
-	//	Norad scoring
-	void						setScoringSawSecurityMonitor(const bool = true);
-	void						setScoringFilledOxygenCanister(const bool = true);
-	void						setScoringFilledArgonCanister(const bool = true);
-	void						setScoringSawUnconsciousOperator(const bool = true);
-	void						setScoringWentThroughPressureDoor(const bool = true);
-	void						setScoringPreppedSub(const bool = true);
-	void						setScoringEnteredSub(const bool = true);
-	void						setScoringExitedSub(const bool = true);
-	void						setScoringSawRobotAt54North(const bool = true);
-	void						setScoringPlayedWithClaw(const bool = true);
-	void						setScoringUsedRetinalChip(const bool = true);
-	void						setScoringFinishedGlobeGame(const bool = true);
-	void						setScoringStoppedNoradRobot(const bool = true);
-	void						setScoringGotNoradOpMemChip(const bool = true);
-	void						setScoringFinishedNorad(const bool = true);
-
-	//	WSC scoring
-	void						setScoringRemovedDart(const bool = true);
-	void						setScoringAnalyzedDart(const bool = true);
-	void						setScoringBuiltAntidote(const bool = true);
-	void						setScoringGotSinclairKey(const bool = true);
-	void						setScoringGotArgonCanister(const bool = true);
-	void						setScoringGotNitrogenCanister(const bool = true);
-	void						setScoringPlayedWithMessages(const bool = true);
-	void						setScoringSawMorphExperiment(const bool = true);
-	void						setScoringEnteredSinclairOffice(const bool = true);
-	void						setScoringSawBrochure(const bool = true);
-	void						setScoringSawSinclairEntry1(const bool = true);
-	void						setScoringSawSinclairEntry2(const bool = true);
-	void						setScoringSawSinclairEntry3(const bool = true);
-	void						setScoringSawWSCDirectory(const bool = true);
-	void						setScoringUsedCrowBarInWSC(const bool = true);
-	void						setScoringFinishedPlasmaDodge(const bool = true);
-	void						setScoringOpenedCatwalk(const bool = true);
-	void						setScoringStoppedWSCRobot(const bool = true);
-	void						setScoringGotWSCOpMemChip(const bool = true);
-	void						setScoringFinishedWSC(const bool = true);
-
-	//	Gandhi scoring
-	void						setScoringMarsGandhi(const bool = true);
-	void						setScoringNoradGandhi(const bool = true);
-	void						setScoringWSCGandhi(const bool = true);
-	
-	//	Scoring "Get" functions.
-	bool					getScoringSawINN();
-	bool					getScoringTookShower();
-	bool					getScoringFixedHair();
-	bool					getScoringGotKeyCard();
-	bool					getScoringReadPaper();
-	bool					getScoringLookThroughTelescope();
-	bool					getScoringSawCaldoriaKiosk();
-	bool					getScoringGoToTSA();
-	bool					getScoringEnterTSA();
-	bool					getScoringSawBust1();
-	bool					getScoringSawBust2();
-	bool					getScoringSawBust3();
-	bool					getScoringSawBust4();
-	bool					getScoringSawBust5();
-	bool					getScoringSawBust6();
-	bool					getScoringSawTheory();
-	bool					getScoringSawBackground();
-	bool					getScoringSawProcedure();
-	bool					getScoringGotJourneymanKey();
-	bool					getScoringGotPegasusBiochip();
-	bool					getScoringGotBiosuit();
-	bool					getScoringGoToPrehistoric();
-	bool					getScoringPutLogInReader();
-	bool					getScoringSawCaldoriaNormal();
-	bool					getScoringSawCaldoriaAltered();
-	bool					getScoringSawNoradNormal();
-	bool					getScoringSawNoradAltered();
-	bool					getScoringSawMarsNormal();
-	bool					getScoringSawMarsAltered();
-	bool					getScoringSawWSCNormal();
-	bool					getScoringSawWSCAltered();
-	bool					getScoringWentToReadyRoom2();
-	bool					getScoringWentAfterSinclair();
-	bool					getScoringUsedCardBomb();
-	bool					getScoringShieldedCardBomb();
-	bool					getScoringStunnedSinclair();
-	bool					getScoringDisarmedNuke();
-	bool					getScoringThrewBreaker();
-	bool					getScoringExtendedBridge();
-	bool					getScoringGotHistoricalLog();
-	bool					getScoringFinishedPrehistoric();
-	bool					getScoringThrownByRobot();
-	bool					getScoringGotMarsCard();
-	bool					getScoringSawMarsKiosk();
-	bool					getScoringSawTransportMap();
-	bool					getScoringGotCrowBar();
-	bool					getScoringTurnedOnTransport();
-	bool					getScoringGotOxygenMask();
-	bool					getScoringAvoidedRobot();
-	bool					getScoringActivatedPlatform();
-	bool					getScoringUsedLiquidNitrogen();
-	bool					getScoringUsedCrowBar();
-	bool					getScoringFoundCardBomb();
-	bool					getScoringDisarmedCardBomb();
-	bool					getScoringGotCardBomb();
-	bool					getScoringThreadedMaze();
-	bool					getScoringThreadedGearRoom();
-	bool					getScoringEnteredShuttle();
-	bool					getScoringEnteredLaunchTube();
-	bool					getScoringStoppedRobotsShuttle();
-	bool					getScoringGotMarsOpMemChip();
-	bool					getScoringFinishedMars();
-	bool					getScoringSawSecurityMonitor();
-	bool					getScoringFilledOxygenCanister();
-	bool					getScoringFilledArgonCanister();
-	bool					getScoringSawUnconsciousOperator();
-	bool					getScoringWentThroughPressureDoor();
-	bool					getScoringPreppedSub();
-	bool					getScoringEnteredSub();
-	bool					getScoringExitedSub();
-	bool					getScoringSawRobotAt54North();
-	bool					getScoringPlayedWithClaw();
-	bool					getScoringUsedRetinalChip();
-	bool					getScoringFinishedGlobeGame();
-	bool					getScoringStoppedNoradRobot();
-	bool					getScoringGotNoradOpMemChip();
-	bool					getScoringFinishedNorad();
-	bool					getScoringRemovedDart();
-	bool					getScoringAnalyzedDart();
-	bool					getScoringBuiltAntidote();
-	bool					getScoringGotSinclairKey();
-	bool					getScoringGotArgonCanister();
-	bool					getScoringGotNitrogenCanister();
-	bool					getScoringPlayedWithMessages();
-	bool					getScoringSawMorphExperiment();
-	bool					getScoringEnteredSinclairOffice();
-	bool					getScoringSawBrochure();
-	bool					getScoringSawSinclairEntry1();
-	bool					getScoringSawSinclairEntry2();
-	bool					getScoringSawSinclairEntry3();
-	bool					getScoringSawWSCDirectory();
-	bool					getScoringUsedCrowBarInWSC();
-	bool					getScoringFinishedPlasmaDodge();
-	bool					getScoringOpenedCatwalk();
-	bool					getScoringStoppedWSCRobot();
-	bool					getScoringGotWSCOpMemChip();
-	bool					getScoringFinishedWSC();
-	bool					getScoringMarsGandhi();
-	bool					getScoringNoradGandhi();
-	bool					getScoringWSCGandhi();
-
-	GameScoreType			getCaldoriaTSAScore();
-	GameScoreType			getPrehistoricScore();
-	GameScoreType			getMarsScore();
-	GameScoreType			getNoradScore();
-	GameScoreType			getWSCScore();
-	GameScoreType			getGandhiScore();
-	GameScoreType			getTotalScore();
-
-	void					writeCaldoriaState(Common::WriteStream *stream);
-	void					readCaldoriaState(Common::ReadStream *stream);
-	void						resetCaldoriaState();
-	
-	void					writeTSAState(Common::WriteStream *stream);
-	void					readTSAState(Common::ReadStream *stream);
-	void						resetTSAState();
-	
-	void					writePrehistoricState(Common::WriteStream *stream);
-	void					readPrehistoricState(Common::ReadStream *stream);
-	void						resetPrehistoricState();
-	
-	void					writeNoradState(Common::WriteStream *stream);
-	void					readNoradState(Common::ReadStream *stream);
-	void						resetNoradState();
-	
-	void					writeMarsState(Common::WriteStream *stream);
-	void					readMarsState(Common::ReadStream *stream);
-	void						resetMarsState();
-	
-	void					writeWSCState(Common::WriteStream *stream);
-	void					readWSCState(Common::ReadStream *stream);
-	void						resetWSCState();
-	
-	//	Globals.
-	void						setWalkthroughMode(bool);
-	bool					getWalkthroughMode();
-	void						setShieldOn(bool);
-	bool					getShieldOn();
-	void						setEasterEgg(bool);
-	bool					getEasterEgg();
-	void						setBeenToWSC(bool value);
-	bool					getBeenToWSC();
-	void						setBeenToMars(bool value);
-	bool					getBeenToMars();
-	void						setBeenToNorad(bool value);
-	bool					getBeenToNorad();
-	void						setWSCFinished(bool);
-	bool					getWSCFinished();
-	void						setMarsFinished(bool);
-	bool					getMarsFinished();
-	void						setNoradFinished(bool);
-	bool					getNoradFinished();
-	bool					allTimeZonesFinished();
-	void						setTakenItemID(ItemID, bool);
-	bool					isTakenItemID(ItemID);
-	void						setTakenItem(Item *, bool);
-	bool					isTakenItem(Item *);
-	
-	//	Caldoria
-	void						setCaldoriaFuseTimeLimit(const TimeValue);
-	TimeValue				getCaldoriaFuseTimeLimit();
-	void						setCaldoriaSeenPullback(bool);
-	bool					getCaldoriaSeenPullback();
-	void						setCaldoriaMadeOJ(bool);
-	bool					getCaldoriaMadeOJ();
-	void						setCaldoriaWokenUp(bool);
-	bool					getCaldoriaWokenUp();
-	void						setCaldoriaDidRecalibration(bool);
-	bool					getCaldoriaDidRecalibration();
-	void						setCaldoriaSeenSinclairInElevator(bool);
-	bool					getCaldoriaSeenSinclairInElevator();
-	void						setCaldoriaINNAnnouncing(bool);
-	bool					getCaldoriaINNAnnouncing();
-	void						setCaldoriaSeenINN(bool);
-	bool					getCaldoriaSeenINN();
-	void						setCaldoriaSeenMessages(bool);
-	bool					getCaldoriaSeenMessages();
-	void						setCaldoriaSinclairShot(bool);
-	bool					getCaldoriaSinclairShot();
-	void						setCaldoriaBombDisarmed(bool);
-	bool					getCaldoriaBombDisarmed();
-	void						setCaldoriaRoofDoorOpen(bool);
-	bool					getCaldoriaRoofDoorOpen();
-	void						setCaldoriaDoneHygiene(bool);
-	bool					getCaldoriaDoneHygiene();
-	void						setCaldoriaSawVoiceAnalysis(bool);
-	bool					getCaldoriaSawVoiceAnalysis();
-	void						setCaldoriaDoorBombed(bool);
-	bool					getCaldoriaDoorBombed();
-	void						setCaldoriaGunAimed(bool);
-	bool					getCaldoriaGunAimed();
-	
-	//	TSA
-	void						setRipTimerTime(TimeValue);
-	TimeValue				getRipTimerTime();
-	void						setTSAFuseTimeLimit(TimeValue);
-	TimeValue				getTSAFuseTimeLimit();
-	void						setT0BMonitorMode(byte);
-	byte						getT0BMonitorMode();
-	void						setTSAState(byte);
-	byte						getTSAState();
-	void						setT0BMonitorStart(TimeValue);
-	TimeValue				getT0BMonitorStart();
-	void						setTSAIDedAtDoor(bool);
-	bool					getTSAIDedAtDoor();
-	void						setTSA0BZoomedIn(bool);
-	bool					getTSA0BZoomedIn();
-	void						setTSAFrontDoorUnlockedOutside(bool);
-	bool					getTSAFrontDoorUnlockedOutside();
-	void						setTSAFrontDoorUnlockedInside(bool);
-	bool					getTSAFrontDoorUnlockedInside();
-	void						setTSASeenRobotGreeting(bool);
-	bool					getTSASeenRobotGreeting();
-	void						setTSASeenTheory(bool);
-	bool					getTSASeenTheory();
-	void						setTSASeenBackground(bool);
-	bool					getTSASeenBackground();
-	void						setTSASeenProcedure(bool);
-	bool					getTSASeenProcedure();
-	void						setTSASeenAgent3AtDoor(bool);
-	bool					getTSASeenAgent3AtDoor();
-	void						setTSACommandCenterLocked(bool);
-	bool					getTSACommandCenterLocked();
-	void						setTSASeenCaldoriaNormal(bool);
-	bool					getTSASeenCaldoriaNormal();
-	void						setTSASeenCaldoriaAltered(bool);
-	bool					getTSASeenCaldoriaAltered();
-	void						setTSASeenNoradNormal(bool);
-	bool					getTSASeenNoradNormal();
-	void						setTSASeenNoradAltered(bool);
-	bool					getTSASeenNoradAltered();
-	void						setTSASeenMarsNormal(bool);
-	bool					getTSASeenMarsNormal();
-	void						setTSASeenMarsAltered(bool);
-	bool					getTSASeenMarsAltered();
-	void						setTSASeenWSCNormal(bool);
-	bool					getTSASeenWSCNormal();
-	void						setTSASeenWSCAltered(bool);
-	bool					getTSASeenWSCAltered();
-	void						setTSABiosuitOn(bool);
-	bool					getTSABiosuitOn();
-	
-	//	Prehistoric
-	void						setPrehistoricTriedToExtendBridge(bool);
-	bool					getPrehistoricTriedToExtendBridge();
-	void						setPrehistoricSeenTimeStream(bool);
-	bool					getPrehistoricSeenTimeStream();
-	void						setPrehistoricSeenFlyer1(bool);
-	bool					getPrehistoricSeenFlyer1();
-	void						setPrehistoricSeenFlyer2(bool);
-	bool					getPrehistoricSeenFlyer2();
-	void						setPrehistoricSeenBridgeZoom(bool);
-	bool					getPrehistoricSeenBridgeZoom();
-	void						setPrehistoricBreakerThrown(bool);
-	bool					getPrehistoricBreakerThrown();
-	
-	//	Norad
-	void						setNoradSeenTimeStream(bool);
-	bool					getNoradSeenTimeStream();
-	void						setNoradGassed(bool);
-	bool					getNoradGassed();
-	void						setNoradFillingStationOn(bool);
-	bool					getNoradFillingStationOn();
-	void						setNoradN22MessagePlayed(bool);
-	bool					getNoradN22MessagePlayed();
-	void						setNoradPlayedGlobeGame(bool);
-	bool					getNoradPlayedGlobeGame();
-	void						setNoradBeatRobotWithClaw(bool);
-	bool					getNoradBeatRobotWithClaw();
-	void						setNoradBeatRobotWithDoor(bool);
-	bool					getNoradBeatRobotWithDoor();
-	void						setNoradRetScanGood(bool);
-	bool					getNoradRetScanGood();
-	void						setNoradWaitingForLaser(bool);
-	bool					getNoradWaitingForLaser();
-	void						setNoradSubRoomPressure(uint16);
-	uint16					getNoradSubRoomPressure();
-	void						setNoradSubPrepState(NoradSubPrepState);
-	NoradSubPrepState		getNoradSubPrepState();
-	void						setNoradArrivedFromSub(bool);
-	bool					getNoradArrivedFromSub();
-	
-	//	Mars
-	void						setMarsSeenTimeStream(bool);
-	bool					getMarsSeenTimeStream();	
-	void						setMarsHeardUpperPodMessage(bool);
-	bool					getMarsHeardUpperPodMessage();
-	void						setMarsRobotThrownPlayer(bool);
-	bool					getMarsRobotThrownPlayer();
-	void						setMarsHeardCheckInMessage(bool);
-	bool					getMarsHeardCheckInMessage();
-	void						setMarsPodAtUpperPlatform(bool);
-	bool					getMarsPodAtUpperPlatform();
-	void						setMarsSeenThermalScan(bool);
-	bool					getMarsSeenThermalScan();
-	void						setMarsArrivedBelow(bool);
-	bool					getMarsArrivedBelow();
-	void						setMarsSeenRobotAtReactor(bool);
-	bool					getMarsSeenRobotAtReactor();
-	void						setMarsAvoidedReactorRobot(bool);
-	bool					getMarsAvoidedReactorRobot();
-	void						setMarsInAirlock(bool);
-	bool					getMarsInAirlock();
-	void						setMarsAirlockOpen(bool);
-	bool					getMarsAirlockOpen();
-	void						setMarsMaskOnFiller(bool);
-	bool					getMarsMaskOnFiller();
-	void						setMarsLockFrozen(bool);
-	bool					getMarsLockFrozen();
-	void						setMarsLockBroken(bool);
-	bool					getMarsLockBroken();
-	void						setMarsMazeDoorPair1(bool);
-	bool					getMarsMazeDoorPair1();
-	void						setMarsMazeDoorPair2(bool);
-	bool					getMarsMazeDoorPair2();
-	void						setMarsMazeDoorPair3(bool);
-	bool					getMarsMazeDoorPair3();
-	void						setMarsSawRobotLeave(bool);
-	bool					getMarsSawRobotLeave();
-	void						setMarsSecurityDown(bool);
-	bool					getMarsSecurityDown();
-	void						setMarsFinishedCanyonChase(bool);
-	bool					getMarsFinishedCanyonChase();
-	void						setMarsThreadedMaze(bool);
-	bool					getMarsThreadedMaze();
-	void						setMarsHitRobotWithCannon(bool);
-	bool					getMarsHitRobotWithCannon();
-	void						setMarsReadyForShuttleTransport(bool);
-	bool					getMarsReadyForShuttleTransport();
-
-	//	WSC
-	void						setWSCSeenTimeStream(bool);
-	bool					getWSCSeenTimeStream();
-	void						setWSCPoisoned(bool);
-	bool					getWSCPoisoned();
-	void						setWSCAnsweredAboutDart(bool);
-	bool					getWSCAnsweredAboutDart();
-	void						setWSCRemovedDart(bool);
-	bool					getWSCRemovedDart();
-	void						setWSCAnalyzerOn(bool);
-	bool					getWSCAnalyzerOn();
-	void						setWSCDartInAnalyzer(bool);
-	bool					getWSCDartInAnalyzer();
-	void						setWSCAnalyzedDart(bool);
-	bool					getWSCAnalyzedDart();
-	void						setWSCSawMorph(bool);
-	bool					getWSCSawMorph();
-	void						setWSCDesignedAntidote(bool);
-	bool					getWSCDesignedAntidote();
-	void						setWSCPickedUpAntidote(bool);
-	bool					getWSCPickedUpAntidote();
-	void						setWSCOfficeMessagesOpen(bool);
-	bool					getWSCOfficeMessagesOpen();
-	void						setWSCSeenNerd(bool);
-	bool					getWSCSeenNerd();
-	void						setWSCHeardPage1(bool);
-	bool					getWSCHeardPage1();
-	void						setWSCHeardPage2(bool);
-	bool					getWSCHeardPage2();
-	void						setWSCHeardCheckIn(bool);
-	bool					getWSCHeardCheckIn();
-	void						setWSCDidPlasmaDodge(bool);
-	bool					getWSCDidPlasmaDodge();
-	void						setWSCSeenSinclairLecture(bool);
-	bool					getWSCSeenSinclairLecture();
-	void						setWSCBeenAtWSC93(bool);
-	bool					getWSCBeenAtWSC93();
-	void						setWSCCatwalkDark(bool);
-	bool					getWSCCatwalkDark();
-	void						setWSCRobotDead(bool);
-	bool					getWSCRobotDead();
-	void						setWSCRobotGone(bool);
-	bool					getWSCRobotGone();
+	void setScoringSawCaldoriaKiosk(const bool = true);
+	void setScoringGoToTSA(const bool = true);
+	void setScoringEnterTSA(const bool = true);
+	void setScoringSawBust1(const bool = true);
+	void setScoringSawBust2(const bool = true);
+	void setScoringSawBust3(const bool = true);
+	void setScoringSawBust4(const bool = true);
+	void setScoringSawBust5(const bool = true);
+	void setScoringSawBust6(const bool = true);
+	void setScoringSawTheory(const bool = true);
+	void setScoringSawBackground(const bool = true);
+	void setScoringSawProcedure(const bool = true);
+	void setScoringGotJourneymanKey(const bool = true);
+	void setScoringGotPegasusBiochip(const bool = true);
+	void setScoringGotBiosuit(const bool = true);
+	void setScoringGoToPrehistoric(const bool = true);
+	void setScoringPutLogInReader(const bool = true);
+	void setScoringSawCaldoriaNormal(const bool = true);
+	void setScoringSawCaldoriaAltered(const bool = true);
+	void setScoringSawNoradNormal(const bool = true);
+	void setScoringSawNoradAltered(const bool = true);
+	void setScoringSawMarsNormal(const bool = true);
+	void setScoringSawMarsAltered(const bool = true);
+	void setScoringSawWSCNormal(const bool = true);
+	void setScoringSawWSCAltered(const bool = true);
+	void setScoringWentToReadyRoom2(const bool = true);
+	void setScoringWentAfterSinclair(const bool = true);
+	void setScoringUsedCardBomb(const bool = true);
+	void setScoringShieldedCardBomb(const bool = true);
+	void setScoringStunnedSinclair(const bool = true);
+	void setScoringDisarmedNuke(const bool = true);
+
+	// Prehistoric scoring
+	void setScoringThrewBreaker(const bool = true);
+	void setScoringExtendedBridge(const bool = true);
+	void setScoringGotHistoricalLog(const bool = true);
+	void setScoringFinishedPrehistoric(const bool = true);
+
+	// Mars scoring
+	void setScoringThrownByRobot(const bool = true);
+	void setScoringGotMarsCard(const bool = true);
+	void setScoringSawMarsKiosk(const bool = true);
+	void setScoringSawTransportMap(const bool = true);
+	void setScoringGotCrowBar(const bool = true);
+	void setScoringTurnedOnTransport(const bool = true);
+	void setScoringGotOxygenMask(const bool = true);
+	void setScoringAvoidedRobot(const bool = true);
+	void setScoringActivatedPlatform(const bool = true);
+	void setScoringUsedLiquidNitrogen(const bool = true);
+	void setScoringUsedCrowBar(const bool = true);
+	void setScoringFoundCardBomb(const bool = true);
+	void setScoringDisarmedCardBomb(const bool = true);
+	void setScoringGotCardBomb(const bool = true);
+	void setScoringThreadedMaze(const bool = true);
+	void setScoringThreadedGearRoom(const bool = true);
+	void setScoringEnteredShuttle(const bool = true);
+	void setScoringEnteredLaunchTube(const bool = true);
+	void setScoringStoppedRobotsShuttle(const bool = true);
+	void setScoringGotMarsOpMemChip(const bool = true);
+	void setScoringFinishedMars(const bool = true);
+
+	// Norad scoring
+	void setScoringSawSecurityMonitor(const bool = true);
+	void setScoringFilledOxygenCanister(const bool = true);
+	void setScoringFilledArgonCanister(const bool = true);
+	void setScoringSawUnconsciousOperator(const bool = true);
+	void setScoringWentThroughPressureDoor(const bool = true);
+	void setScoringPreppedSub(const bool = true);
+	void setScoringEnteredSub(const bool = true);
+	void setScoringExitedSub(const bool = true);
+	void setScoringSawRobotAt54North(const bool = true);
+	void setScoringPlayedWithClaw(const bool = true);
+	void setScoringUsedRetinalChip(const bool = true);
+	void setScoringFinishedGlobeGame(const bool = true);
+	void setScoringStoppedNoradRobot(const bool = true);
+	void setScoringGotNoradOpMemChip(const bool = true);
+	void setScoringFinishedNorad(const bool = true);
+
+	// WSC scoring
+	void setScoringRemovedDart(const bool = true);
+	void setScoringAnalyzedDart(const bool = true);
+	void setScoringBuiltAntidote(const bool = true);
+	void setScoringGotSinclairKey(const bool = true);
+	void setScoringGotArgonCanister(const bool = true);
+	void setScoringGotNitrogenCanister(const bool = true);
+	void setScoringPlayedWithMessages(const bool = true);
+	void setScoringSawMorphExperiment(const bool = true);
+	void setScoringEnteredSinclairOffice(const bool = true);
+	void setScoringSawBrochure(const bool = true);
+	void setScoringSawSinclairEntry1(const bool = true);
+	void setScoringSawSinclairEntry2(const bool = true);
+	void setScoringSawSinclairEntry3(const bool = true);
+	void setScoringSawWSCDirectory(const bool = true);
+	void setScoringUsedCrowBarInWSC(const bool = true);
+	void setScoringFinishedPlasmaDodge(const bool = true);
+	void setScoringOpenedCatwalk(const bool = true);
+	void setScoringStoppedWSCRobot(const bool = true);
+	void setScoringGotWSCOpMemChip(const bool = true);
+	void setScoringFinishedWSC(const bool = true);
+
+	// Gandhi scoring
+	void setScoringMarsGandhi(const bool = true);
+	void setScoringNoradGandhi(const bool = true);
+	void setScoringWSCGandhi(const bool = true);
+	
+	// Scoring "Get" functions.
+	bool getScoringSawINN();
+	bool getScoringTookShower();
+	bool getScoringFixedHair();
+	bool getScoringGotKeyCard();
+	bool getScoringReadPaper();
+	bool getScoringLookThroughTelescope();
+	bool getScoringSawCaldoriaKiosk();
+	bool getScoringGoToTSA();
+	bool getScoringEnterTSA();
+	bool getScoringSawBust1();
+	bool getScoringSawBust2();
+	bool getScoringSawBust3();
+	bool getScoringSawBust4();
+	bool getScoringSawBust5();
+	bool getScoringSawBust6();
+	bool getScoringSawTheory();
+	bool getScoringSawBackground();
+	bool getScoringSawProcedure();
+	bool getScoringGotJourneymanKey();
+	bool getScoringGotPegasusBiochip();
+	bool getScoringGotBiosuit();
+	bool getScoringGoToPrehistoric();
+	bool getScoringPutLogInReader();
+	bool getScoringSawCaldoriaNormal();
+	bool getScoringSawCaldoriaAltered();
+	bool getScoringSawNoradNormal();
+	bool getScoringSawNoradAltered();
+	bool getScoringSawMarsNormal();
+	bool getScoringSawMarsAltered();
+	bool getScoringSawWSCNormal();
+	bool getScoringSawWSCAltered();
+	bool getScoringWentToReadyRoom2();
+	bool getScoringWentAfterSinclair();
+	bool getScoringUsedCardBomb();
+	bool getScoringShieldedCardBomb();
+	bool getScoringStunnedSinclair();
+	bool getScoringDisarmedNuke();
+	bool getScoringThrewBreaker();
+	bool getScoringExtendedBridge();
+	bool getScoringGotHistoricalLog();
+	bool getScoringFinishedPrehistoric();
+	bool getScoringThrownByRobot();
+	bool getScoringGotMarsCard();
+	bool getScoringSawMarsKiosk();
+	bool getScoringSawTransportMap();
+	bool getScoringGotCrowBar();
+	bool getScoringTurnedOnTransport();
+	bool getScoringGotOxygenMask();
+	bool getScoringAvoidedRobot();
+	bool getScoringActivatedPlatform();
+	bool getScoringUsedLiquidNitrogen();
+	bool getScoringUsedCrowBar();
+	bool getScoringFoundCardBomb();
+	bool getScoringDisarmedCardBomb();
+	bool getScoringGotCardBomb();
+	bool getScoringThreadedMaze();
+	bool getScoringThreadedGearRoom();
+	bool getScoringEnteredShuttle();
+	bool getScoringEnteredLaunchTube();
+	bool getScoringStoppedRobotsShuttle();
+	bool getScoringGotMarsOpMemChip();
+	bool getScoringFinishedMars();
+	bool getScoringSawSecurityMonitor();
+	bool getScoringFilledOxygenCanister();
+	bool getScoringFilledArgonCanister();
+	bool getScoringSawUnconsciousOperator();
+	bool getScoringWentThroughPressureDoor();
+	bool getScoringPreppedSub();
+	bool getScoringEnteredSub();
+	bool getScoringExitedSub();
+	bool getScoringSawRobotAt54North();
+	bool getScoringPlayedWithClaw();
+	bool getScoringUsedRetinalChip();
+	bool getScoringFinishedGlobeGame();
+	bool getScoringStoppedNoradRobot();
+	bool getScoringGotNoradOpMemChip();
+	bool getScoringFinishedNorad();
+	bool getScoringRemovedDart();
+	bool getScoringAnalyzedDart();
+	bool getScoringBuiltAntidote();
+	bool getScoringGotSinclairKey();
+	bool getScoringGotArgonCanister();
+	bool getScoringGotNitrogenCanister();
+	bool getScoringPlayedWithMessages();
+	bool getScoringSawMorphExperiment();
+	bool getScoringEnteredSinclairOffice();
+	bool getScoringSawBrochure();
+	bool getScoringSawSinclairEntry1();
+	bool getScoringSawSinclairEntry2();
+	bool getScoringSawSinclairEntry3();
+	bool getScoringSawWSCDirectory();
+	bool getScoringUsedCrowBarInWSC();
+	bool getScoringFinishedPlasmaDodge();
+	bool getScoringOpenedCatwalk();
+	bool getScoringStoppedWSCRobot();
+	bool getScoringGotWSCOpMemChip();
+	bool getScoringFinishedWSC();
+	bool getScoringMarsGandhi();
+	bool getScoringNoradGandhi();
+	bool getScoringWSCGandhi();
+
+	GameScoreType getCaldoriaTSAScore();
+	GameScoreType getPrehistoricScore();
+	GameScoreType getMarsScore();
+	GameScoreType getNoradScore();
+	GameScoreType getWSCScore();
+	GameScoreType getGandhiScore();
+	GameScoreType getTotalScore();
+
+	void writeCaldoriaState(Common::WriteStream *stream);
+	void readCaldoriaState(Common::ReadStream *stream);
+	void resetCaldoriaState();
+	
+	void writeTSAState(Common::WriteStream *stream);
+	void readTSAState(Common::ReadStream *stream);
+	void resetTSAState();
+	
+	void writePrehistoricState(Common::WriteStream *stream);
+	void readPrehistoricState(Common::ReadStream *stream);
+	void resetPrehistoricState();
+	
+	void writeNoradState(Common::WriteStream *stream);
+	void readNoradState(Common::ReadStream *stream);
+	void resetNoradState();
+	
+	void writeMarsState(Common::WriteStream *stream);
+	void readMarsState(Common::ReadStream *stream);
+	void resetMarsState();
+	
+	void writeWSCState(Common::WriteStream *stream);
+	void readWSCState(Common::ReadStream *stream);
+	void resetWSCState();
+	
+	// Globals.
+	void setWalkthroughMode(bool);
+	bool getWalkthroughMode();
+	void setShieldOn(bool);
+	bool getShieldOn();
+	void setEasterEgg(bool);
+	bool getEasterEgg();
+	void setBeenToWSC(bool value);
+	bool getBeenToWSC();
+	void setBeenToMars(bool value);
+	bool getBeenToMars();
+	void setBeenToNorad(bool value);
+	bool getBeenToNorad();
+	void setWSCFinished(bool);
+	bool getWSCFinished();
+	void setMarsFinished(bool);
+	bool getMarsFinished();
+	void setNoradFinished(bool);
+	bool getNoradFinished();
+	bool allTimeZonesFinished();
+	void setTakenItemID(ItemID, bool);
+	bool isTakenItemID(ItemID);
+	void setTakenItem(Item *, bool);
+	bool isTakenItem(Item *);
+	
+	// Caldoria
+	void setCaldoriaFuseTimeLimit(const TimeValue);
+	TimeValue getCaldoriaFuseTimeLimit();
+	void setCaldoriaSeenPullback(bool);
+	bool getCaldoriaSeenPullback();
+	void setCaldoriaMadeOJ(bool);
+	bool getCaldoriaMadeOJ();
+	void setCaldoriaWokenUp(bool);
+	bool getCaldoriaWokenUp();
+	void setCaldoriaDidRecalibration(bool);
+	bool getCaldoriaDidRecalibration();
+	void setCaldoriaSeenSinclairInElevator(bool);
+	bool getCaldoriaSeenSinclairInElevator();
+	void setCaldoriaINNAnnouncing(bool);
+	bool getCaldoriaINNAnnouncing();
+	void setCaldoriaSeenINN(bool);
+	bool getCaldoriaSeenINN();
+	void setCaldoriaSeenMessages(bool);
+	bool getCaldoriaSeenMessages();
+	void setCaldoriaSinclairShot(bool);
+	bool getCaldoriaSinclairShot();
+	void setCaldoriaBombDisarmed(bool);
+	bool getCaldoriaBombDisarmed();
+	void setCaldoriaRoofDoorOpen(bool);
+	bool getCaldoriaRoofDoorOpen();
+	void setCaldoriaDoneHygiene(bool);
+	bool getCaldoriaDoneHygiene();
+	void setCaldoriaSawVoiceAnalysis(bool);
+	bool getCaldoriaSawVoiceAnalysis();
+	void setCaldoriaDoorBombed(bool);
+	bool getCaldoriaDoorBombed();
+	void setCaldoriaGunAimed(bool);
+	bool getCaldoriaGunAimed();
+	
+	// TSA
+	void setRipTimerTime(TimeValue);
+	TimeValue getRipTimerTime();
+	void setTSAFuseTimeLimit(TimeValue);
+	TimeValue getTSAFuseTimeLimit();
+	void setT0BMonitorMode(byte);
+	byte getT0BMonitorMode();
+	void setTSAState(byte);
+	byte getTSAState();
+	void setT0BMonitorStart(TimeValue);
+	TimeValue getT0BMonitorStart();
+	void setTSAIDedAtDoor(bool);
+	bool getTSAIDedAtDoor();
+	void setTSA0BZoomedIn(bool);
+	bool getTSA0BZoomedIn();
+	void setTSAFrontDoorUnlockedOutside(bool);
+	bool getTSAFrontDoorUnlockedOutside();
+	void setTSAFrontDoorUnlockedInside(bool);
+	bool getTSAFrontDoorUnlockedInside();
+	void setTSASeenRobotGreeting(bool);
+	bool getTSASeenRobotGreeting();
+	void setTSASeenTheory(bool);
+	bool getTSASeenTheory();
+	void setTSASeenBackground(bool);
+	bool getTSASeenBackground();
+	void setTSASeenProcedure(bool);
+	bool getTSASeenProcedure();
+	void setTSASeenAgent3AtDoor(bool);
+	bool getTSASeenAgent3AtDoor();
+	void setTSACommandCenterLocked(bool);
+	bool getTSACommandCenterLocked();
+	void setTSASeenCaldoriaNormal(bool);
+	bool getTSASeenCaldoriaNormal();
+	void setTSASeenCaldoriaAltered(bool);
+	bool getTSASeenCaldoriaAltered();
+	void setTSASeenNoradNormal(bool);
+	bool getTSASeenNoradNormal();
+	void setTSASeenNoradAltered(bool);
+	bool getTSASeenNoradAltered();
+	void setTSASeenMarsNormal(bool);
+	bool getTSASeenMarsNormal();
+	void setTSASeenMarsAltered(bool);
+	bool getTSASeenMarsAltered();
+	void setTSASeenWSCNormal(bool);
+	bool getTSASeenWSCNormal();
+	void setTSASeenWSCAltered(bool);
+	bool getTSASeenWSCAltered();
+	void setTSABiosuitOn(bool);
+	bool getTSABiosuitOn();
+	
+	// Prehistoric
+	void setPrehistoricTriedToExtendBridge(bool);
+	bool getPrehistoricTriedToExtendBridge();
+	void setPrehistoricSeenTimeStream(bool);
+	bool getPrehistoricSeenTimeStream();
+	void setPrehistoricSeenFlyer1(bool);
+	bool getPrehistoricSeenFlyer1();
+	void setPrehistoricSeenFlyer2(bool);
+	bool getPrehistoricSeenFlyer2();
+	void setPrehistoricSeenBridgeZoom(bool);
+	bool getPrehistoricSeenBridgeZoom();
+	void setPrehistoricBreakerThrown(bool);
+	bool getPrehistoricBreakerThrown();
+	
+	// Norad
+	void setNoradSeenTimeStream(bool);
+	bool getNoradSeenTimeStream();
+	void setNoradGassed(bool);
+	bool getNoradGassed();
+	void setNoradFillingStationOn(bool);
+	bool getNoradFillingStationOn();
+	void setNoradN22MessagePlayed(bool);
+	bool getNoradN22MessagePlayed();
+	void setNoradPlayedGlobeGame(bool);
+	bool getNoradPlayedGlobeGame();
+	void setNoradBeatRobotWithClaw(bool);
+	bool getNoradBeatRobotWithClaw();
+	void setNoradBeatRobotWithDoor(bool);
+	bool getNoradBeatRobotWithDoor();
+	void setNoradRetScanGood(bool);
+	bool getNoradRetScanGood();
+	void setNoradWaitingForLaser(bool);
+	bool getNoradWaitingForLaser();
+	void setNoradSubRoomPressure(uint16);
+	uint16 getNoradSubRoomPressure();
+	void setNoradSubPrepState(NoradSubPrepState);
+	NoradSubPrepState getNoradSubPrepState();
+	void setNoradArrivedFromSub(bool);
+	bool getNoradArrivedFromSub();
+	
+	// Mars
+	void setMarsSeenTimeStream(bool);
+	bool getMarsSeenTimeStream();	
+	void setMarsHeardUpperPodMessage(bool);
+	bool getMarsHeardUpperPodMessage();
+	void setMarsRobotThrownPlayer(bool);
+	bool getMarsRobotThrownPlayer();
+	void setMarsHeardCheckInMessage(bool);
+	bool getMarsHeardCheckInMessage();
+	void setMarsPodAtUpperPlatform(bool);
+	bool getMarsPodAtUpperPlatform();
+	void setMarsSeenThermalScan(bool);
+	bool getMarsSeenThermalScan();
+	void setMarsArrivedBelow(bool);
+	bool getMarsArrivedBelow();
+	void setMarsSeenRobotAtReactor(bool);
+	bool getMarsSeenRobotAtReactor();
+	void setMarsAvoidedReactorRobot(bool);
+	bool getMarsAvoidedReactorRobot();
+	void setMarsInAirlock(bool);
+	bool getMarsInAirlock();
+	void setMarsAirlockOpen(bool);
+	bool getMarsAirlockOpen();
+	void setMarsMaskOnFiller(bool);
+	bool getMarsMaskOnFiller();
+	void setMarsLockFrozen(bool);
+	bool getMarsLockFrozen();
+	void setMarsLockBroken(bool);
+	bool getMarsLockBroken();
+	void setMarsMazeDoorPair1(bool);
+	bool getMarsMazeDoorPair1();
+	void setMarsMazeDoorPair2(bool);
+	bool getMarsMazeDoorPair2();
+	void setMarsMazeDoorPair3(bool);
+	bool getMarsMazeDoorPair3();
+	void setMarsSawRobotLeave(bool);
+	bool getMarsSawRobotLeave();
+	void setMarsSecurityDown(bool);
+	bool getMarsSecurityDown();
+	void setMarsFinishedCanyonChase(bool);
+	bool getMarsFinishedCanyonChase();
+	void setMarsThreadedMaze(bool);
+	bool getMarsThreadedMaze();
+	void setMarsHitRobotWithCannon(bool);
+	bool getMarsHitRobotWithCannon();
+	void setMarsReadyForShuttleTransport(bool);
+	bool getMarsReadyForShuttleTransport();
+
+	// WSC
+	void setWSCSeenTimeStream(bool);
+	bool getWSCSeenTimeStream();
+	void setWSCPoisoned(bool);
+	bool getWSCPoisoned();
+	void setWSCAnsweredAboutDart(bool);
+	bool getWSCAnsweredAboutDart();
+	void setWSCRemovedDart(bool);
+	bool getWSCRemovedDart();
+	void setWSCAnalyzerOn(bool);
+	bool getWSCAnalyzerOn();
+	void setWSCDartInAnalyzer(bool);
+	bool getWSCDartInAnalyzer();
+	void setWSCAnalyzedDart(bool);
+	bool getWSCAnalyzedDart();
+	void setWSCSawMorph(bool);
+	bool getWSCSawMorph();
+	void setWSCDesignedAntidote(bool);
+	bool getWSCDesignedAntidote();
+	void setWSCPickedUpAntidote(bool);
+	bool getWSCPickedUpAntidote();
+	void setWSCOfficeMessagesOpen(bool);
+	bool getWSCOfficeMessagesOpen();
+	void setWSCSeenNerd(bool);
+	bool getWSCSeenNerd();
+	void setWSCHeardPage1(bool);
+	bool getWSCHeardPage1();
+	void setWSCHeardPage2(bool);
+	bool getWSCHeardPage2();
+	void setWSCHeardCheckIn(bool);
+	bool getWSCHeardCheckIn();
+	void setWSCDidPlasmaDodge(bool);
+	bool getWSCDidPlasmaDodge();
+	void setWSCSeenSinclairLecture(bool);
+	bool getWSCSeenSinclairLecture();
+	void setWSCBeenAtWSC93(bool);
+	bool getWSCBeenAtWSC93();
+	void setWSCCatwalkDark(bool);
+	bool getWSCCatwalkDark();
+	void setWSCRobotDead(bool);
+	bool getWSCRobotDead();
+	void setWSCRobotGone(bool);
+	bool getWSCRobotGone();
 
 protected:
 	friend class Common::Singleton<SingletonBaseType>;
@@ -845,7 +845,7 @@ private:
 	RoomID _currentRoom;
 	DirectionConstant _currentDirection;
 	NeighborhoodID _nexNeighborhoodID;
-	RoomID _nexRoomID;
+	RoomID _nextRoomID;
 	DirectionConstant _nextDirection;
 	NeighborhoodID _lastNeighborhood;
 	RoomID _lastRoom;
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index bb5167b..d0b8b69 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -139,7 +139,7 @@ void InputDevice::getInput(Input &input, const InputBits filter) {
 	input.setAltDown(altDown);
 }
 
-//	Wait until the input device stops returning input allowed by filter...
+// Wait until the input device stops returning input allowed by filter...
 void InputDevice::waitInput(const InputBits filter) {
 	if (filter != 0) {
 		for (;;) {
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 1aae16c..57d5f93 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -409,10 +409,10 @@ public:
 	virtual bool releaseInputFocus() { return true; }
 	virtual void grabInputFocus() {}
 	
-	//	This returns bits set for what kinds of input to accept.
+	// This returns bits set for what kinds of input to accept.
 	virtual InputBits getInputFilter();
 
-	//	This returns bits defining what input constitutes a "click."
+	// This returns bits defining what input constitutes a "click."
 	virtual InputBits getClickFilter();
 
 	virtual void allowInput(const bool allow) { _allowInput = allow; }
diff --git a/engines/pegasus/items/inventory.cpp b/engines/pegasus/items/inventory.cpp
index e30fcac..16cced3 100755
--- a/engines/pegasus/items/inventory.cpp
+++ b/engines/pegasus/items/inventory.cpp
@@ -40,7 +40,7 @@ Inventory::~Inventory() {
 
 void Inventory::setWeightLimit(WeightType limit) {
 	_weightLimit = limit;
-	//	*** What to do if the new weight limit is greater than the current weight?
+	// *** What to do if the new weight limit is greater than the current weight?
 }
 
 WeightType Inventory::getWeight() {
@@ -52,7 +52,7 @@ WeightType Inventory::getWeight() {
 	return result;
 }
 
-//	If the item already belongs, just return kInventoryOK.
+// If the item already belongs, just return kInventoryOK.
 InventoryResult Inventory::addItem(Item *item) {
 	if (itemInInventory(item))
 		return kInventoryOK;
@@ -134,7 +134,7 @@ Item *Inventory::findItemByID(ItemID id) {
 	return _inventoryList.findItemByID(id);
 }
 
-//	Return -1 if not found.
+// Return -1 if not found.
 
 int32 Inventory::findIndexOf(Item *item) {
 	uint32 i = 0;
@@ -145,7 +145,7 @@ int32 Inventory::findIndexOf(Item *item) {
 	return -1;
 }
 
-//	Return -1 if not found.
+// Return -1 if not found.
 
 int32 Inventory::findIndexOf(ItemID id) {
 	uint32 i = 0;
diff --git a/engines/pegasus/items/inventory.h b/engines/pegasus/items/inventory.h
index db872b1..099ba52 100755
--- a/engines/pegasus/items/inventory.h
+++ b/engines/pegasus/items/inventory.h
@@ -33,11 +33,11 @@ namespace Pegasus {
 
 class Item;
 
-//	Inventories have a "current item". This item is the default item the player can
-//	use. In a text adventure system, the current item would be "it", as in
-//	"Hit the troll with it," where "it" would refer to some weapon which is the current
-//	item. In a graphic adventure, the current item would be the item the user selects
-//	to use with the mouse or other pointing device.
+// Inventories have a "current item". This item is the default item the player can
+// use. In a text adventure system, the current item would be "it", as in
+// "Hit the troll with it," where "it" would refer to some weapon which is the current
+// item. In a graphic adventure, the current item would be the item the user selects
+// to use with the mouse or other pointing device.
 
 class Inventory {
 public:
diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 7be095c..1f88777 100755
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -171,7 +171,7 @@ void InventoryPicture::panelUp() {
 	allowInput(true);
 }
 
-//	Must ensure that the picture matches the _inventory member variable.
+// Must ensure that the picture matches the _inventory member variable.
 void InventoryPicture::activateInventoryPicture() {
 	if (_active)
 		return;
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
index 83e3b02..a49bb4a 100755
--- a/engines/pegasus/items/item.cpp
+++ b/engines/pegasus/items/item.cpp
@@ -217,7 +217,7 @@ TimeValue Item::getSharedAreaTime() const {
 	return time;
 }
 
-//	Must affect images in shared area.
+// Must affect images in shared area.
 void Item::select() {
 	_isSelected = true;
 
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
index b50f850..efcf241 100755
--- a/engines/pegasus/items/item.h
+++ b/engines/pegasus/items/item.h
@@ -40,7 +40,7 @@ namespace Common {
 
 namespace Pegasus {
 
-//	JMPItemInfo contains resource data used by all Items.
+// JMPItemInfo contains resource data used by all Items.
 
 struct JMPItemInfo {
 	TimeValue infoLeftTime;
@@ -50,23 +50,21 @@ struct JMPItemInfo {
 	uint32 dragSpriteUsedID;
 };
 
-//	ItemStateEntry contains a single state/TimeValue pair. The TimeValue is
-//	the time value to set the shared area movie that corresponds with the given
-//	state of an inventory item.
+// ItemStateEntry contains a single state/TimeValue pair. The TimeValue is
+// the time value to set the shared area movie that corresponds with the given
+// state of an inventory item.
 
 struct ItemStateEntry {
 	ItemState itemState;
 	TimeValue itemTime;
 };
 
-//	ItemStateInfoHandle is an array of ItemStateEntry.
-
 struct ItemStateInfo {
-	uint16 numEntries; //	For easy ResEdit access
+	uint16 numEntries; // For easy ResEdit access
 	ItemStateEntry *entries;
 };
 
-//	ItemExtraEntry
+// ItemExtraEntry
 
 static const short kLeftAreaExtra = 0;
 static const short kMiddleAreaExtra = 1;
@@ -79,16 +77,14 @@ struct ItemExtraEntry {
 	TimeValue extraStop;
 };
 
-//	tItemExtraInfoHandle is an array of tItemExtraEntry.
-
 struct ItemExtraInfo {
-	uint16 numEntries;		//	For easy ResEdit access
+	uint16 numEntries; // For easy ResEdit access
 	ItemExtraEntry *entries;
 };
 
-//	Inventory info resource type and ID:
-//	Individual inventory items are stored in these resource types.
-//	Resource ID is item ID + kItemBaseResID.
+// Inventory info resource type and ID:
+// Individual inventory items are stored in these resource types.
+// Resource ID is item ID + kItemBaseResID.
 
 static const uint32 kItemInfoResType = MKTAG('I', 't', 'e', 'm');       // JMPItemInfoHandle
 static const uint32 kLeftAreaInfoResType = MKTAG('L', 'e', 'f', 't');   // ItemStateInfoHandle
@@ -98,7 +94,7 @@ static const uint32 kItemExtraInfoResType = MKTAG('I', 'X', 't', 'r');	 // ItemE
 
 static const uint16 kItemBaseResID = 128;
 
-//	Item IDs.
+// Item IDs.
 
 static const ItemID kAirMask = 7;
 static const ItemID kAntidote = 8;
@@ -119,7 +115,7 @@ static const ItemID kSinclairKey = 22;
 static const ItemID kStunGun = 23;
 static const ItemID kArgonPickup = 24;
 
-//	Biochips.
+// Biochips.
 
 static const ItemID kAIBiochip = 0;
 static const ItemID kInterfaceBiochip = 1;
@@ -131,7 +127,7 @@ static const ItemID kShieldBiochip = 6;
 
 static const ItemID kNumItems = 25;
 
-//	Item States.
+// Item States.
 
 static const ItemState kAI000 = 0;
 static const ItemState kAI005 = 1;
@@ -253,7 +249,7 @@ static const ItemState kNitrogenEmpty = 116;
 static const ItemState kNitrogenFull = 117;
 static const ItemState kFullGlass = 118;
 
-//	Extra IDs.
+// Extra IDs.
 
 static const uint32 kRetinalScanSearching = 0;
 static const uint32 kRetinalScanActivated = 1;
@@ -323,8 +319,8 @@ public:
 		deselect	--	called when this item is no longer current.
 		activate	--	called on the current item when the panel is closed.
 	*/
-	//	In an override of these three member functions, you must call the inherited
-	//	member functions.
+	// In an override of these three member functions, you must call the inherited
+	// member functions.
 	virtual void select();
 	virtual void deselect();
 	virtual bool isSelected() { return _isSelected; }
@@ -336,8 +332,8 @@ public:
 	virtual void removedFromInventory() {}
 	virtual void dropped() {}
 
-	//	Called when the shared area is taken by another item, but this item is still
-	//	selected.
+	// Called when the shared area is taken by another item, but this item is still
+	// selected.
 	virtual void giveUpSharedArea() {}
 	virtual void takeSharedArea() {}
 	
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index b1763a5..4f8947b 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -142,7 +142,7 @@ static const CoordType kMainMenuQuitTop = 428;
 static const CoordType kMainMenuQuitSelectLeft = 152;
 static const CoordType kMainMenuQuitSelectTop = 424;
 
-//	Never set the current input handler to the MainMenu.
+// Never set the current input handler to the MainMenu.
 MainMenu::MainMenu() : GameMenu(kMainMenuID), _menuBackground(0), _overviewButton(0),
 		_restoreButton(0), _adventureButton(0), _walkthroughButton(0), _startButton(0),
 		_creditsButton(0), _quitButton(0), _largeSelect(0), _smallSelect(0) {
@@ -447,9 +447,9 @@ static const TimeValue kOriginalTeamTime = 3000;
 static const TimeValue kTalentTime = 4440;
 static const TimeValue kOtherTitlesTime = 4680;
 
-static const TimeValue kFrameIncrement = 120;		//	Three frames...
+static const TimeValue kFrameIncrement = 120; // Three frames...
 
-//	Never set the current input handler to the CreditsMenu.
+// Never set the current input handler to the CreditsMenu.
 CreditsMenu::CreditsMenu() : GameMenu(kCreditsMenuID), _menuBackground(0), _creditsMovie(0),
 		_mainMenuButton(0), _largeSelect(0), _smallSelect(0) {
 
@@ -979,7 +979,7 @@ static const CoordType kQuitTop = kPauseTop + 302;
 static const CoordType kQuitSelectLeft = kPauseLeft - 44;
 static const CoordType kQuitSelectTop = kPauseTop + 297;
 
-//	These are relative to the pause background.
+// These are relative to the pause background.
 static const CoordType kPauseScoreLeft = 130;
 static const CoordType kPauseScoreTop = 34;
 static const CoordType kPauseScoreRight = kPauseScoreLeft + 108;
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 14e6f25..324a86f 100755
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -41,7 +41,7 @@ Movie::~Movie() {
 	releaseMovie();
 }
 
-//	*** Make sure this will stop displaying the movie.
+// *** Make sure this will stop displaying the movie.
 
 void Movie::releaseMovie() {
 	if (_video) {
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 1ea6e12..a4beecd 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -146,7 +146,7 @@ static const TimeValue k5To2Time = 41240;
 
 static const TimeValue k5To3Time = 41280;
 
-//	FuseFunction functions...
+// FuseFunction functions...
 
 const NotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
 
@@ -182,7 +182,7 @@ Caldoria::~Caldoria() {
 void Caldoria::init() {
 	Neighborhood::init();
 
-	//	We need this notification flag as well.
+	// We need this notification flag as well.
 	_neighborhoodNotification.notifyMe(this, kSinclairLoopDoneFlag, kSinclairLoopDoneFlag);
 
 	_sinclairInterrupt.initCallBack(&_navMovie, kCallBackAtTime);
@@ -948,7 +948,7 @@ void Caldoria::setUpRoofTop() {
 		if (GameState.getCurrentDirection() == kEast && GameState.getCaldoriaGunAimed())
 			startExtraSequence(kCa53EastShootSinclair, kExtraCompletedFlag, false);
 		else
-			//	Fall through...
+			// Fall through...
 	case kCaldoria49:
 	case kCaldoria50:
 	case kCaldoria51:
@@ -1548,9 +1548,9 @@ void Caldoria::newInteraction(const InteractionID interactionID) {
 	}
 }
 
-//	Only called when trying to pick up an item and the player can't (because
-//	the inventory is too full or because the player lets go of the item before
-//	dropping it into the inventory).
+// Only called when trying to pick up an item and the player can't (because
+// the inventory is too full or because the player lets go of the item before
+// dropping it into the inventory).
 Hotspot *Caldoria::getItemScreenSpot(Item *item, DisplayElement *element) {
 	HotSpotID destSpotID = kNoHotSpotID;
 	
@@ -1919,7 +1919,7 @@ Common::String Caldoria::getHintMovie(uint hintNum) {
 				else if (GameState.isTakenItemID(kShieldBiochip))
 					return "Images/AI/Caldoria/X48ND3";
 
-				//	*** Doesn't work yet, need global movies.
+				// *** Doesn't work yet, need global movies.
 				break;
 			} 
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
index 64e566e..f02101e 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.h
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.h
@@ -34,13 +34,13 @@ static const TimeScale kCaldoriaMovieScale = 600;
 static const TimeScale kCaldoriaFramesPerSecond = 15;
 static const TimeScale kCaldoriaFrameDuration = 40;
 
-//	Alternate IDs.
+// Alternate IDs.
 
 static const AlternateID kAltCaldoriaNormal = 0;
 static const AlternateID kAltCaldoriaRoofDoorBlown = 2;
 static const AlternateID kAltCaldoriaSinclairDown = 3;
 
-//	Room IDs.
+// Room IDs.
 
 static const RoomID kCaldoria00 = 1;
 static const RoomID kCaldoria01 = 2;
@@ -106,7 +106,7 @@ static const RoomID kCaldoria55 = 61;
 static const RoomID kCaldoria56 = 62;
 static const RoomID kCaldoriaDeathRoom = 0;
 
-//	Hot Spot Activation IDs.
+// Hot Spot Activation IDs.
 
 static const HotSpotActivationID kActivate4DClosed = 1;
 static const HotSpotActivationID kActivate4DOpen = 2;
@@ -124,7 +124,7 @@ static const HotSpotActivationID kActivateReadyToTransport = 13;
 static const HotSpotActivationID kActivateRoofSlotEmpty = 14;
 static const HotSpotActivationID kActivateZoomedOnSinclair = 15;
 
-//	Hot Spot IDs.
+// Hot Spot IDs.
 
 static const HotSpotID kCa4DEnvironOpenSpotID = 5000;
 static const HotSpotID kCa4DEnvironCloseSpotID = 5001;
@@ -196,7 +196,7 @@ static const HotSpotID kCaldoriaRoofDoorSpotID = 5066;
 static const HotSpotID kCaldoriaRoofCardDropSpotID = 5067;
 static const HotSpotID kCaldoria53EastSinclairTargetSpotID = 5068;
 
-//	Extra sequence IDs.
+// Extra sequence IDs.
 
 static const ExtraID kCaldoriaWakeUpView1 = 0;
 static const ExtraID kCaldoria00WakeUp1 = 1;
@@ -310,14 +310,14 @@ static const ExtraID kCaldoria56BombStage6 = 108;
 static const ExtraID kCaldoria56BombStage7 = 109;
 static const ExtraID kCaldoria56BombExplodes = 110;
 
-//	Caldoria interactions.
+// Caldoria interactions.
 
 static const InteractionID kCaldoria4DInteractionID = 0;
 static const InteractionID kCaldoriaBombInteractionID = 1;
 static const InteractionID kCaldoriaMessagesInteractionID = 2;
 static const InteractionID kCaldoriaMirrorInteractionID = 3;
 
-//	Caldoria:
+// Caldoria:
 
 static const DisplayOrder kVidPhoneOrder = kMonitorLayer;
 static const DisplayOrder k4DSpritesOrder = kMonitorLayer;
@@ -330,7 +330,7 @@ static const DisplayOrder kCaldoriaBombTimerOrder = kCaldoriaBombGridOrder + 1;
 
 /////////////////////////////////////////////
 //
-//	Caldoria
+// Caldoria
 
 static const CoordType kCaldoriaVidPhoneLeft = kNavAreaLeft + 105;
 static const CoordType kCaldoriaVidPhoneTop = kNavAreaTop + 28;
@@ -374,7 +374,7 @@ static const CoordType kCaldoriaBombGridTop = kNavAreaTop + 58;
 static const CoordType kCaldoriaBombTimerLeft = kNavAreaLeft + 58;
 static const CoordType kCaldoriaBombTimerTop = kNavAreaTop + 204;
 
-//	Caldoria display IDs.
+// Caldoria display IDs.
 
 static const DisplayElementID kCaldoriaVidPhoneID = kNeighborhoodDisplayID;
 static const DisplayElementID kCaldoria4DSpritesID = kCaldoriaVidPhoneID + 1;
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
index 0326bb7..d8ac3b0 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -30,9 +30,9 @@
 namespace Pegasus {
 
 static const TimeValue kSwitchableSlop = 3 * kCaldoriaFrameDuration;
-//	Two seconds - some slop
+// Two seconds - some slop
 static const TimeValue kSwitchableDuration = kCaldoriaMovieScale * 2 - kSwitchableSlop;
-//	Twelve frames + some slop
+// Twelve frames + some slop
 static const TimeValue kNonswitchableDuration = kCaldoriaFrameDuration * 12 + kSwitchableSlop;
 
 static const TimeValue kSwitchable1Start = 0;
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index 55c36b6..cd2af13 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -40,8 +40,8 @@ namespace Pegasus {
 typedef byte DoorFlags;
 
 enum {
-	kDoorPresentBit,				//	Bit set if there is a door here.
-	kDoorLockedBit					//	Bit set if door is locked, clear if unlocked.
+	kDoorPresentBit, // Bit set if there is a door here.
+	kDoorLockedBit   // Bit set if door is locked, clear if unlocked.
 };
 
 static const DoorFlags kNoDoorFlags = 0;
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index 10b1b59..baa3381 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -68,11 +68,11 @@ public:
 		AlternateID altCode;
 		TimeValue movieStart;
 		TimeValue movieEnd;
-		//	fExitEnd is the end of the optimized run of walks.
+		// exitEnd is the end of the optimized run of walks.
 		TimeValue exitEnd;
 		TimeValue originalEnd;
-		//	fExitLoop is the loop start time of the optimized run of walks if the run
-		//	loops back on itself (so far, only in TSA).
+		// exitLoop is the loop start time of the optimized run of walks if the run
+		// loops back on itself (so far, only in TSA).
 		TimeValue exitLoop;
 		RoomID exitRoom;
 		DirectionConstant exitDirection;
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
index d75e5e9..2638271 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.h
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -53,12 +53,12 @@ public:
 
 		HotSpotID hotspot;
 		HotSpotActivationID hotspotActivation;
-		//	Location hot spot lives in:
+		// Location hot spot lives in:
 		RoomID hotspotRoom;
 		DirectionConstant hotspotDirection;
-		//	Extra to play if this is a "play extra" hot spot.
+		// Extra to play if this is a "play extra" hot spot.
 		ExtraID hotspotExtra;
-		//	Item corresponding to this hot spot if it is an item-related hot spot.
+		// Item corresponding to this hot spot if it is an item-related hot spot.
 		ItemID hotspotItem;
 	};
 
diff --git a/engines/pegasus/neighborhood/mars/constants.h b/engines/pegasus/neighborhood/mars/constants.h
index b1013da..82a7f03 100755
--- a/engines/pegasus/neighborhood/mars/constants.h
+++ b/engines/pegasus/neighborhood/mars/constants.h
@@ -30,7 +30,7 @@
 
 namespace Pegasus {
 
-//	Element Coordinates
+// Element Coordinates
 
 static const CoordType kUndoHiliteLeft = kNavAreaLeft + 140;
 static const CoordType kUndoHiliteTop = kNavAreaTop + 36;
@@ -136,7 +136,7 @@ static const TimeValue kLaunchTubeReachedTime = 60 * 600 + 38 * 600 - kCanyonCha
 static const TimeValue kCanyonChaseFinishedTime = kCanyonChaseStop - kCanyonChaseStart -
 											kLaunchTubeReachedTime;
 
-//	Left shuttle.
+// Left shuttle.
 
 static const TimeValue kShuttleLeftIntroStart = 0;
 static const TimeValue kShuttleLeftIntroStop = 400;
@@ -155,7 +155,7 @@ static const TimeValue kShuttleLeftGravitonTime = 600;
 
 static const TimeValue kShuttleLeftTractorTime = 640;
 
-//	Right shuttle.
+// Right shuttle.
 
 static const TimeValue kShuttleRightIntroStart = 0;
 static const TimeValue kShuttleRightIntroStop = 400;
@@ -175,7 +175,7 @@ static const TimeValue kShuttleRightGravitonTime = 1000;
 
 static const TimeValue kShuttleRightOverloadTime = 1040;
 
-//	Lower Left shuttle.
+// Lower Left shuttle.
 
 static const TimeValue kShuttleLowerLeftCollisionTime = 0;
 
@@ -183,7 +183,7 @@ static const TimeValue kShuttleLowerLeftTubeTime = 40;
 
 static const TimeValue kShuttleLowerLeftAutopilotTime = 80;
 
-//	Lower Right shuttle.
+// Lower Right shuttle.
 
 static const TimeValue kShuttleLowerRightOffTime = 0;
 
@@ -193,7 +193,7 @@ static const TimeValue kShuttleLowerRightTransportTime = 80;
 
 static const TimeValue kShuttleLowerRightTransportHiliteTime = 120;
 
-//	Center shuttle.
+// Center shuttle.
 
 static const TimeValue kShuttleCenterBoardingTime = 0;
 
@@ -223,7 +223,7 @@ static const TimeValue kShuttleCenterScanningTime = 480;
 
 static const TimeValue kShuttleCenterSafeTime = 520;
 
-//	Upper Left shuttle.
+// Upper Left shuttle.
 
 static const TimeValue kShuttleUpperLeftDimTime = 0;
 
@@ -233,7 +233,7 @@ static const TimeValue kShuttleUpperLeftGravitonTime = 80;
 
 static const TimeValue kShuttleUpperLeftTractorTime = 120;
 
-//	Upper Right shuttle.
+// Upper Right shuttle.
 
 static const TimeValue kShuttleUpperRightLockedTime = 0;
 
@@ -245,7 +245,7 @@ static const TimeValue kShuttleUpperRightOverloadTime = 120;
 
 static const TimeValue kShuttleUpperRightTargetDestroyedTime = 160;
 
-//	Shuttle distance
+// Shuttle distance
 
 static const int kShuttleDistance = 500;
 
@@ -469,7 +469,7 @@ static const TimeScale kMarsMovieScale = 600;
 static const TimeScale kMarsFramesPerSecond = 15;
 static const TimeScale kMarsFrameDuration = 40;
 
-//	Alternate IDs.
+// Alternate IDs.
 
 static const AlternateID kAltMarsNormal = 0;
 static const AlternateID kAltMarsPodAtMars34 = 1;
@@ -482,7 +482,7 @@ static const AlternateID kAltMarsMaskOnFiller = 7;
 static const AlternateID kAltMars60AirlockEast = 8;
 static const AlternateID kAltMars60AirlockWest = 9;
 
-//	Room IDs.
+// Room IDs.
 
 static const RoomID kMars0A = 0;
 static const RoomID kMars00 = 1;
@@ -711,7 +711,7 @@ static const RoomID kMarsMaze199 = 223;
 static const RoomID kMarsMaze200 = 224;
 static const RoomID kMarsDeathRoom = 225;
 
-//	Hot Spot Activation IDs.
+// Hot Spot Activation IDs.
 
 static const HotSpotActivationID kActivationReadyForKiosk = 1;
 static const HotSpotActivationID kActivationKioskChoice = 2;
@@ -738,7 +738,7 @@ static const HotSpotActivationID kActivateReactorBombExposed = 22;
 static const HotSpotActivationID kActivationRobotHeadClosed = 23;
 static const HotSpotActivationID kActivationRobotHeadOpen = 24;
 
-//	Hot Spot IDs.
+// Hot Spot IDs.
 
 static const HotSpotID kMars11NorthKioskSpotID = 5000;
 static const HotSpotID kMars11NorthKioskSightsSpotID = 5001;
@@ -814,7 +814,7 @@ static const HotSpotID kRobotShuttleMapChipSpotID = 5070;
 static const HotSpotID kRobotShuttleOpticalChipSpotID = 5071;
 static const HotSpotID kRobotShuttleShieldChipSpotID = 5072;
 
-//	Extra sequence IDs.
+// Extra sequence IDs.
 
 static const ExtraID kMarsArrivalFromTSA = 0;
 static const ExtraID kMars0AWatchShuttleDepart = 1;
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
index 140bd12..13dc6df 100755
--- a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
+++ b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
@@ -38,7 +38,7 @@ static const float kGravitonXOrigin = convertScreenHToSpaceX(kGravitonOriginH, k
 static const float kGravitonYOrigin = convertScreenVToSpaceY(kGravitonOriginV, kGravitonMinDistance);
 static const float kGravitonZOrigin = kGravitonMinDistance;
 
-//	Width of graviton sprite...
+// Width of graviton sprite...
 static const CoordType kGravitonMaxScreenWidth = 78;
 static const CoordType kGravitonMaxScreenHeight = 46;
 
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index c836367..b516989 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -240,7 +240,7 @@ void Neighborhood::arriveAt(RoomID room, DirectionConstant direction) {
 	checkContinuePoint(room, direction);
 }
 
-//	These functions can be overridden to tweak the exact frames used.
+// These functions can be overridden to tweak the exact frames used.
 
 void Neighborhood::getExitEntry(const RoomID room, const DirectionConstant direction, ExitTable::Entry &entry) {
 	entry = _exitTable.findEntry(room, direction, _currentAlternate);
@@ -305,7 +305,7 @@ void Neighborhood::getExtraEntry(const uint32 id, ExtraTable::Entry &extraEntry)
 
 /////////////////////////////////////////////
 //
-//	"Can" functions: Called to see whether or not a user is allowed to do something
+// "Can" functions: Called to see whether or not a user is allowed to do something
 
 CanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	DoorTable::Entry door;
@@ -313,8 +313,8 @@ CanMoveForwardReason Neighborhood::canMoveForward(ExitTable::Entry &entry) {
 	getExitEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), entry);
 	getDoorEntry(GameState.getCurrentRoom(), GameState.getCurrentDirection(), door);
 
-	//	Fixed this so that doors that don't lead anywhere can be opened, but not walked
-	//	through.
+	// Fixed this so that doors that don't lead anywhere can be opened, but not walked
+	// through.
 	if (door.flags & kDoorPresentMask) {
 		if (GameState.isCurrentDoorOpen()) {
 			if (entry.exitRoom == kNoRoomID)
@@ -593,9 +593,9 @@ void Neighborhood::stopStriding() {
 			kMoveForwardCompletedFlag, kNeighborhoodMovieCompletedFlag | kMoveForwardCompletedFlag);
 }
 
-//	Compass support
+// Compass support
 int16 Neighborhood::getStaticCompassAngle(const RoomID, const DirectionConstant dir) {
-	//	North, south, east, west
+	// North, south, east, west
 	static const int16 compassAngles[] = { 0, 180, 90, 270 };
 	return compassAngles[dir];
 }
@@ -1358,8 +1358,8 @@ void Neighborhood::getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec
 }
 
 void Neighborhood::setUpAIRules() {
-	//	Set up default rules here:
-	//	--  Energy warning rules.
+	// Set up default rules here:
+	// --  Energy warning rules.
 
 	if (g_AIArea) {
 		g_AIArea->forceAIUnlocked();
diff --git a/engines/pegasus/neighborhood/norad/constants.h b/engines/pegasus/neighborhood/norad/constants.h
index e86422a..37c1769 100755
--- a/engines/pegasus/neighborhood/norad/constants.h
+++ b/engines/pegasus/neighborhood/norad/constants.h
@@ -207,7 +207,7 @@ static const int16 kElevatorCompassAngle = -40;
 static const int16 kSubPlatformCompassAngle = 45;
 static const int16 kSubControlCompassAngle = -10;
 
-//	Norad interactions.
+// Norad interactions.
 
 static const InteractionID kNoradGlobeGameInteractionID = 0;
 static const InteractionID kNoradECRMonitorInteractionID = 1;
@@ -219,7 +219,7 @@ static const InteractionID kNoradSubPlatformInteractionID = 6;
 
 /////////////////////////////////////////////
 //
-//	Norad Alpha
+// Norad Alpha
 
 static const CoordType kECRSlideShowLeft = kNavAreaLeft + 78;
 static const CoordType kECRSlideShowTop = kNavAreaTop + 1;
@@ -306,7 +306,7 @@ static const CoordType kNoradGreenBallAtDTop = kNoradClawMonitorTop + 49;
 
 /////////////////////////////////////////////
 //
-//	Norad Delta
+// Norad Delta
 
 static const CoordType kGlobeMonitorLeft = kNavAreaLeft + 360;
 static const CoordType kGlobeMonitorTop = kNavAreaTop + 144;
@@ -359,7 +359,7 @@ static const CoordType kGlobeLowerNamesTop = kNavAreaTop + 212;
 static const CoordType kGlobeCountdownLeft = kNavAreaLeft + 478;
 static const CoordType kGlobeCountdownTop = kNavAreaTop + 164;
 
-//	Norad Alpha display IDs.
+// Norad Alpha display IDs.
 
 static const DisplayElementID kECRSlideShowMovieID = kNeighborhoodDisplayID;
 static const DisplayElementID kECRPanID = kECRSlideShowMovieID + 1;
@@ -383,7 +383,7 @@ static const DisplayElementID kSubControlCCWID = kSubControlUpID + 1;
 static const DisplayElementID kSubControlCWID = kSubControlCCWID + 1;
 static const DisplayElementID kClawMonitorGreenBallID = kSubControlCWID + 1;
 
-//	Norad Delta display IDs.
+// Norad Delta display IDs.
 
 static const DisplayElementID kGlobeMonitorID = kNeighborhoodDisplayID;
 static const DisplayElementID kGlobeMovieID = kGlobeMonitorID + 14;
@@ -403,7 +403,7 @@ static const DisplayElementID kGlobeUpperNamesID = kTargetHiliteLowerRightID + 1
 static const DisplayElementID kGlobeLowerNamesID = kGlobeUpperNamesID + 1;
 static const DisplayElementID kGlobeCountdownID = kGlobeLowerNamesID + 1;
 
-//	Norad Alpha:
+// Norad Alpha:
 
 static const DisplayOrder kECRMonitorOrder = kMonitorLayer;
 static const DisplayOrder kECRPanOrder = kECRMonitorOrder + 1;
@@ -431,7 +431,7 @@ static const DisplayOrder kSubControlCCWOrder = kSubControlUpOrder + 1;
 static const DisplayOrder kSubControlCWOrder = kSubControlCCWOrder + 1;
 static const DisplayOrder kClawMonitorGreenBallOrder = kSubControlCWOrder + 1;
 
-//	Norad Delta:
+// Norad Delta:
 
 static const DisplayOrder kGlobeMonitorLayer = kMonitorLayer;
 static const DisplayOrder kGlobeMovieLayer = kGlobeMonitorLayer + 1;
@@ -441,17 +441,17 @@ static const DisplayOrder kGlobeUpperNamesLayer = kGlobeHilitesLayer + 1;
 static const DisplayOrder kGlobeLowerNamesLayer = kGlobeUpperNamesLayer + 1;
 static const DisplayOrder kGlobeCountdownLayer = kGlobeLowerNamesLayer + 1;
 
-//	Norad Alpha Tables
+// Norad Alpha Tables
 
 static const TimeScale kNoradAlphaMovieScale = 600;
 static const TimeScale kNoradAlphaFramesPerSecond = 15;
 static const TimeScale kNoradAlphaFrameDuration = 40;
 
-//	Alternate IDs.
+// Alternate IDs.
 
 static const AlternateID kAltNoradAlphaNormal = 0;
 
-//	Room IDs.
+// Room IDs.
 
 static const RoomID kNorad01 = 0;
 static const RoomID kNorad01East = 1;
@@ -484,10 +484,10 @@ static const RoomID kNorad21West = 27;
 static const RoomID kNorad22 = 28;
 static const RoomID kNorad22West = 29;
 
-//	Hot Spot Activation IDs.
+// Hot Spot Activation IDs.
 
 
-//	Hot Spot IDs.
+// Hot Spot IDs.
 
 static const HotSpotID kNorad01ECRSpotID = 5000;
 static const HotSpotID kNorad01GasSpotID = 5001;
@@ -537,7 +537,7 @@ static const HotSpotID kNorad22ClawUpSpotID = 5044;
 static const HotSpotID kNorad22ClawCCWSpotID = 5045;
 static const HotSpotID kNorad22ClawCWSpotID = 5046;
 
-//	Extra sequence IDs.
+// Extra sequence IDs.
 
 static const ExtraID kNoradArriveFromTSA = 0;
 static const ExtraID kNorad01RobotTaunt = 1;
@@ -583,7 +583,7 @@ static const ExtraID kN22ClawDCounterclockwise = 40;
 static const ExtraID kN22ClawDClockwise = 41;
 
 
-//	Norad Delta Extra sequence IDs.
+// Norad Delta Extra sequence IDs.
 
 static const ExtraID kArriveFromSubChase = 0;
 static const ExtraID kN59ZoomWithRobot = 1;
@@ -654,11 +654,11 @@ static const TimeScale kNoradDeltaMovieScale = 600;
 static const TimeScale kNoradDeltaFramesPerSecond = 15;
 static const TimeScale kNoradDeltaFrameDuration = 40;
 
-//	Alternate IDs.
+// Alternate IDs.
 
 static const AlternateID kAltNoradDeltaNormal = 0;
 
-//	Room IDs.
+// Room IDs.
 
 static const RoomID kNorad41 = 0;
 static const RoomID kNorad42 = 1;
@@ -700,10 +700,10 @@ static const RoomID kNorad78 = 36;
 static const RoomID kNorad79 = 37;
 static const RoomID kNorad79West = 38;
 
-//	Hot Spot Activation IDs.
+// Hot Spot Activation IDs.
 
 
-//	Hot Spot IDs.
+// Hot Spot IDs.
 
 static const HotSpotID kNorad48ElevatorSpotID = 5000;
 static const HotSpotID kNorad48ElevatorOutSpotID = 5001;
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.cpp b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
index d413554..7d4c1c5 100755
--- a/engines/pegasus/neighborhood/norad/delta/globegame.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
@@ -196,7 +196,7 @@ void GlobeTracker::stopGlobeMovie() {
 	}
 }
 
-//	Globe game PICTs:
+// Globe game PICTs:
 static const ResIDType kGlobeCircleLeftPICTID = 300;
 static const ResIDType kGlobeCircleRightPICTID = 301;
 static const ResIDType kGlobeCircleUpPICTID = 302;
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index 8a306fe..b0e5b98 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -678,9 +678,9 @@ void SubControlRoom::receiveNotification(Notification *notification, const Notif
 						dispatchClawAction(kMoveLeftActionIndex);
 						break;
 					case kClawAtB:
-						if (_clawStartPosition == kClawAtD)				//	Norad Alpha
+						if (_clawStartPosition == kClawAtD)             // Norad Alpha
 							dispatchClawAction(kMoveLeftActionIndex);
-						else if (_clawStartPosition == kClawAtC)		//	Norad Delta
+						else if (_clawStartPosition == kClawAtC)        // Norad Delta
 							dispatchClawAction(kMoveUpActionIndex);
 						break;
 					case kClawAtC:
@@ -728,7 +728,7 @@ void SubControlRoom::activateHotspots() {
 		g_allHotspots.activateOneHotspot(_clawControlSpotID);
 		break;
 	case kClawMenu:
-		//	This could be called during a move, so use _clawNextPosition.
+		// This could be called during a move, so use _clawNextPosition.
 		if (_playingAgainstRobot) {
 			g_allHotspots.deactivateOneHotspot(_outSpotID);
 			if (_robotState != kRobotApproaching && _nextAction == kNoActionIndex)
@@ -813,9 +813,9 @@ void SubControlRoom::clickInHotspot(const Input &input, const Hotspot *spot) {
 					dispatchClawAction(kMoveLeftActionIndex);
 					break;
 				case kClawAtB:
-					if (_clawStartPosition == kClawAtD)				//	Norad Alpha
+					if (_clawStartPosition == kClawAtD)             // Norad Alpha
 						dispatchClawAction(kMoveLeftActionIndex);
-					else if (_clawStartPosition == kClawAtC)		//	Norad Delta
+					else if (_clawStartPosition == kClawAtC)        // Norad Delta
 						dispatchClawAction(kMoveUpActionIndex);
 					break;
 				case kClawAtC:
diff --git a/engines/pegasus/neighborhood/spot.cpp b/engines/pegasus/neighborhood/spot.cpp
index 00c471e..f285bf9 100755
--- a/engines/pegasus/neighborhood/spot.cpp
+++ b/engines/pegasus/neighborhood/spot.cpp
@@ -55,10 +55,10 @@ void SpotTable::clear() {
 	_entries.clear();
 }
 
-//	Two CSpotIndices are equal if
-//		In addition to having their rooms, directions and alt codes identical...
-//		They are both either loops or once only animations AND
-//		They overlap in at least one of the on arrival, on turn and on door open bits.
+// Two SpotTable::Entries are equal if
+//      In addition to having their rooms, directions and alt codes identical...
+//      They are both either loops or once only animations AND
+//      They overlap in at least one of the on arrival, on turn and on door open bits.
 SpotTable::Entry SpotTable::findEntry(RoomID room, DirectionConstant direction, SpotFlags srcFlags, AlternateID altCode) {
 	for (uint32 i = 0; i < _entries.size(); i++)
 		if (_entries[i].room == room && _entries[i].direction == direction && _entries[i].altCode == altCode && (_entries[i].srcFlags & kSpotLoopsMask) == (srcFlags & kSpotLoopsMask) && ((_entries[i].srcFlags & srcFlags) & kSpotTriggers) != 0)
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index 086f1b2..4be0864 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -40,7 +40,7 @@ namespace Pegasus {
 typedef byte SpotFlags;
 
 enum {
-	kSpotLoopsBit,			//	Loop or once only?
+	kSpotLoopsBit, // Loop or once only?
 	kSpotOnArrivalBit,
 	kSpotOnTurnBit,
 	kSpotOnDoorOpenBit
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
index cc917a8..91a876c 100755
--- a/engines/pegasus/notification.cpp
+++ b/engines/pegasus/notification.cpp
@@ -45,9 +45,9 @@ Notification::~Notification() {
 		_owner->removeNotification(this);
 }
 
-//	Selectively set or clear notificiation bits.
-//	Wherever mask is 0, leave existing bits untouched.
-//	Wherever mask is 1, set bit equivalent to flags.
+// Selectively set or clear notificiation bits.
+// Wherever mask is 0, leave existing bits untouched.
+// Wherever mask is 1, set bit equivalent to flags.
 void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags flags, NotificationFlags mask) {
 	for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
 		if (it->receiver == receiver) {
@@ -87,7 +87,7 @@ void Notification::checkReceivers() {
 			it->receiver->receiveNotification(this, currentFlags);
 }
 
-//	Receiver entries are equal if their receivers are equal.
+// Receiver entries are equal if their receivers are equal.
 
 int operator==(const ReceiverEntry &entry1, const ReceiverEntry &entry2) {
 	return	entry1.receiver == entry2.receiver;
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
index 91901c9..142bf8c 100755
--- a/engines/pegasus/notification.h
+++ b/engines/pegasus/notification.h
@@ -57,12 +57,12 @@ public:
 	Notification(const NotificationID id, NotificationManager *owner);
 	virtual ~Notification();
 
-	//	NotifyMe will have this receiver notified when any of the specified notification
-	//	flags are set.
-	//	If there is already a notification set for this receiver, NotifyMe does a bitwise
-	//	OR with the receiver's current notification flags.
+	// notifyMe will have this receiver notified when any of the specified notification
+	// flags are set.
+	// If there is already a notification set for this receiver, notifyMe does a bitwise
+	// OR with the receiver's current notification flags.
 
-	//	Can selectively set or clear notification bits by using the flags and mask argument.
+	// Can selectively set or clear notification bits by using the flags and mask argument.
 
 	void notifyMe(NotificationReceiver*, NotificationFlags flags, NotificationFlags mask);
 	void cancelNotification(NotificationReceiver *receiver);
@@ -88,8 +88,8 @@ public:
 	virtual ~NotificationReceiver();
 	
 protected:
-	//	ReceiveNotification is called automatically whenever a notification that this
-	//	receiver depends on has its flags set
+	// receiveNotification is called automatically whenever a notification that this
+	// receiver depends on has its flags set
 	
 	virtual void receiveNotification(Notification *, const NotificationFlags);
 	virtual void newNotification(Notification *notification);
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index f5efbc0..2f1da77 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1613,10 +1613,10 @@ void PegasusEngine::dragTerminated(const Input &) {
 			delete _draggingSprite;
 	} else if (_dragType == kDragInventoryUse) {
 		if (finalSpot && (finalSpot->getHotspotFlags() & kDropItemSpotFlag) != 0) {
-			//	*** Need to decide on a case by case basis what to do here.
-			//	the crowbar should break the cover off the Mars reactor if its frozen, the
-			//	global transport card should slide through the slot, the oxygen mask should
-			//	attach to the filling station, and so on...
+			// *** Need to decide on a case by case basis what to do here.
+			// the crowbar should break the cover off the Mars reactor if its frozen, the
+			// global transport card should slide through the slot, the oxygen mask should
+			// attach to the filling station, and so on...
 			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
 			delete _draggingSprite;
 		} else {
@@ -1635,7 +1635,7 @@ void PegasusEngine::dragItem(const Input &input, Item *item, DragType type) {
 	_draggingItem = item;
 	_dragType = type;
 
-	//	Create the sprite.
+	// Create the sprite.
 	_draggingSprite = _draggingItem->getDragSprite(kDraggingSpriteID);
 	Common::Point where;
 	input.getInputLocation(where);
@@ -1644,7 +1644,7 @@ void PegasusEngine::dragItem(const Input &input, Item *item, DragType type) {
 	r1 = Common::Rect::center(where.x, where.y, r1.width(), r1.height());
 	_draggingSprite->setBounds(r1);
 
-	//	Set up drag constraints.
+	// Set up drag constraints.
 	DisplayElement *navMovie = _gfx->findDisplayElement(kNavMovieID);
 	Common::Rect r2;
 	navMovie->getBounds(r2);
diff --git a/engines/pegasus/scoring.h b/engines/pegasus/scoring.h
index efae17c..6ca9974 100755
--- a/engines/pegasus/scoring.h
+++ b/engines/pegasus/scoring.h
@@ -32,7 +32,7 @@ namespace Pegasus {
 
 /////////////////////////////////////////////
 //
-//	Scoring.
+// Scoring.
 
 static const CoordType kDeathScreenScoreLeft = 151;
 static const CoordType kDeathScreenScoreTop = 212;
@@ -40,7 +40,7 @@ static const CoordType kDeathScreenScoreWidth = 124;
 static const CoordType kDeathScreenScoreHeight = 12;
 static const CoordType kDeathScreenScoreSkipVert = -16;
 
-//	Caldoria & TSA
+// Caldoria & TSA
 
 static const GameScoreType kSawINNScore					= 5;
 static const GameScoreType kTookShowerScore				= 2;
@@ -124,7 +124,7 @@ static const GameScoreType kMaxCaldoriaTSAScoreAfter		=	kWentAfterSinclairScore
 static const GameScoreType kMaxCaldoriaTSAScore			=	kMaxCaldoriaTSAScoreBefore +
 														kMaxCaldoriaTSAScoreAfter;
 
-//	Prehistoric
+// Prehistoric
 
 static const GameScoreType kThrewBreakerScore				= 10;
 static const GameScoreType kExtendedBridgeScore			= 10;
@@ -136,7 +136,7 @@ static const GameScoreType kMaxPrehistoricScore			=	kThrewBreakerScore +
 														kGotHistoricalLogScore +
 														kFinishedPrehistoricScore;
 
-//	Mars
+// Mars
 
 static const GameScoreType kThrownByRobotScore			= 3;
 static const GameScoreType kGotMarsCardScore				= 5;
@@ -182,7 +182,7 @@ static const GameScoreType kMaxMarsScore					=	kThrownByRobotScore +
 														kGotMarsOpMemChipScore +
 														kFinishedMarsScore;
 
-//	Norad
+// Norad
 
 static const GameScoreType kSawSecurityMonitorScore		= 5;
 static const GameScoreType kFilledOxygenCanisterScore		= 5;
@@ -216,7 +216,7 @@ static const GameScoreType kMaxNoradScore					=	kSawSecurityMonitorScore +
 														kGotNoradOpMemChipScore +
 														kFinishedNoradScore;
 
-//	WSC
+// WSC
 
 static const GameScoreType kRemovedDartScore				= 5;
 static const GameScoreType kAnalyzedDartScore				= 5;
@@ -260,7 +260,7 @@ static const GameScoreType kMaxWSCScore					=	kRemovedDartScore +
 														kGotWSCOpMemChipScore +
 														kFinishedWSCScore;
 
-//	Gandhi
+// Gandhi
 
 static const GameScoreType kMarsGandhiScore				= 10;
 static const GameScoreType kNoradGandhiScore				= 10;
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
index f6e175d..57cfd52 100755
--- a/engines/pegasus/sound.h
+++ b/engines/pegasus/sound.h
@@ -38,15 +38,15 @@ namespace Pegasus {
 
 class SoundFader;
 
-//	Things you might want to do with sound:
-//		Start it
-//		Stop it
-//		Loop it
-//		Pause it
-//		Set the volume
-//		Set the pitch (rate)
-//		Pan the sound
-//		Change these settings dynamically over time
+// Things you might want to do with sound:
+// - Start it
+// - Stop it
+// - Loop it
+// - Pause it
+// - Set the volume
+// - Set the pitch (rate)
+// - Pan the sound
+// - Change these settings dynamically over time
 
 class Sound {
 public:
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 49071a2..5b7c903 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -275,7 +275,7 @@ void TimeBase::checkCallBacks() {
 	}
 }
 
-//	Protected functions only called by TimeBaseCallBack.
+// Protected functions only called by TimeBaseCallBack.
 
 void TimeBase::addCallBack(TimeBaseCallBack *callBack) {
 	callBack->_nextCallBack = _callBackList;
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index dcd68e4..f32db63 100755
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -47,8 +47,8 @@ private:
 	static uint32 getBlack();
 };
 
-//	Transitions are faders that range over [0,1000], which makes their
-//	"resolution" one tenth of a percent
+// Transitions are faders that range over [0,1000], which makes their
+// "resolution" one tenth of a percent
 
 static const int kTransitionBottom = 0;
 static const int kTransitionTop = 1000;
diff --git a/engines/pegasus/types.h b/engines/pegasus/types.h
index 6527e2c..73a4e98 100755
--- a/engines/pegasus/types.h
+++ b/engines/pegasus/types.h
@@ -118,10 +118,10 @@ typedef int32 AIConditionID;
 
 enum EnergyStage {
 	kStageNoStage,
-	kStageCasual,				//	more than 50% energy
-	kStageWorried,				//	more than 25% energy
-	kStageNervous,				//	more than 5% energy
-	kStagePanicStricken			//	less than 5% energy
+	kStageCasual,       // more than 50% energy
+	kStageWorried,      // more than 25% energy
+	kStageNervous,      // more than 5% energy
+	kStagePanicStricken // less than 5% energy
 };
 
 enum NoradSubPrepState {


Commit: 331da45ae3e1192e348ae817456e9f121ee74577
    https://github.com/scummvm/scummvm/commit/331da45ae3e1192e348ae817456e9f121ee74577
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-20T15:35:33-08:00

Commit Message:
PEGASUS: Make InputDevice into a Singleton

Removes a global construction

Changed paths:
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index b0836ab..9eacb03 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -265,7 +265,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo
 	
 	lockAIOut();
 
-	InputHandler::getCurrentInputDevice()->waitInput(interruptFilter);
+	InputDevice.waitInput(interruptFilter);
 	if (_AIMovie.isMovieValid())
 		_AIMovie.releaseMovie();
 
@@ -295,7 +295,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo
 
 	while (_AIMovie.isRunning()) {
 		Input input;
-		InputHandler::getCurrentInputDevice()->getInput(input, interruptFilter);
+		InputDevice.getInput(input, interruptFilter);
 
 		if (input.anyInput() || vm->shouldQuit()) {
 			result = false;
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index d0b8b69..ef9d9a6 100755
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -30,16 +30,17 @@
 #include "pegasus/input.h"
 #include "pegasus/pegasus.h"
 
+namespace Common {
+DECLARE_SINGLETON(Pegasus::InputDeviceManager);
+}
+
 namespace Pegasus {
 
-InputDevice::InputDevice() {
+InputDeviceManager::InputDeviceManager() {
 	_lastRawBits = kAllUpBits;
 }
 
-InputDevice::~InputDevice() {
-}
-
-void InputDevice::getInput(Input &input, const InputBits filter) {
+void InputDeviceManager::getInput(Input &input, const InputBits filter) {
 	// TODO: Save/Load keys
 
 	InputBits currentBits = 0;
@@ -140,7 +141,7 @@ void InputDevice::getInput(Input &input, const InputBits filter) {
 }
 
 // Wait until the input device stops returning input allowed by filter...
-void InputDevice::waitInput(const InputBits filter) {
+void InputDeviceManager::waitInput(const InputBits filter) {
 	if (filter != 0) {
 		for (;;) {
 			Input input;
@@ -160,7 +161,6 @@ int operator!=(const Input &arg1, const Input &arg2) {
 }
 
 InputHandler *InputHandler::_inputHandler = 0;
-InputDevice InputHandler::_inputDevice;
 bool InputHandler::_invalHotspots = false;
 InputBits InputHandler::_lastFilter = kFilterNoInput;
 
@@ -198,7 +198,7 @@ void InputHandler::getInput(Input &input, Hotspot *&cursorSpot) {
 	else
 		_lastFilter = kFilterAllInput;
 
-	_inputDevice.getInput(input, _lastFilter);
+	InputDevice.getInput(input, _lastFilter);
 
 	if (_inputHandler && _inputHandler->wantsCursor() && (_lastFilter & _inputHandler->getClickFilter()) != 0) {
 		if (cursor->isVisible()) {
@@ -220,7 +220,7 @@ void InputHandler::getInput(Input &input, Hotspot *&cursorSpot) {
 }
 
 void InputHandler::readInputDevice(Input &input) {
-	_inputDevice.getInput(input, kFilterAllInput);
+	InputDevice.getInput(input, kFilterAllInput);
 }
 
 InputHandler::InputHandler(InputHandler *nextHandler) {
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 57d5f93..0ee01f1 100755
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -27,6 +27,7 @@
 #define PEGASUS_INPUT_H
 
 #include "common/rect.h"
+#include "common/singleton.h"
 
 #include "pegasus/constants.h"
 #include "pegasus/types.h"
@@ -36,16 +37,18 @@ namespace Pegasus {
 class Hotspot;
 class Input;
 
-class InputDevice {
+class InputDeviceManager : public Common::Singleton<InputDeviceManager> {
 public:
-	InputDevice();
-	~InputDevice();
+	InputDeviceManager();
+	~InputDeviceManager() {}
 
 	void getInput(Input &, const InputBits);
 
 	void waitInput(const InputBits);
 
 protected:
+	friend class Common::Singleton<SingletonBaseType>;
+
 	InputBits _lastRawBits;
 };
 
@@ -292,7 +295,7 @@ static const InputBits kOpticalInterruption = kFilterAllInputNoAuto;
 class Input {
 friend int operator==(const Input &, const Input &);
 friend int operator!=(const Input &, const Input &);
-friend class InputDevice;
+friend class InputDeviceManager;
 
 public:
 	Input() { clearInput(); }
@@ -385,7 +388,6 @@ class InputHandler {
 public:
 	static InputHandler *setInputHandler(InputHandler*);
 	static InputHandler *getCurrentHandler() { return _inputHandler; }
-	static InputDevice *getCurrentInputDevice() { return &_inputDevice; }
 	static void pollForInput();
 	static void getInput(Input&, Hotspot*&);
 	static void readInputDevice(Input&);
@@ -419,7 +421,6 @@ public:
 
 protected:
 	static InputHandler *_inputHandler;
-	static InputDevice _inputDevice; // TODO: Remove global constructor
 	static bool _invalHotspots;
 	static InputBits _lastFilter;
 	
@@ -487,4 +488,6 @@ public:
 
 } // End of namespace Pegasus
 
+#define InputDevice (::Pegasus::InputDeviceManager::instance())
+
 #endif
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index a4beecd..4842423 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -222,7 +222,7 @@ void Caldoria::start() {
 				}
 			}
 
-			InputHandler::getCurrentInputDevice()->getInput(input, kPullbackInterruptFilter);
+			InputDevice.getInput(input, kPullbackInterruptFilter);
 			if (input.anyInput()) { // TODO: Save/Quit requests
 				skipped = true;
 				break;
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index b516989..224d954 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -882,7 +882,7 @@ void Neighborhood::startExtraSequence(const ExtraID extraID, const NotificationF
 }
 
 bool Neighborhood::startExtraSequenceSync(const ExtraID extraID, const InputBits interruptionFilter) {
-	InputHandler::getCurrentInputDevice()->waitInput(interruptionFilter);
+	InputDevice.waitInput(interruptionFilter);
 	return prepareExtraSync(extraID) && waitMovieFinish(&_navMovie, interruptionFilter);
 }
 
@@ -1315,7 +1315,7 @@ bool Neighborhood::waitMovieFinish(Movie *movie, const InputBits interruptionFil
 	bool openAllowed = _vm->swapLoadAllowed(false);
 
 	while (movie->isRunning()) {
-		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter);
+		InputDevice.getInput(input, interruptionFilter);
 
 		if (input.anyInput() || _vm->shouldQuit()) {
 			result = false;
@@ -1590,7 +1590,7 @@ void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordTy
 	Input input;
 	while (_croppedMovie.isRunning() && !_vm->shouldQuit()) {
 		_vm->processShell();
-		InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter);
+		InputDevice.getInput(input, interruptionFilter);
 		if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request
 			break;
 		_vm->_system->delayMillis(10);
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index c54e252..7f5c392 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -1619,7 +1619,7 @@ void FullTSA::showMainJumpMenu() {
 }
 
 void FullTSA::playTBPMonitor() {
-	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+	InputDevice.waitInput(kFilterAllButtons);
 	
 	if ((GameState.getT0BMonitorMode() & kPlayingTBPMask) == 0) {
 		ExtraID extra;
@@ -1770,7 +1770,7 @@ void FullTSA::initializeComparisonMonitor(const int newMode, const ExtraID compa
 }
 
 void FullTSA::playLeftComparison() {
-	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+	InputDevice.waitInput(kFilterAllButtons);
 
 	if ((GameState.getT0BMonitorMode() & kPlayingLeftComparisonMask) == 0) {
 		ExtraID extra;
@@ -1820,7 +1820,7 @@ void FullTSA::playLeftComparison() {
 }
 
 void FullTSA::playRightComparison() {	
-	InputHandler::getCurrentInputDevice()->waitInput(kFilterAllButtons);
+	InputDevice.waitInput(kFilterAllButtons);
 	
 	if ((GameState.getT0BMonitorMode() & kPlayingRightComparisonMask) == 0) {
 		ExtraID extra;
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 2f1da77..2e352bd 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -281,7 +281,7 @@ void PegasusEngine::runIntro() {
 			}
 
 			Input input;
-			InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+			InputDevice.getInput(input, kFilterAllInput);
 			if (input.anyInput())
 				skipped = true;
 
@@ -892,7 +892,7 @@ void PegasusEngine::doInterfaceOverview() {
 	highlight.setHighlightCornerDiameter(8);
 
 	Input input;
-	InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+	InputDevice.getInput(input, kFilterAllInput);
 
 	Common::Point cursorLoc;
 	input.getInputLocation(cursorLoc);
@@ -934,7 +934,7 @@ void PegasusEngine::doInterfaceOverview() {
 	_gfx->doFadeInSync();
 
 	for (;;) {
-		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+		InputDevice.getInput(input, kFilterAllInput);
 
 		if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too
 			break;
@@ -1150,7 +1150,7 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x
 		}
 
 		Input input;
-		InputHandler::getCurrentInputDevice()->getInput(input, kFilterAllInput);
+		InputDevice.getInput(input, kFilterAllInput);
 		if (input.anyInput())
 			skipped = true;
 


Commit: d29bde9abeb00a42977051bcf6067a71d35fefde
    https://github.com/scummvm/scummvm/commit/d29bde9abeb00a42977051bcf6067a71d35fefde
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-20T15:56:42-08:00

Commit Message:
PEGASUS: Remove another global construction

Changed paths:
    engines/pegasus/neighborhood/mars/reactor.cpp



diff --git a/engines/pegasus/neighborhood/mars/reactor.cpp b/engines/pegasus/neighborhood/mars/reactor.cpp
index b044fc9..478a01c 100755
--- a/engines/pegasus/neighborhood/mars/reactor.cpp
+++ b/engines/pegasus/neighborhood/mars/reactor.cpp
@@ -135,15 +135,6 @@ static const CoordType kReactorHistoryHeight = 168;
 static const CoordType kColorWidths[5] = { 24, 25, 25, 26, 27 };
 static const CoordType kColorHeights[5] = { 14, 15, 17, 17, 19};
 
-// TODO: Remove global construction
-static const CoordType kColorTops[5] = {
-	0,
-	kColorHeights[0],
-	kColorHeights[0] + kColorHeights[1],
-	kColorHeights[0] + kColorHeights[1] + kColorHeights[2],
-	kColorHeights[0] + kColorHeights[1] + kColorHeights[2] + kColorHeights[3],
-};
-
 static const CoordType kHistoryLefts[5][3] = {
 	{ 302 + kNavAreaLeft, 329 + kNavAreaLeft, 357 + kNavAreaLeft },
 	{ 302 + kNavAreaLeft, 331 + kNavAreaLeft, 360 + kNavAreaLeft },
@@ -249,7 +240,15 @@ bool ReactorHistory::isSolved() {
 	return false;
 }
 
-void ReactorHistory::draw(const Common::Rect &) {	
+void ReactorHistory::draw(const Common::Rect &) {
+	static const CoordType kColorTops[5] = {
+		0,
+		kColorHeights[0],
+		kColorHeights[0] + kColorHeights[1],
+		kColorHeights[0] + kColorHeights[1] + kColorHeights[2],
+		kColorHeights[0] + kColorHeights[1] + kColorHeights[2] + kColorHeights[3],
+	};
+
 	if (_colors.isSurfaceValid() && _digits.isSurfaceValid()) {
 		for (int i = 0; i < _numGuesses; ++i) {
 			Common::Rect r1(0, 0, kColorWidths[i], kColorHeights[i]);


Commit: 03eba05b09e5c9e5a351f8111185934b92a3fed3
    https://github.com/scummvm/scummvm/commit/03eba05b09e5c9e5a351f8111185934b92a3fed3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2011-12-21T09:09:01-08:00

Commit Message:
PEGASUS: Use correct CD when outputting saves

For better compatibility when loading saves with the original interpreter

Changed paths:
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 2e352bd..19ebfea 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -88,6 +88,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_draggingItem = 0;
 	_dragType = kDragNoDrag;
 	_idlerHead = 0;
+	_currentCD = 1;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -423,6 +424,7 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	case kPegasusPrimeDisk2GameType:
 	case kPegasusPrimeDisk3GameType:
 	case kPegasusPrimeDisk4GameType:
+		_currentCD = gameType - kPegasusPrimeDisk1GameType + 1;
 		saveType = kNormalSave;
 		break;
 	case kPegasusPrimeContinueType:
@@ -505,12 +507,10 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	// Signature
 	stream->writeUint32BE(kPegasusPrimeCreator);
 
-	if (saveType == kNormalSave) {
-		// TODO: Disc check
-		stream->writeUint32BE(kPegasusPrimeDisk1GameType);
-	} else { // Continue
+	if (saveType == kNormalSave)
+		stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1);
+	else // Continue
 		stream->writeUint32BE(kPegasusPrimeContinueType);
-	}
 
 	stream->writeUint32BE(kPegasusPrimeVersion);
 
@@ -1326,6 +1326,9 @@ void PegasusEngine::performJump(NeighborhoodID neighborhoodID) {
 	Neighborhood *neighborhood;
 	makeNeighborhood(neighborhoodID, neighborhood);
 	useNeighborhood(neighborhood);
+
+	// Update the CD variable (used just for saves currently)
+	_currentCD = getNeighborhoodCD(neighborhoodID);
 }
 
 void PegasusEngine::startNeighborhood() {
@@ -2135,4 +2138,28 @@ ItemID PegasusEngine::pickItemToDestroy() {
 	return kNoItemID;
 }
 
+uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const {
+	switch (neighborhood) {
+	case kCaldoriaID:
+	case kNoradAlphaID:
+	case kNoradSubChaseID:
+		return 1;
+	case kFullTSAID:
+	case kPrehistoricID:
+		return 2;
+	case kMarsID:
+		return 3;
+	case kWSCID:
+	case kNoradDeltaID:
+		return 4;
+	case kTinyTSAID:
+		// Tiny TSA exists on three of the CD's, so just continue
+		// with the CD we're on
+		return _currentCD;
+	}
+
+	// Can't really happen, but it's a good fallback anyway :P
+	return 1;
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index bd8f04b..ef05585 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -248,6 +248,8 @@ private:
 	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
 	Common::RandomSource *_rnd;
 	void doSubChase();
+	uint getNeighborhoodCD(const NeighborhoodID neighborhood) const;
+	uint _currentCD;
 
 	// Menu
 	GameMenu *_gameMenu;


Commit: 71756bdf4eae5ba9cc3f329b85e894f04640aaef
    https://github.com/scummvm/scummvm/commit/71756bdf4eae5ba9cc3f329b85e894f04640aaef
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-20T11:49:16-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A COPYING.FREEFONT
  A audio/softsynth/mt32/AReverbModel.cpp
  A audio/softsynth/mt32/AReverbModel.h
  A audio/softsynth/mt32/DelayReverb.cpp
  A audio/softsynth/mt32/DelayReverb.h
  A audio/softsynth/mt32/FreeverbModel.cpp
  A audio/softsynth/mt32/FreeverbModel.h
  A audio/softsynth/mt32/LA32Ramp.cpp
  A audio/softsynth/mt32/LA32Ramp.h
  A audio/softsynth/mt32/Part.cpp
  A audio/softsynth/mt32/Part.h
  A audio/softsynth/mt32/Partial.cpp
  A audio/softsynth/mt32/Partial.h
  A audio/softsynth/mt32/PartialManager.cpp
  A audio/softsynth/mt32/PartialManager.h
  A audio/softsynth/mt32/Poly.cpp
  A audio/softsynth/mt32/Poly.h
  A audio/softsynth/mt32/Structures.h
  A audio/softsynth/mt32/Synth.cpp
  A audio/softsynth/mt32/Synth.h
  A audio/softsynth/mt32/TVA.cpp
  A audio/softsynth/mt32/TVA.h
  A audio/softsynth/mt32/TVF.cpp
  A audio/softsynth/mt32/TVF.h
  A audio/softsynth/mt32/TVP.cpp
  A audio/softsynth/mt32/TVP.h
  A audio/softsynth/mt32/Tables.cpp
  A audio/softsynth/mt32/Tables.h
  A audio/softsynth/mt32/mmath.h
  A backends/keymapper/hardware-input.cpp
  A backends/keymapper/hardware-input.h
  A backends/keymapper/keymapper-defaults.h
  A backends/platform/iphone/iphone_keyboard.mm
  A backends/platform/iphone/iphone_main.mm
  A backends/platform/iphone/iphone_video.mm
  A backends/platform/iphone/osys_video.mm
  A backends/platform/openpandora/module.mk
  A backends/platform/sdl/macosx/appmenu_osx.h
  A backends/saves/windows/windows-saves.cpp
  A backends/saves/windows/windows-saves.h
  A backends/timer/bada/timer.h
  A common/EventMapper.cpp
  A common/gui_options.cpp
  A common/gui_options.h
  A common/language.cpp
  A common/language.h
  A common/platform.cpp
  A common/platform.h
  A common/rendermode.cpp
  A common/rendermode.h
  A devtools/convbdf.cpp
  A devtools/create_project/xcode.cpp
  A devtools/create_translations/cp_parser.cpp
  A devtools/create_translations/cp_parser.h
  A dists/gph/README-GPH
  A dists/gph/README-GPH.in
  A dists/gph/caanoo/scummvm-gdb.gpe
  A dists/gph/caanoo/scummvm.gpe
  A dists/gph/gp2x/mmuhack/Makefile
  A dists/gph/gp2x/mmuhack/README
  A dists/gph/gp2x/mmuhack/flush_uppermem_cache.h
  A dists/gph/gp2x/mmuhack/flush_uppermem_cache.s
  A dists/gph/gp2x/mmuhack/mmuhack.c
  A dists/gph/gp2x/mmuhack/mmuhack.o
  A dists/gph/gp2x/scummvm.gpe
  A dists/gph/gp2xwiz/scummvm-gdb.gpe
  A dists/gph/gp2xwiz/scummvm.gpe
  A dists/gph/scummvm.ini
  A dists/gph/scummvm.ini.in
  A dists/gph/scummvm.png
  A dists/gph/scummvmb.png
  A dists/iphone/scummvm.xcodeproj/project.pbxproj
  A dists/macosx/scummvm_osx_appcast.xml
  A dists/openpandora/PXML.xml
  A dists/openpandora/PXML.xml.in
  A dists/openpandora/PXML_schema.xsd
  A dists/openpandora/README-OPENPANDORA
  A dists/openpandora/README-OPENPANDORA.in
  A dists/openpandora/README-PND.txt
  A dists/openpandora/README-PND.txt.in
  A dists/openpandora/icon/preview-pic.png
  A dists/openpandora/icon/scummvm.png
  A dists/openpandora/index.html
  A dists/openpandora/index.html.in
  A dists/openpandora/pnd_make.sh
  A dists/openpandora/runscummvm.sh
  A dists/win32/migration.bat
  A dists/win32/migration.txt
  A engines/dreamweb/newplace.cpp
  A engines/dreamweb/rain.cpp
  A engines/dreamweb/titles.cpp
  A engines/gob/cheater.cpp
  A engines/gob/cheater.h
  A engines/gob/cheater_geisha.cpp
  A engines/gob/cmpfile.cpp
  A engines/gob/cmpfile.h
  A engines/gob/minigames/geisha/meter.cpp
  A engines/gob/minigames/geisha/meter.h
  A engines/gob/minigames/geisha/oko.cpp
  A engines/gob/minigames/geisha/oko.h
  A engines/kyra/chargen.cpp
  A engines/kyra/darkmoon.cpp
  A engines/kyra/darkmoon.h
  A engines/kyra/eob.cpp
  A engines/kyra/eob.h
  A engines/kyra/eobcommon.cpp
  A engines/kyra/eobcommon.h
  A engines/kyra/gui_eob.cpp
  A engines/kyra/gui_eob.h
  A engines/kyra/gui_rpg.cpp
  A engines/kyra/gui_v1.cpp
  A engines/kyra/gui_v1.h
  A engines/kyra/items_eob.cpp
  A engines/kyra/kyra_rpg.cpp
  A engines/kyra/kyra_rpg.h
  A engines/kyra/magic_eob.cpp
  A engines/kyra/saveload_eob.cpp
  A engines/kyra/saveload_rpg.cpp
  A engines/kyra/scene_eob.cpp
  A engines/kyra/scene_rpg.cpp
  A engines/kyra/screen_eob.cpp
  A engines/kyra/screen_eob.h
  A engines/kyra/script_eob.cpp
  A engines/kyra/script_eob.h
  A engines/kyra/sequences_darkmoon.cpp
  A engines/kyra/sequences_eob.cpp
  A engines/kyra/sprites_eob.cpp
  A engines/kyra/sprites_rpg.cpp
  A engines/kyra/staticres_eob.cpp
  A engines/kyra/staticres_rpg.cpp
  A engines/kyra/text_rpg.cpp
  A engines/kyra/text_rpg.h
  A engines/kyra/timer_eob.cpp
  A engines/kyra/timer_rpg.cpp
  A engines/mohawk/cstime_graphics.cpp
  A engines/mohawk/cstime_graphics.h
  A engines/mohawk/livingbooks_graphics.cpp
  A engines/mohawk/livingbooks_graphics.h
  A engines/mohawk/myst_graphics.cpp
  A engines/mohawk/myst_graphics.h
  A engines/mohawk/riven_graphics.cpp
  A engines/mohawk/riven_graphics.h
  A engines/scumm/player_apple2.cpp
  A engines/scumm/player_apple2.h
  A engines/tsage/ringworld2/ringworld2_scenes1.cpp
  A engines/tsage/ringworld2/ringworld2_scenes1.h
  A engines/tsage/ringworld2/ringworld2_scenes3.cpp
  A engines/tsage/ringworld2/ringworld2_scenes3.h
  A graphics/decoders/bmp.cpp
  A graphics/decoders/bmp.h
  A graphics/decoders/image_decoder.h
  A graphics/decoders/jpeg.cpp
  A graphics/decoders/jpeg.h
  A graphics/decoders/pict.cpp
  A graphics/decoders/pict.h
  A graphics/decoders/png.cpp
  A graphics/decoders/png.h
  A graphics/fonts/ttf.cpp
  A graphics/fonts/ttf.h
  A gui/themes/fonts/FreeMonoBold.ttf
  A gui/themes/fonts/FreeSans.ttf
  A gui/themes/fonts/FreeSansBold.ttf
  A gui/themes/scummmodern/FreeMonoBold.ttf
  A gui/themes/scummmodern/FreeSans.ttf
  A gui/themes/scummmodern/FreeSansBold.ttf
  A po/eu.po
  A po/iso-8859-2.cp
  A po/iso-8859-5.cp
  A video/psx_decoder.cpp
  A video/psx_decoder.h
  R audio/softsynth/mt32/i386.cpp
  R audio/softsynth/mt32/i386.h
  R audio/softsynth/mt32/mt32_file.cpp
  R audio/softsynth/mt32/mt32_file.h
  R audio/softsynth/mt32/part.cpp
  R audio/softsynth/mt32/part.h
  R audio/softsynth/mt32/partial.cpp
  R audio/softsynth/mt32/partial.h
  R audio/softsynth/mt32/partialManager.cpp
  R audio/softsynth/mt32/partialManager.h
  R audio/softsynth/mt32/structures.h
  R audio/softsynth/mt32/synth.cpp
  R audio/softsynth/mt32/synth.h
  R audio/softsynth/mt32/tables.cpp
  R audio/softsynth/mt32/tables.h
  R backends/keymapper/hardware-key.h
  R backends/keymapper/types.h
  R backends/platform/iphone/blit_arm.s
  R backends/platform/iphone/iphone_keyboard.m
  R backends/platform/iphone/iphone_main.m
  R backends/platform/iphone/iphone_video.m
  R backends/platform/iphone/osys_video.cpp
  R backends/platform/openpandora/module.mk
  R backends/platform/sdl/hardwarekeys.cpp
  R backends/platform/sdl/macosx/appmenu_osx.h
  R backends/platform/iphone/blit_arm.h
  R backends/timer/bada/timer.h
  R devtools/convbdf.c
  R devtools/create_project/xcode.cpp
  R backends/platform/gph/devices/common/README-GPH
  R backends/platform/gph/devices/caanoo/scummvm-gdb.gpe
  R backends/platform/gph/devices/caanoo/scummvm.gpe
  R backends/platform/gph/devices/gp2x/mmuhack/Makefile
  R backends/platform/gph/devices/gp2x/mmuhack/README
  R backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h
  R backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s
  R backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c
  R backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o
  R backends/platform/gph/devices/gp2x/scummvm.gpe
  R backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe
  R backends/platform/gph/devices/gp2xwiz/scummvm.gpe
  R backends/platform/gph/devices/common/scummvm.ini
  R backends/platform/gph/devices/common/scummvm.png
  R backends/platform/gph/devices/common/scummvmb.png
  R dists/iphone/scummvm.xcodeproj/project.pbxproj
  R dists/macosx/scummvm_osx_appcast.xml
  R backends/platform/openpandora/build/PXML.xml
  R backends/platform/openpandora/build/PXML_schema.xsd
  R backends/platform/openpandora/build/README-OPENPANDORA
  R backends/platform/openpandora/build/README-PND.txt
  R backends/platform/openpandora/build/icon/preview-pic.png
  R backends/platform/openpandora/build/icon/scummvm.png
  R backends/platform/openpandora/build/index.html
  R backends/platform/openpandora/build/pnd_make.sh
  R backends/platform/openpandora/build/runscummvm.sh
  R engines/dreamweb/README
  R engines/dreamweb/dreambase.h
  R engines/dreamweb/dreamgen.cpp
  R engines/dreamweb/dreamgen.h
  R engines/dreamweb/runtime.h
  R engines/dreamweb/segment.h
  R engines/dreamweb/stubs.h
  R backends/platform/iphone/blit.cpp
  R graphics/imagedec.h
  R graphics/jpeg.cpp
  R graphics/jpeg.h
  R graphics/pict.cpp
  R graphics/pict.h
  R graphics/png.cpp
  R graphics/png.h
  R graphics/imagedec.cpp
    AUTHORS
    COPYRIGHT
    Makefile.common
    NEWS
    README
    audio/decoders/flac.cpp
    audio/decoders/iff_sound.cpp
    audio/decoders/mac_snd.h
    audio/decoders/qdm2.cpp
    audio/decoders/quicktime.cpp
    audio/decoders/quicktime_intern.h
    audio/decoders/raw.cpp
    audio/decoders/voc.cpp
    audio/decoders/voc.h
    audio/decoders/wave.cpp
    audio/mididrv.cpp
    audio/mods/maxtrax.h
    audio/mods/tfmx.cpp
    audio/softsynth/cms.cpp
    audio/softsynth/fmtowns_pc98/towns_pc98_driver.cpp
    audio/softsynth/mt32.cpp
    audio/softsynth/mt32/freeverb.cpp
    audio/softsynth/mt32/freeverb.h
    audio/softsynth/mt32/module.mk
    audio/softsynth/mt32/mt32emu.h
    audio/softsynth/opl/dbopl.cpp
    audio/softsynth/opl/mame.cpp
    audio/softsynth/sid.h
    backends/events/default/default-events.cpp
    backends/events/default/default-events.h
    backends/events/maemosdl/maemosdl-events.cpp
    backends/events/maemosdl/maemosdl-events.h
    backends/events/webossdl/webossdl-events.cpp
    backends/events/webossdl/webossdl-events.h
    backends/fs/symbian/symbian-fs.cpp
    backends/fs/symbian/symbianstream.cpp
    backends/fs/windows/windows-fs.cpp
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/linuxmotosdl/linuxmotosdl-graphics.cpp
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/glerrorcheck.cpp
    backends/graphics/opengl/gltexture.cpp
    backends/graphics/opengl/gltexture.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/keymapper/action.cpp
    backends/keymapper/action.h
    backends/keymapper/keymap.cpp
    backends/keymapper/keymap.h
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.h
    backends/keymapper/remap-dialog.cpp
    backends/keymapper/remap-dialog.h
    backends/midi/coreaudio.cpp
    backends/midi/stmidi.cpp
    backends/midi/timidity.cpp
    backends/midi/windows.cpp
    backends/mixer/symbiansdl/symbiansdl-mixer.cpp
    backends/modular-backend.h
    backends/module.mk
    backends/mutex/null/null-mutex.h
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/asset-archive.cpp
    backends/platform/android/asset-archive.h
    backends/platform/android/events.cpp
    backends/platform/android/texture.cpp
    backends/platform/bada/application.cpp
    backends/platform/bada/audio.cpp
    backends/platform/bada/fs.cpp
    backends/platform/bada/missing.cpp
    backends/platform/bada/portdefs.h
    backends/platform/dc/audio.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcloader.cpp
    backends/platform/dc/display.cpp
    backends/platform/ds/arm7/source/main.cpp
    backends/platform/ds/arm9/source/blitters.cpp
    backends/platform/ds/arm9/source/dsmain.cpp
    backends/platform/ds/arm9/source/scummhelp.h
    backends/platform/gph/caanoo-bundle.mk
    backends/platform/gph/gp2x-bundle.mk
    backends/platform/gph/gp2xwiz-bundle.mk
    backends/platform/iphone/iphone_common.h
    backends/platform/iphone/iphone_keyboard.h
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/module.mk
    backends/platform/iphone/osys_events.cpp
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/linuxmoto/hardwarekeys.cpp
    backends/platform/linuxmoto/linuxmoto-sdl.h
    backends/platform/maemo/maemo-common.h
    backends/platform/maemo/maemo.cpp
    backends/platform/maemo/maemo.h
    backends/platform/n64/osys_n64_utilities.cpp
    backends/platform/openpandora/op-bundle.mk
    backends/platform/ps2/DmaPipe.cpp
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/fileio.cpp
    backends/platform/ps2/icon.cpp
    backends/platform/ps2/icon.h
    backends/platform/ps2/ps2mutex.cpp
    backends/platform/ps2/ps2pad.cpp
    backends/platform/ps2/systemps2.cpp
    backends/platform/psp/default_display_client.h
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/psp_main.cpp
    backends/platform/psp/tests.cpp
    backends/platform/psp/tests.h
    backends/platform/psp/trace.h
    backends/platform/sdl/macosx/appmenu_osx.mm
    backends/platform/sdl/module.mk
    backends/platform/sdl/posix/posix.cpp
    backends/platform/sdl/sdl.h
    backends/platform/sdl/win32/win32.cpp
    backends/platform/symbian/README
    backends/platform/symbian/S60/ScummVM_S60.mmp.in
    backends/platform/symbian/S60/ScummVM_S60_App.mmp
    backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in
    backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in
    backends/platform/symbian/S80/ScummVM_S80.mmp.in
    backends/platform/symbian/S80/ScummVM_S80_App.mmp
    backends/platform/symbian/S90/Scummvm_S90.mmp.in
    backends/platform/symbian/S90/Scummvm_S90_App.mmp
    backends/platform/symbian/UIQ2/ScummVM.rss
    backends/platform/symbian/UIQ3/ScummVM.rss
    backends/platform/symbian/UIQ3/ScummVM_A0000658.rss
    backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in
    backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss
    backends/platform/symbian/mmp/scummvm_agi.mmp.in
    backends/platform/symbian/mmp/scummvm_agos.mmp.in
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/mmp/scummvm_cine.mmp.in
    backends/platform/symbian/mmp/scummvm_cruise.mmp.in
    backends/platform/symbian/mmp/scummvm_draci.mmp.in
    backends/platform/symbian/mmp/scummvm_drascula.mmp.in
    backends/platform/symbian/mmp/scummvm_gob.mmp.in
    backends/platform/symbian/mmp/scummvm_groovie.mmp.in
    backends/platform/symbian/mmp/scummvm_hugo.mmp.in
    backends/platform/symbian/mmp/scummvm_kyra.mmp.in
    backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in
    backends/platform/symbian/mmp/scummvm_lure.mmp.in
    backends/platform/symbian/mmp/scummvm_m4.mmp.in
    backends/platform/symbian/mmp/scummvm_made.mmp.in
    backends/platform/symbian/mmp/scummvm_mohawk.mmp.in
    backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
    backends/platform/symbian/mmp/scummvm_queen.mmp.in
    backends/platform/symbian/mmp/scummvm_saga.mmp.in
    backends/platform/symbian/mmp/scummvm_sci.mmp.in
    backends/platform/symbian/mmp/scummvm_scumm.mmp.in
    backends/platform/symbian/mmp/scummvm_sky.mmp.in
    backends/platform/symbian/mmp/scummvm_sword1.mmp.in
    backends/platform/symbian/mmp/scummvm_sword2.mmp.in
    backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
    backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
    backends/platform/symbian/mmp/scummvm_toon.mmp.in
    backends/platform/symbian/mmp/scummvm_touche.mmp.in
    backends/platform/symbian/mmp/scummvm_tsage.mmp.in
    backends/platform/symbian/mmp/scummvm_tucker.mmp.in
    backends/platform/symbian/res/ScummVmAif.rss
    backends/platform/symbian/res/scummvm.rss
    backends/platform/symbian/res/scummvm_A0000658.rss
    backends/platform/symbian/src/ScummApp.cpp
    backends/platform/symbian/src/ScummApp.h
    backends/platform/symbian/src/ScummVm.hrh
    backends/platform/symbian/src/SymbianActions.cpp
    backends/platform/symbian/src/portdefs.h
    backends/platform/webos/webos.cpp
    backends/platform/webos/webos.h
    backends/platform/wince/wince-sdl.cpp
    backends/plugins/elf/elf-loader.cpp
    backends/taskbar/win32/win32-taskbar.cpp
    backends/timer/bada/timer.cpp
    backends/timer/psp/timer.cpp
    backends/vkeybd/image-map.cpp
    backends/vkeybd/image-map.h
    backends/vkeybd/polygon.cpp
    backends/vkeybd/polygon.h
    backends/vkeybd/virtual-keyboard-gui.cpp
    backends/vkeybd/virtual-keyboard-gui.h
    backends/vkeybd/virtual-keyboard-parser.cpp
    backends/vkeybd/virtual-keyboard-parser.h
    backends/vkeybd/virtual-keyboard.cpp
    backends/vkeybd/virtual-keyboard.h
    base/commandLine.cpp
    base/main.cpp
    base/plugins.cpp
    base/version.cpp
    common/EventDispatcher.cpp
    common/archive.cpp
    common/archive.h
    common/array.h
    common/config-file.cpp
    common/config-manager.cpp
    common/endian.h
    common/events.h
    common/fft.cpp
    common/forbidden.h
    common/fs.cpp
    common/fs.h
    common/hash-str.h
    common/hashmap.h
    common/huffman.h
    common/keyboard.h
    common/list.h
    common/list_intern.h
    common/localization.h
    common/macresman.cpp
    common/macresman.h
    common/math.h
    common/memorypool.cpp
    common/memorypool.h
    common/module.mk
    common/ptr.h
    common/quicktime.cpp
    common/quicktime.h
    common/rect.h
    common/scummsys.h
    common/serializer.h
    common/singleton.h
    common/stack.h
    common/str.cpp
    common/stream.cpp
    common/substream.h
    common/system.h
    common/translation.cpp
    common/translation.h
    common/unarj.cpp
    common/unzip.cpp
    common/util.cpp
    common/util.h
    common/xmlparser.cpp
    common/xmlparser.h
    common/zlib.cpp
    common/zlib.h
    configure
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/create_kyradat.h
    devtools/create_kyradat/extract.cpp
    devtools/create_kyradat/extract.h
    devtools/create_kyradat/games.cpp
    devtools/create_kyradat/module.mk
    devtools/create_kyradat/tables.cpp
    devtools/create_kyradat/util.cpp
    devtools/create_kyradat/util.h
    devtools/create_lure/create_lure_dat.h
    devtools/create_project/create_project.cpp
    devtools/create_translations/create_translations.cpp
    devtools/create_translations/create_translations.h
    devtools/create_translations/module.mk
    devtools/create_translations/po_parser.cpp
    devtools/credits.pl
    devtools/module.mk
    devtools/scumm-md5.txt
    devtools/skycpt/AsciiCptCompile.cpp
    devtools/skycpt/TextFile.cpp
    devtools/skycpt/cptcompiler.cpp
    devtools/tasmrecover/dreamweb/backdrop.asm
    devtools/tasmrecover/dreamweb/debug.asm
    devtools/tasmrecover/dreamweb/dreamweb.asm
    devtools/tasmrecover/dreamweb/keypad.asm
    devtools/tasmrecover/dreamweb/look.asm
    devtools/tasmrecover/dreamweb/monitor.asm
    devtools/tasmrecover/dreamweb/newplace.asm
    devtools/tasmrecover/dreamweb/object.asm
    devtools/tasmrecover/dreamweb/print.asm
    devtools/tasmrecover/dreamweb/saveload.asm
    devtools/tasmrecover/dreamweb/sblaster.asm
    devtools/tasmrecover/dreamweb/sprite.asm
    devtools/tasmrecover/dreamweb/talk.asm
    devtools/tasmrecover/dreamweb/titles.asm
    devtools/tasmrecover/dreamweb/use.asm
    devtools/tasmrecover/dreamweb/vars.asm
    devtools/tasmrecover/dreamweb/vgafades.asm
    devtools/tasmrecover/dreamweb/vgagrafx.asm
    devtools/tasmrecover/tasm-recover
    devtools/tasmrecover/tasm/cpp.py
    devtools/tasmrecover/tasm/parser.py
    devtools/update-version.pl
    dists/android/mkplugin.sh
    dists/debian/copyright
    dists/engine-data/kyra.dat
    dists/macosx/DS_Store
    dists/macosx/Info.plist
    dists/macosx/Info.plist.in
    dists/redhat/scummvm.spec
    dists/redhat/scummvm.spec.in
    dists/scummvm.rc
    dists/scummvm.rc.in
    dists/win32/ScummVM.iss
    dists/win32/scummvm.nsi
    dists/win32/scummvm.nsi.in
    doc/cz/PrectiMe
    doc/de/Liesmich
    doc/de/Neues
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/checks.cpp
    engines/agi/cycle.cpp
    engines/agi/menu.cpp
    engines/agi/menu.h
    engines/agi/objects.cpp
    engines/agi/op_cmd.cpp
    engines/agi/picture.h
    engines/agi/preagi_mickey.h
    engines/agi/preagi_troll.cpp
    engines/agi/preagi_winnie.cpp
    engines/agi/predictive.cpp
    engines/agi/saveload.cpp
    engines/agi/sound_2gs.cpp
    engines/agi/sound_sarien.cpp
    engines/agi/sprite.cpp
    engines/agi/sprite.h
    engines/agi/text.cpp
    engines/agi/wagparser.cpp
    engines/agi/words.cpp
    engines/agos/agos.h
    engines/agos/animation.cpp
    engines/agos/charset-fontdata.cpp
    engines/agos/charset.cpp
    engines/agos/installshield_cab.cpp
    engines/agos/res.cpp
    engines/agos/res_snd.cpp
    engines/agos/saveload.cpp
    engines/agos/script_pn.cpp
    engines/agos/sound.cpp
    engines/agos/sound.h
    engines/agos/string.cpp
    engines/agos/string_pn.cpp
    engines/agos/subroutine.cpp
    engines/cge/bitmap.cpp
    engines/cge/bitmap.h
    engines/cge/cge.cpp
    engines/cge/cge.h
    engines/cge/detection.cpp
    engines/cge/events.cpp
    engines/cge/text.cpp
    engines/cine/detection.cpp
    engines/cine/gfx.cpp
    engines/cine/sound.cpp
    engines/composer/detection.cpp
    engines/cruise/background.cpp
    engines/cruise/backgroundIncrust.cpp
    engines/cruise/cruise.h
    engines/cruise/cruise_main.cpp
    engines/cruise/dataLoader.cpp
    engines/cruise/font.cpp
    engines/cruise/function.cpp
    engines/cruise/mainDraw.cpp
    engines/cruise/saveload.cpp
    engines/cruise/script.cpp
    engines/dialogs.cpp
    engines/draci/barchive.cpp
    engines/draci/sprite.cpp
    engines/draci/walking.cpp
    engines/drascula/animation.cpp
    engines/drascula/drascula.h
    engines/drascula/interface.cpp
    engines/dreamweb/backdrop.cpp
    engines/dreamweb/detection.cpp
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/keypad.cpp
    engines/dreamweb/module.mk
    engines/dreamweb/monitor.cpp
    engines/dreamweb/object.cpp
    engines/dreamweb/pathfind.cpp
    engines/dreamweb/people.cpp
    engines/dreamweb/print.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/sound.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/structs.h
    engines/dreamweb/stubs.cpp
    engines/dreamweb/talk.cpp
    engines/dreamweb/use.cpp
    engines/dreamweb/vgafades.cpp
    engines/dreamweb/vgagrafx.cpp
    engines/engine.cpp
    engines/engine.h
    engines/engines.mk
    engines/game.cpp
    engines/game.h
    engines/gob/anifile.cpp
    engines/gob/anifile.h
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h
    engines/gob/console.cpp
    engines/gob/console.h
    engines/gob/databases.h
    engines/gob/dataio.cpp
    engines/gob/decfile.cpp
    engines/gob/decfile.h
    engines/gob/detection_tables.h
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/hotspots.cpp
    engines/gob/inter.h
    engines/gob/inter_geisha.cpp
    engines/gob/inter_v1.cpp
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/diving.h
    engines/gob/minigames/geisha/evilfish.cpp
    engines/gob/minigames/geisha/evilfish.h
    engines/gob/module.mk
    engines/gob/rxyfile.cpp
    engines/gob/rxyfile.h
    engines/gob/sound/bgatmosphere.h
    engines/groovie/roq.cpp
    engines/groovie/script.cpp
    engines/hugo/dialogs.cpp
    engines/hugo/object.h
    engines/hugo/parser.cpp
    engines/hugo/schedule.cpp
    engines/hugo/sound.cpp
    engines/hugo/sound.h
    engines/hugo/util.cpp
    engines/kyra/animator_hof.cpp
    engines/kyra/animator_lok.cpp
    engines/kyra/animator_mr.cpp
    engines/kyra/animator_v2.cpp
    engines/kyra/debugger.cpp
    engines/kyra/debugger.h
    engines/kyra/detection.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui.cpp
    engines/kyra/gui.h
    engines/kyra/gui_hof.cpp
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_lok.h
    engines/kyra/gui_lol.cpp
    engines/kyra/gui_lol.h
    engines/kyra/gui_mr.cpp
    engines/kyra/gui_v2.cpp
    engines/kyra/gui_v2.h
    engines/kyra/items_lok.cpp
    engines/kyra/items_lol.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_hof.h
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_mr.h
    engines/kyra/kyra_v1.cpp
    engines/kyra/kyra_v1.h
    engines/kyra/kyra_v2.cpp
    engines/kyra/kyra_v2.h
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/module.mk
    engines/kyra/resource.cpp
    engines/kyra/resource.h
    engines/kyra/resource_intern.cpp
    engines/kyra/resource_intern.h
    engines/kyra/saveload.cpp
    engines/kyra/saveload_lok.cpp
    engines/kyra/saveload_lol.cpp
    engines/kyra/scene_lok.cpp
    engines/kyra/scene_lol.cpp
    engines/kyra/scene_v1.cpp
    engines/kyra/scene_v2.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen.h
    engines/kyra/screen_hof.cpp
    engines/kyra/screen_hof.h
    engines/kyra/screen_lok.cpp
    engines/kyra/screen_lok.h
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_lol.h
    engines/kyra/screen_mr.cpp
    engines/kyra/screen_mr.h
    engines/kyra/screen_v2.cpp
    engines/kyra/screen_v2.h
    engines/kyra/script.h
    engines/kyra/script_lok.cpp
    engines/kyra/script_lol.cpp
    engines/kyra/script_tim.cpp
    engines/kyra/script_tim.h
    engines/kyra/script_v1.cpp
    engines/kyra/script_v2.cpp
    engines/kyra/seqplayer.cpp
    engines/kyra/sequences_hof.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/sequences_lol.cpp
    engines/kyra/sound.cpp
    engines/kyra/sound.h
    engines/kyra/sound_adlib.cpp
    engines/kyra/sound_adlib.h
    engines/kyra/sound_amiga.cpp
    engines/kyra/sound_intern.h
    engines/kyra/sound_lol.cpp
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_towns.cpp
    engines/kyra/sprites_lol.cpp
    engines/kyra/staticres.cpp
    engines/kyra/staticres_lol.cpp
    engines/kyra/text_lok.cpp
    engines/kyra/text_lol.cpp
    engines/kyra/text_lol.h
    engines/kyra/timer.cpp
    engines/kyra/timer_lok.cpp
    engines/kyra/timer_lol.cpp
    engines/kyra/vqa.cpp
    engines/kyra/wsamovie.cpp
    engines/lastexpress/data/archive.cpp
    engines/lastexpress/data/archive.h
    engines/lastexpress/entities/alexei.cpp
    engines/lastexpress/entities/chapters.cpp
    engines/lastexpress/entities/entity_intern.h
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/resource.cpp
    engines/lastexpress/resource.h
    engines/lure/debugger.cpp
    engines/lure/game.cpp
    engines/lure/hotspots.cpp
    engines/lure/hotspots.h
    engines/lure/menu.cpp
    engines/lure/res.cpp
    engines/lure/res_struct.cpp
    engines/lure/res_struct.h
    engines/lure/room.cpp
    engines/lure/sound.cpp
    engines/lure/surface.cpp
    engines/made/database.cpp
    engines/made/database.h
    engines/made/graphics.cpp
    engines/made/resource.h
    engines/made/screen.cpp
    engines/made/screenfx.cpp
    engines/made/scriptfuncs.h
    engines/metaengine.h
    engines/mohawk/bitmap.cpp
    engines/mohawk/bitmap.h
    engines/mohawk/console.cpp
    engines/mohawk/cstime.h
    engines/mohawk/detection_tables.h
    engines/mohawk/graphics.cpp
    engines/mohawk/graphics.h
    engines/mohawk/installer_archive.cpp
    engines/mohawk/installer_archive.h
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/livingbooks_code.cpp
    engines/mohawk/module.mk
    engines/mohawk/myst.cpp
    engines/mohawk/myst.h
    engines/mohawk/myst_areas.cpp
    engines/mohawk/myst_areas.h
    engines/mohawk/myst_scripts.cpp
    engines/mohawk/myst_scripts.h
    engines/mohawk/myst_stacks/channelwood.cpp
    engines/mohawk/myst_stacks/credits.cpp
    engines/mohawk/myst_stacks/demo.cpp
    engines/mohawk/myst_stacks/intro.cpp
    engines/mohawk/myst_stacks/mechanical.cpp
    engines/mohawk/myst_stacks/myst.cpp
    engines/mohawk/myst_stacks/preview.cpp
    engines/mohawk/myst_stacks/slides.cpp
    engines/mohawk/myst_stacks/stoneship.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_external.cpp
    engines/mohawk/riven_external.h
    engines/mohawk/riven_saveload.cpp
    engines/mohawk/riven_saveload.h
    engines/mohawk/riven_scripts.cpp
    engines/mohawk/riven_scripts.h
    engines/mohawk/riven_vars.cpp
    engines/mohawk/video.cpp
    engines/parallaction/balloons.cpp
    engines/parallaction/callables_br.cpp
    engines/parallaction/callables_ns.cpp
    engines/parallaction/debug.cpp
    engines/parallaction/dialogue.cpp
    engines/parallaction/disk.cpp
    engines/parallaction/disk_br.cpp
    engines/parallaction/disk_ns.cpp
    engines/parallaction/exec.h
    engines/parallaction/font.cpp
    engines/parallaction/gfxbase.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/graphics.h
    engines/parallaction/gui.h
    engines/parallaction/gui_br.cpp
    engines/parallaction/inventory.cpp
    engines/parallaction/inventory.h
    engines/parallaction/objects.cpp
    engines/parallaction/objects.h
    engines/parallaction/parallaction.cpp
    engines/parallaction/parallaction.h
    engines/parallaction/parser.h
    engines/parallaction/parser_br.cpp
    engines/parallaction/parser_ns.cpp
    engines/parallaction/sound_br.cpp
    engines/parallaction/sound_ns.cpp
    engines/pegasus/cursor.cpp
    engines/pegasus/elements.h
    engines/pegasus/graphics.h
    engines/pegasus/surface.cpp
    engines/queen/input.h
    engines/queen/logic.cpp
    engines/queen/music.cpp
    engines/queen/queen.cpp
    engines/queen/resource.h
    engines/queen/talk.cpp
    engines/saga/actor_path.cpp
    engines/saga/animation.cpp
    engines/saga/gfx.cpp
    engines/saga/interface.cpp
    engines/saga/isomap.cpp
    engines/saga/resource.h
    engines/saga/saga.h
    engines/saga/script.h
    engines/saga/sndres.cpp
    engines/saga/sndres.h
    engines/saga/sound.cpp
    engines/saga/sound.h
    engines/sci/console.cpp
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmenu.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/message.cpp
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/segment.cpp
    engines/sci/engine/segment.h
    engines/sci/engine/vm.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/controls16.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/cursor.h
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/maciconbar.cpp
    engines/sci/graphics/maciconbar.h
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/text16.cpp
    engines/sci/graphics/text32.cpp
    engines/sci/graphics/text32.h
    engines/sci/graphics/transitions.cpp
    engines/sci/parser/said.cpp
    engines/sci/parser/vocabulary.cpp
    engines/sci/resource.cpp
    engines/sci/resource.h
    engines/sci/resource_audio.cpp
    engines/sci/sci.cpp
    engines/sci/sound/drivers/amigamac.cpp
    engines/sci/sound/music.cpp
    engines/sci/sound/music.h
    engines/sci/sound/soundcmd.cpp
    engines/sci/sound/soundcmd.h
    engines/scumm/actor.cpp
    engines/scumm/actor.h
    engines/scumm/boxes.cpp
    engines/scumm/boxes.h
    engines/scumm/charset-fontdata.cpp
    engines/scumm/costume.cpp
    engines/scumm/costume.h
    engines/scumm/cursor.cpp
    engines/scumm/debugger.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection.h
    engines/scumm/detection_tables.h
    engines/scumm/dialogs.cpp
    engines/scumm/dialogs.h
    engines/scumm/gfx.cpp
    engines/scumm/gfx.h
    engines/scumm/gfxARM.s
    engines/scumm/gfx_towns.cpp
    engines/scumm/he/sound_he.cpp
    engines/scumm/he/wiz_he.cpp
    engines/scumm/help.h
    engines/scumm/module.mk
    engines/scumm/object.cpp
    engines/scumm/object.h
    engines/scumm/player_nes.cpp
    engines/scumm/player_pce.cpp
    engines/scumm/player_pce.h
    engines/scumm/player_sid.cpp
    engines/scumm/player_sid.h
    engines/scumm/player_v1.cpp
    engines/scumm/resource.cpp
    engines/scumm/room.cpp
    engines/scumm/saveload.cpp
    engines/scumm/saveload.h
    engines/scumm/script.cpp
    engines/scumm/script_v0.cpp
    engines/scumm/script_v2.cpp
    engines/scumm/script_v4.cpp
    engines/scumm/script_v5.cpp
    engines/scumm/script_v8.cpp
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/scumm/scumm_v0.h
    engines/scumm/scumm_v2.h
    engines/scumm/scumm_v5.h
    engines/scumm/scumm_v7.h
    engines/scumm/smush/smush_player.cpp
    engines/scumm/sound.cpp
    engines/scumm/string.cpp
    engines/scumm/vars.cpp
    engines/scumm/verbs.cpp
    engines/scumm/verbs.h
    engines/sky/autoroute.cpp
    engines/sky/compact.cpp
    engines/sky/control.cpp
    engines/sky/control.h
    engines/sky/detection.cpp
    engines/sky/disk.cpp
    engines/sky/intro.cpp
    engines/sky/logic.cpp
    engines/sky/mouse.cpp
    engines/sky/music/adlibchannel.cpp
    engines/sky/music/gmmusic.cpp
    engines/sky/music/mt32music.cpp
    engines/sky/music/musicbase.cpp
    engines/sky/sky.cpp
    engines/sky/text.cpp
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword1/detection.cpp
    engines/sword1/sword1.cpp
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    engines/sword2/function.cpp
    engines/sword2/music.cpp
    engines/sword2/sprite.cpp
    engines/sword2/sword2.cpp
    engines/sword25/gfx/image/art.cpp
    engines/sword25/gfx/image/imgloader.cpp
    engines/sword25/gfx/screenshot.cpp
    engines/sword25/kernel/inputpersistenceblock.cpp
    engines/sword25/script/luabindhelper.h
    engines/sword25/util/lua/lbaselib.cpp
    engines/sword25/util/lua/llex.cpp
    engines/sword25/util/lua/lobject.cpp
    engines/sword25/util/lua/lstrlib.cpp
    engines/sword25/util/lua/luaconf.h
    engines/sword25/util/lua/scummvm_file.cpp
    engines/sword25/util/pluto/pluto.cpp
    engines/tinsel/background.cpp
    engines/tinsel/bg.cpp
    engines/tinsel/cursor.cpp
    engines/tinsel/detection.cpp
    engines/tinsel/dialogs.cpp
    engines/tinsel/drives.cpp
    engines/tinsel/events.cpp
    engines/tinsel/font.cpp
    engines/tinsel/graphics.cpp
    engines/tinsel/handle.cpp
    engines/tinsel/heapmem.cpp
    engines/tinsel/mareels.cpp
    engines/tinsel/move.cpp
    engines/tinsel/music.cpp
    engines/tinsel/palette.cpp
    engines/tinsel/pcode.cpp
    engines/tinsel/pdisplay.cpp
    engines/tinsel/play.cpp
    engines/tinsel/rince.cpp
    engines/tinsel/saveload.cpp
    engines/tinsel/savescn.cpp
    engines/tinsel/scene.cpp
    engines/tinsel/sched.cpp
    engines/tinsel/scroll.cpp
    engines/tinsel/scroll.h
    engines/tinsel/sound.cpp
    engines/tinsel/strres.cpp
    engines/tinsel/strres.h
    engines/tinsel/sysvar.cpp
    engines/tinsel/text.cpp
    engines/tinsel/timers.cpp
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinsel.cpp
    engines/tinsel/token.cpp
    engines/toltecs/menu.cpp
    engines/toltecs/movie.cpp
    engines/toltecs/resource.h
    engines/toltecs/screen.cpp
    engines/toltecs/script.cpp
    engines/toltecs/script.h
    engines/toltecs/segmap.cpp
    engines/toon/audio.cpp
    engines/toon/character.cpp
    engines/toon/detection.cpp
    engines/toon/path.cpp
    engines/toon/script_func.h
    engines/toon/toon.cpp
    engines/touche/graphics.h
    engines/touche/saveload.cpp
    engines/touche/staticres.cpp
    engines/touche/touche.cpp
    engines/touche/touche.h
    engines/tsage/blue_force/blueforce_dialogs.cpp
    engines/tsage/blue_force/blueforce_logic.cpp
    engines/tsage/blue_force/blueforce_logic.h
    engines/tsage/blue_force/blueforce_scenes0.cpp
    engines/tsage/blue_force/blueforce_scenes0.h
    engines/tsage/blue_force/blueforce_scenes1.cpp
    engines/tsage/blue_force/blueforce_scenes1.h
    engines/tsage/blue_force/blueforce_scenes2.cpp
    engines/tsage/blue_force/blueforce_scenes3.cpp
    engines/tsage/blue_force/blueforce_scenes4.cpp
    engines/tsage/blue_force/blueforce_scenes5.cpp
    engines/tsage/blue_force/blueforce_scenes5.h
    engines/tsage/blue_force/blueforce_scenes6.cpp
    engines/tsage/blue_force/blueforce_scenes7.cpp
    engines/tsage/blue_force/blueforce_scenes8.cpp
    engines/tsage/blue_force/blueforce_scenes9.cpp
    engines/tsage/blue_force/blueforce_scenes9.h
    engines/tsage/converse.cpp
    engines/tsage/core.cpp
    engines/tsage/core.h
    engines/tsage/debugger.cpp
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/events.cpp
    engines/tsage/events.h
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/module.mk
    engines/tsage/resources.cpp
    engines/tsage/resources.h
    engines/tsage/ringworld/ringworld_dialogs.cpp
    engines/tsage/ringworld/ringworld_logic.cpp
    engines/tsage/ringworld/ringworld_logic.h
    engines/tsage/ringworld/ringworld_scenes3.cpp
    engines/tsage/ringworld/ringworld_scenes5.cpp
    engines/tsage/ringworld2/ringworld2_dialogs.cpp
    engines/tsage/ringworld2/ringworld2_logic.cpp
    engines/tsage/ringworld2/ringworld2_logic.h
    engines/tsage/ringworld2/ringworld2_scenes0.cpp
    engines/tsage/ringworld2/ringworld2_scenes0.h
    engines/tsage/ringworld2/ringworld2_scenes2.cpp
    engines/tsage/ringworld2/ringworld2_scenes2.h
    engines/tsage/ringworld2/ringworld2_speakers.cpp
    engines/tsage/ringworld2/ringworld2_speakers.h
    engines/tsage/saveload.cpp
    engines/tsage/saveload.h
    engines/tsage/scenes.cpp
    engines/tsage/staticres.cpp
    engines/tsage/staticres.h
    engines/tsage/tsage.h
    engines/tsage/user_interface.cpp
    engines/tucker/saveload.cpp
    engines/tucker/tucker.h
    graphics/VectorRendererSpec.cpp
    graphics/VectorRendererSpec.h
    graphics/cursorman.cpp
    graphics/font.cpp
    graphics/font.h
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/fonts/bdf.cpp
    graphics/fonts/bdf.h
    graphics/fonts/consolefont.cpp
    graphics/fonts/newfont.cpp
    graphics/fonts/newfont_big.cpp
    graphics/iff.cpp
    graphics/module.mk
    graphics/scaler/thumbnail_intern.cpp
    graphics/sjis.h
    graphics/surface.cpp
    graphics/surface.h
    graphics/yuv_to_rgb.cpp
    graphics/yuv_to_rgb.h
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeParser.cpp
    gui/ThemeParser.h
    gui/about.cpp
    gui/browser_osx.mm
    gui/credits.h
    gui/debugger.cpp
    gui/dialog.cpp
    gui/dialog.h
    gui/gui-manager.cpp
    gui/gui-manager.h
    gui/launcher.cpp
    gui/object.cpp
    gui/object.h
    gui/options.cpp
    gui/options.h
    gui/themes/default.inc
    gui/themes/fonts/README
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/clR6x12-iso-8859-2.fcc
    gui/themes/scummclassic/clR6x12-iso-8859-5.fcc
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummclassic/fixed5x8-iso-8859-2.fcc
    gui/themes/scummclassic/fixed5x8-iso-8859-5.fcc
    gui/themes/scummclassic/helvb12-iso-8859-2.fcc
    gui/themes/scummclassic/helvb12-iso-8859-5.fcc
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/clR6x12-iso-8859-2.fcc
    gui/themes/scummmodern/clR6x12-iso-8859-5.fcc
    gui/themes/scummmodern/eraser.bmp
    gui/themes/scummmodern/fixed5x8-iso-8859-2.fcc
    gui/themes/scummmodern/fixed5x8-iso-8859-5.fcc
    gui/themes/scummmodern/helvb12-iso-8859-1.fcc
    gui/themes/scummmodern/helvb12-iso-8859-2.fcc
    gui/themes/scummmodern/helvb12-iso-8859-5.fcc
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/scummtheme.py
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    gui/widgets/editable.cpp
    gui/widgets/edittext.cpp
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/module.mk
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    test/common/fixedstack.h
    test/common/memoryreadstream.h
    test/common/pack.h
    test/common/stack.h
    test/common/subreadstream.h
    test/cxxtest/cxxtest/ValueTraits.h
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/codecs/mjpeg.cpp
    video/codecs/mjpeg.h
    video/dxa_decoder.cpp
    video/module.mk
    video/qt_decoder.cpp
    video/qt_decoder.h



diff --cc engines/pegasus/cursor.cpp
index 430b319,0000000..ea5fc74
mode 100755,000000..100755
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@@ -1,212 -1,0 +1,212 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/events.h"
 +#include "common/stream.h"
 +#include "common/system.h"
 +#include "graphics/cursorman.h"
- #include "graphics/pict.h"
 +#include "graphics/surface.h"
++#include "graphics/decoders/pict.h"
 +
 +#include "pegasus/cursor.h"
 +#include "pegasus/graphics.h"
 +#include "pegasus/pegasus.h"
 +
 +namespace Pegasus {
 +
 +Cursor::Cursor() {
 +	_cursorObscured = false;
 +	_index = -1;
 +	startIdling();
 +}
 +
 +Cursor::~Cursor() {
 +	for (uint32 i = 0; i < _info.size(); i++) {
 +		if (_info[i].surface) {
 +			_info[i].surface->free();
 +			delete _info[i].surface;
 +		}
 +		delete[] _info[i].palette;
 +	}
 +
 +	stopIdling();
 +}
 +
 +void Cursor::addCursorFrames(uint16 id) {
 +	PegasusEngine *vm = (PegasusEngine *)g_engine;
 +	Common::SeekableReadStream *cursStream = vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), id);
 +	if (!cursStream)
 +		error("Could not load cursor frames set %d", id);
 +
 +	uint16 frameCount = cursStream->readUint16BE();
 +	for (uint16 i = 0; i < frameCount; i++) {
 +		CursorInfo info;
 +		info.tag = cursStream->readUint16BE();
 +		info.hotspot.x = cursStream->readUint16BE();
 +		info.hotspot.y = cursStream->readUint16BE();
 +		info.surface = 0;
 +		info.palette = 0;
 +		info.colorCount = 0;
 +		_info.push_back(info);
 +	}
 +
 +	delete cursStream;
 +
 +	setCurrentFrameIndex(0);
 +}
 +
 +void Cursor::setCurrentFrameIndex(int32 index) {
 +	if (_index != index) {
 +		_index = index;
 +		if (index != -1) {
 +			loadCursorImage(_info[index]);
 +			CursorMan.replaceCursorPalette(_info[index].palette, 0, _info[index].colorCount);
 +			CursorMan.replaceCursor((byte *)_info[index].surface->pixels, _info[index].surface->w, _info[index].surface->h, _info[index].hotspot.x, _info[index].hotspot.y, 0);
 +			((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 +		}
 +	}
 +}
 +
 +int32 Cursor::getCurrentFrameIndex() const {
 +	return _index;
 +}
 +
 +void Cursor::show() {
 +	if (!isVisible())
 +		CursorMan.showMouse(true);
 +
 +	_cursorObscured = false;
 +	((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 +}
 +
 +void Cursor::hide() {
 +	CursorMan.showMouse(false);
 +	setCurrentFrameIndex(0);
 +}
 +
 +void Cursor::hideUntilMoved() {
 +	if (!_cursorObscured) {
 +		hide();
 +		_cursorObscured = true;
 +	}
 +}
 +
 +void Cursor::useIdleTime() {
 +	if (g_system->getEventManager()->getMousePos() != _cursorLocation) {
 +		_cursorLocation = g_system->getEventManager()->getMousePos();
 +		if (_index != -1 && _cursorObscured)
 +			show();
 +		((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 +	}
 +}
 +
 +void Cursor::getCursorLocation(Common::Point &pt) const {
 +	pt = _cursorLocation;
 +}
 +
 +bool Cursor::isVisible() {
 +	return CursorMan.isVisible();
 +}
 +
 +void Cursor::loadCursorImage(CursorInfo &cursorInfo) {
 +	if (cursorInfo.surface)
 +		return;
 +
 +	cursorInfo.surface = new Graphics::Surface();
 +
 +	PegasusEngine *vm = (PegasusEngine *)g_engine;
 +	Common::SeekableReadStream *cicnStream = vm->_resFork->getResource(MKTAG('c', 'i', 'c', 'n'), cursorInfo.tag);
 +
 +	if (!cicnStream)
 +		error("Failed to find color icon %d", cursorInfo.tag);
 +	
 +	// PixMap section
- 	Graphics::PictDecoder::PixMap pixMap = Graphics::PictDecoder::readPixMap(cicnStream);
++	Graphics::PICTDecoder::PixMap pixMap = Graphics::PICTDecoder::readPixMap(*cicnStream);
 +	
 +	// Mask section
 +	cicnStream->readUint32BE(); // mask baseAddr
 +	uint16 maskRowBytes = cicnStream->readUint16BE(); // mask rowBytes
 +	cicnStream->skip(3 * 2); // mask rect
 +	/* uint16 maskHeight = */ cicnStream->readUint16BE();
 +
 +	// Bitmap section
 +	cicnStream->readUint32BE(); // baseAddr
 +	uint16 rowBytes = cicnStream->readUint16BE();
 +	cicnStream->readUint16BE(); // top
 +	cicnStream->readUint16BE(); // left
 +	uint16 height = cicnStream->readUint16BE(); // bottom
 +	cicnStream->readUint16BE(); // right
 +	
 +	// Data section
 +	cicnStream->readUint32BE(); // icon handle
 +	cicnStream->skip(maskRowBytes * height); // FIXME: maskHeight doesn't work here, though the specs say it should
 +	cicnStream->skip(rowBytes * height);
 +	
 +	// Palette section
 +	cicnStream->readUint32BE(); // always 0
 +	cicnStream->readUint16BE(); // always 0
 +	cursorInfo.colorCount = cicnStream->readUint16BE() + 1;
 +	
 +	cursorInfo.palette = new byte[cursorInfo.colorCount * 3];
 +	for (uint16 i = 0; i < cursorInfo.colorCount; i++) {
 +		cicnStream->readUint16BE();
 +		cursorInfo.palette[i * 3] = cicnStream->readUint16BE() >> 8;
 +		cursorInfo.palette[i * 3 + 1] = cicnStream->readUint16BE() >> 8;
 +		cursorInfo.palette[i * 3 + 2] = cicnStream->readUint16BE() >> 8;
 +	}
 +	
 +	// PixMap data
 +	if (pixMap.pixelSize == 8) {
 +		cursorInfo.surface->create(pixMap.rowBytes, pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
 +		cicnStream->read(cursorInfo.surface->pixels, pixMap.rowBytes * pixMap.bounds.height());
 +
 +		// While this looks sensible, it actually doesn't work for some cursors
 +		// (ie. the 'can grab' hand)
 +		//cursorInfo.surface->w = pixMap.bounds.width();
 +	} else if (pixMap.pixelSize == 1) {
 +		cursorInfo.surface->create(pixMap.bounds.width(), pixMap.bounds.height(), Graphics::PixelFormat::createFormatCLUT8());
 +
 +		for (int y = 0; y < pixMap.bounds.height(); y++) {
 +			byte *line = (byte *)cursorInfo.surface->getBasePtr(0, y);
 +
 +			for (int x = 0; x < pixMap.bounds.width();) {
 +				byte b = cicnStream->readByte();
 +
 +				for (int i = 0; i < 8; i++) {
 +					*line++ = ((b & (1 << (7 - i))) != 0) ? 1 : 0;
 +
 +					if (++x == pixMap.bounds.width())
 +						break;
 +				}
 +			}
 +		}
 +	} else {
 +		error("Unhandled %dbpp cicn images", pixMap.pixelSize);
 +	}
 +
 +	delete cicnStream;
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/elements.h
index 6a465d1,0000000..d96d217
mode 100644,000000..100644
--- a/engines/pegasus/elements.h
+++ b/engines/pegasus/elements.h
@@@ -1,254 -1,0 +1,254 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#ifndef PEGASUS_ELEMENTS_H
 +#define PEGASUS_ELEMENTS_H
 +
++#include "common/array.h"
 +#include "common/rect.h"
 +#include "common/str.h"
 +#include "common/system.h"
- #include "graphics/pict.h"
 +#include "graphics/surface.h"
 +
 +#include "pegasus/timers.h"
 +#include "pegasus/util.h"
 +
 +namespace Common {
 +	class MacResManager;
 +}
 +
 +namespace Pegasus {
 +
 +class DisplayElement : public IDObject {
 +friend class GraphicsManager;
 +public:
 +	DisplayElement(const DisplayElementID);
 +	virtual ~DisplayElement();
 +	
 +	void setDisplayOrder(const DisplayOrder);
 +	DisplayOrder getDisplayOrder() const { return _elementOrder; }
 +	
 +	bool validToDraw(DisplayOrder, DisplayOrder);
 +	
 +	virtual void draw(const Common::Rect&) {}
 +	bool isDisplaying() { return _elementIsDisplaying; }
 +	virtual void startDisplaying();
 +	virtual void stopDisplaying();
 +	
 +	virtual void show();
 +	virtual void hide();
 +	bool isVisible() { return _elementIsVisible; }
 +	
 +	// triggerRedraw only triggers a draw if the element is displaying and visible.
 +	void triggerRedraw();
 +	void setTriggeredElement(DisplayElement *);
 +	
 +	virtual void setBounds(const CoordType, const CoordType, const CoordType, const CoordType);
 +	virtual void setBounds(const Common::Rect &);
 +	virtual void getBounds(Common::Rect &) const;
 +	virtual void sizeElement(const CoordType, const CoordType);
 +	virtual void moveElementTo(const CoordType, const CoordType);
 +	virtual void moveElement(const CoordType, const CoordType);
 +	virtual void getLocation(CoordType &, CoordType &) const;
 +	virtual void getCenter(CoordType &, CoordType &) const;
 +	virtual void centerElementAt(const CoordType, const CoordType);
 +
 +protected:
 +	Common::Rect _bounds;
 +	bool _elementIsVisible;
 +	DisplayElement *_triggeredElement;
 +
 +	// Used only by PegasusEngine
 +	bool _elementIsDisplaying;
 +	DisplayOrder _elementOrder;
 +	DisplayElement *_nextElement;
 +};
 +
 +// I'm using the proper "highlight" instead of the evil
 +// QuickDraw "hilite" :P (deal with it!)
 +class DropHighlight : public DisplayElement {
 +public:
 +	DropHighlight(const DisplayElementID);
 +	virtual ~DropHighlight() {}
 +
 +	void setHighlightColor(const uint32 &highlight) { _highlightColor = highlight; }
 +	void getHighlightColor(uint32 &highlight) const { highlight = _highlightColor; } 
 +
 +	void setHighlightThickness(const uint16 thickness) { _thickness = thickness; }
 +	uint16 getHighlightThickness() const { return _thickness; }
 +
 +	void setHighlightCornerDiameter(const uint16 diameter) { _cornerDiameter = diameter; }
 +	uint16 getHighlightCornerDiameter() const { return _cornerDiameter; }
 +
 +	virtual void draw(const Common::Rect&);
 +
 +protected:
 +	uint32 _highlightColor;
 +	uint16 _thickness;
 +	uint16 _cornerDiameter;
 +};
 +
 +class Animation : public DisplayElement, public DynamicElement {
 +public:
 +	Animation(const DisplayElementID id) : DisplayElement(id) {}
 +};
 +
 +class IdlerAnimation : public Animation, public Idler {
 +public:
 +	IdlerAnimation(const DisplayElementID);
 +	
 +	virtual void startDisplaying();
 +	virtual void stopDisplaying();
 +	
 +	TimeValue getLastTime() const { return _lastTime; }
 +
 +protected:
 +	virtual void useIdleTime();
 +	virtual void timeChanged(const TimeValue);
 +	
 +	TimeValue _lastTime;
 +};
 +
 +// This class reads PICT resources and plays them like a movie.
 +// Assumes there is a resource of type 'PFrm' describing the time values for each
 +// PICT frame, as well as the total time in the movie.
 +// Assumes that PICT frames begin at PICT 128
 +
 +class FrameSequence : public IdlerAnimation {
 +public:
 +	FrameSequence(const DisplayElementID);
 +	virtual ~FrameSequence();
 +
 +	void useFileName(const Common::String &fileName);
 +
 +	virtual void openFrameSequence();
 +	virtual void closeFrameSequence();
 +	bool isSequenceOpen() const;
 +	
 +	uint16 getNumFrames() const { return _numFrames; }
 +	virtual uint16 getFrameNum() const { return _currentFrameNum; }
 +	virtual void setFrameNum(const int16);
 +
 +protected:		
 +	virtual void timeChanged(const TimeValue);
 +	virtual void newFrame(const uint16) {}
 +
 +	Common::MacResManager *_resFork;
 +	TimeValue _duration;
 +
 +	uint16 _numFrames;
 +	Common::Array<TimeValue> _frameTimes;
 +
 +	uint16 _currentFrameNum;
 +};
 +
 +class SpriteFrame;
 +
 +class Sprite : public DisplayElement {
 +friend class SpriteFrame;
 +public:
 +	Sprite(const DisplayElementID);
 +	virtual ~Sprite();
 +
 +	virtual void addPICTResourceFrame(const ResIDType, const bool, const CoordType, const CoordType);
 +	virtual uint32 addFrame(SpriteFrame *, const CoordType, const CoordType);
 +	virtual void removeFrame(const uint32);
 +	virtual void discardFrames();
 +	
 +	// Setting the current frame.
 +	// If the index is negative, sets the current frame to NULL and hides the sprite.
 +	// If the index is larger than the number of frames in the sprite, the number
 +	// is treated modulo the number of frames.
 +	virtual void setCurrentFrameIndex(const int32);
 +	virtual uint32 getCurrentFrameIndex() const { return _currentFrameNum; }
 +	
 +	virtual SpriteFrame *getFrame(const int32);
 +	
 +	virtual void draw(const Common::Rect &);
 +	
 +	uint32 getNumFrames() const { return _numFrames; }
 +
 +protected:
 +	struct SpriteFrameRec {
 +		SpriteFrame *frame;
 +		CoordType frameLeft;
 +		CoordType frameTop;
 +	};
 +
 +	uint32 _numFrames;
 +	uint32 _currentFrameNum;
 +	SpriteFrameRec *_currentFrame;
 +	Common::Array<SpriteFrameRec> _frameArray;
 +};
 +
 +class SpriteSequence : public FrameSequence {
 +public:
 +	SpriteSequence(const DisplayElementID id, const DisplayElementID spriteID);
 +	virtual ~SpriteSequence() {}
 +
 +	void useTransparent(bool transparent) { _transparent = transparent; }
 +
 +	virtual void openFrameSequence();
 +	virtual void closeFrameSequence();
 +
 +	virtual void draw(const Common::Rect &);
 +
 +	virtual void setBounds(const Common::Rect &);
 +
 +protected:
 +	virtual void newFrame(const uint16);
 +
 +	bool _transparent;
 +	Sprite _sprite;
 +};
 +
 +class ScreenDimmer : public DisplayElement {
 +public:
 +	ScreenDimmer() : DisplayElement(kScreenDimmerID) {}
 +	virtual ~ScreenDimmer() {}
 +
 +	virtual void draw(const Common::Rect &);
 +};
 +
 +class SoundLevel : public DisplayElement {
 +public:
 +	SoundLevel(const DisplayElementID);
 +	virtual ~SoundLevel() {}
 +	
 +	void incrementLevel();
 +	void decrementLevel();
 +	
 +	uint16 getSoundLevel();
 +	void setSoundLevel(uint16);
 +	
 +	void draw(const Common::Rect &);
 +
 +protected:
 +	uint16 _soundLevel;
 +};
 +
 +} // End of namespace Pegasus
 +
 +#endif
diff --cc engines/pegasus/graphics.h
index 7c5bd69,0000000..5023044
mode 100644,000000..100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@@ -1,90 -1,0 +1,89 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#ifndef PEGASUS_GRAPHICS_H
 +#define PEGASUS_GRAPHICS_H
 +
 +#include "common/rect.h"
 +#include "common/str.h"
 +#include "common/system.h"
- #include "graphics/pict.h"
 +#include "graphics/surface.h"
 +
 +#include "pegasus/constants.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/util.h"
 +
 +namespace Pegasus {
 +
 +class Cursor;
 +class DisplayElement;
 +class PegasusEngine;
 +
 +class GraphicsManager {
 +friend class Cursor;
 +public:
 +	GraphicsManager(PegasusEngine *vm);
 +	~GraphicsManager();
 +
 +	void addDisplayElement(DisplayElement *element);
 +	void removeDisplayElement(DisplayElement *element);
 +	void invalRect(const Common::Rect &rect);
 +	DisplayOrder getBackOfActiveLayer() const { return _backLayer; }
 +	DisplayOrder getFrontOfActiveLayer() const { return _frontLayer; }
 +	void updateDisplay();
 +	Graphics::Surface *getCurSurface() { return _curSurface; }
 +	void setCurSurface(Graphics::Surface *surface) { _curSurface = surface; }
 +	Graphics::Surface *getWorkArea() { return &_workArea; }
 +	void clearScreen();
 +	DisplayElement *findDisplayElement(const DisplayElementID id);
 +	void shakeTheWorld(TimeValue time, TimeScale scale);
 +	void enableErase();
 +	void disableErase();
 +
 +	// These default to black
 +	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
 +	void doFadeInSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
 +
 +protected:
 +	void markCursorAsDirty();
 +
 +private:		
 +	PegasusEngine *_vm;
 +
 +	bool _modifiedScreen, _erase;
 +	Common::Rect _dirtyRect;
 +	DisplayOrder _backLayer, _frontLayer;
 +	DisplayElement *_firstDisplayElement, *_lastDisplayElement;
 +	Graphics::Surface _workArea, *_curSurface;
 +
 +	// Shake Shake Shake!
 +	static const int kMaxShakeOffsets = 17;
 +	Common::Point _shakeOffsets[kMaxShakeOffsets];
 +	void newShakePoint(int32 index1, int32 index2, int32 maxRadius);
 +};
 +
 +} // End of namespace Pegasus
 +
 +#endif
diff --cc engines/pegasus/surface.cpp
index f0c97d6,0000000..897305f
mode 100755,000000..100755
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@@ -1,415 -1,0 +1,392 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/file.h"
 +#include "common/macresman.h"
 +#include "common/stream.h"
 +#include "common/system.h"
- #include "graphics/pict.h"
 +#include "graphics/surface.h"
++#include "graphics/decoders/pict.h"
 +#include "video/video_decoder.h"
 +
 +#include "pegasus/pegasus.h"
 +#include "pegasus/surface.h"
 +
 +namespace Pegasus {
 +
 +Surface::Surface() {
 +	_ownsSurface = false;
 +	_surface = 0;
 +}
 +
 +Surface::~Surface() {
 +	deallocateSurface();
 +}
 +
 +void Surface::deallocateSurface() {
 +	if (_surface) {
 +		if (_ownsSurface) {
 +			_surface->free();
 +			delete _surface;
 +		}
 +
 +		_surface = 0;
 +		_bounds = Common::Rect();
 +		_ownsSurface = false;
 +	}
 +}
 +
 +void Surface::shareSurface(Surface *surface) {
 +	deallocateSurface();
 +
 +	if (surface) {
 +		_ownsSurface = false;
 +		_surface = surface->getSurface();
 +		surface->getSurfaceBounds(_bounds);
 +	}
 +}
 +
 +void Surface::allocateSurface(const Common::Rect &bounds) {
 +	deallocateSurface();
 +
 +	if (bounds.isEmpty())
 +		return;
 +
 +	_bounds = bounds;
 +	_surface = new Graphics::Surface();
 +	_surface->create(bounds.width(), bounds.height(), g_system->getScreenFormat());
 +	_ownsSurface = true;
 +}
 +
 +void Surface::getImageFromPICTFile(const Common::String &fileName) {
 +	Common::File pict;
 +	if (!pict.open(fileName))
 +		error("Could not open picture '%s'", fileName.c_str());
 +
 +	getImageFromPICTStream(&pict);
 +}
 +
 +void Surface::getImageFromPICTResource(Common::MacResManager *resFork, uint16 id) {
 +	Common::SeekableReadStream *res = resFork->getResource(MKTAG('P', 'I', 'C', 'T'), id);
 +	if (!res)
 +		error("Could not open PICT resource %d from '%s'", id, resFork->getBaseFileName().c_str());
 +	
 +	getImageFromPICTStream(res);
 +	delete res;
 +}
 +
 +void Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
- 	Graphics::PictDecoder pict(g_system->getScreenFormat());
- 	byte pal[256 * 3];
- 
- 	Graphics::Surface *surface = pict.decodeImage(stream, pal);
- 
- 	// Create the surface if not present
- 	if (!_surface)
- 		_surface = new Graphics::Surface();
- 
- 	// Update
- 	if (surface->format.bytesPerPixel == 1) {
- 		// Convert to true color
- 		_surface->create(surface->w, surface->h, g_system->getScreenFormat());
- 		
- 		for (int y = 0; y < surface->h; y++) {
- 			for (int x = 0; x < surface->w; x++) {
- 				byte index = *((byte *)surface->getBasePtr(x, y));
- 				uint32 color = _surface->format.RGBToColor(pal[index * 3], pal[index * 3 + 1], pal[index * 3 + 2]);
- 				if (_surface->format.bytesPerPixel == 2)
- 					*((uint16 *)_surface->getBasePtr(x, y)) = color;
- 				else
- 					*((uint32 *)_surface->getBasePtr(x, y)) = color;
- 			}
- 		}
- 	} else {
- 		// Just a copy
- 		_surface->copyFrom(*surface);
- 	}
++	Graphics::PICTDecoder pict;
++
++	if (!pict.loadStream(*stream))
++		error("Failed to load PICT image");
 +
++	_surface = pict.getSurface()->convertTo(g_system->getScreenFormat(), pict.getPalette());
 +	_ownsSurface = true;
 +	_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
 +}
 +
 +void Surface::getImageFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time) {
 +	video->seekToTime(Audio::Timestamp(0, time, 600));
 +	const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +	if (frame) {
 +		if (!_surface)
 +			_surface = new Graphics::Surface();
 +
 +		_surface->copyFrom(*frame);
 +		_ownsSurface = true;
 +		_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
 +	} else {
 +		deallocateSurface();
 +	}
 +}
 +
 +void Surface::copyToCurrentPort() const {
 +	copyToCurrentPort(_bounds);
 +}
 +
 +void Surface::copyToCurrentPortTransparent() const {
 +	copyToCurrentPortTransparent(_bounds);
 +}
 +
 +void Surface::copyToCurrentPort(const Common::Rect &rect) const {
 +	copyToCurrentPort(rect, rect);
 +}
 +
 +void Surface::copyToCurrentPortTransparent(const Common::Rect &rect) const {
 +	copyToCurrentPortTransparent(rect, rect);
 +}
 +
 +void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		memcpy(dst, src, lineSize);
 +		src += _surface->pitch;
 +		dst += screen->pitch;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(src);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 2);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(src);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 4);
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortMasked(const Common::Rect &srcRect, const Common::Rect &dstRect, const Surface *mask) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		byte *maskSrc = (byte *)mask->getSurface()->getBasePtr(0, y);
 +
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(maskSrc);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 2);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(maskSrc);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 4);
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			maskSrc += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
 +	// pixel all the way up.
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(src);
 +				if (!isTransparent(color))
 +					WRITE_UINT16(dst, getGlowColor(color));
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(src);
 +				if (!isTransparent(color))
 +					WRITE_UINT32(dst, getGlowColor(color));
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::scaleTransparentCopy(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// I'm doing simple linear scaling here
 +	// dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH);
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +
 +	int srcW = srcRect.width();
 +	int srcH = srcRect.height();
 +	int dstW = dstRect.width();
 +	int dstH = dstRect.height();
 +
 +	for (int y = 0; y < dstH; y++) {
 +		for (int x = 0; x < dstW; x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
 +			}
 +		}
 +	}
 +}
 +
 +void Surface::scaleTransparentCopyGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// This is the same as scaleTransparentCopy(), but turns the red value of each
 +	// pixel all the way up.
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +
 +	int srcW = srcRect.width();
 +	int srcH = srcRect.height();
 +	int dstW = dstRect.width();
 +	int dstH = dstRect.height();
 +
 +	for (int y = 0; y < dstH; y++) {
 +		for (int x = 0; x < dstW; x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
 +			}
 +		}
 +	}
 +}
 +
 +uint32 Surface::getGlowColor(uint32 color) const {
 +	// Can't just 'or' it on like the original did :P
 +	byte r, g, b;
 +	g_system->getScreenFormat().colorToRGB(color, r, g, b);
 +	return g_system->getScreenFormat().RGBToColor(0xff, g, b);
 +}
 +
 +bool Surface::isTransparent(uint32 color) const {
 +	// HACK: Seems we're truncating some color data somewhere...
 +	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
 +	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
 +
 +	return color == transColor1 || color == transColor2;
 +}
 +
 +PixelImage::PixelImage() {
 +	_transparent = false;
 +}
 +
 +void PixelImage::drawImage(const Common::Rect &sourceBounds, const Common::Rect &destBounds) {
 +	if (!isSurfaceValid())
 +		return;
 +
 +	// Draw from sourceBounds to destBounds based on _transparent
 +	if (_transparent)
 +		copyToCurrentPortTransparent(sourceBounds, destBounds);
 +	else
 +		copyToCurrentPort(sourceBounds, destBounds);
 +}
 +
 +void Frame::initFromPICTFile(const Common::String &fileName, bool transparent) {
 +	getImageFromPICTFile(fileName);
 +	_transparent = transparent;
 +}
 +
 +void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
 +	getImageFromPICTResource(resFork, id);
 +	_transparent = transparent;
 +}
 +
 +void Frame::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
 +	getImageFromMovieFrame(video, time);
 +	_transparent = transparent;
 +}
 +
 +void Picture::draw(const Common::Rect &r) {
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	Common::Rect r1 = r;
 +
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +	surfaceBounds.moveTo(bounds.left, bounds.top);
 +	r1 = r1.findIntersectingRect(surfaceBounds);
 +	getSurfaceBounds(surfaceBounds);
 +
 +	Common::Rect r2 = r1;
 +	r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
 +	drawImage(r2, r1);
 +}
 +
 +void Picture::initFromPICTFile(const Common::String &fileName, bool transparent) {
 +	Frame::initFromPICTFile(fileName, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
 +void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
 +	Frame::initFromPICTResource(resFork, id, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
 +void Picture::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
 +	Frame::initFromMovieFrame(video, time, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
 +} // End of namespace Pegasus


Commit: b2c29410b9e66566ee5c9faad79b58696a6f3095
    https://github.com/scummvm/scummvm/commit/b2c29410b9e66566ee5c9faad79b58696a6f3095
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-20T11:50:06-07:00

Commit Message:
PEGASUS: Add some more protection about junk flying off-screen

Changed paths:
    engines/pegasus/neighborhood/mars/spacejunk.cpp



diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
index 9f34c21..ac8b1a2 100755
--- a/engines/pegasus/neighborhood/mars/spacejunk.cpp
+++ b/engines/pegasus/neighborhood/mars/spacejunk.cpp
@@ -80,7 +80,7 @@ void SpaceJunk::setCenter(const CoordType centerX, const CoordType centerY) {
 
 	Common::Rect r;
 	getBounds(r);
-	r.moveTo(CLIP<int>(centerX - (r.width() >> 1), 0, 640), CLIP<int>(centerY - (r.height() >> 1), 0, 480));
+	r.moveTo(CLIP<int>(centerX - (r.width() >> 1), 0, 640 - r.width()), CLIP<int>(centerY - (r.height() >> 1), 0, 480 - r.height()));
 	setBounds(r);
 }
 


Commit: 6a786129cf04eb9a5ee693750b7ca7e1f9c40ac5
    https://github.com/scummvm/scummvm/commit/6a786129cf04eb9a5ee693750b7ca7e1f9c40ac5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-20T14:31:36-07:00

Commit Message:
PEGASUS: Fix striding

Changed paths:
    engines/pegasus/timers.cpp



diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
index 5b7c903..d03ce91 100755
--- a/engines/pegasus/timers.cpp
+++ b/engines/pegasus/timers.cpp
@@ -244,8 +244,12 @@ void TimeBase::checkCallBacks() {
 
 		if (runner->_type == kCallBackAtTime && runner->_trigger == kTriggerTimeFwd) {
 			if (getTime() >= (runner->_param2 * _preferredScale / runner->_param3) && getRate() > 0) {
+				uint param2 = runner->_param2, param3 = runner->_param3;
 				runner->callBack();
-				runner->_hasBeenTriggered = true;
+				// HACK: Only stop future time forward callbacks if the parameters have not been changed
+				// This fixes striding callbacks. Since only striding callbacks do this kind of
+				// craziness, I'm not too worried about this.
+				runner->_hasBeenTriggered = (runner->_param2 == param2 && runner->_param3 == param3);
 			}
 		} else if (runner->_type == kCallBackAtExtremes) {
 			if (runner->_trigger == kTriggerAtStop) {


Commit: 1ec7e516822ae344cabd8a35ef226653514339f1
    https://github.com/scummvm/scummvm/commit/1ec7e516822ae344cabd8a35ef226653514339f1
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-21T05:22:17-07:00

Commit Message:
PEGASUS: Implement the intro timer

Changed paths:
    engines/pegasus/menu.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 4f8947b..5d90f62 100755
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -1214,6 +1214,8 @@ void PauseMenu::updateDisplay() {
 		_largeSelect.hide();
 		break;
 	}
+
+	((PegasusEngine *)g_engine)->resetIntroTimer();
 }
 
 
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 19ebfea..a346af5 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -89,6 +89,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_dragType = kDragNoDrag;
 	_idlerHead = 0;
 	_currentCD = 1;
+	_introTimer = 0;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -99,11 +100,16 @@ PegasusEngine::~PegasusEngine() {
 	delete _gameMenu;
 	delete _neighborhood;
 	delete _rnd;
+	delete _introTimer;
 
 	// NOTE: This must be deleted last!
 	delete _gfx;
 }
 
+void introTimerExpiredFunction(FunctionPtr *, void *) {
+	((PegasusEngine *)g_engine)->introTimerExpired();
+}
+
 Common::Error PegasusEngine::run() {
 	_console = new PegasusConsole(this);
 	_gfx = new GraphicsManager(this);
@@ -169,6 +175,11 @@ Common::Error PegasusEngine::run() {
 		// Start up the first notification
 		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
 
+	if (!isDemo()) {
+		_introTimer = new FuseFunction();
+		_introTimer->setFunctionPtr(&introTimerExpiredFunction, 0);
+	}
+
 	while (!shouldQuit()) {
 		processShell();
 		_system->delayMillis(10); // Ease off the CPU
@@ -270,6 +281,8 @@ void PegasusEngine::createItem(ItemID itemID, NeighborhoodID neighborhoodID, Roo
 }
 
 void PegasusEngine::runIntro() {
+	stopIntroTimer();
+
 	bool skipped = false;
 
 	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
@@ -601,15 +614,18 @@ void PegasusEngine::receiveNotification(Notification *notification, const Notifi
 	if (&_shellNotification == notification) {
 		switch (flags) {
 		case kGameStartingFlag: {
-			if (!isDemo())
+			useMenu(new MainMenu());
+
+			if (!isDemo()) {
 				runIntro();
-			else
+				resetIntroTimer();
+			} else {
 				showTempScreen("Images/Demo/NGsplashScrn.pict");
+			}
 
 			if (shouldQuit())
 				return;
 
-			useMenu(new MainMenu());
 			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 			_gfx->updateDisplay();
 			((MainMenu *)_gameMenu)->startMainMenuLoop();
@@ -634,7 +650,54 @@ void PegasusEngine::checkCallBacks() {
 }
 
 void PegasusEngine::resetIntroTimer() {
-	// TODO
+	if (!isDemo() && _gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
+		_introTimer->stopFuse();
+		_introTimer->primeFuse(kIntroTimeOut);
+		_introTimer->lightFuse();
+	}
+}
+
+void PegasusEngine::introTimerExpired() {
+	if (_gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
+		((MainMenu *)_gameMenu)->stopMainMenuLoop();
+
+		bool skipped = false;
+
+		Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
+		if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
+			error("Failed to load little movie");
+
+		bool saveAllowed = swapSaveAllowed(false);
+		bool openAllowed = swapLoadAllowed(false);
+
+		skipped = playMovieScaled(video, 0, 0);
+
+		delete video;
+
+		if (shouldQuit())
+			return;
+
+		if (!skipped) {
+			runIntro();
+
+			if (shouldQuit())
+				return;
+		}
+
+		resetIntroTimer();
+		_gfx->invalRect(Common::Rect(0, 0, 640, 480));
+
+		swapSaveAllowed(saveAllowed);
+		swapLoadAllowed(openAllowed);
+
+		_gfx->updateDisplay();
+		((MainMenu *)_gameMenu)->startMainMenuLoop();
+	}
+}
+
+void PegasusEngine::stopIntroTimer() {
+	if (_introTimer)
+		_introTimer->stopFuse();
 }
 
 void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
@@ -681,6 +744,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 
 	switch (command) {
 	case kMenuCmdStartAdventure:
+		stopIntroTimer();
 		GameState.setWalkthroughMode(false);
 		startNewGame();
 		break;
@@ -691,7 +755,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 			_gfx->updateDisplay();
 			_gfx->doFadeInSync();
 		} else {
-			// TODO: Stop intro timer
+			stopIntroTimer();
 			_gfx->doFadeOutSync();
 			useMenu(new CreditsMenu());
 			_gfx->updateDisplay();
@@ -705,17 +769,22 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 		_system->quit();
 		break;
 	case kMenuCmdOverview:
-		// TODO: Stop intro timer
+		stopIntroTimer();
 		doInterfaceOverview();
 		resetIntroTimer();
 		break;
 	case kMenuCmdStartWalkthrough:
+		stopIntroTimer();
 		GameState.setWalkthroughMode(true);
 		startNewGame();
 		break;
 	case kMenuCmdRestore:
+		stopIntroTimer();
+		// fall through
 	case kMenuCmdDeathRestore:
-		showLoadDialog();
+		result = showLoadDialog();
+		if (command == kMenuCmdRestore && result.getCode() != Common::kNoError)
+			resetIntroTimer();
 		break;
 	case kMenuCmdCreditsMainMenu:
 		_gfx->doFadeOutSync();
@@ -769,8 +838,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 		_gfx->updateDisplay();
 		((MainMenu *)_gameMenu)->startMainMenuLoop();
 		_gfx->doFadeInSync();
-		if (!isDemo())
-			resetIntroTimer();
+		resetIntroTimer();
 		break;
 	case kMenuCmdPauseSave:
 		if (showSaveDialog().getCode() != Common::kUserCanceled)
@@ -799,8 +867,7 @@ void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 		_gfx->updateDisplay();
 		((MainMenu *)_gameMenu)->startMainMenuLoop();
 		_gfx->doFadeInSync();
-		if (!isDemo())
-			resetIntroTimer();
+		resetIntroTimer();
 		break;
 	case kMenuCmdNoCommand:
 		break;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index ef05585..c6d4c80 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -39,6 +39,7 @@
 #include "pegasus/hotspot.h"
 #include "pegasus/input.h"
 #include "pegasus/notification.h"
+#include "pegasus/timers.h"
 #include "pegasus/items/autodragger.h"
 #include "pegasus/items/inventory.h"
 #include "pegasus/items/itemdragger.h"
@@ -99,6 +100,7 @@ public:
 	void removeTimeBase(TimeBase *timeBase);
 	void delayShell(TimeValue time, TimeScale scale);
 	void resetIntroTimer();
+	void introTimerExpired();
 	void refreshDisplay();
 	bool playerAlive();
 	void processShell();
@@ -210,8 +212,10 @@ private:
 
 	// Intro
 	void runIntro();
+	void stopIntroTimer();
 	bool detectOpeningClosingDirectory();
 	Common::String _introDirectory;
+	FuseFunction *_introTimer;
 
 	// Idlers
 	Idler *_idlerHead;


Commit: 1e8eea426899fee80bae496ca74b4230294c6e67
    https://github.com/scummvm/scummvm/commit/1e8eea426899fee80bae496ca74b4230294c6e67
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-21T11:55:12-07:00

Commit Message:
CREDITS: Add pegasus

Changed paths:
    AUTHORS
    devtools/credits.pl
    gui/credits.h



diff --git a/AUTHORS b/AUTHORS
index 9f71be9..e13de73 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -137,6 +137,9 @@ ScummVM Team
     Parallaction:
        peres
 
+    Pegasus:
+       Matthew Hoops
+
     Queen:
        David Eriksson        - (retired)
        Gregory Montoir       - (retired)
@@ -597,3 +600,6 @@ Special thanks to
    Broken Sword 2.5 team for providing sources of their engine and their
    great support.
 
+   Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing
+   the source code of The Journeyman Project: Pegasus Prime.
+
diff --git a/devtools/credits.pl b/devtools/credits.pl
index b3a5061..db69756 100755
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@ -608,6 +608,10 @@ begin_credits("Credits");
 				add_person("", "peres", "");
 			end_section();
 
+			begin_section("Pegasus");
+				add_person("Matthew Hoops", "clone2727", "");
+			end_section();
+
 			begin_section("Queen");
 				add_person("David Eriksson", "twogood", "(retired)");
 				add_person("Gregory Montoir", "cyx", "(retired)");
@@ -1127,6 +1131,10 @@ begin_credits("Credits");
     "Broken Sword 2.5 team for providing sources of their engine and their great ".
     "support.");
 
+	add_paragraph(
+    "Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for ".
+    "providing the source code of The Journeyman Project: Pegasus Prime.");
+
 	end_section();
 
 end_credits();
diff --git a/gui/credits.h b/gui/credits.h
index ecfe280..928799e 100644
--- a/gui/credits.h
+++ b/gui/credits.h
@@ -157,6 +157,9 @@ static const char *credits[] = {
 "C1""Parallaction",
 "C0""peres",
 "",
+"C1""Pegasus",
+"C0""Matthew Hoops",
+"",
 "C1""Queen",
 "C0""David Eriksson",
 "C2""(retired)",
@@ -710,5 +713,7 @@ static const char *credits[] = {
 "C0""",
 "C0""Broken Sword 2.5 team for providing sources of their engine and their great support.",
 "C0""",
+"C0""Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing the source code of The Journeyman Project: Pegasus Prime.",
+"C0""",
 "",
 };


Commit: 47ae65e49577b1f881c2f5956ad8550f0089a4fe
    https://github.com/scummvm/scummvm/commit/47ae65e49577b1f881c2f5956ad8550f0089a4fe
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-03-22T08:17:32-07:00

Commit Message:
PEGASUS: Clean up initializePegasusButtons

The exit button now shows in the correct position when pressed and the jump mode has been removed since it is unused

Changed paths:
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.h



diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 7f5c392..0ed3355 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -2159,7 +2159,7 @@ void FullTSA::arriveAtTSA37() {
 		showExtraView(kTSA37AI2ToPrehistoric);
 		break;
 	case kTSAPlayerGotHistoricalLog:
-		initializePegasusButtons(false, true);
+		initializePegasusButtons(false);
 		break;
 	case kPlayerWentToPrehistoric:
 	case kPlayerOnWayToNorad:
@@ -2174,7 +2174,7 @@ void FullTSA::arriveAtTSA37() {
 		showMainJumpMenu();
 		break;
 	case kPlayerFinishedWithTSA:
-		initializePegasusButtons(true, true);
+		initializePegasusButtons(true);
 		break;
 	}
 }
@@ -2703,7 +2703,7 @@ void FullTSA::receiveNotification(Notification *notification, const Notification
 		case kTSA37RecallToDownload:
 		case kTSA37ReviewRequiredToExit:
 			GameState.setTSAState(kTSAPlayerGotHistoricalLog);
-			initializePegasusButtons(kPegasusUnresolved, kPegasusCanExit);
+			initializePegasusButtons(kPegasusUnresolved);
 			break;
 		case kTSA37ZoomToMainMenu:
 		case kTSA37HorseToColonel2:
@@ -2730,7 +2730,7 @@ void FullTSA::receiveNotification(Notification *notification, const Notification
 			break;
 		case kTSA37CongratulationsToExit:
 			GameState.setTSAState(kPlayerFinishedWithTSA);
-			initializePegasusButtons(true, true);
+			initializePegasusButtons(true);
 			break;
 		}
 	}
@@ -2785,7 +2785,7 @@ void FullTSA::arriveFromWSC() {
 	}
 }
 
-void FullTSA::initializePegasusButtons(bool resolved, bool exit) {
+void FullTSA::initializePegasusButtons(bool resolved) {
 	if (resolved) {
 		_sprite1.addPICTResourceFrame(kResolvedPICTID, false, 0, 0);
 		_sprite1.moveElementTo(kResolvedLeft, kResolvedTop);
@@ -2797,18 +2797,10 @@ void FullTSA::initializePegasusButtons(bool resolved, bool exit) {
 	_sprite1.setCurrentFrameIndex(0);
 	_sprite1.show();
 
-	if (exit) {
-		_sprite2.addPICTResourceFrame(kExitPICTID, false, 0, 0);
-		_sprite2.addPICTResourceFrame(kExitHilitedPICTID, false, kExitHilitedLeft - kExitLeft, kExitHilitedTop - kExitTop);
-		_sprite2.moveElementTo(kExitLeft, kExitTop);
-		setCurrentActivation(kActivationReadyToExit);
-	} else {
-		_sprite2.addPICTResourceFrame(kJumpMenuPICTID, false, 0, 0);
-		_sprite2.addPICTResourceFrame(kJumpMenuHilitedPICTID, false, kJumpMenuHilitedLeft - kJumpMenuLeft, kJumpMenuHilitedTop - kJumpMenuTop);
-		_sprite2.moveElementTo(kJumpMenuLeft, kJumpMenuTop);
-		setCurrentActivation(kActivationReadyForJumpMenu);
-	}
-
+	_sprite2.addPICTResourceFrame(kExitPICTID, false, kExitLeft - kExitHilitedLeft, kExitTop - kExitHilitedTop);
+	_sprite2.addPICTResourceFrame(kExitHilitedPICTID, false, 0, 0);
+	_sprite2.moveElementTo(kExitHilitedLeft, kExitHilitedTop);
+	setCurrentActivation(kActivationReadyToExit);
 	_sprite2.setCurrentFrameIndex(0);
 	_sprite2.show();
 }
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
index 0a3f8a2..4260a83 100755
--- a/engines/pegasus/neighborhood/tsa/fulltsa.h
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.h
@@ -136,7 +136,7 @@ protected:
 
 	InputBits getInputFilter();
 	void arriveAt(const RoomID, const DirectionConstant);
-	void initializePegasusButtons(bool, bool);
+	void initializePegasusButtons(bool);
 	void releaseSprites();
 	void showMainJumpMenu();
 	void arriveAtTSA37();


Commit: b6374a3103787415eaad1eb2ea29559bd4c7d372
    https://github.com/scummvm/scummvm/commit/b6374a3103787415eaad1eb2ea29559bd4c7d372
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T07:07:45-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A gui/predictivedialog.cpp
  A gui/predictivedialog.h
  A gui/themes/scummmodern/delbtn.bmp
  R engines/agi/predictive.cpp
    NEWS
    README
    audio/decoders/qdm2.cpp
    backends/platform/iphone/iphone_common.h
    backends/platform/iphone/iphone_video.h
    backends/platform/iphone/iphone_video.mm
    backends/platform/iphone/osys_events.cpp
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_video.mm
    base/commandLine.cpp
    base/main.cpp
    common/gui_options.cpp
    common/gui_options.h
    common/quicktime.cpp
    common/quicktime.h
    common/rect.h
    configure
    devtools/create_project/create_project.cpp
    devtools/scumm-md5.txt
    dists/bada/Res/scummmobile/THEMERC
    dists/bada/Res/scummmobile/scummmobile_layout.stx
    dists/win32/ScummVM.iss
    doc/cz/PrectiMe
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/detection.cpp
    engines/agi/keyboard.cpp
    engines/agi/module.mk
    engines/agi/saveload.cpp
    engines/agos/script_s1.cpp
    engines/cge/cge_main.cpp
    engines/cge/detection.cpp
    engines/cge/sound.cpp
    engines/dreamweb/detection.cpp
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/stubs.cpp
    engines/gob/detection_tables.h
    engines/groovie/groovie.cpp
    engines/kyra/detection.cpp
    engines/kyra/detection_tables.h
    engines/metaengine.h
    engines/queen/queen.cpp
    engines/queen/queen.h
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/sci.cpp
    engines/sci/sound/soundcmd.cpp
    engines/scumm/detection_tables.h
    engines/scumm/scumm-md5.h
    engines/sky/control.cpp
    engines/sky/control.h
    engines/sky/detection.cpp
    engines/sword2/sword2.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/launcher.cpp
    gui/module.mk
    gui/options.cpp
    gui/options.h
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/translations.dat
    gui/widgets/editable.h
    po/POTFILES
    po/cs_CZ.po
    ports.mk





Commit: 851c010feb746680d49b2caa81250bee12c0aeb0
    https://github.com/scummvm/scummvm/commit/851c010feb746680d49b2caa81250bee12c0aeb0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T16:00:14-07:00

Commit Message:
PEGASUS: Remove stray semicolon

Changed paths:
    engines/pegasus/util.h



diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
index 8ca69da..57839fc 100755
--- a/engines/pegasus/util.h
+++ b/engines/pegasus/util.h
@@ -120,7 +120,7 @@ private:
 	Unit _flags[(kNumFlags - 1) / NUM_FLAGS + 1];
 };
 
-#undef NUM_FLAGS;
+#undef NUM_FLAGS
 #undef BIT_INDEX_SHIFT
 #undef BIT_INDEX_MASK
 


Commit: 73f2244a562fe0498720546e57452377752741fb
    https://github.com/scummvm/scummvm/commit/73f2244a562fe0498720546e57452377752741fb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T16:58:50-07:00

Commit Message:
PEGASUS: Remove some useless const modifiers

Thanks to digitall for spotting

Changed paths:
    engines/pegasus/neighborhood/door.h
    engines/pegasus/neighborhood/exit.h
    engines/pegasus/neighborhood/extra.h
    engines/pegasus/neighborhood/hotspotinfo.h
    engines/pegasus/neighborhood/spot.h
    engines/pegasus/neighborhood/turn.h
    engines/pegasus/neighborhood/view.h
    engines/pegasus/neighborhood/zoom.h



diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
index cd2af13..8ea7575 100755
--- a/engines/pegasus/neighborhood/door.h
+++ b/engines/pegasus/neighborhood/door.h
@@ -53,7 +53,7 @@ public:
 	DoorTable() {}
 	~DoorTable() {}
 
-	static const uint32 getResTag() { return MKTAG('D', 'o', 'o', 'r'); }
+	static uint32 getResTag() { return MKTAG('D', 'o', 'o', 'r'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
index baa3381..1715089 100755
--- a/engines/pegasus/neighborhood/exit.h
+++ b/engines/pegasus/neighborhood/exit.h
@@ -42,7 +42,7 @@ public:
 	ExitTable() {}
 	~ExitTable() {}
 
-	static const uint32 getResTag() { return MKTAG('E', 'x', 'i', 't'); }
+	static uint32 getResTag() { return MKTAG('E', 'x', 'i', 't'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/extra.h b/engines/pegasus/neighborhood/extra.h
index 9ac858e..14fcff1 100755
--- a/engines/pegasus/neighborhood/extra.h
+++ b/engines/pegasus/neighborhood/extra.h
@@ -42,7 +42,7 @@ public:
 	ExtraTable() {}
 	~ExtraTable() {}
 
-	static const uint32 getResTag() { return MKTAG('X', 't', 'r', 'a'); }
+	static uint32 getResTag() { return MKTAG('X', 't', 'r', 'a'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
index 2638271..965f445 100755
--- a/engines/pegasus/neighborhood/hotspotinfo.h
+++ b/engines/pegasus/neighborhood/hotspotinfo.h
@@ -42,7 +42,7 @@ public:
 	HotspotInfoTable() {}
 	~HotspotInfoTable() {}
 
-	static const uint32 getResTag() { return MKTAG('H', 'S', 'I', 'n'); }
+	static uint32 getResTag() { return MKTAG('H', 'S', 'I', 'n'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
index 4be0864..a985420 100755
--- a/engines/pegasus/neighborhood/spot.h
+++ b/engines/pegasus/neighborhood/spot.h
@@ -59,7 +59,7 @@ public:
 	SpotTable() {}
 	~SpotTable() {}
 
-	static const uint32 getResTag() { return MKTAG('S', 'p', 'o', 't'); }
+	static uint32 getResTag() { return MKTAG('S', 'p', 'o', 't'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/turn.h b/engines/pegasus/neighborhood/turn.h
index acf770a..329b03e 100755
--- a/engines/pegasus/neighborhood/turn.h
+++ b/engines/pegasus/neighborhood/turn.h
@@ -42,7 +42,7 @@ public:
 	TurnTable() {}
 	~TurnTable() {}
 
-	static const uint32 getResTag() { return MKTAG('T', 'u', 'r', 'n'); }
+	static uint32 getResTag() { return MKTAG('T', 'u', 'r', 'n'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/view.h b/engines/pegasus/neighborhood/view.h
index 1c57351..3397508 100755
--- a/engines/pegasus/neighborhood/view.h
+++ b/engines/pegasus/neighborhood/view.h
@@ -42,7 +42,7 @@ public:
 	ViewTable() {}
 	~ViewTable() {}
 
-	static const uint32 getResTag() { return MKTAG('V', 'i', 'e', 'w'); }
+	static uint32 getResTag() { return MKTAG('V', 'i', 'e', 'w'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();
diff --git a/engines/pegasus/neighborhood/zoom.h b/engines/pegasus/neighborhood/zoom.h
index f822bb7..8bcf897 100755
--- a/engines/pegasus/neighborhood/zoom.h
+++ b/engines/pegasus/neighborhood/zoom.h
@@ -42,7 +42,7 @@ public:
 	ZoomTable() {}
 	~ZoomTable() {}
 
-	static const uint32 getResTag() { return MKTAG('Z', 'o', 'o', 'm'); }
+	static uint32 getResTag() { return MKTAG('Z', 'o', 'o', 'm'); }
 
 	void loadFromStream(Common::SeekableReadStream *stream);
 	void clear();


Commit: 990f7c4ca43fa4157ee6afe46a60c790770c9ed4
    https://github.com/scummvm/scummvm/commit/990f7c4ca43fa4157ee6afe46a60c790770c9ed4
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T17:00:45-07:00

Commit Message:
PEGASUS: Add some braces

Silences digitall's compiler :P

Changed paths:
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/norad/subcontrolroom.cpp



diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 4842423..b7c45dc 100755
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -1284,7 +1284,7 @@ void Caldoria::activateHotspots() {
 
 	switch (GameState.getCurrentRoom()) {
 	case kCaldoriaDrawers:
-		if (getCurrentActivation() == kActivateRightOpen)
+		if (getCurrentActivation() == kActivateRightOpen) {
 			if (GameState.isTakenItemID(kKeyCard)) {
 				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
 				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
@@ -1292,6 +1292,7 @@ void Caldoria::activateHotspots() {
 				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
 				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
 			}
+		}
 	case kCaldoriaReplicator:
 		if (GameState.getCaldoriaMadeOJ())
 			g_allHotspots.deactivateOneHotspot(kCaldoriaMakeOJSpotID);
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
index b0e5b98..2b15ad4 100755
--- a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
+++ b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
@@ -804,7 +804,7 @@ void SubControlRoom::clickInHotspot(const Input &input, const Hotspot *spot) {
 	} else if (clickedID == _outSpotID) {
 		_gameState = kPuttingClawAway;
 
-		if (_currentAction == kNoActionIndex)
+		if (_currentAction == kNoActionIndex) {
 			if (_clawPosition == _clawStartPosition) {
 				GameInteraction::clickInHotspot(input, spot);
 			} else {
@@ -826,6 +826,7 @@ void SubControlRoom::clickInHotspot(const Input &input, const Hotspot *spot) {
 					break;
 				}
 			}
+		}
 	} else {
 		GameInteraction::clickInHotspot(input, spot);
 	}


Commit: c6a74c6e1da90dc3a905a6d97ebca5478d189465
    https://github.com/scummvm/scummvm/commit/c6a74c6e1da90dc3a905a6d97ebca5478d189465
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T17:15:49-07:00

Commit Message:
PEGASUS: Add 'Demo' to the demo's extra field

Changed paths:
    engines/pegasus/detection.cpp



diff --git a/engines/pegasus/detection.cpp b/engines/pegasus/detection.cpp
index 64e7d32..d9afacb 100644
--- a/engines/pegasus/detection.cpp
+++ b/engines/pegasus/detection.cpp
@@ -72,7 +72,7 @@ static const PegasusGameDescription gameDescriptions[] = {
 	{
 		{
 			"pegasus",
-			"",
+			"Demo",
 			AD_ENTRY1s("JMP PP Resources", "d13a602d2498010d720a6534f097f88b", 360129),
 			Common::EN_ANY,
 			Common::kPlatformMacintosh,


Commit: e72f2c3c57b8c0d8fad785702ad5922f0ff0ae85
    https://github.com/scummvm/scummvm/commit/e72f2c3c57b8c0d8fad785702ad5922f0ff0ae85
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-02T17:19:11-07:00

Commit Message:
PEGASUS: Remove some ancient svn tags

Changed paths:
    engines/pegasus/console.cpp
    engines/pegasus/console.h



diff --git a/engines/pegasus/console.cpp b/engines/pegasus/console.cpp
index e66859d..64bd0ba 100644
--- a/engines/pegasus/console.cpp
+++ b/engines/pegasus/console.cpp
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #include "pegasus/console.h"
diff --git a/engines/pegasus/console.h b/engines/pegasus/console.h
index b73b706..f00ee25 100644
--- a/engines/pegasus/console.h
+++ b/engines/pegasus/console.h
@@ -18,9 +18,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $URL$
- * $Id$
- *
  */
 
 #ifndef PEGASUS_CONSOLE_H


Commit: d5341b2fc7a43d63c38e72d671053d28de42e156
    https://github.com/scummvm/scummvm/commit/d5341b2fc7a43d63c38e72d671053d28de42e156
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-03T07:32:32-07:00

Commit Message:
PEGASUS: Implement saving/restoring the in-game AI data

AI data should now be restored properly after the space chase

Changed paths:
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index 9eacb03..b9b5ce9 100755
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -23,6 +23,8 @@
  *
  */
 
+#include "common/memstream.h"
+
 #include "pegasus/cursor.h"
 #include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
@@ -72,11 +74,21 @@ AIArea::~AIArea() {
 
 // Save last state of AI rules...
 void AIArea::saveAIState() {
-	// TODO
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	delete vm->_aiSaveStream;
+
+	Common::MemoryWriteStreamDynamic out;
+	writeAIRules(&out);
+
+	vm->_aiSaveStream = new Common::MemoryReadStream(out.getData(), out.size(), DisposeAfterUse::YES);
 }
 	
 void AIArea::restoreAIState() {
-	// TODO
+	PegasusEngine *vm = (PegasusEngine *)g_engine;
+
+	if (vm->_aiSaveStream)
+		readAIRules(vm->_aiSaveStream);
 }
 
 void AIArea::writeAIRules(Common::WriteStream *stream) {
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index a346af5..46aea73 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -90,6 +90,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 	_idlerHead = 0;
 	_currentCD = 1;
 	_introTimer = 0;
+	_aiSaveStream = 0;
 }
 
 PegasusEngine::~PegasusEngine() {
@@ -101,6 +102,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _neighborhood;
 	delete _rnd;
 	delete _introTimer;
+	delete _aiSaveStream;
 
 	// NOTE: This must be deleted last!
 	delete _gfx;
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index c6d4c80..349856d 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -162,6 +162,7 @@ public:
 	bool canSolve();
 	void prepareForAIHint(const Common::String &);
 	void cleanUpAfterAIHint(const Common::String &);
+	Common::SeekableReadStream *_aiSaveStream;
 
 	// Neighborhood
 	void jumpToNewEnvironment(const NeighborhoodID, const RoomID, const DirectionConstant);


Commit: 2f8e0175248855f2f0f7ae1b2164553f757d2f78
    https://github.com/scummvm/scummvm/commit/2f8e0175248855f2f0f7ae1b2164553f757d2f78
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-03T10:39:48-07:00

Commit Message:
PEGASUS: Add safety check around decodeNextFrame() when playing the Bandai logo

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 46aea73..e863626 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -292,8 +292,11 @@ void PegasusEngine::runIntro() {
 		while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 			if (video->needsUpdate()) {
 				const Graphics::Surface *frame = video->decodeNextFrame();
-				_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
-				_system->updateScreen();
+
+				if (frame) {
+					_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
+					_system->updateScreen();
+				}
 			}
 
 			Input input;


Commit: 983bd16bb78b1a6aa8872f2086dbcbca6954f2fb
    https://github.com/scummvm/scummvm/commit/983bd16bb78b1a6aa8872f2086dbcbca6954f2fb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-03T12:23:08-07:00

Commit Message:
PEGASUS: Fix file permissions

Changed paths:
  A engines/pegasus/ai/ai_action.cpp
  A engines/pegasus/ai/ai_action.h
  A engines/pegasus/ai/ai_area.cpp
  A engines/pegasus/ai/ai_area.h
  A engines/pegasus/ai/ai_condition.cpp
  A engines/pegasus/ai/ai_condition.h
  A engines/pegasus/ai/ai_rule.cpp
  A engines/pegasus/ai/ai_rule.h
  A engines/pegasus/compass.cpp
  A engines/pegasus/compass.h
  A engines/pegasus/constants.h
  A engines/pegasus/cursor.cpp
  A engines/pegasus/cursor.h
  A engines/pegasus/energymonitor.cpp
  A engines/pegasus/energymonitor.h
  A engines/pegasus/fader.cpp
  A engines/pegasus/fader.h
  A engines/pegasus/gamestate.cpp
  A engines/pegasus/gamestate.h
  A engines/pegasus/hotspot.cpp
  A engines/pegasus/hotspot.h
  A engines/pegasus/input.cpp
  A engines/pegasus/input.h
  A engines/pegasus/interaction.h
  A engines/pegasus/interface.cpp
  A engines/pegasus/interface.h
  A engines/pegasus/items/autodragger.cpp
  A engines/pegasus/items/autodragger.h
  A engines/pegasus/items/biochips/aichip.cpp
  A engines/pegasus/items/biochips/aichip.h
  A engines/pegasus/items/biochips/biochipitem.cpp
  A engines/pegasus/items/biochips/biochipitem.h
  A engines/pegasus/items/biochips/mapchip.cpp
  A engines/pegasus/items/biochips/mapchip.h
  A engines/pegasus/items/biochips/mapimage.cpp
  A engines/pegasus/items/biochips/mapimage.h
  A engines/pegasus/items/biochips/opticalchip.cpp
  A engines/pegasus/items/biochips/opticalchip.h
  A engines/pegasus/items/biochips/pegasuschip.cpp
  A engines/pegasus/items/biochips/pegasuschip.h
  A engines/pegasus/items/biochips/retscanchip.cpp
  A engines/pegasus/items/biochips/retscanchip.h
  A engines/pegasus/items/biochips/shieldchip.cpp
  A engines/pegasus/items/biochips/shieldchip.h
  A engines/pegasus/items/inventory.cpp
  A engines/pegasus/items/inventory.h
  A engines/pegasus/items/inventory/airmask.cpp
  A engines/pegasus/items/inventory/airmask.h
  A engines/pegasus/items/inventory/gascanister.cpp
  A engines/pegasus/items/inventory/gascanister.h
  A engines/pegasus/items/inventory/inventoryitem.cpp
  A engines/pegasus/items/inventory/inventoryitem.h
  A engines/pegasus/items/inventory/keycard.cpp
  A engines/pegasus/items/inventory/keycard.h
  A engines/pegasus/items/inventorypicture.cpp
  A engines/pegasus/items/inventorypicture.h
  A engines/pegasus/items/item.cpp
  A engines/pegasus/items/item.h
  A engines/pegasus/items/itemdragger.cpp
  A engines/pegasus/items/itemdragger.h
  A engines/pegasus/items/itemlist.cpp
  A engines/pegasus/items/itemlist.h
  A engines/pegasus/menu.cpp
  A engines/pegasus/menu.h
  A engines/pegasus/movie.cpp
  A engines/pegasus/movie.h
  A engines/pegasus/neighborhood/caldoria/caldoria.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria.h
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.h
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.h
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.h
  A engines/pegasus/neighborhood/door.cpp
  A engines/pegasus/neighborhood/door.h
  A engines/pegasus/neighborhood/exit.cpp
  A engines/pegasus/neighborhood/exit.h
  A engines/pegasus/neighborhood/extra.cpp
  A engines/pegasus/neighborhood/extra.h
  A engines/pegasus/neighborhood/hotspotinfo.cpp
  A engines/pegasus/neighborhood/hotspotinfo.h
  A engines/pegasus/neighborhood/mars/constants.h
  A engines/pegasus/neighborhood/mars/energybeam.cpp
  A engines/pegasus/neighborhood/mars/energybeam.h
  A engines/pegasus/neighborhood/mars/gravitoncannon.cpp
  A engines/pegasus/neighborhood/mars/gravitoncannon.h
  A engines/pegasus/neighborhood/mars/hermite.cpp
  A engines/pegasus/neighborhood/mars/hermite.h
  A engines/pegasus/neighborhood/mars/mars.cpp
  A engines/pegasus/neighborhood/mars/mars.h
  A engines/pegasus/neighborhood/mars/planetmover.cpp
  A engines/pegasus/neighborhood/mars/planetmover.h
  A engines/pegasus/neighborhood/mars/reactor.cpp
  A engines/pegasus/neighborhood/mars/reactor.h
  A engines/pegasus/neighborhood/mars/robotship.cpp
  A engines/pegasus/neighborhood/mars/robotship.h
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.h
  A engines/pegasus/neighborhood/mars/shuttlehud.cpp
  A engines/pegasus/neighborhood/mars/shuttlehud.h
  A engines/pegasus/neighborhood/mars/shuttleweapon.cpp
  A engines/pegasus/neighborhood/mars/shuttleweapon.h
  A engines/pegasus/neighborhood/mars/spacechase3d.cpp
  A engines/pegasus/neighborhood/mars/spacechase3d.h
  A engines/pegasus/neighborhood/mars/spacejunk.cpp
  A engines/pegasus/neighborhood/mars/spacejunk.h
  A engines/pegasus/neighborhood/mars/tractorbeam.cpp
  A engines/pegasus/neighborhood/mars/tractorbeam.h
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.h
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.h
  A engines/pegasus/neighborhood/norad/alpha/panorama.cpp
  A engines/pegasus/neighborhood/norad/alpha/panorama.h
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
  A engines/pegasus/neighborhood/norad/constants.h
  A engines/pegasus/neighborhood/norad/delta/globegame.cpp
  A engines/pegasus/neighborhood/norad/delta/globegame.h
  A engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
  A engines/pegasus/neighborhood/norad/delta/noraddelta.h
  A engines/pegasus/neighborhood/norad/norad.cpp
  A engines/pegasus/neighborhood/norad/norad.h
  A engines/pegasus/neighborhood/norad/noradelevator.cpp
  A engines/pegasus/neighborhood/norad/noradelevator.h
  A engines/pegasus/neighborhood/norad/pressuredoor.cpp
  A engines/pegasus/neighborhood/norad/pressuredoor.h
  A engines/pegasus/neighborhood/norad/pressuretracker.cpp
  A engines/pegasus/neighborhood/norad/pressuretracker.h
  A engines/pegasus/neighborhood/norad/subcontrolroom.cpp
  A engines/pegasus/neighborhood/norad/subcontrolroom.h
  A engines/pegasus/neighborhood/norad/subplatform.cpp
  A engines/pegasus/neighborhood/norad/subplatform.h
  A engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
  A engines/pegasus/neighborhood/prehistoric/prehistoric.h
  A engines/pegasus/neighborhood/spot.cpp
  A engines/pegasus/neighborhood/spot.h
  A engines/pegasus/neighborhood/tsa/fulltsa.cpp
  A engines/pegasus/neighborhood/tsa/fulltsa.h
  A engines/pegasus/neighborhood/tsa/tinytsa.cpp
  A engines/pegasus/neighborhood/tsa/tinytsa.h
  A engines/pegasus/neighborhood/turn.cpp
  A engines/pegasus/neighborhood/turn.h
  A engines/pegasus/neighborhood/view.cpp
  A engines/pegasus/neighborhood/view.h
  A engines/pegasus/neighborhood/wsc/moleculebin.cpp
  A engines/pegasus/neighborhood/wsc/moleculebin.h
  A engines/pegasus/neighborhood/wsc/wsc.cpp
  A engines/pegasus/neighborhood/wsc/wsc.h
  A engines/pegasus/neighborhood/zoom.cpp
  A engines/pegasus/neighborhood/zoom.h
  A engines/pegasus/notification.cpp
  A engines/pegasus/notification.h
  A engines/pegasus/scoring.h
  A engines/pegasus/sound.cpp
  A engines/pegasus/sound.h
  A engines/pegasus/surface.cpp
  A engines/pegasus/surface.h
  A engines/pegasus/timers.cpp
  A engines/pegasus/timers.h
  A engines/pegasus/transition.cpp
  A engines/pegasus/transition.h
  A engines/pegasus/types.h
  A engines/pegasus/util.cpp
  A engines/pegasus/util.h
  R engines/pegasus/ai/ai_action.cpp
  R engines/pegasus/ai/ai_action.h
  R engines/pegasus/ai/ai_area.cpp
  R engines/pegasus/ai/ai_area.h
  R engines/pegasus/ai/ai_condition.cpp
  R engines/pegasus/ai/ai_condition.h
  R engines/pegasus/ai/ai_rule.cpp
  R engines/pegasus/ai/ai_rule.h
  R engines/pegasus/compass.cpp
  R engines/pegasus/compass.h
  R engines/pegasus/constants.h
  R engines/pegasus/cursor.cpp
  R engines/pegasus/cursor.h
  R engines/pegasus/energymonitor.cpp
  R engines/pegasus/energymonitor.h
  R engines/pegasus/fader.cpp
  R engines/pegasus/fader.h
  R engines/pegasus/gamestate.cpp
  R engines/pegasus/gamestate.h
  R engines/pegasus/hotspot.cpp
  R engines/pegasus/hotspot.h
  R engines/pegasus/input.cpp
  R engines/pegasus/input.h
  R engines/pegasus/interaction.h
  R engines/pegasus/interface.cpp
  R engines/pegasus/interface.h
  R engines/pegasus/items/autodragger.cpp
  R engines/pegasus/items/autodragger.h
  R engines/pegasus/items/biochips/aichip.cpp
  R engines/pegasus/items/biochips/aichip.h
  R engines/pegasus/items/biochips/biochipitem.cpp
  R engines/pegasus/items/biochips/biochipitem.h
  R engines/pegasus/items/biochips/mapchip.cpp
  R engines/pegasus/items/biochips/mapchip.h
  R engines/pegasus/items/biochips/mapimage.cpp
  R engines/pegasus/items/biochips/mapimage.h
  R engines/pegasus/items/biochips/opticalchip.cpp
  R engines/pegasus/items/biochips/opticalchip.h
  R engines/pegasus/items/biochips/pegasuschip.cpp
  R engines/pegasus/items/biochips/pegasuschip.h
  R engines/pegasus/items/biochips/retscanchip.cpp
  R engines/pegasus/items/biochips/retscanchip.h
  R engines/pegasus/items/biochips/shieldchip.cpp
  R engines/pegasus/items/biochips/shieldchip.h
  R engines/pegasus/items/inventory.cpp
  R engines/pegasus/items/inventory.h
  R engines/pegasus/items/inventory/airmask.cpp
  R engines/pegasus/items/inventory/airmask.h
  R engines/pegasus/items/inventory/gascanister.cpp
  R engines/pegasus/items/inventory/gascanister.h
  R engines/pegasus/items/inventory/inventoryitem.cpp
  R engines/pegasus/items/inventory/inventoryitem.h
  R engines/pegasus/items/inventory/keycard.cpp
  R engines/pegasus/items/inventory/keycard.h
  R engines/pegasus/items/inventorypicture.cpp
  R engines/pegasus/items/inventorypicture.h
  R engines/pegasus/items/item.cpp
  R engines/pegasus/items/item.h
  R engines/pegasus/items/itemdragger.cpp
  R engines/pegasus/items/itemdragger.h
  R engines/pegasus/items/itemlist.cpp
  R engines/pegasus/items/itemlist.h
  R engines/pegasus/menu.cpp
  R engines/pegasus/menu.h
  R engines/pegasus/movie.cpp
  R engines/pegasus/movie.h
  R engines/pegasus/neighborhood/caldoria/caldoria.cpp
  R engines/pegasus/neighborhood/caldoria/caldoria.h
  R engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
  R engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
  R engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
  R engines/pegasus/neighborhood/caldoria/caldoriabomb.h
  R engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
  R engines/pegasus/neighborhood/caldoria/caldoriamessages.h
  R engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
  R engines/pegasus/neighborhood/caldoria/caldoriamirror.h
  R engines/pegasus/neighborhood/door.cpp
  R engines/pegasus/neighborhood/door.h
  R engines/pegasus/neighborhood/exit.cpp
  R engines/pegasus/neighborhood/exit.h
  R engines/pegasus/neighborhood/extra.cpp
  R engines/pegasus/neighborhood/extra.h
  R engines/pegasus/neighborhood/hotspotinfo.cpp
  R engines/pegasus/neighborhood/hotspotinfo.h
  R engines/pegasus/neighborhood/mars/constants.h
  R engines/pegasus/neighborhood/mars/energybeam.cpp
  R engines/pegasus/neighborhood/mars/energybeam.h
  R engines/pegasus/neighborhood/mars/gravitoncannon.cpp
  R engines/pegasus/neighborhood/mars/gravitoncannon.h
  R engines/pegasus/neighborhood/mars/hermite.cpp
  R engines/pegasus/neighborhood/mars/hermite.h
  R engines/pegasus/neighborhood/mars/mars.cpp
  R engines/pegasus/neighborhood/mars/mars.h
  R engines/pegasus/neighborhood/mars/planetmover.cpp
  R engines/pegasus/neighborhood/mars/planetmover.h
  R engines/pegasus/neighborhood/mars/reactor.cpp
  R engines/pegasus/neighborhood/mars/reactor.h
  R engines/pegasus/neighborhood/mars/robotship.cpp
  R engines/pegasus/neighborhood/mars/robotship.h
  R engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
  R engines/pegasus/neighborhood/mars/shuttleenergymeter.h
  R engines/pegasus/neighborhood/mars/shuttlehud.cpp
  R engines/pegasus/neighborhood/mars/shuttlehud.h
  R engines/pegasus/neighborhood/mars/shuttleweapon.cpp
  R engines/pegasus/neighborhood/mars/shuttleweapon.h
  R engines/pegasus/neighborhood/mars/spacechase3d.cpp
  R engines/pegasus/neighborhood/mars/spacechase3d.h
  R engines/pegasus/neighborhood/mars/spacejunk.cpp
  R engines/pegasus/neighborhood/mars/spacejunk.h
  R engines/pegasus/neighborhood/mars/tractorbeam.cpp
  R engines/pegasus/neighborhood/mars/tractorbeam.h
  R engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
  R engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
  R engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
  R engines/pegasus/neighborhood/norad/alpha/fillingstation.h
  R engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
  R engines/pegasus/neighborhood/norad/alpha/noradalpha.h
  R engines/pegasus/neighborhood/norad/alpha/panorama.cpp
  R engines/pegasus/neighborhood/norad/alpha/panorama.h
  R engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
  R engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
  R engines/pegasus/neighborhood/norad/constants.h
  R engines/pegasus/neighborhood/norad/delta/globegame.cpp
  R engines/pegasus/neighborhood/norad/delta/globegame.h
  R engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
  R engines/pegasus/neighborhood/norad/delta/noraddelta.h
  R engines/pegasus/neighborhood/norad/norad.cpp
  R engines/pegasus/neighborhood/norad/norad.h
  R engines/pegasus/neighborhood/norad/noradelevator.cpp
  R engines/pegasus/neighborhood/norad/noradelevator.h
  R engines/pegasus/neighborhood/norad/pressuredoor.cpp
  R engines/pegasus/neighborhood/norad/pressuredoor.h
  R engines/pegasus/neighborhood/norad/pressuretracker.cpp
  R engines/pegasus/neighborhood/norad/pressuretracker.h
  R engines/pegasus/neighborhood/norad/subcontrolroom.cpp
  R engines/pegasus/neighborhood/norad/subcontrolroom.h
  R engines/pegasus/neighborhood/norad/subplatform.cpp
  R engines/pegasus/neighborhood/norad/subplatform.h
  R engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
  R engines/pegasus/neighborhood/prehistoric/prehistoric.h
  R engines/pegasus/neighborhood/spot.cpp
  R engines/pegasus/neighborhood/spot.h
  R engines/pegasus/neighborhood/tsa/fulltsa.cpp
  R engines/pegasus/neighborhood/tsa/fulltsa.h
  R engines/pegasus/neighborhood/tsa/tinytsa.cpp
  R engines/pegasus/neighborhood/tsa/tinytsa.h
  R engines/pegasus/neighborhood/turn.cpp
  R engines/pegasus/neighborhood/turn.h
  R engines/pegasus/neighborhood/view.cpp
  R engines/pegasus/neighborhood/view.h
  R engines/pegasus/neighborhood/wsc/moleculebin.cpp
  R engines/pegasus/neighborhood/wsc/moleculebin.h
  R engines/pegasus/neighborhood/wsc/wsc.cpp
  R engines/pegasus/neighborhood/wsc/wsc.h
  R engines/pegasus/neighborhood/zoom.cpp
  R engines/pegasus/neighborhood/zoom.h
  R engines/pegasus/notification.cpp
  R engines/pegasus/notification.h
  R engines/pegasus/scoring.h
  R engines/pegasus/sound.cpp
  R engines/pegasus/sound.h
  R engines/pegasus/surface.cpp
  R engines/pegasus/surface.h
  R engines/pegasus/timers.cpp
  R engines/pegasus/timers.h
  R engines/pegasus/transition.cpp
  R engines/pegasus/transition.h
  R engines/pegasus/types.h
  R engines/pegasus/util.cpp
  R engines/pegasus/util.h



diff --git a/engines/pegasus/ai/ai_action.cpp b/engines/pegasus/ai/ai_action.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_action.h b/engines/pegasus/ai/ai_action.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_area.h b/engines/pegasus/ai/ai_area.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_condition.cpp b/engines/pegasus/ai/ai_condition.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_condition.h b/engines/pegasus/ai/ai_condition.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_rule.cpp b/engines/pegasus/ai/ai_rule.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/ai/ai_rule.h b/engines/pegasus/ai/ai_rule.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/compass.cpp b/engines/pegasus/compass.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/compass.h b/engines/pegasus/compass.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/cursor.h b/engines/pegasus/cursor.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/energymonitor.cpp b/engines/pegasus/energymonitor.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/energymonitor.h b/engines/pegasus/energymonitor.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/fader.cpp b/engines/pegasus/fader.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/fader.h b/engines/pegasus/fader.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/interaction.h b/engines/pegasus/interaction.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/interface.cpp b/engines/pegasus/interface.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/interface.h b/engines/pegasus/interface.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/autodragger.cpp b/engines/pegasus/items/autodragger.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/autodragger.h b/engines/pegasus/items/autodragger.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/aichip.cpp b/engines/pegasus/items/biochips/aichip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/aichip.h b/engines/pegasus/items/biochips/aichip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/biochipitem.cpp b/engines/pegasus/items/biochips/biochipitem.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/biochipitem.h b/engines/pegasus/items/biochips/biochipitem.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/mapchip.cpp b/engines/pegasus/items/biochips/mapchip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/mapchip.h b/engines/pegasus/items/biochips/mapchip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/mapimage.cpp b/engines/pegasus/items/biochips/mapimage.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/mapimage.h b/engines/pegasus/items/biochips/mapimage.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/opticalchip.cpp b/engines/pegasus/items/biochips/opticalchip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/opticalchip.h b/engines/pegasus/items/biochips/opticalchip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/pegasuschip.h b/engines/pegasus/items/biochips/pegasuschip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/retscanchip.cpp b/engines/pegasus/items/biochips/retscanchip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/retscanchip.h b/engines/pegasus/items/biochips/retscanchip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/shieldchip.cpp b/engines/pegasus/items/biochips/shieldchip.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/biochips/shieldchip.h b/engines/pegasus/items/biochips/shieldchip.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory.cpp b/engines/pegasus/items/inventory.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory.h b/engines/pegasus/items/inventory.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/airmask.cpp b/engines/pegasus/items/inventory/airmask.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/airmask.h b/engines/pegasus/items/inventory/airmask.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/gascanister.cpp b/engines/pegasus/items/inventory/gascanister.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/gascanister.h b/engines/pegasus/items/inventory/gascanister.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/inventoryitem.cpp b/engines/pegasus/items/inventory/inventoryitem.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/inventoryitem.h b/engines/pegasus/items/inventory/inventoryitem.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/keycard.cpp b/engines/pegasus/items/inventory/keycard.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventory/keycard.h b/engines/pegasus/items/inventory/keycard.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/inventorypicture.h b/engines/pegasus/items/inventorypicture.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/item.cpp b/engines/pegasus/items/item.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/item.h b/engines/pegasus/items/item.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/itemdragger.cpp b/engines/pegasus/items/itemdragger.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/itemdragger.h b/engines/pegasus/items/itemdragger.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/menu.h b/engines/pegasus/menu.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.h b/engines/pegasus/neighborhood/caldoria/caldoria.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp b/engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriabomb.h b/engines/pegasus/neighborhood/caldoria/caldoriabomb.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamessages.h b/engines/pegasus/neighborhood/caldoria/caldoriamessages.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.h b/engines/pegasus/neighborhood/caldoria/caldoriamirror.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/door.cpp b/engines/pegasus/neighborhood/door.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/door.h b/engines/pegasus/neighborhood/door.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/exit.cpp b/engines/pegasus/neighborhood/exit.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/exit.h b/engines/pegasus/neighborhood/exit.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/extra.cpp b/engines/pegasus/neighborhood/extra.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/extra.h b/engines/pegasus/neighborhood/extra.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/hotspotinfo.cpp b/engines/pegasus/neighborhood/hotspotinfo.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/hotspotinfo.h b/engines/pegasus/neighborhood/hotspotinfo.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/constants.h b/engines/pegasus/neighborhood/mars/constants.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/energybeam.cpp b/engines/pegasus/neighborhood/mars/energybeam.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/energybeam.h b/engines/pegasus/neighborhood/mars/energybeam.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.cpp b/engines/pegasus/neighborhood/mars/gravitoncannon.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/gravitoncannon.h b/engines/pegasus/neighborhood/mars/gravitoncannon.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/hermite.cpp b/engines/pegasus/neighborhood/mars/hermite.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/hermite.h b/engines/pegasus/neighborhood/mars/hermite.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/planetmover.cpp b/engines/pegasus/neighborhood/mars/planetmover.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/planetmover.h b/engines/pegasus/neighborhood/mars/planetmover.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/reactor.cpp b/engines/pegasus/neighborhood/mars/reactor.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/reactor.h b/engines/pegasus/neighborhood/mars/reactor.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/robotship.h b/engines/pegasus/neighborhood/mars/robotship.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp b/engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttleenergymeter.h b/engines/pegasus/neighborhood/mars/shuttleenergymeter.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.cpp b/engines/pegasus/neighborhood/mars/shuttlehud.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttlehud.h b/engines/pegasus/neighborhood/mars/shuttlehud.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.cpp b/engines/pegasus/neighborhood/mars/shuttleweapon.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/shuttleweapon.h b/engines/pegasus/neighborhood/mars/shuttleweapon.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.cpp b/engines/pegasus/neighborhood/mars/spacechase3d.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/spacechase3d.h b/engines/pegasus/neighborhood/mars/spacechase3d.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.cpp b/engines/pegasus/neighborhood/mars/spacejunk.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/spacejunk.h b/engines/pegasus/neighborhood/mars/spacejunk.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.cpp b/engines/pegasus/neighborhood/mars/tractorbeam.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/mars/tractorbeam.h b/engines/pegasus/neighborhood/mars/tractorbeam.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h b/engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.h b/engines/pegasus/neighborhood/norad/alpha/fillingstation.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.h b/engines/pegasus/neighborhood/norad/alpha/noradalpha.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.h b/engines/pegasus/neighborhood/norad/alpha/panorama.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h b/engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/constants.h b/engines/pegasus/neighborhood/norad/constants.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.cpp b/engines/pegasus/neighborhood/norad/delta/globegame.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/delta/globegame.h b/engines/pegasus/neighborhood/norad/delta/globegame.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.h b/engines/pegasus/neighborhood/norad/delta/noraddelta.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/norad.cpp b/engines/pegasus/neighborhood/norad/norad.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/norad.h b/engines/pegasus/neighborhood/norad/norad.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.cpp b/engines/pegasus/neighborhood/norad/noradelevator.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/noradelevator.h b/engines/pegasus/neighborhood/norad/noradelevator.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.cpp b/engines/pegasus/neighborhood/norad/pressuredoor.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/pressuredoor.h b/engines/pegasus/neighborhood/norad/pressuredoor.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.cpp b/engines/pegasus/neighborhood/norad/pressuretracker.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.h b/engines/pegasus/neighborhood/norad/pressuretracker.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.cpp b/engines/pegasus/neighborhood/norad/subcontrolroom.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/subcontrolroom.h b/engines/pegasus/neighborhood/norad/subcontrolroom.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/subplatform.cpp b/engines/pegasus/neighborhood/norad/subplatform.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/norad/subplatform.h b/engines/pegasus/neighborhood/norad/subplatform.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.h b/engines/pegasus/neighborhood/prehistoric/prehistoric.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/spot.cpp b/engines/pegasus/neighborhood/spot.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/spot.h b/engines/pegasus/neighborhood/spot.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.h b/engines/pegasus/neighborhood/tsa/fulltsa.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.cpp b/engines/pegasus/neighborhood/tsa/tinytsa.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/tsa/tinytsa.h b/engines/pegasus/neighborhood/tsa/tinytsa.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/turn.cpp b/engines/pegasus/neighborhood/turn.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/turn.h b/engines/pegasus/neighborhood/turn.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/view.cpp b/engines/pegasus/neighborhood/view.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/view.h b/engines/pegasus/neighborhood/view.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/wsc/moleculebin.cpp b/engines/pegasus/neighborhood/wsc/moleculebin.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/wsc/moleculebin.h b/engines/pegasus/neighborhood/wsc/moleculebin.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/wsc/wsc.h b/engines/pegasus/neighborhood/wsc/wsc.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/zoom.cpp b/engines/pegasus/neighborhood/zoom.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/neighborhood/zoom.h b/engines/pegasus/neighborhood/zoom.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/scoring.h b/engines/pegasus/scoring.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/sound.h b/engines/pegasus/sound.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/surface.cpp b/engines/pegasus/surface.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/surface.h b/engines/pegasus/surface.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/timers.cpp b/engines/pegasus/timers.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/timers.h b/engines/pegasus/timers.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/types.h b/engines/pegasus/types.h
old mode 100755
new mode 100644
diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
old mode 100755
new mode 100644
diff --git a/engines/pegasus/util.h b/engines/pegasus/util.h
old mode 100755
new mode 100644


Commit: 87fd7e2d357928df0b3ba4b596bcbc016a9ee2e6
    https://github.com/scummvm/scummvm/commit/87fd7e2d357928df0b3ba4b596bcbc016a9ee2e6
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-05T12:58:35-07:00

Commit Message:
PEGASUS: Warn when a sound file can't be found

Changed paths:
    engines/pegasus/sound.cpp



diff --git a/engines/pegasus/sound.cpp b/engines/pegasus/sound.cpp
index 3fd7a2a..bf15858 100644
--- a/engines/pegasus/sound.cpp
+++ b/engines/pegasus/sound.cpp
@@ -54,6 +54,7 @@ void Sound::initFromAIFFFile(const Common::String &fileName) {
 
 	Common::File *file = new Common::File();
 	if (!file->open(fileName)) {
+		warning("Failed to open AIFF file '%s'", fileName.c_str());
 		delete file;
 		return;
 	}
@@ -65,6 +66,9 @@ void Sound::initFromQuickTime(const Common::String &fileName) {
 	disposeSound();
 
 	_stream = Audio::makeQuickTimeStream(fileName);
+
+	if (!_stream)
+		warning("Failed to open QuickTime file '%s'", fileName.c_str());
 }
 
 void Sound::attachFader(SoundFader *fader) {


Commit: 9b66f04db96ae722653b427b02c7add1cded1b14
    https://github.com/scummvm/scummvm/commit/9b66f04db96ae722653b427b02c7add1cded1b14
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-05T12:58:49-07:00

Commit Message:
PEGASUS: Silence a gcc 4.6 warning

Changed paths:
    engines/pegasus/neighborhood/norad/alpha/panorama.cpp



diff --git a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
index 614595b..ecd4282 100644
--- a/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/panorama.cpp
@@ -195,7 +195,6 @@ void Panorama::loadStrips(CoordType stripLeft, CoordType stripRight) {
 		if (overlapLeft <= overlapRight) {
 			Common::Rect r1((overlapLeft - _stripLeft) * _stripWidth, 0,
 					(overlapRight - _stripLeft + 1) * _stripWidth, _panoramaHeight);
-			Common::Rect r2 = r1;
 
 			if (stripLeft < _stripLeft) {
 				Common::Rect bounds;


Commit: 1646313214d20354f0cc9aacc6b00ce145010065
    https://github.com/scummvm/scummvm/commit/1646313214d20354f0cc9aacc6b00ce145010065
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-06T06:46:04-07:00

Commit Message:
PEGASUS: Fix setChar() call fail

Thanks to Tommy for reporting

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 324a86f..9a13864 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -67,7 +67,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 		if (newName.contains(':'))
 			for (uint i = 0; i < newName.size(); i++)
 				if (newName[i] == ':')
-					newName.setChar(i, '_');
+					newName.setChar('_', i);
 
 		if (!_video->loadFile(newName))
 			error("Could not load video '%s'", fileName.c_str());


Commit: 3abacdae830392ae72d4d5c02c596af87370255e
    https://github.com/scummvm/scummvm/commit/3abacdae830392ae72d4d5c02c596af87370255e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-06T11:23:00-07:00

Commit Message:
PEGASUS: Attempt to fix compilation on MSVC

Changed paths:
    engines/pegasus/neighborhood/mars/robotship.cpp
    engines/pegasus/transition.h



diff --git a/engines/pegasus/neighborhood/mars/robotship.cpp b/engines/pegasus/neighborhood/mars/robotship.cpp
index 9776027..a0ff749 100644
--- a/engines/pegasus/neighborhood/mars/robotship.cpp
+++ b/engines/pegasus/neighborhood/mars/robotship.cpp
@@ -262,7 +262,7 @@ void RobotShip::makeVelocityVector(CoordType x1, CoordType y1, CoordType x2, Coo
 	CoordType length = ((PegasusEngine *)g_engine)->getRandomNumber(kVelocityVectorSlop - 1) + kVelocityVectorLength;
 	vector.x = x2 - x1;
 	vector.y = y2 - y1;
-	float oldLength = sqrt(vector.x * vector.x + vector.y * vector.y);
+	float oldLength = sqrt((float)(vector.x * vector.x + vector.y * vector.y));
 	vector.x = (int)(vector.x * length / oldLength);
 	vector.y = (int)(vector.y * length / oldLength);
 }
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index f32db63..5f2b797 100644
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -102,4 +102,4 @@ protected:
 
 } // End of namespace Pegasus
 
-#endif
\ No newline at end of file
+#endif


Commit: 2c2633e5443a6e3b168b8c7b3b33160f82ef0481
    https://github.com/scummvm/scummvm/commit/2c2633e5443a6e3b168b8c7b3b33160f82ef0481
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-06T11:49:47-07:00

Commit Message:
PEGASUS: More MSVC "fixes"

Changed paths:
    engines/pegasus/items/biochips/aichip.h
    engines/pegasus/neighborhood/zoom.cpp
    engines/pegasus/scoring.h



diff --git a/engines/pegasus/items/biochips/aichip.h b/engines/pegasus/items/biochips/aichip.h
index e0cbd99..7a33953 100644
--- a/engines/pegasus/items/biochips/aichip.h
+++ b/engines/pegasus/items/biochips/aichip.h
@@ -66,4 +66,4 @@ extern AIChip *g_AIChip;
 
 } // End of namespace Pegasus
 
-#endif
\ No newline at end of file
+#endif
diff --git a/engines/pegasus/neighborhood/zoom.cpp b/engines/pegasus/neighborhood/zoom.cpp
index b7cadfa..478ec6e 100644
--- a/engines/pegasus/neighborhood/zoom.cpp
+++ b/engines/pegasus/neighborhood/zoom.cpp
@@ -71,4 +71,4 @@ ZoomTable::Entry ZoomTable::findEntry(HotSpotID hotspot) {
 	return Entry();
 }
 
-} // End of namespace Pegasus
\ No newline at end of file
+} // End of namespace Pegasus
diff --git a/engines/pegasus/scoring.h b/engines/pegasus/scoring.h
index 6ca9974..fbf8641 100644
--- a/engines/pegasus/scoring.h
+++ b/engines/pegasus/scoring.h
@@ -278,4 +278,4 @@ static const GameScoreType kMaxTotalScore					=	kMaxCaldoriaTSAScore +
 														kMaxGandhiScore;
 } // End of namespace Pegasus
 
-#endif
\ No newline at end of file
+#endif


Commit: b07d03dedfdd842a1b55178c5c38a357ae4518c8
    https://github.com/scummvm/scummvm/commit/b07d03dedfdd842a1b55178c5c38a357ae4518c8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-06T12:19:32-07:00

Commit Message:
PEGASUS: Silence an MSVC warning

Changed paths:
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/neighborhood.h



diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 224d954..c8fc28e 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -205,7 +205,7 @@ void Neighborhood::receiveNotification(Notification *, const NotificationFlags f
 		die(_extraDeathReason);
 }
 
-void Neighborhood::arriveAt(RoomID room, DirectionConstant direction) {
+void Neighborhood::arriveAt(const RoomID room, const DirectionConstant direction) {
 	if (g_map)
 		g_map->moveToMapLocation(GameState.getCurrentNeighborhood(), room, direction);
 
diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h
index 93d29b6..8a38eb3 100644
--- a/engines/pegasus/neighborhood/neighborhood.h
+++ b/engines/pegasus/neighborhood/neighborhood.h
@@ -132,7 +132,7 @@ public:
 	virtual void cantMoveThatWay(CanMoveForwardReason);
 	virtual void cantTurnThatWay(CanTurnReason) {}
 	virtual void cantOpenDoor(CanOpenDoorReason);
-	virtual void arriveAt(RoomID room, DirectionConstant direction);
+	virtual void arriveAt(const RoomID room, const DirectionConstant direction);
 	virtual void turnTo(const DirectionConstant);
 	virtual void spotCompleted();
 	virtual void doorOpened();


Commit: a2454f6563d2a7e7eadb15668e8f2ff76a4a0a28
    https://github.com/scummvm/scummvm/commit/a2454f6563d2a7e7eadb15668e8f2ff76a4a0a28
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-06T16:18:41-07:00

Commit Message:
PEGASUS: Use an Array instead of a List for NotificationReceivers

Fixes occasional crashes with the norad sub controls. CodeWarrior's iterators used indices unlike our List iterators, thus necessitating the change here.

Changed paths:
    engines/pegasus/notification.cpp
    engines/pegasus/notification.h



diff --git a/engines/pegasus/notification.cpp b/engines/pegasus/notification.cpp
index 91a876c..4179afa 100644
--- a/engines/pegasus/notification.cpp
+++ b/engines/pegasus/notification.cpp
@@ -38,8 +38,8 @@ Notification::Notification(const NotificationID id, NotificationManager *owner)
 }
 
 Notification::~Notification() {
-	for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
-		it->receiver->newNotification(NULL);
+	for (uint i = 0; i < _receivers.size(); i++)
+		_receivers[i].receiver->newNotification(NULL);
 
 	if (_owner)
 		_owner->removeNotification(this);
@@ -49,9 +49,9 @@ Notification::~Notification() {
 // Wherever mask is 0, leave existing bits untouched.
 // Wherever mask is 1, set bit equivalent to flags.
 void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags flags, NotificationFlags mask) {
-	for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++) {
-		if (it->receiver == receiver) {
-			it->mask = (it->mask & ~mask) | (flags & mask);
+	for (uint i = 0; i < _receivers.size(); i++) {
+		if (_receivers[i].receiver == receiver) {
+			_receivers[i].mask = (_receivers[i].mask & ~mask) | (flags & mask);
 			receiver->newNotification(this);
 			return;
 		}
@@ -66,11 +66,11 @@ void Notification::notifyMe(NotificationReceiver *receiver, NotificationFlags fl
 }
 
 void Notification::cancelNotification(NotificationReceiver *receiver) {
-	for (ReceiverIterator it = _receivers.begin(); it != _receivers.end();) {
-		if (it->receiver == receiver)
-			it = _receivers.erase(it);
-		else
-			it++;
+	for (uint i = 0; i < _receivers.size(); i++) {
+		if (_receivers[i].receiver == receiver) {
+			_receivers.remove_at(i);
+			i--;
+		}
 	}
 }
 
@@ -82,9 +82,9 @@ void Notification::checkReceivers() {
 	NotificationFlags currentFlags = _currentFlags;
 	_currentFlags = kNoNotificationFlags;
 
-	for (ReceiverIterator it = _receivers.begin(); it != _receivers.end(); it++)
-		if (it->mask & currentFlags)
-			it->receiver->receiveNotification(this, currentFlags);
+	for (uint i = 0; i < _receivers.size(); i++)
+		if (_receivers[i].mask & currentFlags)
+			_receivers[i].receiver->receiveNotification(this, currentFlags);
 }
 
 // Receiver entries are equal if their receivers are equal.
diff --git a/engines/pegasus/notification.h b/engines/pegasus/notification.h
index 142bf8c..e795a4b 100644
--- a/engines/pegasus/notification.h
+++ b/engines/pegasus/notification.h
@@ -26,6 +26,7 @@
 #ifndef PEGASUS_NOTIFICATION_H
 #define PEGASUS_NOTIFICATION_H
 
+#include "common/array.h"
 #include "common/list.h"
 
 #include "pegasus/types.h"
@@ -44,7 +45,7 @@ struct ReceiverEntry {
 int operator==(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
 int operator!=(const ReceiverEntry &entry1, const ReceiverEntry &entry2);
 
-typedef Common::List<ReceiverEntry> ReceiverList;
+typedef Common::Array<ReceiverEntry> ReceiverList;
 
 /*
 	A notification can have 32 flags associated with it, which can be user-defined.


Commit: 1fb5238cf32a1fea07e26ba3693c7d6c97dd9023
    https://github.com/scummvm/scummvm/commit/1fb5238cf32a1fea07e26ba3693c7d6c97dd9023
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-07T13:35:50-07:00

Commit Message:
PEGASUS: Fix potentially uninitialized hotspot pointer

Should fix some crashes on Windows

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index ef9d9a6..c60f00d 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -180,7 +180,7 @@ InputHandler *InputHandler::setInputHandler(InputHandler *currentHandler) {
 void InputHandler::pollForInput() {
 	if (_inputHandler) {
 		Input input;
-		Hotspot *cursorSpot;
+		Hotspot *cursorSpot = 0;
 
 		InputHandler::getInput(input, cursorSpot);
 		if (_inputHandler->isClickInput(input, cursorSpot))


Commit: 5dfa4333d1a566f064101ca505cd15c77e3c86c0
    https://github.com/scummvm/scummvm/commit/5dfa4333d1a566f064101ca505cd15c77e3c86c0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-07T18:19:11-07:00

Commit Message:
COMMON: Hopefully fix AppleDouble files with directories

Changed paths:
    common/macresman.cpp
    common/macresman.h



diff --git a/common/macresman.cpp b/common/macresman.cpp
index 14bdfa7..f2f020c 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -124,7 +124,7 @@ bool MacResManager::open(String filename) {
 	File *file = new File();
 
 	// First, let's try to see if the Mac converted name exists
-	if (file->open("._" + filename) && loadFromAppleDouble(*file)) {
+	if (file->open(constructAppleDoubleName(filename)) && loadFromAppleDouble(*file)) {
 		_baseFileName = filename;
 		return true;
 	}
@@ -185,7 +185,7 @@ bool MacResManager::open(FSNode path, String filename) {
 #endif
 
 	// First, let's try to see if the Mac converted name exists
-	FSNode fsNode = path.getChild("._" + filename);
+	FSNode fsNode = path.getChild(constructAppleDoubleName(filename));
 	if (fsNode.exists() && !fsNode.isDirectory()) {
 		SeekableReadStream *stream = fsNode.createReadStream();
 		if (loadFromAppleDouble(*stream)) {
@@ -253,7 +253,7 @@ bool MacResManager::exists(const String &filename) {
 		return true;
 
 	// Check if we have an AppleDouble file
-	if (tempFile.open("._" + filename) && tempFile.readUint32BE() == 0x00051607)
+	if (tempFile.open(constructAppleDoubleName(filename)) && tempFile.readUint32BE() == 0x00051607)
 		return true;
 
 	return false;
@@ -574,4 +574,20 @@ void MacResManager::readMap() {
 	}
 }
 
+Common::String MacResManager::constructAppleDoubleName(Common::String name) {
+	// Insert "._" before the last portion of a path name
+	for (int i = name.size() - 1; i >= 0; i--) {
+		if (i == 0) {
+			name.insertChar('_', 0);
+			name.insertChar('.', 0);
+		} else if (name[i] == '/') {
+			name.insertChar('_', i + 1);
+			name.insertChar('.', i + 1);
+			break;
+		}
+	}
+
+	return name;
+}
+
 } // End of namespace Common
diff --git a/common/macresman.h b/common/macresman.h
index 6820106..f334405 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -175,6 +175,8 @@ private:
 	bool loadFromMacBinary(SeekableReadStream &stream);
 	bool loadFromAppleDouble(SeekableReadStream &stream);
 
+	static Common::String constructAppleDoubleName(Common::String name);
+
 	enum {
 		kResForkNone = 0,
 		kResForkRaw,


Commit: f58d834cdaf4ddd741ccdcb0f9a7d0f2adcfa785
    https://github.com/scummvm/scummvm/commit/f58d834cdaf4ddd741ccdcb0f9a7d0f2adcfa785
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-09T08:18:55-07:00

Commit Message:
COMMON: Add a KBD_META key state flag

Changed paths:
    common/keyboard.h



diff --git a/common/keyboard.h b/common/keyboard.h
index e6db086..64c6cc4 100644
--- a/common/keyboard.h
+++ b/common/keyboard.h
@@ -224,12 +224,13 @@ enum {
 	KBD_CTRL  = 1 << 0,
 	KBD_ALT   = 1 << 1,
 	KBD_SHIFT = 1 << 2,
-	KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT),
+	KBD_META  = 1 << 3,
+	KBD_NON_STICKY = (KBD_CTRL|KBD_ALT|KBD_SHIFT|KBD_META),
 
 	// Sticky modifier flags
-	KBD_NUM   = 1 << 3,
-	KBD_CAPS  = 1 << 4,
-	KBD_SCRL  = 1 << 5,
+	KBD_NUM   = 1 << 4,
+	KBD_CAPS  = 1 << 5,
+	KBD_SCRL  = 1 << 6,
 	KBD_STICKY = (KBD_NUM|KBD_CAPS|KBD_SCRL)
 
 };


Commit: ec0b4f7b96676dac890503cc156113b0966886b3
    https://github.com/scummvm/scummvm/commit/ec0b4f7b96676dac890503cc156113b0966886b3
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-09T08:19:25-07:00

Commit Message:
SDL: Allow for the meta key flag to be used

Changed paths:
    backends/events/sdl/sdl-events.cpp



diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
index f941716..0ca5bbb 100644
--- a/backends/events/sdl/sdl-events.cpp
+++ b/backends/events/sdl/sdl-events.cpp
@@ -191,6 +191,8 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
 #endif
 	if (mod & KMOD_CTRL)
 		event.kbd.flags |= Common::KBD_CTRL;
+	if (mod & KMOD_META)
+		event.kbd.flags |= Common::KBD_META;
 
 	// Sticky flags
 	if (mod & KMOD_NUM)


Commit: 981833b34e73905045338053d528af68f81884d7
    https://github.com/scummvm/scummvm/commit/981833b34e73905045338053d528af68f81884d7
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-09T08:20:18-07:00

Commit Message:
PEGASUS: Add support for load/save keys

Changed paths:
    engines/pegasus/ai/ai_area.cpp
    engines/pegasus/input.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/ai/ai_area.cpp b/engines/pegasus/ai/ai_area.cpp
index b9b5ce9..e4d3104 100644
--- a/engines/pegasus/ai/ai_area.cpp
+++ b/engines/pegasus/ai/ai_area.cpp
@@ -309,7 +309,7 @@ bool AIArea::playAIMovie(const LowerAreaSignature area, const Common::String &mo
 		Input input;
 		InputDevice.getInput(input, interruptFilter);
 
-		if (input.anyInput() || vm->shouldQuit()) {
+		if (input.anyInput() || vm->shouldQuit() || vm->saveRequested() || vm->loadRequested()) {
 			result = false;
 			break;
 		}
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index c60f00d..0250ecf 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -41,8 +41,6 @@ InputDeviceManager::InputDeviceManager() {
 }
 
 void InputDeviceManager::getInput(Input &input, const InputBits filter) {
-	// TODO: Save/Load keys
-
 	InputBits currentBits = 0;
 	bool consoleRequested = false;
 	bool altDown = false;
@@ -102,6 +100,17 @@ void InputDeviceManager::getInput(Input &input, const InputBits filter) {
 				if (event.kbd.flags & Common::KBD_CTRL) // Console!
 					consoleRequested = true;
 				break;
+			case Common::KEYCODE_s:
+				// We support meta where available and control elsewhere
+				if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
+					((PegasusEngine *)g_engine)->requestSave();
+				break;
+			case Common::KEYCODE_o: // o for open (original)
+			case Common::KEYCODE_l: // l for load (ScummVM terminology)
+				// We support meta where available and control elsewhere
+				if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
+					((PegasusEngine *)g_engine)->requestLoad();
+				break;
 			default:
 				break;
 			}
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index b7c45dc..dedfd88 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -223,7 +223,7 @@ void Caldoria::start() {
 			}
 
 			InputDevice.getInput(input, kPullbackInterruptFilter);
-			if (input.anyInput()) { // TODO: Save/Quit requests
+			if (input.anyInput() || _vm->saveRequested() || _vm->loadRequested()) {
 				skipped = true;
 				break;
 			}
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index c8fc28e..3378459 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -1591,7 +1591,7 @@ void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, CoordTy
 	while (_croppedMovie.isRunning() && !_vm->shouldQuit()) {
 		_vm->processShell();
 		InputDevice.getInput(input, interruptionFilter);
-		if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request
+		if (input.anyInput() || _vm->saveRequested() || _vm->loadRequested() || _vm->shouldQuit())
 			break;
 		_vm->_system->delayMillis(10);
 	}
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index e863626..225bcbc 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -78,6 +78,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede
 		_smallInfoMovie(kNoDisplayElement) {
 	_continuePoint = 0;
 	_saveAllowed = _loadAllowed = true;
+	_saveRequested = _loadRequested = false;
 	_gameMenu = 0;
 	_deathReason = kDeathStranded;
 	_neighborhood = 0;
@@ -891,8 +892,55 @@ void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 		_console->onFrame();
 	}
 
-	// TODO: Save request
-	// TODO: Load request
+	// Handle save requests here
+	if (_saveRequested && _saveAllowed) {
+		_saveRequested = false;
+
+		// Can only save during a game and not in the demo
+		if (g_neighborhood && !isDemo()) {
+			pauseEngine(true);
+			showSaveDialog();
+			pauseEngine(false);
+		}
+	}
+
+	// Handle load requests here
+	if (_loadRequested && _loadAllowed) {
+		_loadRequested = false;
+
+		// WORKAROUND: Do not entertain load requests when the pause menu is up
+		// The original did and the game entered a bad state after loading.
+		// It's theoretically possible to make it so it does work while the
+		// pause menu is up, but the pause state of the engine is just too weird.
+		// Just use the pause menu's restore button since it's there for that
+		// for you to load anyway.
+		if (!isDemo() && !(_gameMenu && _gameMenu->getObjectID() == kPauseMenuID)) {
+			pauseEngine(true);
+
+			if (g_neighborhood) {
+				makeContinuePoint();
+
+				Common::Error result = showLoadDialog();
+				if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled)
+					loadFromContinuePoint();
+			} else {
+				if (_introTimer)
+					_introTimer->stopFuse();
+
+				Common::Error result = showLoadDialog();
+				if (result.getCode() != Common::kNoError) {
+					if (!_gameMenu) {
+						useMenu(new MainMenu());
+						((MainMenu *)_gameMenu)->startMainMenuLoop();
+					}
+
+					resetIntroTimer();
+				}
+			}
+
+			pauseEngine(false);
+		}
+	}
 }
 
 void PegasusEngine::doInterfaceOverview() {
@@ -1008,7 +1056,7 @@ void PegasusEngine::doInterfaceOverview() {
 	for (;;) {
 		InputDevice.getInput(input, kFilterAllInput);
 
-		if (input.anyInput() || shouldQuit()) // TODO: Check for save/load requests too
+		if (input.anyInput() || shouldQuit() || _loadRequested || _saveRequested)
 			break;
 
 		input.getInputLocation(cursorLoc);
@@ -1055,7 +1103,8 @@ void PegasusEngine::doInterfaceOverview() {
 	((MainMenu *)_gameMenu)->startMainMenuLoop();
 	_gfx->doFadeInSync();
 
-	// TODO: Cancel save/load requests?
+	_saveRequested = false;
+	_loadRequested = false;
 }
 
 void PegasusEngine::showTempScreen(const Common::String &fileName) {
@@ -1223,7 +1272,7 @@ bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x
 
 		Input input;
 		InputDevice.getInput(input, kFilterAllInput);
-		if (input.anyInput())
+		if (input.anyInput() || _saveRequested || _loadRequested)
 			skipped = true;
 
 		_system->delayMillis(10);
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 349856d..a1b4cff 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -189,6 +189,10 @@ public:
 		_loadAllowed = allow;
 		return old;
 	}
+	void requestSave() { _saveRequested = true; }
+	bool saveRequested() const { return _saveRequested; }
+	void requestLoad() { _loadRequested = true; }
+	bool loadRequested() const { return _loadRequested; }
 
 protected:
 	Common::Error run();
@@ -243,6 +247,7 @@ private:
 	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
 	Common::Error showLoadDialog();
 	Common::Error showSaveDialog();
+	bool _saveRequested, _loadRequested;
 
 	// Misc.
 	Hotspot _returnHotspot;


Commit: 6ae0ff377894ea3188fc1f2c9ffc5c75a12907dd
    https://github.com/scummvm/scummvm/commit/6ae0ff377894ea3188fc1f2c9ffc5c75a12907dd
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-10T11:47:16-07:00

Commit Message:
PEGASUS: Mark the cursor as dirty when hiding it too

Changed paths:
    engines/pegasus/cursor.cpp



diff --git a/engines/pegasus/cursor.cpp b/engines/pegasus/cursor.cpp
index ea5fc74..205336a 100644
--- a/engines/pegasus/cursor.cpp
+++ b/engines/pegasus/cursor.cpp
@@ -104,6 +104,7 @@ void Cursor::show() {
 void Cursor::hide() {
 	CursorMan.showMouse(false);
 	setCurrentFrameIndex(0);
+	((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty();
 }
 
 void Cursor::hideUntilMoved() {


Commit: f087f20fa247ef780cb5172319064dec51f2cac5
    https://github.com/scummvm/scummvm/commit/f087f20fa247ef780cb5172319064dec51f2cac5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-11T06:33:43-07:00

Commit Message:
PEGASUS: Fix the pegasus biochip recall button highlight

Changed paths:
    engines/pegasus/items/biochips/pegasuschip.cpp



diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
index 1e3e0d7..320662a 100644
--- a/engines/pegasus/items/biochips/pegasuschip.cpp
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -155,7 +155,17 @@ void PegasusChip::clickInPegasusHotspot() {
 		break;
 	}
 
-	setItemState(hiliteState);
+	// WORKAROUND: The original called setItemState() here. However,
+	// since we're overriding select() to call setUpPegasusChip(),
+	// the highlighted frame is never displayed! So, we're manually
+	// setting the state and selecting the item. Also of note is that
+	// setItemState() for this class is effectively useless since it
+	// always gets overriden in the select() function. The only reason
+	// that this doesn't end in infinite recursion is because setItemState()
+	// has a check against the current state to make sure you don't call
+	// select() again. </rant>
+	_itemState = hiliteState;
+	BiochipItem::select();
 
 	uint32 time = g_system->getMillis();
 	while (g_system->getMillis() < time + 500) {


Commit: 5ee569bce634d6704703239e665d865afc4e48fb
    https://github.com/scummvm/scummvm/commit/5ee569bce634d6704703239e665d865afc4e48fb
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-11T08:39:56-07:00

Commit Message:
PEGASUS: Fix ghosted biochips when loading saved games

Could happen when loading saved games that have fewer biochips than you previously had.

Changed paths:
    engines/pegasus/items/inventorypicture.cpp



diff --git a/engines/pegasus/items/inventorypicture.cpp b/engines/pegasus/items/inventorypicture.cpp
index 1f88777..84999c0 100644
--- a/engines/pegasus/items/inventorypicture.cpp
+++ b/engines/pegasus/items/inventorypicture.cpp
@@ -197,12 +197,12 @@ void InventoryPicture::activateInventoryPicture() {
 			_panelMovie.redrawMovieWorld();
 		}
 
-		_panelMovie.setTime(0);
 		uint32 numSlots = _itemsPerRow * _numberOfRows;
 
 		for (uint32 i = numItems; i < numSlots; i++) {
 			getItemXY(i, x, y);
 			_panelMovie.moveMovieBoxTo(x, y);
+			_panelMovie.setTime(0);
 			_panelMovie.redrawMovieWorld();
 		}
 


Commit: 9971e74c4c481f99401212b469e9c79185fa6e70
    https://github.com/scummvm/scummvm/commit/9971e74c4c481f99401212b469e9c79185fa6e70
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-19T05:16:24-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Conflicts:
	base/plugins.cpp
	configure

Changed paths:
  A engines/configure.engines
  A engines/plugins_table.h
  A video/codecs/svq1.cpp
  A video/codecs/svq1.h
  A video/codecs/svq1_cb.h
  A video/codecs/svq1_vlc.h
    Makefile
    audio/decoders/qdm2.cpp
    audio/decoders/quicktime.cpp
    base/plugins.cpp
    common/cosinetables.cpp
    common/cosinetables.h
    common/dct.cpp
    common/dct.h
    common/fft.cpp
    common/fft.h
    common/module.mk
    common/rdft.cpp
    common/rdft.h
    common/sinetables.cpp
    common/sinetables.h
    common/util.h
    configure
    devtools/create_project/config.h
    devtools/create_project/create_project.cpp
    devtools/create_project/xcode.cpp
    devtools/scumm-md5.txt
    dists/samsungtv/scummvm.dat
    engines/agos/agos.h
    engines/agos/saveload.cpp
    engines/drascula/detection.cpp
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/stubs.cpp
    engines/groovie/roq.cpp
    engines/kyra/sequences_lok.cpp
    engines/mohawk/myst_stacks/intro.cpp
    engines/parallaction/disk_ns.cpp
    engines/sci/engine/workarounds.cpp
    engines/sci/sound/drivers/midi.cpp
    engines/scumm/imuse_digi/dimuse_sndmgr.h
    engines/scumm/proc3ARM.s
    engines/scumm/script_v0.cpp
    engines/scumm/scumm-md5.h
    engines/sword25/fmv/movieplayer.cpp
    graphics/decoders/bmp.h
    graphics/decoders/jpeg.h
    graphics/decoders/pict.h
    graphics/surface.cpp
    graphics/yuv_to_rgb.cpp
    graphics/yuv_to_rgb.h
    gui/themes/translations.dat
    po/es_ES.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    video/module.mk
    video/qt_decoder.cpp
    video/smk_decoder.cpp



diff --cc engines/configure.engines
index 0000000,6e8db01..93c3493
mode 000000,100644..100644
--- a/engines/configure.engines
+++ b/engines/configure.engines
@@@ -1,0 -1,47 +1,48 @@@
+ # This file is included from the main "configure" script
+ add_engine scumm "SCUMM" yes "scumm_7_8 he"
+ add_engine scumm_7_8 "v7 & v8 games" yes
+ add_engine he "HE71+ games" yes
+ add_engine agi "AGI" yes
+ add_engine agos "AGOS" yes "agos2"
+ add_engine agos2 "AGOS 2 games" yes
+ add_engine cge "CGE" yes
+ add_engine cine "Cinematique evo 1" yes
+ add_engine composer "Magic Composer" no
+ add_engine cruise "Cinematique evo 2" yes
+ add_engine draci "Dragon History" yes
+ add_engine drascula "Drascula: The Vampire Strikes Back" yes
+ add_engine dreamweb "Dreamweb" no
+ add_engine gob "Gobli*ns" yes
+ add_engine groovie "Groovie" yes "groovie2"
+ add_engine groovie2 "Groovie 2 games" no
+ add_engine hugo "Hugo Trilogy" yes
+ add_engine kyra "Legend of Kyrandia" yes "lol eob"
+ add_engine lol "Lands of Lore" yes
+ add_engine eob "Eye of the Beholder" no
+ add_engine lastexpress "The Last Express" no
+ add_engine lure "Lure of the Temptress" yes
+ add_engine made "MADE" yes
+ add_engine mohawk "Mohawk" yes "cstime myst riven"
+ add_engine cstime "Where in Time is Carmen Sandiego?" no
+ add_engine riven "Riven: The Sequel to Myst" no
+ add_engine myst "Myst" no
+ add_engine parallaction "Parallaction" yes
++add_engine pegasus "The Journeyman Project: Pegasus Prime" no
+ add_engine queen "Flight of the Amazon Queen" yes
+ add_engine saga "SAGA" yes "ihnm saga2"
+ add_engine ihnm "IHNM" yes
+ add_engine saga2 "SAGA 2 games" no
+ add_engine sci "SCI" yes "sci32"
+ add_engine sci32 "SCI32 games" no
+ add_engine sky "Beneath a Steel Sky" yes
+ add_engine sword1 "Broken Sword" yes
+ add_engine sword2 "Broken Sword II" yes
+ add_engine sword25 "Broken Sword 2.5" no
+ add_engine teenagent "Teen Agent" yes
+ add_engine testbed "TestBed: the Testing framework" no
+ add_engine tinsel "Tinsel" yes
+ add_engine toltecs "3 Skulls of the Toltecs" no
+ add_engine toon "Toonstruck" yes
+ add_engine touche "Touche: The Adventures of the Fifth Musketeer" yes
+ add_engine tsage "TsAGE" yes
+ add_engine tucker "Bud Tucker in Double Trouble" yes
diff --cc engines/plugins_table.h
index 0000000,fac9567..bfd4371
mode 000000,100644..100644
--- a/engines/plugins_table.h
+++ b/engines/plugins_table.h
@@@ -1,0 -1,103 +1,106 @@@
+ // This file is being included by "base/plugins.cpp"
+ #if PLUGIN_ENABLED_STATIC(SCUMM)
+ LINK_PLUGIN(SCUMM)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(AGI)
+ LINK_PLUGIN(AGI)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(AGOS)
+ LINK_PLUGIN(AGOS)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(CGE)
+ LINK_PLUGIN(CGE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(CINE)
+ LINK_PLUGIN(CINE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(COMPOSER)
+ LINK_PLUGIN(COMPOSER)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(CRUISE)
+ LINK_PLUGIN(CRUISE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(DRACI)
+ LINK_PLUGIN(DRACI)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(DRASCULA)
+ LINK_PLUGIN(DRASCULA)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(DREAMWEB)
+ LINK_PLUGIN(DREAMWEB)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(GOB)
+ LINK_PLUGIN(GOB)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(GROOVIE)
+ LINK_PLUGIN(GROOVIE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(HUGO)
+ LINK_PLUGIN(HUGO)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(KYRA)
+ LINK_PLUGIN(KYRA)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(LASTEXPRESS)
+ LINK_PLUGIN(LASTEXPRESS)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(LURE)
+ LINK_PLUGIN(LURE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(MADE)
+ LINK_PLUGIN(MADE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(MOHAWK)
+ LINK_PLUGIN(MOHAWK)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(PARALLACTION)
+ LINK_PLUGIN(PARALLACTION)
+ #endif
++#if PLUGIN_ENABLED_STATIC(PEGASUS)
++LINK_PLUGIN(PEGASUS)
++#endif
+ #if PLUGIN_ENABLED_STATIC(QUEEN)
+ LINK_PLUGIN(QUEEN)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SAGA)
+ LINK_PLUGIN(SAGA)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SCI)
+ LINK_PLUGIN(SCI)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SKY)
+ LINK_PLUGIN(SKY)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SWORD1)
+ LINK_PLUGIN(SWORD1)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SWORD2)
+ LINK_PLUGIN(SWORD2)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(SWORD25)
+ LINK_PLUGIN(SWORD25)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TEENAGENT)
+ LINK_PLUGIN(TEENAGENT)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TESTBED)
+ LINK_PLUGIN(TESTBED)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TINSEL)
+ LINK_PLUGIN(TINSEL)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TOLTECS)
+ LINK_PLUGIN(TOLTECS)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TOON)
+ LINK_PLUGIN(TOON)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TSAGE)
+ LINK_PLUGIN(TSAGE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TOUCHE)
+ LINK_PLUGIN(TOUCHE)
+ #endif
+ #if PLUGIN_ENABLED_STATIC(TUCKER)
+ LINK_PLUGIN(TUCKER)
+ #endif


Commit: 99eb8762c4cd46357288c2d47ec719c48ada4d80
    https://github.com/scummvm/scummvm/commit/99eb8762c4cd46357288c2d47ec719c48ada4d80
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-26T10:54:12-07:00

Commit Message:
PEGASUS: Allow control for the easter egg key as well

Fixes issues where the OS can intercept the key

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 0250ecf..492b02b 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -120,7 +120,9 @@ void InputDeviceManager::getInput(Input &input, const InputBits filter) {
 			// trying to do alt+enter or something). Since it's only used
 			// as an easter egg, I'm just going to handle it as a separate
 			// bool value.
-			if (event.kbd.flags & Common::KBD_ALT)
+			// WORKAROUND x2: I'm also accepting control here since an
+			// alt+click is often intercepted by the OS.
+			if (event.kbd.flags & (Common::KBD_ALT|Common::KBD_CTRL))
 				altDown = true;
 		}
 	}


Commit: 68438a2919df2756942193d9b1b77496828fd45a
    https://github.com/scummvm/scummvm/commit/68438a2919df2756942193d9b1b77496828fd45a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-04T08:22:56-07:00

Commit Message:
PEGASUS: Add a workaround for the canyon/space chase segfault

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 225bcbc..d2d1973 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -575,6 +575,13 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 }
 
 void PegasusEngine::makeContinuePoint() {
+	// WORKAROUND: Do not attempt to make a continue point if the interface is not set
+	// up. The original did *not* do this and attempting to restore the game using the pause
+	// menu during the canyon/space chase sequence would segfault the game and crash the
+	// system. Nice!
+	if (!g_interface)
+		return;
+
 	delete _continuePoint;
 
 	Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);


Commit: e80d622fa5b3a834faff22ac777838388c0cdf10
    https://github.com/scummvm/scummvm/commit/e80d622fa5b3a834faff22ac777838388c0cdf10
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-04T20:32:29-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A engines/dreamweb/mouse.cpp
    NEWS
    audio/decoders/quicktime.cpp
    backends/graphics/opengl/opengl-graphics.cpp
    base/main.cpp
    common/unzip.cpp
    configure
    devtools/create_project/create_project.cpp
    devtools/scumm-md5.txt
    engines/agi/saveload.cpp
    engines/configure.engines
    engines/cruise/cruise_main.cpp
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/module.mk
    engines/dreamweb/stubs.cpp
    engines/kyra/screen.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/features.h
    engines/sci/graphics/cursor.cpp
    engines/sci/sound/music.cpp
    engines/scumm/detection.cpp
    engines/scumm/scumm-md5.h
    engines/sword25/script/luabindhelper.cpp
    engines/tinsel/detection_tables.h
    engines/tinsel/music.cpp
    engines/tinsel/music.h
    engines/tinsel/tinlib.cpp
    graphics/decoders/bmp.h
    graphics/decoders/pict.cpp
    graphics/fontman.cpp
    graphics/fontman.h
    graphics/fonts/bdf.h
    graphics/fonts/ttf.cpp
    graphics/fonts/ttf.h
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/dialog.cpp
    gui/dialog.h
    gui/gui-manager.cpp
    gui/launcher.cpp
    gui/predictivedialog.cpp
    gui/predictivedialog.h
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/classic_gfx.stx
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/widget.cpp
    gui/widget.h





Commit: 974eb12fcce42067b5a52bc7f50a1edccf0d5f39
    https://github.com/scummvm/scummvm/commit/974eb12fcce42067b5a52bc7f50a1edccf0d5f39
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-11T08:37:47-07:00

Commit Message:
PEGASUS: Rewrite the input code to more closely emulate what the original did

Now the easter egg key works better and so does striding.

Changed paths:
    engines/pegasus/input.cpp
    engines/pegasus/input.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 492b02b..0ec8907 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -37,95 +37,88 @@ DECLARE_SINGLETON(Pegasus::InputDeviceManager);
 namespace Pegasus {
 
 InputDeviceManager::InputDeviceManager() {
+	// Set all keys to "not down"
+	_keyMap[Common::KEYCODE_UP] = false;
+	_keyMap[Common::KEYCODE_KP8] = false;
+	_keyMap[Common::KEYCODE_LEFT] = false;
+	_keyMap[Common::KEYCODE_KP4] = false;
+	_keyMap[Common::KEYCODE_DOWN] = false;
+	_keyMap[Common::KEYCODE_KP5] = false;
+	_keyMap[Common::KEYCODE_RIGHT] = false;
+	_keyMap[Common::KEYCODE_KP6] = false;
+	_keyMap[Common::KEYCODE_RETURN] = false;
+	_keyMap[Common::KEYCODE_SPACE] = false;
+	_keyMap[Common::KEYCODE_t] = false;
+	_keyMap[Common::KEYCODE_KP_EQUALS] = false;
+	_keyMap[Common::KEYCODE_i] = false;
+	_keyMap[Common::KEYCODE_KP_DIVIDE] = false;
+	_keyMap[Common::KEYCODE_q] = false;
+	_keyMap[Common::KEYCODE_ESCAPE] = false;
+	_keyMap[Common::KEYCODE_p] = false;
+	_keyMap[Common::KEYCODE_TILDE] = false;
+	_keyMap[Common::KEYCODE_BACKQUOTE] = false;
+	_keyMap[Common::KEYCODE_NUMLOCK] = false;
+	_keyMap[Common::KEYCODE_BACKSPACE] = false;
+	_keyMap[Common::KEYCODE_KP_MULTIPLY] = false;
+	_keyMap[Common::KEYCODE_LALT] = false;
+	_keyMap[Common::KEYCODE_RALT] = false;
+	_keyMap[Common::KEYCODE_e] = false;
+
+	g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 2, false);
 	_lastRawBits = kAllUpBits;
+	_consoleRequested = false;
+}
+
+InputDeviceManager::~InputDeviceManager() {
+	g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);
 }
 
 void InputDeviceManager::getInput(Input &input, const InputBits filter) {
+	// Poll for events, but ignore them!
+	// We'll pick them up in notifyEvent()
+	// We do that so that any pollEvent() call can update the variables
+	// (ie. if one uses enter to access the restore menu, we never receive
+	// the key up event, which leads to bad things)
+	// This is to closely emulate what the GetKeys() function did on Mac OS
+	Common::Event event;
+	while (g_system->getEventManager()->pollEvent(event))
+		;
+
+	// Now create the bitfield
 	InputBits currentBits = 0;
-	bool consoleRequested = false;
-	bool altDown = false;
 
-	Common::Event event;
-	while (g_system->getEventManager()->pollEvent(event)) {
-		// We only care about key down here
-		// We're mapping from ScummVM events to pegasus events, which
-		// are based on pippin events.
-		if (event.type == Common::EVENT_KEYDOWN) {
-			switch (event.kbd.keycode) {
-			case Common::KEYCODE_UP:
-			case Common::KEYCODE_KP8:
-				currentBits |= (kRawButtonDown << kUpButtonShift);
-				break;
-			case Common::KEYCODE_LEFT:
-			case Common::KEYCODE_KP4:
-				currentBits |= (kRawButtonDown << kLeftButtonShift);
-				break;
-			case Common::KEYCODE_DOWN:
-			case Common::KEYCODE_KP5:
-				currentBits |= (kRawButtonDown << kDownButtonShift);
-				break;
-			case Common::KEYCODE_RIGHT:
-			case Common::KEYCODE_KP6:
-				currentBits |= (kRawButtonDown << kRightButtonShift);
-				break;
-			case Common::KEYCODE_RETURN:
-			case Common::KEYCODE_SPACE:
-				currentBits |= (kRawButtonDown << kTwoButtonShift);
-				break;
-			case Common::KEYCODE_t:
-			case Common::KEYCODE_KP_EQUALS:
-				currentBits |= (kRawButtonDown << kThreeButtonShift);
-				break;
-			case Common::KEYCODE_i:
-			case Common::KEYCODE_KP_DIVIDE:
-				currentBits |= (kRawButtonDown << kFourButtonShift);
-				break;
-			case Common::KEYCODE_q:
-				currentBits |= (kRawButtonDown << kMod1ButtonShift);
-				break;
-			case Common::KEYCODE_ESCAPE:
-			case Common::KEYCODE_p:
-				currentBits |= (kRawButtonDown << kMod3ButtonShift);
-				break;
-			case Common::KEYCODE_TILDE:
-			case Common::KEYCODE_BACKQUOTE:
-			case Common::KEYCODE_NUMLOCK: // Yes, the original uses Num Lock/Clear on the Mac...
-				currentBits |= (kRawButtonDown << kLeftFireButtonShift);
-				break;
-			case Common::KEYCODE_BACKSPACE:
-			case Common::KEYCODE_KP_MULTIPLY:
-				currentBits |= (kRawButtonDown << kRightFireButtonShift);
-				break;
-			case Common::KEYCODE_d:
-				if (event.kbd.flags & Common::KBD_CTRL) // Console!
-					consoleRequested = true;
-				break;
-			case Common::KEYCODE_s:
-				// We support meta where available and control elsewhere
-				if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
-					((PegasusEngine *)g_engine)->requestSave();
-				break;
-			case Common::KEYCODE_o: // o for open (original)
-			case Common::KEYCODE_l: // l for load (ScummVM terminology)
-				// We support meta where available and control elsewhere
-				if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
-					((PegasusEngine *)g_engine)->requestLoad();
-				break;
-			default:
-				break;
-			}
-
-			// WORKAROUND: The original had a specific key for this, but
-			// pressing alt would count as an event (and mess up someone
-			// trying to do alt+enter or something). Since it's only used
-			// as an easter egg, I'm just going to handle it as a separate
-			// bool value.
-			// WORKAROUND x2: I'm also accepting control here since an
-			// alt+click is often intercepted by the OS.
-			if (event.kbd.flags & (Common::KBD_ALT|Common::KBD_CTRL))
-				altDown = true;
-		}
-	}
+	if (_keyMap[Common::KEYCODE_UP] || _keyMap[Common::KEYCODE_KP8])
+		currentBits |= (kRawButtonDown << kUpButtonShift);
+
+	if (_keyMap[Common::KEYCODE_DOWN] || _keyMap[Common::KEYCODE_KP5])
+		currentBits |= (kRawButtonDown << kDownButtonShift);
+
+	if (_keyMap[Common::KEYCODE_LEFT] || _keyMap[Common::KEYCODE_KP4])
+		currentBits |= (kRawButtonDown << kLeftButtonShift);
+
+	if (_keyMap[Common::KEYCODE_RIGHT] || _keyMap[Common::KEYCODE_KP6])
+		currentBits |= (kRawButtonDown << kRightButtonShift);
+
+	if (_keyMap[Common::KEYCODE_SPACE] || _keyMap[Common::KEYCODE_RETURN])
+		currentBits |= (kRawButtonDown << kTwoButtonShift);
+
+	if (_keyMap[Common::KEYCODE_t] || _keyMap[Common::KEYCODE_KP_EQUALS])
+		currentBits |= (kRawButtonDown << kThreeButtonShift);
+
+	if (_keyMap[Common::KEYCODE_i] || _keyMap[Common::KEYCODE_KP_DIVIDE])
+		currentBits |= (kRawButtonDown << kFourButtonShift);
+
+	if (_keyMap[Common::KEYCODE_q])
+		currentBits |= (kRawButtonDown << kMod1ButtonShift);
+
+	if (_keyMap[Common::KEYCODE_ESCAPE] || _keyMap[Common::KEYCODE_p])
+		currentBits |= (kRawButtonDown << kMod3ButtonShift);
+
+	if (_keyMap[Common::KEYCODE_TILDE] || _keyMap[Common::KEYCODE_BACKQUOTE] || _keyMap[Common::KEYCODE_NUMLOCK])
+		currentBits |= (kRawButtonDown << kLeftFireButtonShift);
+
+	if (_keyMap[Common::KEYCODE_BACKSPACE] || _keyMap[Common::KEYCODE_KP_MULTIPLY])
+		currentBits |= (kRawButtonDown << kRightFireButtonShift);
 
 	// Update mouse button state
 	// Note that we don't use EVENT_LBUTTONUP/EVENT_LBUTTONDOWN because
@@ -145,10 +138,17 @@ void InputDeviceManager::getInput(Input &input, const InputBits filter) {
 	_lastRawBits = currentBits;
 
 	// Set the console to be requested or not
-	input.setConsoleRequested(consoleRequested);
-
-	// Same for alt
-	input.setAltDown(altDown);
+	input.setConsoleRequested(_consoleRequested);
+
+	// WORKAROUND: The original had this in currentBits, but then
+	// pressing alt would count as an event (and mess up someone
+	// trying to do alt+enter or something). Since it's only used
+	// as an easter egg, I'm just going to handle it as a separate
+	// bool value.
+	// WORKAROUND x2: I'm also accepting 'e' here since an
+	// alt+click is often intercepted by the OS. 'e' is used as the
+	// easter egg key in Buried in Time and Legacy of Time.
+	input.setAltDown(_keyMap[Common::KEYCODE_LALT] || _keyMap[Common::KEYCODE_RALT] || _keyMap[Common::KEYCODE_e]);
 }
 
 // Wait until the input device stops returning input allowed by filter...
@@ -163,6 +163,48 @@ void InputDeviceManager::waitInput(const InputBits filter) {
 	}
 }
 
+bool InputDeviceManager::notifyEvent(const Common::Event &event) {
+	// We're mapping from ScummVM events to pegasus events, which
+	// are based on pippin events.
+	_consoleRequested = false;
+
+	switch (event.type) {
+	case Common::EVENT_KEYDOWN:
+		switch (event.kbd.keycode) {
+		case Common::KEYCODE_d:
+			if (event.kbd.flags & Common::KBD_CTRL) // Console!
+				_consoleRequested = true;
+			break;
+		case Common::KEYCODE_s:
+			// We support meta where available and control elsewhere
+			if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
+				((PegasusEngine *)g_engine)->requestSave();
+			break;
+		case Common::KEYCODE_o: // o for open (original)
+		case Common::KEYCODE_l: // l for load (ScummVM terminology)
+			// We support meta where available and control elsewhere
+			if (event.kbd.flags & (Common::KBD_CTRL|Common::KBD_META))
+				((PegasusEngine *)g_engine)->requestLoad();
+			break;
+		default:
+			// Otherwise, set the key to down if we have it
+			if (_keyMap.contains(event.kbd.keycode))
+				_keyMap[event.kbd.keycode] = true;
+			break;
+		}
+		break;
+	case Common::EVENT_KEYUP:
+		// Set the key to up if we have it
+		if (_keyMap.contains(event.kbd.keycode))
+			_keyMap[event.kbd.keycode] = false;
+		break;
+	default:
+		break;
+	}
+
+	return false;
+}
+
 int operator==(const Input &arg1, const Input &arg2) {
 	return arg1._inputState == arg2._inputState;
 }
diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h
index 0ee01f1..f6c29e7 100644
--- a/engines/pegasus/input.h
+++ b/engines/pegasus/input.h
@@ -26,6 +26,8 @@
 #ifndef PEGASUS_INPUT_H
 #define PEGASUS_INPUT_H
 
+#include "common/events.h"
+#include "common/hashmap.h"
 #include "common/rect.h"
 #include "common/singleton.h"
 
@@ -37,10 +39,12 @@ namespace Pegasus {
 class Hotspot;
 class Input;
 
-class InputDeviceManager : public Common::Singleton<InputDeviceManager> {
+class InputDeviceManager : public Common::Singleton<InputDeviceManager>, public Common::EventObserver {
 public:
 	InputDeviceManager();
-	~InputDeviceManager() {}
+	~InputDeviceManager();
+
+	bool notifyEvent(const Common::Event &event);
 
 	void getInput(Input &, const InputBits);
 
@@ -49,7 +53,10 @@ public:
 protected:
 	friend class Common::Singleton<SingletonBaseType>;
 
+	// Keep track of which keys are down (= true) or not
+	Common::HashMap<uint, bool> _keyMap;
 	InputBits _lastRawBits;
+	bool _consoleRequested;
 };
 
 enum {
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index d2d1973..701c416 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -104,6 +104,7 @@ PegasusEngine::~PegasusEngine() {
 	delete _rnd;
 	delete _introTimer;
 	delete _aiSaveStream;
+	InputDeviceManager::destroy();
 
 	// NOTE: This must be deleted last!
 	delete _gfx;


Commit: 175befc3f127d547f94ff83a688f72c88996f2b9
    https://github.com/scummvm/scummvm/commit/175befc3f127d547f94ff83a688f72c88996f2b9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-12T17:23:07-07:00

Commit Message:
PEGASUS: Fix compilation with optimizations enabled

Changed paths:
    engines/pegasus/util.cpp



diff --git a/engines/pegasus/util.cpp b/engines/pegasus/util.cpp
index c38054d..03bc572 100644
--- a/engines/pegasus/util.cpp
+++ b/engines/pegasus/util.cpp
@@ -68,7 +68,7 @@ void FunctionPtr::callFunction() {
 		(*_function)(this, _functionArg);
 }
 
-inline int32 pegasusRound(const int32 a, const int32 b) {
+int32 pegasusRound(const int32 a, const int32 b) {
 	if (b < 0)
 		if (a < 0)
 			return -((a - (-b >> 1)) / -b);


Commit: b2506abccf6aa64da31b497b45fe0e1949530053
    https://github.com/scummvm/scummvm/commit/b2506abccf6aa64da31b497b45fe0e1949530053
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-12T17:27:48-07:00

Commit Message:
PEGASUS: Fix some warnings found with optimizations on

Changed paths:
    engines/pegasus/items/biochips/opticalchip.cpp
    engines/pegasus/items/biochips/pegasuschip.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp



diff --git a/engines/pegasus/items/biochips/opticalchip.cpp b/engines/pegasus/items/biochips/opticalchip.cpp
index 6a9a41d..0f60981 100644
--- a/engines/pegasus/items/biochips/opticalchip.cpp
+++ b/engines/pegasus/items/biochips/opticalchip.cpp
@@ -138,9 +138,6 @@ void OpticalChip::playOpMemMovie(HotSpotID id) {
 
 	ItemState state = getItemState(), newState;
 	switch (state) {
-	case kOptical000:
-		// Can never happen.
-		break;
 	case kOptical001:
 		newState = kOptical002;
 		break;
@@ -176,6 +173,9 @@ void OpticalChip::playOpMemMovie(HotSpotID id) {
 		else
 			newState = kOptical211;
 		break;
+	case kOptical000: // Can never happen.
+	default:
+		error("Invalid optical chip state");
 	}
 
 	setItemState(newState);
diff --git a/engines/pegasus/items/biochips/pegasuschip.cpp b/engines/pegasus/items/biochips/pegasuschip.cpp
index 320662a..c0c3f6b 100644
--- a/engines/pegasus/items/biochips/pegasuschip.cpp
+++ b/engines/pegasus/items/biochips/pegasuschip.cpp
@@ -153,6 +153,8 @@ void PegasusChip::clickInPegasusHotspot() {
 	case kPegasusWSC10:
 		hiliteState = kPegasusWSC11;
 		break;
+	default:
+		error("Invalid pegasus chip state");
 	}
 
 	// WORKAROUND: The original called setItemState() here. However,
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index dedfd88..0e5868c 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -1495,6 +1495,8 @@ void Caldoria::clickOnDoorbell(const HotSpotID doorBellSpotID) {
 	case kCaldoria35DoorbellSpotID:
 		extra = kCaldoria35Doorbell;
 		break;
+	default:
+		error("Invalid doorbell hotspot");
 	}
 
 	getExtraEntry(extra, entry);
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index 0ed3355..ccc0834 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -1640,6 +1640,8 @@ void FullTSA::playTBPMonitor() {
 			extra = kTSA0BTBPProcedure;
 			GameState.setScoringSawProcedure(true);
 			break;
+		default:
+			error("Invalid monitor mode");
 		}
 
 		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingTBPMask);
@@ -1796,6 +1798,8 @@ void FullTSA::playLeftComparison() {
 			extra = kTSA0BWSCAltered;
 			GameState.setScoringSawWSCAltered(true);
 			break;
+		default:
+			error("Invalid monitor mode");
 		}
 
 		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingLeftComparisonMask);
@@ -1846,6 +1850,8 @@ void FullTSA::playRightComparison() {
 			extra = kTSA0BWSCUnaltered;
 			GameState.setScoringSawWSCNormal(true);
 			break;
+		default:
+			error("Invalid monitor mode");
 		}
 
 		GameState.setT0BMonitorMode(GameState.getT0BMonitorMode() | kPlayingRightComparisonMask);


Commit: f1f6a82cd57fceb52afdd393f44a80c40f3c9a15
    https://github.com/scummvm/scummvm/commit/f1f6a82cd57fceb52afdd393f44a80c40f3c9a15
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-24T21:35:38-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A backends/midi/sndio.cpp
  A common/coroutines.cpp
  A common/coroutines.h
  A engines/sci/engine/kgraphics32.cpp
  R engines/tinsel/coroutine.h
  R engines/tinsel/coroutine.cpp
    NEWS
    audio/decoders/quicktime.cpp
    backends/module.mk
    base/plugins.cpp
    base/version.cpp
    common/module.mk
    common/quicktime.cpp
    configure
    devtools/create_project/msbuild.cpp
    devtools/create_project/visualstudio.cpp
    engines/cruise/cruise.cpp
    engines/cruise/detection.cpp
    engines/cruise/staticres.cpp
    engines/cruise/staticres.h
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/monitor.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/sound.cpp
    engines/kyra/items_lol.cpp
    engines/kyra/lol.cpp
    engines/kyra/lol.h
    engines/kyra/script_lol.cpp
    engines/kyra/sprites_lol.cpp
    engines/mohawk/cursors.cpp
    engines/mohawk/myst_stacks/dni.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/riven_external.cpp
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/pegasus/movie.cpp
    engines/pegasus/pegasus.cpp
    engines/saga/introproc_ite.cpp
    engines/sci/console.cpp
    engines/sci/console.h
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h
    engines/sci/engine/vm.h
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/text32.cpp
    engines/sci/graphics/view.cpp
    engines/sci/module.mk
    engines/sci/resource.cpp
    engines/sci/resource.h
    engines/sci/sci.cpp
    engines/scumm/he/resource_he.cpp
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/fmv/theora_decoder.h
    engines/tinsel/actors.cpp
    engines/tinsel/background.h
    engines/tinsel/bg.cpp
    engines/tinsel/bmv.cpp
    engines/tinsel/bmv.h
    engines/tinsel/dialogs.cpp
    engines/tinsel/drives.cpp
    engines/tinsel/drives.h
    engines/tinsel/effect.cpp
    engines/tinsel/events.cpp
    engines/tinsel/events.h
    engines/tinsel/faders.cpp
    engines/tinsel/handle.cpp
    engines/tinsel/module.mk
    engines/tinsel/move.cpp
    engines/tinsel/pcode.cpp
    engines/tinsel/pcode.h
    engines/tinsel/pdisplay.cpp
    engines/tinsel/play.cpp
    engines/tinsel/play.h
    engines/tinsel/polygons.cpp
    engines/tinsel/rince.cpp
    engines/tinsel/rince.h
    engines/tinsel/savescn.cpp
    engines/tinsel/scene.cpp
    engines/tinsel/sched.cpp
    engines/tinsel/sched.h
    engines/tinsel/text.h
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinsel.cpp
    engines/tinsel/token.cpp
    engines/tsage/ringworld2/ringworld2_scenes1.cpp
    engines/tsage/ringworld2/ringworld2_scenes3.cpp
    graphics/decoders/bmp.cpp
    graphics/decoders/bmp.h
    graphics/decoders/image_decoder.h
    graphics/decoders/pict.cpp
    graphics/decoders/pict.h
    graphics/decoders/png.cpp
    graphics/decoders/png.h
    graphics/wincursor.cpp
    graphics/wincursor.h
    gui/widget.cpp
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/eu.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/psx_decoder.cpp
    video/psx_decoder.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp
    video/smk_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h



diff --cc engines/pegasus/movie.cpp
index 9a13864,0000000..f4aa9ee
mode 100644,000000..100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@@ -1,250 -1,0 +1,250 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/system.h"
 +#include "graphics/surface.h"
 +#include "video/qt_decoder.h"
 +#include "video/video_decoder.h"
 +
 +#include "pegasus/movie.h"
 +
 +namespace Pegasus {
 +
 +Movie::Movie(const DisplayElementID id) : Animation(id) {
 +	_video = 0;
 +	setScale(600);
 +}
 +
 +Movie::~Movie() {
 +	releaseMovie();
 +}
 +
 +// *** Make sure this will stop displaying the movie.
 +
 +void Movie::releaseMovie() {
 +	if (_video) {
 +		delete _video;
 +		_video = 0;
 +		disposeAllCallBacks();
 +		deallocateSurface();
 +	}
 +
 +	setBounds(Common::Rect(0, 0, 0, 0));
 +}
 +
 +void Movie::initFromMovieFile(const Common::String &fileName, bool transparent) {
 +	_transparent = transparent;
 +
 +	releaseMovie();
 +	_video = new Video::QuickTimeDecoder();
 +	if (!_video->loadFile(fileName)) {
 +		// Replace any colon with an underscore, since only Mac OS X
 +		// supports that. See PegasusEngine::detectOpeningClosingDirectory()
 +		// for more info.
 +		Common::String newName(fileName);
 +		if (newName.contains(':'))
 +			for (uint i = 0; i < newName.size(); i++)
 +				if (newName[i] == ':')
 +					newName.setChar('_', i);
 +
 +		if (!_video->loadFile(newName))
 +			error("Could not load video '%s'", fileName.c_str());
 +	}
 +
 +	_video->pauseVideo(true);
 +
 +	Common::Rect bounds(0, 0, _video->getWidth(), _video->getHeight());
 +	sizeElement(_video->getWidth(), _video->getHeight());
 +	_movieBox = bounds;
 +
 +	if (!isSurfaceValid())
 +		allocateSurface(bounds);
 +
 +	setStart(0, getScale());
 +	setStop(_video->getDuration() * getScale() / 1000, getScale());
 +}
 +
 +void Movie::redrawMovieWorld() {
 +	if (_video && _video->needsUpdate()) {
 +		const Graphics::Surface *frame = _video->decodeNextFrame();
 +
 +		if (!frame)
 +			return;
 +
 +		// Copy to the surface using _movieBox
 +		uint16 width = MIN<int>(frame->w, _movieBox.width());
 +		uint16 height = MIN<int>(frame->h, _movieBox.height());
 +
 +		for (uint16 y = 0; y < height; y++)
 +			memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
 +
 +		triggerRedraw();
 +	}
 +}
 +
 +void Movie::draw(const Common::Rect &r) {	
 +	Common::Rect worldBounds = _movieBox;
 +	Common::Rect elementBounds;
 +	getBounds(elementBounds);
 +
 +	worldBounds.moveTo(elementBounds.left, elementBounds.top);
 +	Common::Rect r1 = r.findIntersectingRect(worldBounds);
 +
 +	Common::Rect r2 = r1;
 +	r2.translate(_movieBox.left - elementBounds.left, _movieBox.top - elementBounds.top);
 +	drawImage(r2, r1);
 +}
 +
 +void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 +	_movieBox.moveTo(h, v);
 +}
 +
 +void Movie::setVolume(uint16 volume) {
 +	// TODO
 +}
 +
 +void Movie::setTime(const TimeValue time, const TimeScale scale) {
 +	if (_video) {
 +		// Don't go past the ends of the movie
 +		Common::Rational timeFrac = Common::Rational(time, ((scale == 0) ? getScale() : scale));
 +
 +		if (timeFrac < Common::Rational(_startTime, _startScale))
 +			timeFrac = Common::Rational(_startTime, _startScale);
 +		else if (timeFrac >= Common::Rational(_stopTime, _stopScale))
 +			return;
 +
 +		_video->seekToTime(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator()));
 +		_time = timeFrac;
 +		_lastMillis = 0;
 +	}
 +}
 +
 +void Movie::setRate(const Common::Rational rate) {
 +	if (rate != 1 && rate != 0) {
 +		warning("Cannot set movie rate");
 +		start();
 +		return;
 +	}
 +
 +	TimeBase::setRate(rate);
 +}
 +
 +void Movie::start() {
 +	if (_video && _video->isPaused())
 +		_video->pauseVideo(false);
 +
 +	TimeBase::start();
 +}
 +
 +void Movie::stop() {
 +	if (_video && !_video->isPaused())
 +		_video->pauseVideo(true);
 +
 +	TimeBase::stop();
 +}
 +
 +void Movie::resume() {
 +	if (_video)
 +		_video->pauseVideo(false);
 +
 +	TimeBase::resume();
 +}
 +
 +void Movie::pause() {
 +	if (_video)
 +		_video->pauseVideo(true);
 +
 +	TimeBase::pause();
 +}
 +
 +TimeValue Movie::getDuration(const TimeScale scale) const {
 +	// Unlike TimeBase::getDuration(), this returns the whole duration of the movie
 +	// The original source has a TODO to make this behave like TimeBase::getDuration(),
 +	// but the problem is that too much code requires this function to behave this way...
 +
 +	if (_video)
 +		return _video->getDuration() * ((scale == 0) ? getScale() : scale) / 1000;
 +
 +	return 0;
 +}
 +
 +void Movie::updateTime() {
 +	// The reason why we overrode TimeBase's updateTime():
 +	// Again, avoiding timers and handling it here
 +	if (_video && !_video->isPaused()) {
 +		redrawMovieWorld();
 +
 +		uint32 startTime = _startTime * getScale() / _startScale;
 +		uint32 stopTime = _stopTime * getScale() / _stopScale;
- 		uint32 actualTime = CLIP<int>(_video->getElapsedTime() * getScale() / 1000, startTime, stopTime);
++		uint32 actualTime = CLIP<int>(_video->getTime() * getScale() / 1000, startTime, stopTime);
 +		_time = Common::Rational(actualTime, getScale());
 +	}
 +}
 +
 +GlowingMovie::GlowingMovie(const DisplayElementID id) : Movie(id) {
 +	_glowing = false;
 +}
 +
 +void GlowingMovie::draw(const Common::Rect &r) {
 +	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
 +	// never fall off the screen.
 +	if (_glowing) {
 +		Common::Rect bounds;
 +		getBounds(bounds);
 +
 +		copyToCurrentPortTransparentGlow(_movieBox, bounds);
 +	} else {
 +		Movie::draw(r);
 +	}
 +}
 +
 +void GlowingMovie::setBounds(const Common::Rect &r) {
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +
 +	if (r != bounds) {
 +		// Avoid Movie::setBounds.
 +		// clone2727 asks why, but goes along with it
 +		Animation::setBounds(r);
 +	}
 +}
 +
 +ScalingMovie::ScalingMovie(const DisplayElementID id) : GlowingMovie(id) {
 +}
 +
 +void ScalingMovie::draw(const Common::Rect &) {
 +	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
 +	// never fall off the screen.
 +
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +
 +	if (_glowing)
 +		scaleTransparentCopyGlow(_movieBox, bounds);
 +	else
 +		scaleTransparentCopy(_movieBox, bounds);
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/pegasus.cpp
index 701c416,0000000..1665b47
mode 100644,000000..100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@@ -1,2294 -1,0 +1,2294 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/config-manager.h"
 +#include "common/error.h"
 +#include "common/events.h"
 +#include "common/fs.h"
 +#include "common/file.h"
 +#include "common/memstream.h"
 +#include "common/savefile.h"
 +#include "common/textconsole.h"
 +#include "common/translation.h"
 +#include "common/random.h"
 +#include "base/plugins.h"
 +#include "base/version.h"
 +#include "gui/saveload.h"
 +#include "video/qt_decoder.h"
 +
 +#include "pegasus/console.h"
 +#include "pegasus/cursor.h"
 +#include "pegasus/energymonitor.h"
 +#include "pegasus/gamestate.h"
 +#include "pegasus/interface.h"
 +#include "pegasus/menu.h"
 +#include "pegasus/movie.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/timers.h"
 +#include "pegasus/ai/ai_area.h"
 +#include "pegasus/items/itemlist.h"
 +#include "pegasus/items/biochips/aichip.h"
 +#include "pegasus/items/biochips/biochipitem.h"
 +#include "pegasus/items/biochips/mapchip.h"
 +#include "pegasus/items/biochips/opticalchip.h"
 +#include "pegasus/items/biochips/pegasuschip.h"
 +#include "pegasus/items/biochips/retscanchip.h"
 +#include "pegasus/items/biochips/shieldchip.h"
 +#include "pegasus/items/inventory/airmask.h"
 +#include "pegasus/items/inventory/gascanister.h"
 +#include "pegasus/items/inventory/inventoryitem.h"
 +#include "pegasus/items/inventory/keycard.h"
 +#include "pegasus/neighborhood/neighborhood.h"
 +#include "pegasus/neighborhood/caldoria/caldoria.h"
 +#include "pegasus/neighborhood/mars/mars.h"
 +#include "pegasus/neighborhood/norad/constants.h"
 +#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 +#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 +#include "pegasus/neighborhood/prehistoric/prehistoric.h"
 +#include "pegasus/neighborhood/tsa/fulltsa.h"
 +#include "pegasus/neighborhood/tsa/tinytsa.h"
 +#include "pegasus/neighborhood/wsc/wsc.h"
 +
 +namespace Pegasus {
 +
 +PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
 +		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID), _itemDragger(this), _bigInfoMovie(kNoDisplayElement),
 +		_smallInfoMovie(kNoDisplayElement) {
 +	_continuePoint = 0;
 +	_saveAllowed = _loadAllowed = true;
 +	_saveRequested = _loadRequested = false;
 +	_gameMenu = 0;
 +	_deathReason = kDeathStranded;
 +	_neighborhood = 0;
 +	_FXLevel = 0x80;
 +	_ambientLevel = 0x80;
 +	_gameMode = kNoMode;
 +	_switchModesSync = false;
 +	_draggingItem = 0;
 +	_dragType = kDragNoDrag;
 +	_idlerHead = 0;
 +	_currentCD = 1;
 +	_introTimer = 0;
 +	_aiSaveStream = 0;
 +}
 +
 +PegasusEngine::~PegasusEngine() {
 +	delete _resFork;
 +	delete _console;
 +	delete _cursor;
 +	delete _continuePoint;
 +	delete _gameMenu;
 +	delete _neighborhood;
 +	delete _rnd;
 +	delete _introTimer;
 +	delete _aiSaveStream;
 +	InputDeviceManager::destroy();
 +
 +	// NOTE: This must be deleted last!
 +	delete _gfx;
 +}
 +
 +void introTimerExpiredFunction(FunctionPtr *, void *) {
 +	((PegasusEngine *)g_engine)->introTimerExpired();
 +}
 +
 +Common::Error PegasusEngine::run() {
 +	_console = new PegasusConsole(this);
 +	_gfx = new GraphicsManager(this);
 +	_resFork = new Common::MacResManager();
 +	_cursor = new Cursor();
 +	_rnd = new Common::RandomSource("Pegasus");
 +	
 +	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 +		error("Could not load JMP PP Resources");
 +
 +	// Initialize items
 +	createItems();
 +
 +	// Initialize cursors
 +	_cursor->addCursorFrames(0x80); // Main
 +	_cursor->addCursorFrames(900);  // Mars Shuttle
 +
 +	// Initialize the item dragger bounds
 +	_itemDragger.setHighlightBounds();
 +
 +	if (!isDemo() && !detectOpeningClosingDirectory()) {
 +		Common::String message = "Missing intro directory. ";
 +
 +		// Give Mac OS X a more specific message because we can
 +#ifdef MACOSX
 +		message += "Make sure \"Opening/Closing\" is present.";
 +#else
 +		message += "Be sure to rename \"Opening/Closing\" to \"Opening_Closing\".";
 +#endif
 +
 +		GUIErrorMessage(message);
 +		warning("%s", message.c_str());
 +		return Common::kNoGameDataFoundError;
 +	}
 +
 +	// Set up input
 +	InputHandler::setInputHandler(this);
 +	allowInput(true);
 +
 +	// Set up inventories
 +	_items.setWeightLimit(9);
 +	_items.setOwnerID(kPlayerID);
 +	_biochips.setWeightLimit(8);
 +	_biochips.setOwnerID(kPlayerID);
 +
 +	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 +	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 +	g_allHotspots.push_back(&_returnHotspot);
 +
 +	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 +	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
 +
 +	// Load from the launcher/cli if requested (and don't show the intro in those cases)
 +	bool doIntro = true;
 +	if (ConfMan.hasKey("save_slot")) {
 +		uint32 gameToLoad = ConfMan.getInt("save_slot");
 +		doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError);
 +	}
 +
 +	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
 +
 +	if (doIntro)
 +		// Start up the first notification
 +		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
 +
 +	if (!isDemo()) {
 +		_introTimer = new FuseFunction();
 +		_introTimer->setFunctionPtr(&introTimerExpiredFunction, 0);
 +	}
 +
 +	while (!shouldQuit()) {
 +		processShell();
 +		_system->delayMillis(10); // Ease off the CPU
 +	}
 +
 +	return Common::kNoError;
 +}
 +
 +bool PegasusEngine::detectOpeningClosingDirectory() {
 +	// We need to detect what our Opening/Closing directory is listed as
 +	// On the original disc, it was 'Opening/Closing' but only HFS(+) supports the slash
 +	// Mac OS X will display this as 'Opening:Closing' and we can use that directly
 +	// On other systems, users will need to rename to "Opening_Closing"
 +
 +	Common::FSNode gameDataDir(ConfMan.get("path"));
 +	gameDataDir = gameDataDir.getChild("Images");
 +
 +	if (!gameDataDir.exists())
 +		return false;
 +
 +	Common::FSList fsList;
 +	if (!gameDataDir.getChildren(fsList, Common::FSNode::kListDirectoriesOnly, true))
 +		return false;
 +
 +	for (uint i = 0; i < fsList.size() && _introDirectory.empty(); i++) {
 +		Common::String name = fsList[i].getName();
 +
 +		if (name.equalsIgnoreCase("Opening:Closing"))
 +			_introDirectory = name;
 +		else if (name.equalsIgnoreCase("Opening_Closing"))
 +			_introDirectory = name;
 +	}
 +
 +	if (_introDirectory.empty())
 +		return false;
 +
 +	debug(0, "Detected intro location as '%s'", _introDirectory.c_str());
 +	_introDirectory = Common::String("Images/") + _introDirectory;
 +	return true;
 +}
 +
 +void PegasusEngine::createItems() {
 +	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 +
 +	uint16 entryCount = res->readUint16BE();
 +
 +	for (uint16 i = 0; i < entryCount; i++) {
 +		ItemID itemID = res->readUint16BE();
 +		NeighborhoodID neighborhoodID = res->readUint16BE();
 +		RoomID roomID = res->readUint16BE();
 +		DirectionConstant direction = res->readByte();
 +		res->readByte(); // alignment
 +
 +		createItem(itemID, neighborhoodID, roomID, direction);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction) {
 +	switch (itemID) {
 +	case kInterfaceBiochip:
 +		// Unused in game, but still in the data and we need to create
 +		// it because it's saved/loaded from save files.
 +		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kAIBiochip:
 +		new AIChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kPegasusBiochip:
 +		new PegasusChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kOpticalBiochip:
 +		new OpticalChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kMapBiochip:
 +		new MapChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kRetinalScanBiochip:
 +		new RetScanChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kShieldBiochip:
 +		new ShieldChip(itemID, neighborhoodID, roomID, direction);
 +		break;		
 +	case kAirMask:
 +		new AirMask(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kKeyCard:
 +		new KeyCard(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kGasCanister:
 +		new GasCanister(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	default:
 +		// Everything else is a normal inventory item
 +		new InventoryItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	}
 +}
 +
 +void PegasusEngine::runIntro() {
 +	stopIntroTimer();
 +
 +	bool skipped = false;
 +
 +	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
 +		while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +			if (video->needsUpdate()) {
 +				const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +				if (frame) {
 +					_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
 +					_system->updateScreen();
 +				}
 +			}
 +
 +			Input input;
 +			InputDevice.getInput(input, kFilterAllInput);
 +			if (input.anyInput())
 +				skipped = true;
 +
 +			_system->delayMillis(10);
 +		}
 +	}
 +
 +	delete video;
 +
 +	if (shouldQuit() || skipped)
 +		return;
 +
 +	video = new Video::QuickTimeDecoder();
 +
 +	if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
 +		error("Could not load intro movie");
 +
 +	video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
 +
 +	playMovieScaled(video, 0, 0);
 +
 +	delete video;
 +}
 +
 +Common::Error PegasusEngine::showLoadDialog() {
 +	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
 +	slc.setSaveMode(false);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (loadGameState(slot).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	slc.close();
 +
 +	return result;
 +}
 +
 +Common::Error PegasusEngine::showSaveDialog() {
 +	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"));
 +	slc.setSaveMode(true);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (saveGameState(slot, slc.getResultString()).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	slc.close();
 +
 +	return result;
 +}
 +
 +GUI::Debugger *PegasusEngine::getDebugger() {
 +	return _console;
 +}
 +
 +void PegasusEngine::addIdler(Idler *idler) {
 +	idler->_nextIdler = _idlerHead;
 +	if (_idlerHead)
 +		_idlerHead->_prevIdler = idler;
 +	idler->_prevIdler = 0;
 +	_idlerHead = idler;
 +}
 +
 +void PegasusEngine::removeIdler(Idler *idler) {
 +	if (idler->_prevIdler)
 +		idler->_prevIdler->_nextIdler = idler->_nextIdler;
 +	if (idler->_nextIdler)
 +		idler->_nextIdler->_prevIdler = idler->_prevIdler;
 +	if (idler == _idlerHead)
 +		_idlerHead = idler->_nextIdler;
 +	idler->_nextIdler = 0;
 +	idler->_prevIdler = 0;
 +}
 +
 +void PegasusEngine::giveIdleTime() {
 +	for (Idler *idler = _idlerHead; idler != 0; idler = idler->_nextIdler)
 +		idler->useIdleTime();
 +}
 +
 +void PegasusEngine::addTimeBase(TimeBase *timeBase) {
 +	_timeBases.push_back(timeBase);
 +}
 +
 +void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
 +	_timeBases.remove(timeBase);
 +}
 +
 +bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 +	// Dispose currently running stuff
 +	useMenu(0);
 +	useNeighborhood(0);
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +	_currentItemID = kNoItemID;
 +	_currentBiochipID = kNoItemID;
 +
 +	if (!g_interface)
 +		createInterface();
 +
 +	// Signature
 +	uint32 creator = stream->readUint32BE();
 +	if (creator != kPegasusPrimeCreator) {
 +		warning("Bad save creator '%s'", tag2str(creator));
 +		return false;
 +	}
 +
 +	uint32 gameType = stream->readUint32BE();
 +	int saveType;
 +
 +	switch (gameType) {
 +	case kPegasusPrimeDisk1GameType:
 +	case kPegasusPrimeDisk2GameType:
 +	case kPegasusPrimeDisk3GameType:
 +	case kPegasusPrimeDisk4GameType:
 +		_currentCD = gameType - kPegasusPrimeDisk1GameType + 1;
 +		saveType = kNormalSave;
 +		break;
 +	case kPegasusPrimeContinueType:
 +		saveType = kContinueSave;
 +		break;
 +	default:
 +		// There are five other possible game types on the Pippin
 +		// version, but hopefully we don't see any of those here
 +		warning("Unhandled pegasus game type '%s'", tag2str(gameType));
 +		return false;
 +	}
 +
 +	uint32 version = stream->readUint32BE();
 +	if (version != kPegasusPrimeVersion) {
 +		warning("Where did you get this save? It's a beta (v%04x)!", version & 0x7fff);
 +		return false;
 +	}
 +
 +	// Game State
 +	GameState.readGameState(stream);
 +
 +	// Energy
 +	setLastEnergyValue(stream->readUint32BE());
 +
 +	// Death reason
 +	setEnergyDeathReason(stream->readByte());
 +
 +	// Items
 +	g_allItems.readFromStream(stream);
 +
 +	// Inventory
 +	byte itemCount = stream->readByte();
 +
 +	if (itemCount > 0) {
 +		for (byte i = 0; i < itemCount; i++) {
 +			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToInventory(inv);
 +		}
 +
 +		g_interface->setCurrentInventoryItemID((ItemID)stream->readUint16BE());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = stream->readByte();
 +
 +	if (biochipCount > 0) {
 +		for (byte i = 0; i < biochipCount; i++) {
 +			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToBiochips(biochip);
 +		}
 +
 +		g_interface->setCurrentBiochipID((ItemID)stream->readUint16BE());
 +	}
 +
 +
 +	// TODO: Disc check
 +
 +	// Jump to environment
 +	jumpToNewEnvironment(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	performJump(GameState.getCurrentNeighborhood());
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->readAIRules(stream);
 +
 +	startNeighborhood();
 +
 +	// Make a new continue point if this isn't already one
 +	if (saveType == kNormalSave)
 +		makeContinuePoint();
 +
 +	return true;
 +}
 +
 +bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 +	if (g_neighborhood)
 +		g_neighborhood->flushGameState();
 +
 +	// Signature
 +	stream->writeUint32BE(kPegasusPrimeCreator);
 +
 +	if (saveType == kNormalSave)
 +		stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1);
 +	else // Continue
 +		stream->writeUint32BE(kPegasusPrimeContinueType);
 +
 +	stream->writeUint32BE(kPegasusPrimeVersion);
 +
 +	// Game State
 +	GameState.writeGameState(stream);
 +
 +	// Energy
 +	stream->writeUint32BE(getSavedEnergyValue());
 +
 +	// Death reason
 +	stream->writeByte(getEnergyDeathReason());
 +
 +	// Items
 +	g_allItems.writeToStream(stream);
 +
 +	// Inventory
 +	byte itemCount = _items.getNumItems();
 +	stream->writeByte(itemCount);
 +
 +	if (itemCount > 0) {
 +		for (uint32 i = 0; i < itemCount; i++)
 +			stream->writeUint16BE(_items.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentInventoryItem()->getObjectID());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = _biochips.getNumItems();
 +	stream->writeByte(biochipCount);
 +
 +	if (biochipCount > 0) {
 +		for (uint32 i = 0; i < biochipCount; i++)
 +			stream->writeUint16BE(_biochips.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentBiochip()->getObjectID());
 +	}
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->writeAIRules(stream);
 +
 +	return true;
 +}
 +
 +void PegasusEngine::makeContinuePoint() {
 +	// WORKAROUND: Do not attempt to make a continue point if the interface is not set
 +	// up. The original did *not* do this and attempting to restore the game using the pause
 +	// menu during the canyon/space chase sequence would segfault the game and crash the
 +	// system. Nice!
 +	if (!g_interface)
 +		return;
 +
 +	delete _continuePoint;
 +
 +	Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);
 +	writeToStream(&newPoint, kContinueSave);
 +	_continuePoint = new Common::MemoryReadStream(newPoint.getData(), newPoint.size(), DisposeAfterUse::YES);
 +}
 +
 +void PegasusEngine::loadFromContinuePoint() {
 +	// Failure to load a continue point is fatal
 +
 +	if (!_continuePoint)
 +		error("Attempting to load from non-existant continue point");
 +
 +	if (!loadFromStream(_continuePoint))
 +		error("Failed loading continue point");
 +}
 +
 +Common::Error PegasusEngine::loadGameState(int slot) {
 +	Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
 +	Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);
 +	if (!loadFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = loadFromStream(loadFile);
 +	delete loadFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
 +	Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
 +	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
 +	if (!saveFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = writeToStream(saveFile, kNormalSave);
 +	delete saveFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +void PegasusEngine::receiveNotification(Notification *notification, const NotificationFlags flags) {
 +	if (&_shellNotification == notification) {
 +		switch (flags) {
 +		case kGameStartingFlag: {
 +			useMenu(new MainMenu());
 +
 +			if (!isDemo()) {
 +				runIntro();
 +				resetIntroTimer();
 +			} else {
 +				showTempScreen("Images/Demo/NGsplashScrn.pict");
 +			}
 +
 +			if (shouldQuit())
 +				return;
 +
 +			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +			_gfx->updateDisplay();
 +			((MainMenu *)_gameMenu)->startMainMenuLoop();
 +			break;
 +		}
 +		case kPlayerDiedFlag:
 +			doDeath();
 +			break;
 +		case kNeedNewJumpFlag:
 +			performJump(GameState.getNextNeighborhood());
 +			startNeighborhood();
 +			break;
 +		default:
 +			break;
 +		}
 +	}
 +}
 +
 +void PegasusEngine::checkCallBacks() {
 +	for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +		(*it)->checkCallBacks();
 +}
 +
 +void PegasusEngine::resetIntroTimer() {
 +	if (!isDemo() && _gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		_introTimer->stopFuse();
 +		_introTimer->primeFuse(kIntroTimeOut);
 +		_introTimer->lightFuse();
 +	}
 +}
 +
 +void PegasusEngine::introTimerExpired() {
 +	if (_gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		((MainMenu *)_gameMenu)->stopMainMenuLoop();
 +
 +		bool skipped = false;
 +
 +		Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +		if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
 +			error("Failed to load little movie");
 +
 +		bool saveAllowed = swapSaveAllowed(false);
 +		bool openAllowed = swapLoadAllowed(false);
 +
 +		skipped = playMovieScaled(video, 0, 0);
 +
 +		delete video;
 +
 +		if (shouldQuit())
 +			return;
 +
 +		if (!skipped) {
 +			runIntro();
 +
 +			if (shouldQuit())
 +				return;
 +		}
 +
 +		resetIntroTimer();
 +		_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +
 +		swapSaveAllowed(saveAllowed);
 +		swapLoadAllowed(openAllowed);
 +
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	}
 +}
 +
 +void PegasusEngine::stopIntroTimer() {
 +	if (_introTimer)
 +		_introTimer->stopFuse();
 +}
 +
 +void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
 +	if (time == 0 || scale == 0)
 +		return;
 +
 +	uint32 startTime = g_system->getMillis();
 +	uint32 timeInMillis = time * 1000 / scale;
 +
 +	while (g_system->getMillis() < startTime + timeInMillis) {
 +		checkCallBacks();
 +		_gfx->updateDisplay();
 +	}
 +}
 +
 +void PegasusEngine::useMenu(GameMenu *newMenu) {
 +	if (_gameMenu) {
 +		_gameMenu->restorePreviousHandler();
 +		delete _gameMenu;
 +	}
 +
 +	_gameMenu = newMenu;
 +
 +	if (_gameMenu)
 +		_gameMenu->becomeCurrentHandler();
 +}
 +
 +bool PegasusEngine::checkGameMenu() {
 +	GameMenuCommand command = kMenuCmdNoCommand;
 +
 +	if (_gameMenu) {
 +		command = _gameMenu->getLastCommand();
 +		if (command != kMenuCmdNoCommand) {
 +			_gameMenu->clearLastCommand();
 +			doGameMenuCommand(command);
 +		}
 +	}
 +
 +	return command != kMenuCmdNoCommand;
 +}
 +
 +void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 +	Common::Error result;
 +
 +	switch (command) {
 +	case kMenuCmdStartAdventure:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(false);
 +		startNewGame();
 +		break;
 +	case kMenuCmdCredits:
 +		if (isDemo()) {
 +			showTempScreen("Images/Demo/DemoCredits.pict");
 +			_gfx->doFadeOutSync();
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		} else {
 +			stopIntroTimer();
 +			_gfx->doFadeOutSync();
 +			useMenu(new CreditsMenu());
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		}
 +		break;
 +	case kMenuCmdQuit:
 +	case kMenuCmdDeathQuitDemo:
 +		if (isDemo())
 +			showTempScreen("Images/Demo/NGquitScrn.pict");
 +		_system->quit();
 +		break;
 +	case kMenuCmdOverview:
 +		stopIntroTimer();
 +		doInterfaceOverview();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdStartWalkthrough:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(true);
 +		startNewGame();
 +		break;
 +	case kMenuCmdRestore:
 +		stopIntroTimer();
 +		// fall through
 +	case kMenuCmdDeathRestore:
 +		result = showLoadDialog();
 +		if (command == kMenuCmdRestore && result.getCode() != Common::kNoError)
 +			resetIntroTimer();
 +		break;
 +	case kMenuCmdCreditsMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdDeathContinue:
 +		if (((DeathMenu *)_gameMenu)->playerWon()) {
 +			if (isDemo()) {
 +				showTempScreen("Images/Demo/DemoCredits.pict");
 +				_gfx->doFadeOutSync();
 +				_gfx->updateDisplay();
 +				_gfx->doFadeInSync();
 +			} else {
 +				_gfx->doFadeOutSync();
 +				useMenu(0);
 +				_gfx->clearScreen();
 +				_gfx->updateDisplay();
 +
 +				Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +				if (!video->loadFile(_introDirectory + "/Closing.movie"))
 +					error("Could not load closing movie");
 +
 +				uint16 x = (640 - video->getWidth() * 2) / 2;
 +				uint16 y = (480 - video->getHeight() * 2) / 2;
 +
 +				playMovieScaled(video, x, y);
 +
 +				delete video;
 +
 +				if (shouldQuit())
 +					return;
 +
 +				useMenu(new MainMenu());
 +				_gfx->updateDisplay();
 +				((MainMenu *)_gameMenu)->startMainMenuLoop();
 +				_gfx->doFadeInSync();
 +				resetIntroTimer();
 +			}
 +		} else {
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdDeathMainMenuDemo:
 +	case kMenuCmdDeathMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdPauseSave:
 +		if (showSaveDialog().getCode() != Common::kUserCanceled)
 +			pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseContinue:
 +		pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseRestore:
 +		makeContinuePoint();
 +		result = showLoadDialog();
 +
 +		if (result.getCode() == Common::kNoError) {
 +			// Successfully loaded, unpause the game
 +			pauseMenu(false);
 +		} else if (result.getCode() != Common::kUserCanceled) {
 +			// Try to get us back to a sane state
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdPauseQuit:
 +		_gfx->doFadeOutSync();
 +		throwAwayEverything();
 +		pauseMenu(false);
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdNoCommand:
 +		break;
 +	default:
 +		error("Unknown menu command %d", command);
 +	}
 +}
 +
 +void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (!checkGameMenu())
 +		shellGameInput(input, cursorSpot);
 +
 +	// Handle the console here
 +	if (input.isConsoleRequested()) {
 +		_console->attach();
 +		_console->onFrame();
 +	}
 +
 +	// Handle save requests here
 +	if (_saveRequested && _saveAllowed) {
 +		_saveRequested = false;
 +
 +		// Can only save during a game and not in the demo
 +		if (g_neighborhood && !isDemo()) {
 +			pauseEngine(true);
 +			showSaveDialog();
 +			pauseEngine(false);
 +		}
 +	}
 +
 +	// Handle load requests here
 +	if (_loadRequested && _loadAllowed) {
 +		_loadRequested = false;
 +
 +		// WORKAROUND: Do not entertain load requests when the pause menu is up
 +		// The original did and the game entered a bad state after loading.
 +		// It's theoretically possible to make it so it does work while the
 +		// pause menu is up, but the pause state of the engine is just too weird.
 +		// Just use the pause menu's restore button since it's there for that
 +		// for you to load anyway.
 +		if (!isDemo() && !(_gameMenu && _gameMenu->getObjectID() == kPauseMenuID)) {
 +			pauseEngine(true);
 +
 +			if (g_neighborhood) {
 +				makeContinuePoint();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled)
 +					loadFromContinuePoint();
 +			} else {
 +				if (_introTimer)
 +					_introTimer->stopFuse();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError) {
 +					if (!_gameMenu) {
 +						useMenu(new MainMenu());
 +						((MainMenu *)_gameMenu)->startMainMenuLoop();
 +					}
 +
 +					resetIntroTimer();
 +				}
 +			}
 +
 +			pauseEngine(false);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::doInterfaceOverview() {
 +	static const short kNumOverviewSpots = 11;
 +	static const Common::Rect overviewSpots[kNumOverviewSpots] = {
 +		Common::Rect(354, 318, 354 + 204, 318 + 12),
 +		Common::Rect(211, 34, 211 + 114, 34 + 28),
 +		Common::Rect(502, 344, 502 + 138, 344 + 120),
 +		Common::Rect(132, 40, 132 + 79, 40 + 22),
 +		Common::Rect(325, 40, 332 + 115, 40 + 22),
 +		Common::Rect(70, 318, 70 + 284, 318 + 12),
 +		Common::Rect(76, 334, 76 + 96, 334 + 96),
 +		Common::Rect(64, 64, 64 + 512, 64 + 256),
 +		Common::Rect(364, 334, 364 + 96, 334 + 96),
 +		Common::Rect(172, 334, 172 + 192, 334 + 96),
 +		Common::Rect(542, 36, 542 + 58, 36 + 20)
 +	};
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +
 +	Picture leftBackground(kNoDisplayElement);
 +	leftBackground.initFromPICTFile("Images/Interface/OVLeft.mac");
 +	leftBackground.setDisplayOrder(0);
 +	leftBackground.moveElementTo(kBackground1Left, kBackground1Top);
 +	leftBackground.startDisplaying();
 +	leftBackground.show();
 +
 +	Picture topBackground(kNoDisplayElement);
 +	topBackground.initFromPICTFile("Images/Interface/OVTop.mac");
 +	topBackground.setDisplayOrder(0);
 +	topBackground.moveElementTo(kBackground2Left, kBackground2Top);
 +	topBackground.startDisplaying();
 +	topBackground.show();
 +
 +	Picture rightBackground(kNoDisplayElement);
 +	rightBackground.initFromPICTFile("Images/Interface/OVRight.mac");
 +	rightBackground.setDisplayOrder(0);
 +	rightBackground.moveElementTo(kBackground3Left, kBackground3Top);
 +	rightBackground.startDisplaying();
 +	rightBackground.show();
 +
 +	Picture bottomBackground(kNoDisplayElement);
 +	bottomBackground.initFromPICTFile("Images/Interface/OVBottom.mac");
 +	bottomBackground.setDisplayOrder(0);
 +	bottomBackground.moveElementTo(kBackground4Left, kBackground4Top);
 +	bottomBackground.startDisplaying();
 +	bottomBackground.show();
 +
 +	Picture controllerHighlight(kNoDisplayElement);
 +	controllerHighlight.initFromPICTFile("Images/Interface/OVcontrollerHilite.mac");
 +	controllerHighlight.setDisplayOrder(0);
 +	controllerHighlight.moveElementTo(kOverviewControllerLeft, kOverviewControllerTop);
 +	controllerHighlight.startDisplaying();
 +
 +	Movie overviewText(kNoDisplayElement);
 +	overviewText.initFromMovieFile("Images/Interface/Overview Mac.movie");
 +	overviewText.setDisplayOrder(0);
 +	overviewText.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +	overviewText.startDisplaying();
 +	overviewText.show();
 +	overviewText.redrawMovieWorld();
 +
 +	DropHighlight highlight(kNoDisplayElement);
 +	highlight.setDisplayOrder(1);
 +	highlight.startDisplaying();
 +	highlight.setHighlightThickness(4);
 +	highlight.setHighlightColor(g_system->getScreenFormat().RGBToColor(239, 239, 0));
 +	highlight.setHighlightCornerDiameter(8);
 +
 +	Input input;
 +	InputDevice.getInput(input, kFilterAllInput);
 +
 +	Common::Point cursorLoc;
 +	input.getInputLocation(cursorLoc);
 +
 +	uint16 i;
 +	for (i = 0; i < kNumOverviewSpots; ++i)
 +		if (overviewSpots[i].contains(cursorLoc))
 +			break;
 +
 +	TimeValue time;
 +	if (i == kNumOverviewSpots)
 +		time = 5;
 +	else if (i > 4)
 +		time = i + 1;
 +	else
 +		time = i;
 +
 +	if (time == 2) {
 +		highlight.hide();
 +		controllerHighlight.show();
 +	} else if (i != kNumOverviewSpots) {
 +		controllerHighlight.hide();
 +		Common::Rect r = overviewSpots[i];
 +		r.grow(5);
 +		highlight.setBounds(r);
 +		highlight.show();
 +	} else {
 +		highlight.hide();
 +		controllerHighlight.hide();
 +	}
 +
 +	overviewText.setTime(time * 3 + 2, 15);
 +	overviewText.redrawMovieWorld();
 +
 +	_cursor->setCurrentFrameIndex(3);
 +	_cursor->show();
 +
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +
 +	for (;;) {
 +		InputDevice.getInput(input, kFilterAllInput);
 +
 +		if (input.anyInput() || shouldQuit() || _loadRequested || _saveRequested)
 +			break;
 +
 +		input.getInputLocation(cursorLoc);
 +		for (i = 0; i < kNumOverviewSpots; ++i)
 +			if (overviewSpots[i].contains(cursorLoc))
 +				break;
 +
 +		if (i == kNumOverviewSpots)
 +			time = 5;
 +		else if (i > 4)
 +			time = i + 1;
 +		else
 +			time = i;
 +
 +		if (time == 2) {
 +			highlight.hide();
 +			controllerHighlight.show();
 +		} else if (i != kNumOverviewSpots) {
 +			controllerHighlight.hide();
 +			Common::Rect r = overviewSpots[i];
 +			r.grow(5);
 +			highlight.setBounds(r);
 +			highlight.show();
 +		} else {
 +			highlight.hide();
 +			controllerHighlight.hide();
 +		}
 +
 +		overviewText.setTime(time * 3 + 2, 15);
 +		overviewText.redrawMovieWorld();
 +
 +		refreshDisplay();
 +	}
 +
 +	if (shouldQuit())
 +		return;
 +
 +	highlight.hide();
 +	_cursor->hide();
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(new MainMenu());
 +	_gfx->updateDisplay();
 +	((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	_gfx->doFadeInSync();
 +
 +	_saveRequested = false;
 +	_loadRequested = false;
 +}
 +
 +void PegasusEngine::showTempScreen(const Common::String &fileName) {
 +	_gfx->doFadeOutSync();
 +
 +	Picture picture(0);
 +	picture.initFromPICTFile(fileName);
 +	picture.setDisplayOrder(kMaxAvailableOrder);
 +	picture.startDisplaying();
 +	picture.show();
 +	_gfx->updateDisplay();
 +
 +	_gfx->doFadeInSync();
 +
 +	// Wait for the next event
 +	bool done = false;
 +	while (!shouldQuit() && !done) {
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event)) {
 +			switch (event.type) {
 +			case Common::EVENT_LBUTTONUP:
 +			case Common::EVENT_RBUTTONUP:
 +			case Common::EVENT_KEYDOWN:
 +				done = true;
 +				break;
 +			default:
 +				break;
 +			}
 +		}
 +
 +		_system->delayMillis(10);
 +	}
 +}
 +
 +void PegasusEngine::refreshDisplay() {
 +	giveIdleTime();
 +	_gfx->updateDisplay();
 +}
 +
 +void PegasusEngine::resetEnergyDeathReason() {
 +	switch (getCurrentNeighborhoodID()) {
 +	case kMarsID:
 +		_deathReason = kDeathArrestedInMars;
 +		break;
 +	case kNoradAlphaID:
 +	case kNoradDeltaID:
 +		_deathReason = kDeathArrestedInNorad;
 +		break;
 +	case kWSCID:
 +		_deathReason = kDeathArrestedInWSC;
 +		break;
 +	default:
 +		_deathReason = kDeathStranded;
 +		break;
 +	}
 +}
 +
 +bool PegasusEngine::playerHasItem(const Item *item) {
 +	return playerHasItemID(item->getObjectID());
 +}
 +
 +bool PegasusEngine::playerHasItemID(const ItemID itemID) {
 +	return itemInInventory(itemID) || itemInBiochips(itemID);
 +}
 +
 +InventoryItem *PegasusEngine::getCurrentInventoryItem() {
 +	if (g_interface)
 +		return g_interface->getCurrentInventoryItem();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInInventory(InventoryItem *item) {
 +	return _items.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInInventory(ItemID id) {
 +	return _items.itemInInventory(id);
 +}
 +
 +BiochipItem *PegasusEngine::getCurrentBiochip() {
 +	if (g_interface)
 +		return g_interface->getCurrentBiochip();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInBiochips(BiochipItem *item) {
 +	return _biochips.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInBiochips(ItemID id) {
 +	return _biochips.itemInInventory(id);
 +}
 +
 +bool PegasusEngine::playerAlive() {
 +	return (_shellNotification.getNotificationFlags() & kPlayerDiedFlag) == 0;
 +}
 +
 +Common::String PegasusEngine::getBriefingMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getBriefingMovie();
 +
 +	return Common::String();
 +}
 +
 +Common::String PegasusEngine::getEnvScanMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getEnvScanMovie();
 +
 +	return Common::String();
 +}
 +
 +uint PegasusEngine::getNumHints() {
 +	if (_neighborhood)
 +		return _neighborhood->getNumHints();
 +
 +	return 0;
 +}
 +
 +Common::String PegasusEngine::getHintMovie(uint hintNum) {
 +	if (_neighborhood)
 +		return _neighborhood->getHintMovie(hintNum);
 +
 +	return Common::String();
 +}
 +
 +bool PegasusEngine::canSolve() {
 +	if (_neighborhood)
 +		return _neighborhood->canSolve();
 +
 +	return false;
 +}
 +
 +void PegasusEngine::prepareForAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->prepareForAIHint(movieName);
 +}
 +
 +void PegasusEngine::cleanUpAfterAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->cleanUpAfterAIHint(movieName);
 +}
 +
 +void PegasusEngine::jumpToNewEnvironment(const NeighborhoodID neighborhoodID, const RoomID roomID, const DirectionConstant direction) {
 +	GameState.setNextLocation(neighborhoodID, roomID, direction);
 +	_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
 +}
 +
 +void PegasusEngine::checkFlashlight() {
 +	if (_neighborhood)
 +		_neighborhood->checkFlashlight();
 +}
 +
 +bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y) {
 +	bool skipped = false;
 +
 +	while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, x, y);
 +		}
 +
 +		Input input;
 +		InputDevice.getInput(input, kFilterAllInput);
 +		if (input.anyInput() || _saveRequested || _loadRequested)
 +			skipped = true;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	return skipped;
 +}
 +
 +void PegasusEngine::die(const DeathReason reason) {
 +	Input dummy;
 +	if (isDragging())
 +		_itemDragger.stopTracking(dummy);
 +
 +	_deathReason = reason;
 +	_shellNotification.setNotificationFlags(kPlayerDiedFlag, kPlayerDiedFlag);
 +}
 +
 +void PegasusEngine::doDeath() {
 +	_gfx->doFadeOutSync();
 +	throwAwayEverything();
 +	useMenu(new DeathMenu(_deathReason));
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +}
 +
 +void PegasusEngine::throwAwayEverything() {
 +	if (_items.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentInventoryItem()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	if (_biochips.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentBiochip()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	useMenu(0);
 +	useNeighborhood(0);
 +
 +	delete g_interface;
 +	g_interface = 0;
 +}
 +
 +void PegasusEngine::processShell() {
 +	checkCallBacks();
 +	checkNotifications();
 +	InputHandler::pollForInput();
 +	refreshDisplay();
 +}
 +
 +void PegasusEngine::createInterface() {
 +	if (!g_interface)
 +		new Interface();
 +
 +	g_interface->createInterface();
 +}
 +
 +void PegasusEngine::setGameMode(const GameMode newMode) {
 +	if (newMode != _gameMode && canSwitchGameMode(newMode, _gameMode)) {
 +		switchGameMode(newMode, _gameMode);
 +		_gameMode = newMode;
 +	}
 +}
 +
 +void PegasusEngine::switchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	// Start raising panels before lowering panels, to give the activating panel time
 +	// to set itself up without cutting into the lowering panel's animation time.
 +	
 +	if (_switchModesSync) {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawerSync();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawerSync();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawerSync();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawerSync();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	} else {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawer();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawer();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawer();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawer();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	}
 +}
 +
 +bool PegasusEngine::canSwitchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	if (newMode == kModeInventoryPick && oldMode == kModeBiochipPick)
 +		return false;
 +	if (newMode == kModeBiochipPick && oldMode == kModeInventoryPick)
 +		return false;
 +	return true;
 +}
 +
 +bool PegasusEngine::itemInLocation(const ItemID itemID, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 +	NeighborhoodID itemNeighborhood;
 +	RoomID itemRoom;
 +	DirectionConstant itemDirection;
 +	
 +	Item *item = g_allItems.findItemByID(itemID);
 +	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 +
 +	return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
 +}
 +
 +InventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	do {
 +		if (g_interface)
 +			result = g_interface->addInventoryItem(item);
 +		else
 +			result = _items.addItem(item);
 +
 +		if (result == kTooMuchWeight)
 +			destroyInventoryItem(pickItemToDestroy());
 +	} while (result != kInventoryOK);
 +
 +	GameState.setTakenItem(item, true);
 +	if (g_neighborhood)
 +			g_neighborhood->pickedUpItem(item);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 +	delete _neighborhood;
 +	_neighborhood = neighborhood;
 +
 +	if (_neighborhood) {
 +		InputHandler::setInputHandler(_neighborhood);
 +		_neighborhood->init();
 +		_neighborhood->moveNavTo(kNavAreaLeft, kNavAreaTop);
 +		g_interface->setDate(_neighborhood->getDateResID());
 +	} else {
 +		InputHandler::setInputHandler(this);
 +	}
 +}
 +
 +void PegasusEngine::performJump(NeighborhoodID neighborhoodID) {
 +	if (_neighborhood)
 +		useNeighborhood(0);
 +
 +	// Sub chase is special
 +	if (neighborhoodID == kNoradSubChaseID) {
 +		throwAwayEverything();
 +		doSubChase();
 +
 +		if (shouldQuit())
 +			return;
 +
 +		neighborhoodID = kNoradDeltaID;
 +		GameState.setNextRoom(kNorad41);
 +		GameState.setNextDirection(kEast);
 +	}
 +
 +	Neighborhood *neighborhood;
 +	makeNeighborhood(neighborhoodID, neighborhood);
 +	useNeighborhood(neighborhood);
 +
 +	// Update the CD variable (used just for saves currently)
 +	_currentCD = getNeighborhoodCD(neighborhoodID);
 +}
 +
 +void PegasusEngine::startNeighborhood() {
 +	if (g_interface && _currentItemID != kNoItemID)
 +		g_interface->setCurrentInventoryItemID(_currentItemID);
 +	
 +	if (g_interface && _currentBiochipID != kNoItemID)
 +		g_interface->setCurrentBiochipID(_currentBiochipID);
 +	
 +	setGameMode(kModeNavigation);
 +	
 +	if (_neighborhood)
 +		_neighborhood->start();
 +}
 +
 +void PegasusEngine::startNewGame() {
 +	// WORKAROUND: The original game ignored the menu difficulty
 +	// setting. We're going to pass it through here so that
 +	// the menu actually makes sense now.
 +	bool isWalkthrough = GameState.getWalkthroughMode();
 +	GameState.resetGameState();
 +	GameState.setWalkthroughMode(isWalkthrough);
 +
 +	// TODO: Enable erase
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +	_gfx->updateDisplay();
 +
 +	createInterface();
 +
 +	if (isDemo()) {
 +		setLastEnergyValue(kFullEnergy);
 +		jumpToNewEnvironment(kPrehistoricID, kPrehistoric02, kSouth);
 +		GameState.setPrehistoricSeenTimeStream(false);
 +		GameState.setPrehistoricSeenFlyer1(false);
 +		GameState.setPrehistoricSeenFlyer2(false);
 +		GameState.setPrehistoricSeenBridgeZoom(false);
 +		GameState.setPrehistoricBreakerThrown(false);
 +	} else {
 +		jumpToNewEnvironment(kCaldoriaID, kCaldoria00, kEast);
 +	}
 +
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +
 +	BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
 +	addItemToBiochips(biochip);
 +
 +	if (isDemo()) {
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
 +		addItemToBiochips(biochip);
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
 +		addItemToBiochips(biochip);
 +		InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
 +		addItemToInventory(item);
 +		item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
 +		addItemToInventory(item);
 +		_currentItemID = kJourneymanKey;
 +	} else {
 +		_currentItemID = kNoItemID;
 +	}
 +
 +	_currentBiochipID = kAIBiochip;
 +
 +	// Clear jump notification flags and just perform the jump...
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	
 +	performJump(GameState.getNextNeighborhood());
 +	
 +	startNeighborhood();
 +}
 +
 +void PegasusEngine::makeNeighborhood(NeighborhoodID neighborhoodID, Neighborhood *&neighborhood) {
 +	// TODO: CD check
 +
 +	switch (neighborhoodID) {
 +	case kCaldoriaID:
 +		neighborhood = new Caldoria(g_AIArea, this);
 +		break;
 +	case kMarsID:
 +		neighborhood = new Mars(g_AIArea, this);
 +		break;
 +	case kPrehistoricID:
 +		neighborhood = new Prehistoric(g_AIArea, this);
 +		break;
 +	case kFullTSAID:
 +		neighborhood = new FullTSA(g_AIArea, this);
 +		break;
 +	case kTinyTSAID:
 +		neighborhood = new TinyTSA(g_AIArea, this);
 +		break;
 +	case kWSCID:
 +		neighborhood = new WSC(g_AIArea, this);
 +		break;
 +	case kNoradAlphaID:
 +		neighborhood = new NoradAlpha(g_AIArea, this);
 +		break;
 +	case kNoradDeltaID:
 +		createInterface();
 +		neighborhood = new NoradDelta(g_AIArea, this);
 +		break;
 +	default:
 +		error("Unknown neighborhood %d", neighborhoodID);
 +	}
 +}
 +
 +bool PegasusEngine::wantsCursor() {
 +	return _gameMenu == 0;
 +}
 +
 +void PegasusEngine::updateCursor(const Common::Point, const Hotspot *cursorSpot) {	
 +	if (_itemDragger.isTracking()) {
 +		_cursor->setCurrentFrameIndex(5);
 +	} else {
 +		if (!cursorSpot) {
 +			_cursor->setCurrentFrameIndex(0);
 +		} else {
 +			uint32 id = cursorSpot->getObjectID();
 +
 +			switch (id) {
 +			case kCurrentItemSpotID:
 +				if (countInventoryItems() != 0)
 +					_cursor->setCurrentFrameIndex(4);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +				break;
 +			default:
 +				HotSpotFlags flags = cursorSpot->getHotspotFlags();
 +
 +				if (flags & kZoomInSpotFlag)
 +					_cursor->setCurrentFrameIndex(1);
 +				else if (flags & kZoomOutSpotFlag)
 +					_cursor->setCurrentFrameIndex(2);
 +				else if (flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag))
 +					_cursor->setCurrentFrameIndex(4);
 +				else if (flags & kJMPClickingSpotFlags)
 +					_cursor->setCurrentFrameIndex(3);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +			}
 +		}
 +	}
 +}
 +
 +void PegasusEngine::toggleInventoryDisplay() {
 +	if (_gameMode == kModeInventoryPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeInventoryPick);
 +}
 +
 +void PegasusEngine::toggleBiochipDisplay() {
 +	if (_gameMode == kModeBiochipPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeBiochipPick);
 +}
 +
 +void PegasusEngine::showInfoScreen() {	
 +	if (g_neighborhood) {
 +		// Break the input handler chain...
 +		_savedHandler = InputHandler::getCurrentHandler();
 +		InputHandler::setInputHandler(this);
 +		
 +		Picture *pushPicture = ((Neighborhood *)g_neighborhood)->getTurnPushPicture();
 +		
 +		_bigInfoMovie.shareSurface(pushPicture);
 +		_smallInfoMovie.shareSurface(pushPicture);
 +
 +		g_neighborhood->hideNav();
 +
 +		_smallInfoMovie.initFromMovieFile("Images/Items/Info Right Movie");
 +		_smallInfoMovie.setDisplayOrder(kInfoSpinOrder);
 +		_smallInfoMovie.moveElementTo(kNavAreaLeft + 304, kNavAreaTop + 8);
 +		_smallInfoMovie.moveMovieBoxTo(304, 8);
 +		_smallInfoMovie.startDisplaying();
 +		_smallInfoMovie.show();
 +
 +		TimeValue startTime, stopTime;
 +		g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +		_smallInfoMovie.setSegment(startTime, stopTime);
 +		_smallInfoMovie.setTime(startTime);
 +		_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +		_bigInfoMovie.initFromMovieFile("Images/Items/Info Left Movie");
 +		_bigInfoMovie.setDisplayOrder(kInfoBackgroundOrder);
 +		_bigInfoMovie.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +		_bigInfoMovie.startDisplaying();
 +		_bigInfoMovie.show();
 +		_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +
 +		_bigInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.start();
 +	}
 +}
 +
 +void PegasusEngine::hideInfoScreen() {
 +	if (g_neighborhood) {
 +		InputHandler::setInputHandler(_savedHandler);
 +
 +		_bigInfoMovie.hide();
 +		_bigInfoMovie.stopDisplaying();
 +		_bigInfoMovie.releaseMovie();
 +
 +		_smallInfoMovie.hide();
 +		_smallInfoMovie.stopDisplaying();
 +		_smallInfoMovie.stop();
 +		_smallInfoMovie.releaseMovie();
 +
 +		g_neighborhood->showNav();
 +	}
 +}
 +
 +void PegasusEngine::raiseInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawer();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawer();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawer();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawer();
 +}
 +
 +void PegasusEngine::raiseInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::toggleInfo() {
 +	if (_gameMode == kModeInfoScreen)
 +		setGameMode(kModeNavigation);
 +	else if (_gameMode == kModeNavigation)
 +		setGameMode(kModeInfoScreen);
 +}
 +
 +void PegasusEngine::dragTerminated(const Input &) {
 +	Hotspot *finalSpot = _itemDragger.getLastHotspot();
 +	InventoryResult result;
 +
 +	if (_dragType == kDragInventoryPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kInventoryDropSpotID)
 +			result = addItemToInventory((InventoryItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragBiochipPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kBiochipDropSpotID)
 +			result = addItemToBiochips((BiochipItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragInventoryUse) {
 +		if (finalSpot && (finalSpot->getHotspotFlags() & kDropItemSpotFlag) != 0) {
 +			// *** Need to decide on a case by case basis what to do here.
 +			// the crowbar should break the cover off the Mars reactor if its frozen, the
 +			// global transport card should slide through the slot, the oxygen mask should
 +			// attach to the filling station, and so on...
 +			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
 +			delete _draggingSprite;
 +		} else {
 +			autoDragItemIntoInventory(_draggingItem, _draggingSprite);
 +		}
 +	}
 +
 +	_dragType = kDragNoDrag;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +
 +void PegasusEngine::dragItem(const Input &input, Item *item, DragType type) {	
 +	_draggingItem = item;
 +	_dragType = type;
 +
 +	// Create the sprite.
 +	_draggingSprite = _draggingItem->getDragSprite(kDraggingSpriteID);
 +	Common::Point where;
 +	input.getInputLocation(where);
 +	Common::Rect r1;
 +	_draggingSprite->getBounds(r1);
 +	r1 = Common::Rect::center(where.x, where.y, r1.width(), r1.height());
 +	_draggingSprite->setBounds(r1);
 +
 +	// Set up drag constraints.
 +	DisplayElement *navMovie = _gfx->findDisplayElement(kNavMovieID);
 +	Common::Rect r2;
 +	navMovie->getBounds(r2);
 +	r2.left -= r1.width() / 3;
 +	r2.right += r1.width() / 3;
 +	r2.top -= r1.height() / 3;
 +	r2.bottom += r2.height() / 3;
 +
 +	r1 = Common::Rect(-30000, -30000, 30000, 30000);
 +	_itemDragger.setDragConstraints(r2, r1);
 +
 +	// Start dragging.
 +	_draggingSprite->setDisplayOrder(kDragSpriteOrder);
 +	_draggingSprite->startDisplaying();
 +	_draggingSprite->show();
 +	_itemDragger.setDragSprite(_draggingSprite);
 +	_itemDragger.setNextHandler(_neighborhood);
 +	_itemDragger.startTracking(input);
 +
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +}
 +
 +void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_gameMode == kModeInfoScreen) {
 +		if (JMPPPInput::isToggleAIMiddleInput(input)) {
 +			LowerClientSignature middleOwner = g_AIArea->getMiddleAreaOwner();
 +			g_AIArea->toggleMiddleAreaOwner();
 +
 +			if (middleOwner != g_AIArea->getMiddleAreaOwner()) {
 +				_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +				_smallInfoMovie.stop();
 +				_smallInfoMovie.setFlags(0);
 +
 +				TimeValue startTime, stopTime;
 +				g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +				_smallInfoMovie.setSegment(startTime, stopTime);
 +				_smallInfoMovie.setTime(startTime);
 +				_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +				_bigInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.start();
 +			}
 +		}
 +	} else {
 +		if (JMPPPInput::isRaiseInventoryInput(input))
 +			toggleInventoryDisplay();
 +
 +		if (JMPPPInput::isRaiseBiochipsInput(input))
 +			toggleBiochipDisplay();
 +
 +		if (JMPPPInput::isTogglePauseInput(input) && _neighborhood)
 +			pauseMenu(!isPaused());
 +	}
 +
 +	if (JMPPPInput::isToggleInfoInput(input))
 +		toggleInfo();
 +}
 +
 +void PegasusEngine::activateHotspots() {
 +	if (_gameMode == kModeInfoScreen) {
 +		g_allHotspots.activateOneHotspot(kInfoReturnSpotID);
 +	} else {
 +		// Set up hot spots.
 +		if (_dragType == kDragInventoryPickup)
 +			g_allHotspots.activateOneHotspot(kInventoryDropSpotID);
 +		else if (_dragType == kDragBiochipPickup)
 +			g_allHotspots.activateOneHotspot(kBiochipDropSpotID);
 +		else if (_dragType == kDragNoDrag)
 +			g_allHotspots.activateMaskedHotspots(kShellSpotFlag);
 +	}
 +}
 +
 +bool PegasusEngine::isClickInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_cursor->isVisible() && cursorSpot)
 +		return JMPPPInput::isClickInput(input);
 +	else
 +		return false;
 +}
 +
 +InputBits PegasusEngine::getClickFilter() {
 +	return JMPPPInput::getClickInputFilter();
 +}
 +
 +void PegasusEngine::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 +	if (clickedSpot->getObjectID() == kCurrentItemSpotID) {
 +		InventoryItem *currentItem = getCurrentInventoryItem();
 +		if (currentItem) {
 +			removeItemFromInventory(currentItem);
 +			dragItem(input, currentItem, kDragInventoryUse);
 +		}
 +	} else if (clickedSpot->getObjectID() == kInfoReturnSpotID) {
 +		toggleInfo();
 +	}
 +}
 +
 +InventoryResult PegasusEngine::removeItemFromInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	if (g_interface)
 +		result = g_interface->removeInventoryItem(item);
 +	else
 +		result = _items.removeItem(item);
 +
 +	// This should never happen
 +	assert(result == kInventoryOK);
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromInventory() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromInventory();
 +	else
 +		_items.removeAllItems();
 +}
 +
 +/////////////////////////////////////////////
 +//
 +// Biochip handling.
 +
 +// Adding biochips to the biochip drawer is a little funny, because of two things:
 +//      --  We get the map biochip and pegasus biochip at the same time by dragging
 +//          one sprite in TSA
 +//      --  We can drag in more than one copy of the various biochips.
 +// Because of this we need to make sure that no more than one copy of each biochip
 +// is ever added.
 +
 +InventoryResult PegasusEngine::addItemToBiochips(BiochipItem *biochip) {
 +	InventoryResult result;
 +
 +	if (g_interface)
 +		result = g_interface->addBiochip(biochip);
 +	else
 +		result = _biochips.addItem(biochip);
 +
 +	// This can never happen
 +	assert(result == kInventoryOK);
 +
 +	GameState.setTakenItem(biochip, true);
 +
 +	if (g_neighborhood)
 +		g_neighborhood->pickedUpItem(biochip);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromBiochips() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromBiochips();
 +	else
 +		_biochips.removeAllItems();
 +}
 +
 +void PegasusEngine::setSoundFXLevel(uint16 fxLevel) {
 +	_FXLevel = fxLevel;
 +	if (_neighborhood)
 +		_neighborhood->setSoundFXLevel(fxLevel);
 +	if (g_AIArea)
 +		g_AIArea->setAIVolume(fxLevel);
 +}
 +
 +void PegasusEngine::setAmbienceLevel(uint16 ambientLevel) {
 +	_ambientLevel = ambientLevel;
 +	if (_neighborhood)
 +		_neighborhood->setAmbienceLevel(ambientLevel);
 +}
 +
 +void PegasusEngine::pauseMenu(bool menuUp) {
 +	if (menuUp) {
 +		pauseEngine(true);
 +		_screenDimmer.startDisplaying();
 +		_screenDimmer.show();
 +		_gfx->updateDisplay();
 +		useMenu(new PauseMenu());
 +	} else {
 +		pauseEngine(false);
 +		_screenDimmer.hide();
 +		_screenDimmer.stopDisplaying();
 +		useMenu(0);
 +		g_AIArea->checkMiddleArea();
 +	}
 +}
 +
 +void PegasusEngine::autoDragItemIntoRoom(Item *item, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start, stop;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Hotspot *dropSpot = _neighborhood->getItemScreenSpot(item, draggingSprite);
 +
 +	if (dropSpot) {
 +		dropSpot->getCenter(stop.x, stop.y);
 +	} else {
 +		stop.x = kNavAreaLeft + 256;
 +		stop.y = kNavAreaTop + 128;
 +	}
 +
 +	Common::Rect bounds;
 +	draggingSprite->getBounds(bounds);
 +	stop.x -= bounds.width() >> 1;
 +	stop.y -= bounds.height() >> 1;
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	_neighborhood->dropItemIntoRoom(_draggingItem, dropSpot);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Common::Rect r;
 +	draggingSprite->getBounds(r);
 +
 +	Common::Point stop((76 + 172 - r.width()) / 2, 334 - (2 * r.height() / 3));
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	addItemToInventory((InventoryItem *)_draggingItem);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +NeighborhoodID PegasusEngine::getCurrentNeighborhoodID() const {
 +	if (_neighborhood)
 +		return _neighborhood->getObjectID();
 +
 +	return kNoNeighborhoodID;
 +}
 +
 +void PegasusEngine::pauseEngineIntern(bool pause) {
 +	Engine::pauseEngineIntern(pause);
 +
 +	if (pause) {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->pause();
 +	} else {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->resume();
 +	}
 +}
 +
 +uint PegasusEngine::getRandomBit() {
 +	return _rnd->getRandomBit();
 +}
 +
 +uint PegasusEngine::getRandomNumber(uint max) {
 +	return _rnd->getRandomNumber(max);
 +}
 +
 +void PegasusEngine::shuffleArray(int32 *arr, int32 count) {	
 +	if (count > 1) {
 +		for (int32 i = 1; i < count; ++i) {
 +			int32 j = _rnd->getRandomNumber(i);
 +			if (j != i)
 +				SWAP(arr[i], arr[j]);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::playEndMessage() {
 +	if (g_interface) {
 +		allowInput(false);
 +		g_interface->playEndMessage();
 +		allowInput(true);
 +	}
 +
 +	die(kPlayerWonGame);
 +}
 +
 +void PegasusEngine::doSubChase() {
 +	static const uint32 endTime = 133200 * 1000 / 600;
 +
 +	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie"))
 +		error("Failed to load sub chase");
 +
- 	while (!shouldQuit() && !video->endOfVideo() && video->getElapsedTime() < endTime) {
++	while (!shouldQuit() && !video->endOfVideo() && video->getTime() < endTime) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, 0, 0);
 +		}
 +
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event))
 +			;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	delete video;
 +}
 +
 +void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y) {
 +	// Scale up the frame doing some simple scaling
 +	Graphics::Surface scaledFrame;
 +	scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
 +	const byte *src = (const byte *)frame->pixels;
 +	byte *dst1 = (byte *)scaledFrame.pixels;
 +	byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
 +
 +	for (int i = 0; i < frame->h; i++) {
 +		for (int j = 0; j < frame->w; j++) {
 +			memcpy(dst1, src, frame->format.bytesPerPixel);
 +			dst1 += frame->format.bytesPerPixel;
 +			memcpy(dst1, src, frame->format.bytesPerPixel);
 +			dst1 += frame->format.bytesPerPixel;
 +			memcpy(dst2, src, frame->format.bytesPerPixel);
 +			dst2 += frame->format.bytesPerPixel;
 +			memcpy(dst2, src, frame->format.bytesPerPixel);
 +			dst2 += frame->format.bytesPerPixel;
 +			src += frame->format.bytesPerPixel;
 +		}
 +
 +		src += frame->pitch - frame->format.bytesPerPixel * frame->w;
 +		dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
 +		dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
 +	}
 +
 +	_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
 +	_system->updateScreen();
 +	scaledFrame.free();
 +}
 +
 +void PegasusEngine::destroyInventoryItem(const ItemID itemID) {
 +	InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
 +
 +	ItemExtraEntry entry;
 +
 +	switch (itemID) {
 +	case kAirMask:
 +		item->findItemExtra(kRemoveAirMask, entry);
 +		item->setItemRoom(kMarsID, kMars49, kSouth);
 +		break;
 +	case kArgonCanister:
 +		item->findItemExtra(kRemoveArgon, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	case kCrowbar:
 +		item->findItemExtra(kRemoveCrowbar, entry);
 +		item->setItemRoom(kMarsID, kMars34, kSouth);
 +		break;
 +	case kJourneymanKey:
 +		item->findItemExtra(kRemoveJourneymanKey, entry);
 +		item->setItemRoom(kFullTSAID, kTSA22Red, kEast);
 +		break;
 +	case kMarsCard:
 +		item->findItemExtra(kRemoveMarsCard, entry);
 +		item->setItemRoom(kMarsID, kMars31South, kSouth);
 +		break;
 +	case kNitrogenCanister:
 +		item->findItemExtra(kRemoveNitrogen, entry);
 +		item->setItemRoom(kWSCID, kWSC02Messages, kSouth);
 +		break;
 +	case kOrangeJuiceGlassEmpty:
 +		item->findItemExtra(kRemoveGlass, entry);
 +		item->setItemRoom(kCaldoriaID, kCaldoriaReplicator, kNorth);
 +		break;
 +	case kPoisonDart:
 +		item->findItemExtra(kRemoveDart, entry);
 +		item->setItemRoom(kWSCID, kWSC01, kWest);
 +		break;
 +	case kSinclairKey:
 +		item->findItemExtra(kRemoveSinclairKey, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	default:
 +		return;
 +	}
 +
 +	g_interface->setCurrentInventoryItemID(itemID);
 +	g_AIArea->playAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
 +	removeItemFromInventory(item);
 +}
 +
 +ItemID PegasusEngine::pickItemToDestroy() {
 +/*
 +	Must pick an item to destroy
 +	
 +	Part I: Polite -- try to find an item that's been used
 +	Part II: Desperate -- return the first available item.
 +*/
 +
 +	// Polite:
 +	if (playerHasItemID(kOrangeJuiceGlassEmpty))
 +		return kOrangeJuiceGlassEmpty;
 +	if (playerHasItemID(kPoisonDart)) {
 +		if (GameState.getCurrentNeighborhood() != kWSCID ||
 +				GameState.getWSCAnalyzedDart())
 +			return kPoisonDart;
 +	}
 +	if (playerHasItemID(kJourneymanKey)) {
 +		if (GameState.getTSAState() >= kTSAPlayerGotHistoricalLog &&
 +				GameState.getTSAState() != kPlayerOnWayToPrehistoric &&
 +				GameState.getTSAState() != kPlayerWentToPrehistoric)
 +			return kJourneymanKey;
 +	}
 +	if (playerHasItemID(kMarsCard)) {
 +		if (GameState.getCurrentNeighborhood() != kMarsID || GameState.getMarsArrivedBelow())
 +			return kMarsCard;
 +	}
 +
 +	// Don't want to deal with deleting the sinclair key and argon canister, since it's
 +	// impossible to pick them up one at a time.
 +
 +	if (playerHasItemID(kNitrogenCanister)) {
 +		if (GameState.getScoringGotCardBomb() && GameState.getCurrentNeighborhood() != kMarsID)
 +			return kNitrogenCanister;
 +	}
 +	if (playerHasItemID(kCrowbar)) {
 +		if (GameState.getCurrentNeighborhood() == kWSCID) {
 +			if (GameState.getCurrentRoom() >= kWSC62)
 +				return kCrowbar;
 +		} else if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (GameState.getScoringGotCardBomb())
 +				return kCrowbar;
 +		} else
 +			return kCrowbar;
 +	}
 +	if (playerHasItemID(kAirMask)) {
 +		if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (g_neighborhood->getAirQuality(GameState.getCurrentRoom()) == kAirQualityGood)
 +				return kAirMask;
 +		} else if (GameState.getCurrentNeighborhood() != kNoradAlphaID &&
 +				GameState.getCurrentNeighborhood() != kNoradDeltaID) {
 +			return kAirMask;
 +		}
 +	}
 +
 +	// Desperate:
 +	if (playerHasItemID(kPoisonDart))
 +		return kPoisonDart;
 +	if (playerHasItemID(kJourneymanKey))
 +		return kJourneymanKey;
 +	if (playerHasItemID(kMarsCard))
 +		return kMarsCard;
 +	if (playerHasItemID(kNitrogenCanister))
 +		return kNitrogenCanister;
 +	if (playerHasItemID(kCrowbar))
 +		return kCrowbar;
 +	if (playerHasItemID(kAirMask))
 +		return kAirMask;
 +
 +	// Should never get this far...
 +	error("Could not find item to delete");
 +
 +	return kNoItemID;
 +}
 +
 +uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const {
 +	switch (neighborhood) {
 +	case kCaldoriaID:
 +	case kNoradAlphaID:
 +	case kNoradSubChaseID:
 +		return 1;
 +	case kFullTSAID:
 +	case kPrehistoricID:
 +		return 2;
 +	case kMarsID:
 +		return 3;
 +	case kWSCID:
 +	case kNoradDeltaID:
 +		return 4;
 +	case kTinyTSAID:
 +		// Tiny TSA exists on three of the CD's, so just continue
 +		// with the CD we're on
 +		return _currentCD;
 +	}
 +
 +	// Can't really happen, but it's a good fallback anyway :P
 +	return 1;
 +}
 +
 +} // End of namespace Pegasus


Commit: 9d7432a3720a646433be6fa18710720a84eda5fa
    https://github.com/scummvm/scummvm/commit/9d7432a3720a646433be6fa18710720a84eda5fa
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-24T21:37:23-07:00

Commit Message:
PEGASUS: Allow for keypad enter to be used

For consistency with keypad arrows

Changed paths:
    engines/pegasus/input.cpp



diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 0ec8907..e11be2c 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -63,6 +63,7 @@ InputDeviceManager::InputDeviceManager() {
 	_keyMap[Common::KEYCODE_LALT] = false;
 	_keyMap[Common::KEYCODE_RALT] = false;
 	_keyMap[Common::KEYCODE_e] = false;
+	_keyMap[Common::KEYCODE_KP_ENTER] = false;
 
 	g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 2, false);
 	_lastRawBits = kAllUpBits;
@@ -99,7 +100,7 @@ void InputDeviceManager::getInput(Input &input, const InputBits filter) {
 	if (_keyMap[Common::KEYCODE_RIGHT] || _keyMap[Common::KEYCODE_KP6])
 		currentBits |= (kRawButtonDown << kRightButtonShift);
 
-	if (_keyMap[Common::KEYCODE_SPACE] || _keyMap[Common::KEYCODE_RETURN])
+	if (_keyMap[Common::KEYCODE_SPACE] || _keyMap[Common::KEYCODE_RETURN] || _keyMap[Common::KEYCODE_KP_ENTER])
 		currentBits |= (kRawButtonDown << kTwoButtonShift);
 
 	if (_keyMap[Common::KEYCODE_t] || _keyMap[Common::KEYCODE_KP_EQUALS])


Commit: e67ba769b35afcdeded56ad7c278206ed014476d
    https://github.com/scummvm/scummvm/commit/e67ba769b35afcdeded56ad7c278206ed014476d
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-28T14:00:50-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
    devtools/scumm-md5.txt
    engines/agos/animation.cpp
    engines/agos/animation.h
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/sci/detection_tables.h
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/video/robot_decoder.cpp
    engines/sci/video/robot_decoder.h
    engines/scumm/detection.cpp
    engines/scumm/detection.h
    engines/scumm/detection_tables.h
    engines/scumm/scumm-md5.h
    engines/sword25/fmv/theora_decoder.cpp
    engines/sword25/fmv/theora_decoder.h
    gui/themes/translations.dat
    po/cs_CZ.po
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/coktel_decoder.cpp
    video/coktel_decoder.h
    video/psx_decoder.cpp
    video/psx_decoder.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp
    video/smk_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h





Commit: f02b696573fe4281e4890d71b74671804a5ebf41
    https://github.com/scummvm/scummvm/commit/f02b696573fe4281e4890d71b74671804a5ebf41
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-05-28T14:04:56-07:00

Commit Message:
PEGASUS: Implement setting movie volume

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index f4aa9ee..b7c025a 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -122,7 +122,8 @@ void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 }
 
 void Movie::setVolume(uint16 volume) {
-	// TODO
+	if (_video)
+		_video->setVolume(MIN<uint>(volume, 0xFF));
 }
 
 void Movie::setTime(const TimeValue time, const TimeScale scale) {


Commit: 625f6cc71657e95e0361edefa333a38910c1aca5
    https://github.com/scummvm/scummvm/commit/625f6cc71657e95e0361edefa333a38910c1aca5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-06-15T22:43:32-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A engines/dreamweb/sound.h
  A engines/gob/inter_littlered.cpp
  A engines/gob/minigames/geisha/mouth.cpp
  A engines/gob/minigames/geisha/mouth.h
  A engines/gob/minigames/geisha/submarine.cpp
  A engines/gob/minigames/geisha/submarine.h
  A engines/gob/sound/adlplayer.cpp
  A engines/gob/sound/adlplayer.h
  A engines/gob/sound/musplayer.cpp
  A engines/gob/sound/musplayer.h
  A engines/sci/engine/file.cpp
  A engines/sci/engine/file.h
    NEWS
    README
    audio/decoders/voc.cpp
    audio/mods/maxtrax.h
    audio/mods/protracker.cpp
    audio/mods/protracker.h
    audio/mods/tfmx.h
    backends/graphics/graphics.h
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/openglsdl/openglsdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.h
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/display.cpp
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_video.mm
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/osys_psp.h
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_gfx.cpp
    common/coroutines.cpp
    common/coroutines.h
    common/system.h
    common/taskbar.h
    common/updates.h
    configure
    devtools/scumm-md5.txt
    dists/scummvm.6
    engines/agi/saveload.cpp
    engines/agos/charset-fontdata.cpp
    engines/cge/events.cpp
    engines/cruise/menu.cpp
    engines/dialogs.cpp
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/keypad.cpp
    engines/dreamweb/monitor.cpp
    engines/dreamweb/newplace.cpp
    engines/dreamweb/object.cpp
    engines/dreamweb/people.cpp
    engines/dreamweb/print.cpp
    engines/dreamweb/rain.cpp
    engines/dreamweb/saveload.cpp
    engines/dreamweb/sound.cpp
    engines/dreamweb/sprite.cpp
    engines/dreamweb/stubs.cpp
    engines/dreamweb/talk.cpp
    engines/dreamweb/titles.cpp
    engines/dreamweb/use.cpp
    engines/dreamweb/vgafades.cpp
    engines/dreamweb/vgagrafx.cpp
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h
    engines/gob/cheater.h
    engines/gob/cheater_geisha.cpp
    engines/gob/detection.cpp
    engines/gob/detection_tables.h
    engines/gob/draw.cpp
    engines/gob/draw.h
    engines/gob/draw_v1.cpp
    engines/gob/draw_v2.cpp
    engines/gob/global.cpp
    engines/gob/global.h
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/init.h
    engines/gob/init_fascin.cpp
    engines/gob/init_geisha.cpp
    engines/gob/init_v1.cpp
    engines/gob/init_v2.cpp
    engines/gob/inter.cpp
    engines/gob/inter.h
    engines/gob/inter_fascin.cpp
    engines/gob/inter_geisha.cpp
    engines/gob/inter_v1.cpp
    engines/gob/inter_v2.cpp
    engines/gob/inter_v7.cpp
    engines/gob/minigames/geisha/diving.cpp
    engines/gob/minigames/geisha/evilfish.cpp
    engines/gob/minigames/geisha/evilfish.h
    engines/gob/minigames/geisha/meter.cpp
    engines/gob/minigames/geisha/meter.h
    engines/gob/minigames/geisha/penetration.cpp
    engines/gob/minigames/geisha/penetration.h
    engines/gob/module.mk
    engines/gob/mult.cpp
    engines/gob/mult_v2.cpp
    engines/gob/palanim.cpp
    engines/gob/resources.cpp
    engines/gob/resources.h
    engines/gob/sound/adlib.cpp
    engines/gob/sound/adlib.h
    engines/gob/sound/sound.cpp
    engines/gob/sound/sound.h
    engines/gob/sound/soundblaster.cpp
    engines/gob/sound/soundblaster.h
    engines/gob/surface.cpp
    engines/gob/surface.h
    engines/gob/util.cpp
    engines/gob/util.h
    engines/gob/video.cpp
    engines/gob/videoplayer.cpp
    engines/gob/videoplayer.h
    engines/groovie/cursor.cpp
    engines/hugo/console.cpp
    engines/hugo/dialogs.cpp
    engines/hugo/dialogs.h
    engines/hugo/display.cpp
    engines/hugo/display.h
    engines/hugo/file.cpp
    engines/hugo/file.h
    engines/hugo/file_v1d.cpp
    engines/hugo/file_v1w.cpp
    engines/hugo/file_v2d.cpp
    engines/hugo/file_v3d.cpp
    engines/hugo/game.h
    engines/hugo/hugo.cpp
    engines/hugo/hugo.h
    engines/hugo/intro.cpp
    engines/hugo/intro.h
    engines/hugo/inventory.cpp
    engines/hugo/inventory.h
    engines/hugo/mouse.cpp
    engines/hugo/mouse.h
    engines/hugo/object.cpp
    engines/hugo/object.h
    engines/hugo/object_v1d.cpp
    engines/hugo/object_v1w.cpp
    engines/hugo/object_v2d.cpp
    engines/hugo/object_v3d.cpp
    engines/hugo/parser.cpp
    engines/hugo/parser.h
    engines/hugo/parser_v1d.cpp
    engines/hugo/parser_v1w.cpp
    engines/hugo/parser_v2d.cpp
    engines/hugo/parser_v3d.cpp
    engines/hugo/route.cpp
    engines/hugo/route.h
    engines/hugo/schedule.cpp
    engines/hugo/schedule.h
    engines/hugo/sound.cpp
    engines/hugo/sound.h
    engines/kyra/animator_hof.cpp
    engines/kyra/animator_mr.cpp
    engines/kyra/detection_tables.h
    engines/kyra/gui_hof.cpp
    engines/kyra/gui_lok.cpp
    engines/kyra/gui_mr.cpp
    engines/kyra/gui_v1.cpp
    engines/kyra/gui_v2.cpp
    engines/kyra/items_hof.cpp
    engines/kyra/items_lok.cpp
    engines/kyra/items_mr.cpp
    engines/kyra/items_v2.cpp
    engines/kyra/kyra_hof.cpp
    engines/kyra/kyra_lok.cpp
    engines/kyra/kyra_mr.cpp
    engines/kyra/kyra_v2.cpp
    engines/kyra/screen.cpp
    engines/kyra/screen_lok.cpp
    engines/kyra/script_hof.cpp
    engines/kyra/script_lok.cpp
    engines/kyra/script_mr.cpp
    engines/kyra/sequences_lok.cpp
    engines/kyra/text_hof.cpp
    engines/kyra/text_lok.cpp
    engines/kyra/text_mr.cpp
    engines/lastexpress/data/cursor.cpp
    engines/mohawk/cursors.cpp
    engines/mohawk/myst.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/video.cpp
    engines/parallaction/saveload.cpp
    engines/pegasus/pegasus.cpp
    engines/sci/console.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics32.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/ksound.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/workarounds.cpp
    engines/sci/event.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/text32.cpp
    engines/sci/graphics/text32.h
    engines/sci/module.mk
    engines/sci/video/robot_decoder.cpp
    engines/scumm/cursor.cpp
    engines/scumm/detection.cpp
    engines/scumm/detection_tables.h
    engines/scumm/he/intern_he.h
    engines/scumm/he/logic/football.cpp
    engines/scumm/he/logic_he.cpp
    engines/scumm/he/logic_he.h
    engines/scumm/he/script_v100he.cpp
    engines/scumm/he/script_v60he.cpp
    engines/scumm/he/script_v90he.cpp
    engines/scumm/he/sound_he.cpp
    engines/scumm/script.cpp
    engines/scumm/scumm-md5.h
    engines/scumm/scumm.cpp
    engines/scumm/scumm.h
    engines/sword1/objectman.cpp
    engines/sword1/text.cpp
    engines/sword25/gfx/image/art.cpp
    engines/sword25/gfx/image/art.h
    engines/tinsel/tinsel.h
    engines/toon/anim.cpp
    engines/toon/character.cpp
    engines/toon/character.h
    engines/toon/drew.cpp
    engines/toon/drew.h
    engines/toon/flux.cpp
    engines/toon/flux.h
    engines/toon/path.cpp
    engines/toon/path.h
    engines/toon/toon.cpp
    engines/tsage/scenes.cpp
    graphics/cursorman.cpp
    graphics/cursorman.h
    graphics/scaler.cpp
    graphics/scaler/aspect.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/ThemeParser.cpp
    gui/ThemeParser.h
    gui/launcher.cpp
    gui/saveload.cpp
    gui/saveload.h
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/widget.cpp
    gui/widget.h
    video/codecs/qtrle.cpp
    video/codecs/qtrle.h
    video/codecs/rpza.cpp
    video/codecs/rpza.h
    video/coktel_decoder.cpp
    video/coktel_decoder.h



diff --cc engines/pegasus/pegasus.cpp
index 1665b47,0000000..43ffc4c
mode 100644,000000..100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@@ -1,2294 -1,0 +1,2292 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/config-manager.h"
 +#include "common/error.h"
 +#include "common/events.h"
 +#include "common/fs.h"
 +#include "common/file.h"
 +#include "common/memstream.h"
 +#include "common/savefile.h"
 +#include "common/textconsole.h"
 +#include "common/translation.h"
 +#include "common/random.h"
 +#include "base/plugins.h"
 +#include "base/version.h"
 +#include "gui/saveload.h"
 +#include "video/qt_decoder.h"
 +
 +#include "pegasus/console.h"
 +#include "pegasus/cursor.h"
 +#include "pegasus/energymonitor.h"
 +#include "pegasus/gamestate.h"
 +#include "pegasus/interface.h"
 +#include "pegasus/menu.h"
 +#include "pegasus/movie.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/timers.h"
 +#include "pegasus/ai/ai_area.h"
 +#include "pegasus/items/itemlist.h"
 +#include "pegasus/items/biochips/aichip.h"
 +#include "pegasus/items/biochips/biochipitem.h"
 +#include "pegasus/items/biochips/mapchip.h"
 +#include "pegasus/items/biochips/opticalchip.h"
 +#include "pegasus/items/biochips/pegasuschip.h"
 +#include "pegasus/items/biochips/retscanchip.h"
 +#include "pegasus/items/biochips/shieldchip.h"
 +#include "pegasus/items/inventory/airmask.h"
 +#include "pegasus/items/inventory/gascanister.h"
 +#include "pegasus/items/inventory/inventoryitem.h"
 +#include "pegasus/items/inventory/keycard.h"
 +#include "pegasus/neighborhood/neighborhood.h"
 +#include "pegasus/neighborhood/caldoria/caldoria.h"
 +#include "pegasus/neighborhood/mars/mars.h"
 +#include "pegasus/neighborhood/norad/constants.h"
 +#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 +#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 +#include "pegasus/neighborhood/prehistoric/prehistoric.h"
 +#include "pegasus/neighborhood/tsa/fulltsa.h"
 +#include "pegasus/neighborhood/tsa/tinytsa.h"
 +#include "pegasus/neighborhood/wsc/wsc.h"
 +
 +namespace Pegasus {
 +
 +PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
 +		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID), _itemDragger(this), _bigInfoMovie(kNoDisplayElement),
 +		_smallInfoMovie(kNoDisplayElement) {
 +	_continuePoint = 0;
 +	_saveAllowed = _loadAllowed = true;
 +	_saveRequested = _loadRequested = false;
 +	_gameMenu = 0;
 +	_deathReason = kDeathStranded;
 +	_neighborhood = 0;
 +	_FXLevel = 0x80;
 +	_ambientLevel = 0x80;
 +	_gameMode = kNoMode;
 +	_switchModesSync = false;
 +	_draggingItem = 0;
 +	_dragType = kDragNoDrag;
 +	_idlerHead = 0;
 +	_currentCD = 1;
 +	_introTimer = 0;
 +	_aiSaveStream = 0;
 +}
 +
 +PegasusEngine::~PegasusEngine() {
 +	delete _resFork;
 +	delete _console;
 +	delete _cursor;
 +	delete _continuePoint;
 +	delete _gameMenu;
 +	delete _neighborhood;
 +	delete _rnd;
 +	delete _introTimer;
 +	delete _aiSaveStream;
 +	InputDeviceManager::destroy();
 +
 +	// NOTE: This must be deleted last!
 +	delete _gfx;
 +}
 +
 +void introTimerExpiredFunction(FunctionPtr *, void *) {
 +	((PegasusEngine *)g_engine)->introTimerExpired();
 +}
 +
 +Common::Error PegasusEngine::run() {
 +	_console = new PegasusConsole(this);
 +	_gfx = new GraphicsManager(this);
 +	_resFork = new Common::MacResManager();
 +	_cursor = new Cursor();
 +	_rnd = new Common::RandomSource("Pegasus");
 +	
 +	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 +		error("Could not load JMP PP Resources");
 +
 +	// Initialize items
 +	createItems();
 +
 +	// Initialize cursors
 +	_cursor->addCursorFrames(0x80); // Main
 +	_cursor->addCursorFrames(900);  // Mars Shuttle
 +
 +	// Initialize the item dragger bounds
 +	_itemDragger.setHighlightBounds();
 +
 +	if (!isDemo() && !detectOpeningClosingDirectory()) {
 +		Common::String message = "Missing intro directory. ";
 +
 +		// Give Mac OS X a more specific message because we can
 +#ifdef MACOSX
 +		message += "Make sure \"Opening/Closing\" is present.";
 +#else
 +		message += "Be sure to rename \"Opening/Closing\" to \"Opening_Closing\".";
 +#endif
 +
 +		GUIErrorMessage(message);
 +		warning("%s", message.c_str());
 +		return Common::kNoGameDataFoundError;
 +	}
 +
 +	// Set up input
 +	InputHandler::setInputHandler(this);
 +	allowInput(true);
 +
 +	// Set up inventories
 +	_items.setWeightLimit(9);
 +	_items.setOwnerID(kPlayerID);
 +	_biochips.setWeightLimit(8);
 +	_biochips.setOwnerID(kPlayerID);
 +
 +	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 +	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 +	g_allHotspots.push_back(&_returnHotspot);
 +
 +	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 +	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
 +
 +	// Load from the launcher/cli if requested (and don't show the intro in those cases)
 +	bool doIntro = true;
 +	if (ConfMan.hasKey("save_slot")) {
 +		uint32 gameToLoad = ConfMan.getInt("save_slot");
 +		doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError);
 +	}
 +
 +	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
 +
 +	if (doIntro)
 +		// Start up the first notification
 +		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
 +
 +	if (!isDemo()) {
 +		_introTimer = new FuseFunction();
 +		_introTimer->setFunctionPtr(&introTimerExpiredFunction, 0);
 +	}
 +
 +	while (!shouldQuit()) {
 +		processShell();
 +		_system->delayMillis(10); // Ease off the CPU
 +	}
 +
 +	return Common::kNoError;
 +}
 +
 +bool PegasusEngine::detectOpeningClosingDirectory() {
 +	// We need to detect what our Opening/Closing directory is listed as
 +	// On the original disc, it was 'Opening/Closing' but only HFS(+) supports the slash
 +	// Mac OS X will display this as 'Opening:Closing' and we can use that directly
 +	// On other systems, users will need to rename to "Opening_Closing"
 +
 +	Common::FSNode gameDataDir(ConfMan.get("path"));
 +	gameDataDir = gameDataDir.getChild("Images");
 +
 +	if (!gameDataDir.exists())
 +		return false;
 +
 +	Common::FSList fsList;
 +	if (!gameDataDir.getChildren(fsList, Common::FSNode::kListDirectoriesOnly, true))
 +		return false;
 +
 +	for (uint i = 0; i < fsList.size() && _introDirectory.empty(); i++) {
 +		Common::String name = fsList[i].getName();
 +
 +		if (name.equalsIgnoreCase("Opening:Closing"))
 +			_introDirectory = name;
 +		else if (name.equalsIgnoreCase("Opening_Closing"))
 +			_introDirectory = name;
 +	}
 +
 +	if (_introDirectory.empty())
 +		return false;
 +
 +	debug(0, "Detected intro location as '%s'", _introDirectory.c_str());
 +	_introDirectory = Common::String("Images/") + _introDirectory;
 +	return true;
 +}
 +
 +void PegasusEngine::createItems() {
 +	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 +
 +	uint16 entryCount = res->readUint16BE();
 +
 +	for (uint16 i = 0; i < entryCount; i++) {
 +		ItemID itemID = res->readUint16BE();
 +		NeighborhoodID neighborhoodID = res->readUint16BE();
 +		RoomID roomID = res->readUint16BE();
 +		DirectionConstant direction = res->readByte();
 +		res->readByte(); // alignment
 +
 +		createItem(itemID, neighborhoodID, roomID, direction);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction) {
 +	switch (itemID) {
 +	case kInterfaceBiochip:
 +		// Unused in game, but still in the data and we need to create
 +		// it because it's saved/loaded from save files.
 +		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kAIBiochip:
 +		new AIChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kPegasusBiochip:
 +		new PegasusChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kOpticalBiochip:
 +		new OpticalChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kMapBiochip:
 +		new MapChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kRetinalScanBiochip:
 +		new RetScanChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kShieldBiochip:
 +		new ShieldChip(itemID, neighborhoodID, roomID, direction);
 +		break;		
 +	case kAirMask:
 +		new AirMask(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kKeyCard:
 +		new KeyCard(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kGasCanister:
 +		new GasCanister(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	default:
 +		// Everything else is a normal inventory item
 +		new InventoryItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	}
 +}
 +
 +void PegasusEngine::runIntro() {
 +	stopIntroTimer();
 +
 +	bool skipped = false;
 +
 +	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
 +		while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +			if (video->needsUpdate()) {
 +				const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +				if (frame) {
 +					_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
 +					_system->updateScreen();
 +				}
 +			}
 +
 +			Input input;
 +			InputDevice.getInput(input, kFilterAllInput);
 +			if (input.anyInput())
 +				skipped = true;
 +
 +			_system->delayMillis(10);
 +		}
 +	}
 +
 +	delete video;
 +
 +	if (shouldQuit() || skipped)
 +		return;
 +
 +	video = new Video::QuickTimeDecoder();
 +
 +	if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
 +		error("Could not load intro movie");
 +
 +	video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
 +
 +	playMovieScaled(video, 0, 0);
 +
 +	delete video;
 +}
 +
 +Common::Error PegasusEngine::showLoadDialog() {
- 	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"));
- 	slc.setSaveMode(false);
++	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (loadGameState(slot).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	slc.close();
 +
 +	return result;
 +}
 +
 +Common::Error PegasusEngine::showSaveDialog() {
- 	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"));
- 	slc.setSaveMode(true);
++	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (saveGameState(slot, slc.getResultString()).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	slc.close();
 +
 +	return result;
 +}
 +
 +GUI::Debugger *PegasusEngine::getDebugger() {
 +	return _console;
 +}
 +
 +void PegasusEngine::addIdler(Idler *idler) {
 +	idler->_nextIdler = _idlerHead;
 +	if (_idlerHead)
 +		_idlerHead->_prevIdler = idler;
 +	idler->_prevIdler = 0;
 +	_idlerHead = idler;
 +}
 +
 +void PegasusEngine::removeIdler(Idler *idler) {
 +	if (idler->_prevIdler)
 +		idler->_prevIdler->_nextIdler = idler->_nextIdler;
 +	if (idler->_nextIdler)
 +		idler->_nextIdler->_prevIdler = idler->_prevIdler;
 +	if (idler == _idlerHead)
 +		_idlerHead = idler->_nextIdler;
 +	idler->_nextIdler = 0;
 +	idler->_prevIdler = 0;
 +}
 +
 +void PegasusEngine::giveIdleTime() {
 +	for (Idler *idler = _idlerHead; idler != 0; idler = idler->_nextIdler)
 +		idler->useIdleTime();
 +}
 +
 +void PegasusEngine::addTimeBase(TimeBase *timeBase) {
 +	_timeBases.push_back(timeBase);
 +}
 +
 +void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
 +	_timeBases.remove(timeBase);
 +}
 +
 +bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 +	// Dispose currently running stuff
 +	useMenu(0);
 +	useNeighborhood(0);
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +	_currentItemID = kNoItemID;
 +	_currentBiochipID = kNoItemID;
 +
 +	if (!g_interface)
 +		createInterface();
 +
 +	// Signature
 +	uint32 creator = stream->readUint32BE();
 +	if (creator != kPegasusPrimeCreator) {
 +		warning("Bad save creator '%s'", tag2str(creator));
 +		return false;
 +	}
 +
 +	uint32 gameType = stream->readUint32BE();
 +	int saveType;
 +
 +	switch (gameType) {
 +	case kPegasusPrimeDisk1GameType:
 +	case kPegasusPrimeDisk2GameType:
 +	case kPegasusPrimeDisk3GameType:
 +	case kPegasusPrimeDisk4GameType:
 +		_currentCD = gameType - kPegasusPrimeDisk1GameType + 1;
 +		saveType = kNormalSave;
 +		break;
 +	case kPegasusPrimeContinueType:
 +		saveType = kContinueSave;
 +		break;
 +	default:
 +		// There are five other possible game types on the Pippin
 +		// version, but hopefully we don't see any of those here
 +		warning("Unhandled pegasus game type '%s'", tag2str(gameType));
 +		return false;
 +	}
 +
 +	uint32 version = stream->readUint32BE();
 +	if (version != kPegasusPrimeVersion) {
 +		warning("Where did you get this save? It's a beta (v%04x)!", version & 0x7fff);
 +		return false;
 +	}
 +
 +	// Game State
 +	GameState.readGameState(stream);
 +
 +	// Energy
 +	setLastEnergyValue(stream->readUint32BE());
 +
 +	// Death reason
 +	setEnergyDeathReason(stream->readByte());
 +
 +	// Items
 +	g_allItems.readFromStream(stream);
 +
 +	// Inventory
 +	byte itemCount = stream->readByte();
 +
 +	if (itemCount > 0) {
 +		for (byte i = 0; i < itemCount; i++) {
 +			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToInventory(inv);
 +		}
 +
 +		g_interface->setCurrentInventoryItemID((ItemID)stream->readUint16BE());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = stream->readByte();
 +
 +	if (biochipCount > 0) {
 +		for (byte i = 0; i < biochipCount; i++) {
 +			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToBiochips(biochip);
 +		}
 +
 +		g_interface->setCurrentBiochipID((ItemID)stream->readUint16BE());
 +	}
 +
 +
 +	// TODO: Disc check
 +
 +	// Jump to environment
 +	jumpToNewEnvironment(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	performJump(GameState.getCurrentNeighborhood());
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->readAIRules(stream);
 +
 +	startNeighborhood();
 +
 +	// Make a new continue point if this isn't already one
 +	if (saveType == kNormalSave)
 +		makeContinuePoint();
 +
 +	return true;
 +}
 +
 +bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 +	if (g_neighborhood)
 +		g_neighborhood->flushGameState();
 +
 +	// Signature
 +	stream->writeUint32BE(kPegasusPrimeCreator);
 +
 +	if (saveType == kNormalSave)
 +		stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1);
 +	else // Continue
 +		stream->writeUint32BE(kPegasusPrimeContinueType);
 +
 +	stream->writeUint32BE(kPegasusPrimeVersion);
 +
 +	// Game State
 +	GameState.writeGameState(stream);
 +
 +	// Energy
 +	stream->writeUint32BE(getSavedEnergyValue());
 +
 +	// Death reason
 +	stream->writeByte(getEnergyDeathReason());
 +
 +	// Items
 +	g_allItems.writeToStream(stream);
 +
 +	// Inventory
 +	byte itemCount = _items.getNumItems();
 +	stream->writeByte(itemCount);
 +
 +	if (itemCount > 0) {
 +		for (uint32 i = 0; i < itemCount; i++)
 +			stream->writeUint16BE(_items.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentInventoryItem()->getObjectID());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = _biochips.getNumItems();
 +	stream->writeByte(biochipCount);
 +
 +	if (biochipCount > 0) {
 +		for (uint32 i = 0; i < biochipCount; i++)
 +			stream->writeUint16BE(_biochips.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentBiochip()->getObjectID());
 +	}
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->writeAIRules(stream);
 +
 +	return true;
 +}
 +
 +void PegasusEngine::makeContinuePoint() {
 +	// WORKAROUND: Do not attempt to make a continue point if the interface is not set
 +	// up. The original did *not* do this and attempting to restore the game using the pause
 +	// menu during the canyon/space chase sequence would segfault the game and crash the
 +	// system. Nice!
 +	if (!g_interface)
 +		return;
 +
 +	delete _continuePoint;
 +
 +	Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);
 +	writeToStream(&newPoint, kContinueSave);
 +	_continuePoint = new Common::MemoryReadStream(newPoint.getData(), newPoint.size(), DisposeAfterUse::YES);
 +}
 +
 +void PegasusEngine::loadFromContinuePoint() {
 +	// Failure to load a continue point is fatal
 +
 +	if (!_continuePoint)
 +		error("Attempting to load from non-existant continue point");
 +
 +	if (!loadFromStream(_continuePoint))
 +		error("Failed loading continue point");
 +}
 +
 +Common::Error PegasusEngine::loadGameState(int slot) {
 +	Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
 +	Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);
 +	if (!loadFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = loadFromStream(loadFile);
 +	delete loadFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
 +	Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
 +	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
 +	if (!saveFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = writeToStream(saveFile, kNormalSave);
 +	delete saveFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +void PegasusEngine::receiveNotification(Notification *notification, const NotificationFlags flags) {
 +	if (&_shellNotification == notification) {
 +		switch (flags) {
 +		case kGameStartingFlag: {
 +			useMenu(new MainMenu());
 +
 +			if (!isDemo()) {
 +				runIntro();
 +				resetIntroTimer();
 +			} else {
 +				showTempScreen("Images/Demo/NGsplashScrn.pict");
 +			}
 +
 +			if (shouldQuit())
 +				return;
 +
 +			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +			_gfx->updateDisplay();
 +			((MainMenu *)_gameMenu)->startMainMenuLoop();
 +			break;
 +		}
 +		case kPlayerDiedFlag:
 +			doDeath();
 +			break;
 +		case kNeedNewJumpFlag:
 +			performJump(GameState.getNextNeighborhood());
 +			startNeighborhood();
 +			break;
 +		default:
 +			break;
 +		}
 +	}
 +}
 +
 +void PegasusEngine::checkCallBacks() {
 +	for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +		(*it)->checkCallBacks();
 +}
 +
 +void PegasusEngine::resetIntroTimer() {
 +	if (!isDemo() && _gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		_introTimer->stopFuse();
 +		_introTimer->primeFuse(kIntroTimeOut);
 +		_introTimer->lightFuse();
 +	}
 +}
 +
 +void PegasusEngine::introTimerExpired() {
 +	if (_gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		((MainMenu *)_gameMenu)->stopMainMenuLoop();
 +
 +		bool skipped = false;
 +
 +		Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +		if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
 +			error("Failed to load little movie");
 +
 +		bool saveAllowed = swapSaveAllowed(false);
 +		bool openAllowed = swapLoadAllowed(false);
 +
 +		skipped = playMovieScaled(video, 0, 0);
 +
 +		delete video;
 +
 +		if (shouldQuit())
 +			return;
 +
 +		if (!skipped) {
 +			runIntro();
 +
 +			if (shouldQuit())
 +				return;
 +		}
 +
 +		resetIntroTimer();
 +		_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +
 +		swapSaveAllowed(saveAllowed);
 +		swapLoadAllowed(openAllowed);
 +
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	}
 +}
 +
 +void PegasusEngine::stopIntroTimer() {
 +	if (_introTimer)
 +		_introTimer->stopFuse();
 +}
 +
 +void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
 +	if (time == 0 || scale == 0)
 +		return;
 +
 +	uint32 startTime = g_system->getMillis();
 +	uint32 timeInMillis = time * 1000 / scale;
 +
 +	while (g_system->getMillis() < startTime + timeInMillis) {
 +		checkCallBacks();
 +		_gfx->updateDisplay();
 +	}
 +}
 +
 +void PegasusEngine::useMenu(GameMenu *newMenu) {
 +	if (_gameMenu) {
 +		_gameMenu->restorePreviousHandler();
 +		delete _gameMenu;
 +	}
 +
 +	_gameMenu = newMenu;
 +
 +	if (_gameMenu)
 +		_gameMenu->becomeCurrentHandler();
 +}
 +
 +bool PegasusEngine::checkGameMenu() {
 +	GameMenuCommand command = kMenuCmdNoCommand;
 +
 +	if (_gameMenu) {
 +		command = _gameMenu->getLastCommand();
 +		if (command != kMenuCmdNoCommand) {
 +			_gameMenu->clearLastCommand();
 +			doGameMenuCommand(command);
 +		}
 +	}
 +
 +	return command != kMenuCmdNoCommand;
 +}
 +
 +void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 +	Common::Error result;
 +
 +	switch (command) {
 +	case kMenuCmdStartAdventure:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(false);
 +		startNewGame();
 +		break;
 +	case kMenuCmdCredits:
 +		if (isDemo()) {
 +			showTempScreen("Images/Demo/DemoCredits.pict");
 +			_gfx->doFadeOutSync();
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		} else {
 +			stopIntroTimer();
 +			_gfx->doFadeOutSync();
 +			useMenu(new CreditsMenu());
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		}
 +		break;
 +	case kMenuCmdQuit:
 +	case kMenuCmdDeathQuitDemo:
 +		if (isDemo())
 +			showTempScreen("Images/Demo/NGquitScrn.pict");
 +		_system->quit();
 +		break;
 +	case kMenuCmdOverview:
 +		stopIntroTimer();
 +		doInterfaceOverview();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdStartWalkthrough:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(true);
 +		startNewGame();
 +		break;
 +	case kMenuCmdRestore:
 +		stopIntroTimer();
 +		// fall through
 +	case kMenuCmdDeathRestore:
 +		result = showLoadDialog();
 +		if (command == kMenuCmdRestore && result.getCode() != Common::kNoError)
 +			resetIntroTimer();
 +		break;
 +	case kMenuCmdCreditsMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdDeathContinue:
 +		if (((DeathMenu *)_gameMenu)->playerWon()) {
 +			if (isDemo()) {
 +				showTempScreen("Images/Demo/DemoCredits.pict");
 +				_gfx->doFadeOutSync();
 +				_gfx->updateDisplay();
 +				_gfx->doFadeInSync();
 +			} else {
 +				_gfx->doFadeOutSync();
 +				useMenu(0);
 +				_gfx->clearScreen();
 +				_gfx->updateDisplay();
 +
 +				Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +				if (!video->loadFile(_introDirectory + "/Closing.movie"))
 +					error("Could not load closing movie");
 +
 +				uint16 x = (640 - video->getWidth() * 2) / 2;
 +				uint16 y = (480 - video->getHeight() * 2) / 2;
 +
 +				playMovieScaled(video, x, y);
 +
 +				delete video;
 +
 +				if (shouldQuit())
 +					return;
 +
 +				useMenu(new MainMenu());
 +				_gfx->updateDisplay();
 +				((MainMenu *)_gameMenu)->startMainMenuLoop();
 +				_gfx->doFadeInSync();
 +				resetIntroTimer();
 +			}
 +		} else {
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdDeathMainMenuDemo:
 +	case kMenuCmdDeathMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdPauseSave:
 +		if (showSaveDialog().getCode() != Common::kUserCanceled)
 +			pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseContinue:
 +		pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseRestore:
 +		makeContinuePoint();
 +		result = showLoadDialog();
 +
 +		if (result.getCode() == Common::kNoError) {
 +			// Successfully loaded, unpause the game
 +			pauseMenu(false);
 +		} else if (result.getCode() != Common::kUserCanceled) {
 +			// Try to get us back to a sane state
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdPauseQuit:
 +		_gfx->doFadeOutSync();
 +		throwAwayEverything();
 +		pauseMenu(false);
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdNoCommand:
 +		break;
 +	default:
 +		error("Unknown menu command %d", command);
 +	}
 +}
 +
 +void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (!checkGameMenu())
 +		shellGameInput(input, cursorSpot);
 +
 +	// Handle the console here
 +	if (input.isConsoleRequested()) {
 +		_console->attach();
 +		_console->onFrame();
 +	}
 +
 +	// Handle save requests here
 +	if (_saveRequested && _saveAllowed) {
 +		_saveRequested = false;
 +
 +		// Can only save during a game and not in the demo
 +		if (g_neighborhood && !isDemo()) {
 +			pauseEngine(true);
 +			showSaveDialog();
 +			pauseEngine(false);
 +		}
 +	}
 +
 +	// Handle load requests here
 +	if (_loadRequested && _loadAllowed) {
 +		_loadRequested = false;
 +
 +		// WORKAROUND: Do not entertain load requests when the pause menu is up
 +		// The original did and the game entered a bad state after loading.
 +		// It's theoretically possible to make it so it does work while the
 +		// pause menu is up, but the pause state of the engine is just too weird.
 +		// Just use the pause menu's restore button since it's there for that
 +		// for you to load anyway.
 +		if (!isDemo() && !(_gameMenu && _gameMenu->getObjectID() == kPauseMenuID)) {
 +			pauseEngine(true);
 +
 +			if (g_neighborhood) {
 +				makeContinuePoint();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled)
 +					loadFromContinuePoint();
 +			} else {
 +				if (_introTimer)
 +					_introTimer->stopFuse();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError) {
 +					if (!_gameMenu) {
 +						useMenu(new MainMenu());
 +						((MainMenu *)_gameMenu)->startMainMenuLoop();
 +					}
 +
 +					resetIntroTimer();
 +				}
 +			}
 +
 +			pauseEngine(false);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::doInterfaceOverview() {
 +	static const short kNumOverviewSpots = 11;
 +	static const Common::Rect overviewSpots[kNumOverviewSpots] = {
 +		Common::Rect(354, 318, 354 + 204, 318 + 12),
 +		Common::Rect(211, 34, 211 + 114, 34 + 28),
 +		Common::Rect(502, 344, 502 + 138, 344 + 120),
 +		Common::Rect(132, 40, 132 + 79, 40 + 22),
 +		Common::Rect(325, 40, 332 + 115, 40 + 22),
 +		Common::Rect(70, 318, 70 + 284, 318 + 12),
 +		Common::Rect(76, 334, 76 + 96, 334 + 96),
 +		Common::Rect(64, 64, 64 + 512, 64 + 256),
 +		Common::Rect(364, 334, 364 + 96, 334 + 96),
 +		Common::Rect(172, 334, 172 + 192, 334 + 96),
 +		Common::Rect(542, 36, 542 + 58, 36 + 20)
 +	};
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +
 +	Picture leftBackground(kNoDisplayElement);
 +	leftBackground.initFromPICTFile("Images/Interface/OVLeft.mac");
 +	leftBackground.setDisplayOrder(0);
 +	leftBackground.moveElementTo(kBackground1Left, kBackground1Top);
 +	leftBackground.startDisplaying();
 +	leftBackground.show();
 +
 +	Picture topBackground(kNoDisplayElement);
 +	topBackground.initFromPICTFile("Images/Interface/OVTop.mac");
 +	topBackground.setDisplayOrder(0);
 +	topBackground.moveElementTo(kBackground2Left, kBackground2Top);
 +	topBackground.startDisplaying();
 +	topBackground.show();
 +
 +	Picture rightBackground(kNoDisplayElement);
 +	rightBackground.initFromPICTFile("Images/Interface/OVRight.mac");
 +	rightBackground.setDisplayOrder(0);
 +	rightBackground.moveElementTo(kBackground3Left, kBackground3Top);
 +	rightBackground.startDisplaying();
 +	rightBackground.show();
 +
 +	Picture bottomBackground(kNoDisplayElement);
 +	bottomBackground.initFromPICTFile("Images/Interface/OVBottom.mac");
 +	bottomBackground.setDisplayOrder(0);
 +	bottomBackground.moveElementTo(kBackground4Left, kBackground4Top);
 +	bottomBackground.startDisplaying();
 +	bottomBackground.show();
 +
 +	Picture controllerHighlight(kNoDisplayElement);
 +	controllerHighlight.initFromPICTFile("Images/Interface/OVcontrollerHilite.mac");
 +	controllerHighlight.setDisplayOrder(0);
 +	controllerHighlight.moveElementTo(kOverviewControllerLeft, kOverviewControllerTop);
 +	controllerHighlight.startDisplaying();
 +
 +	Movie overviewText(kNoDisplayElement);
 +	overviewText.initFromMovieFile("Images/Interface/Overview Mac.movie");
 +	overviewText.setDisplayOrder(0);
 +	overviewText.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +	overviewText.startDisplaying();
 +	overviewText.show();
 +	overviewText.redrawMovieWorld();
 +
 +	DropHighlight highlight(kNoDisplayElement);
 +	highlight.setDisplayOrder(1);
 +	highlight.startDisplaying();
 +	highlight.setHighlightThickness(4);
 +	highlight.setHighlightColor(g_system->getScreenFormat().RGBToColor(239, 239, 0));
 +	highlight.setHighlightCornerDiameter(8);
 +
 +	Input input;
 +	InputDevice.getInput(input, kFilterAllInput);
 +
 +	Common::Point cursorLoc;
 +	input.getInputLocation(cursorLoc);
 +
 +	uint16 i;
 +	for (i = 0; i < kNumOverviewSpots; ++i)
 +		if (overviewSpots[i].contains(cursorLoc))
 +			break;
 +
 +	TimeValue time;
 +	if (i == kNumOverviewSpots)
 +		time = 5;
 +	else if (i > 4)
 +		time = i + 1;
 +	else
 +		time = i;
 +
 +	if (time == 2) {
 +		highlight.hide();
 +		controllerHighlight.show();
 +	} else if (i != kNumOverviewSpots) {
 +		controllerHighlight.hide();
 +		Common::Rect r = overviewSpots[i];
 +		r.grow(5);
 +		highlight.setBounds(r);
 +		highlight.show();
 +	} else {
 +		highlight.hide();
 +		controllerHighlight.hide();
 +	}
 +
 +	overviewText.setTime(time * 3 + 2, 15);
 +	overviewText.redrawMovieWorld();
 +
 +	_cursor->setCurrentFrameIndex(3);
 +	_cursor->show();
 +
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +
 +	for (;;) {
 +		InputDevice.getInput(input, kFilterAllInput);
 +
 +		if (input.anyInput() || shouldQuit() || _loadRequested || _saveRequested)
 +			break;
 +
 +		input.getInputLocation(cursorLoc);
 +		for (i = 0; i < kNumOverviewSpots; ++i)
 +			if (overviewSpots[i].contains(cursorLoc))
 +				break;
 +
 +		if (i == kNumOverviewSpots)
 +			time = 5;
 +		else if (i > 4)
 +			time = i + 1;
 +		else
 +			time = i;
 +
 +		if (time == 2) {
 +			highlight.hide();
 +			controllerHighlight.show();
 +		} else if (i != kNumOverviewSpots) {
 +			controllerHighlight.hide();
 +			Common::Rect r = overviewSpots[i];
 +			r.grow(5);
 +			highlight.setBounds(r);
 +			highlight.show();
 +		} else {
 +			highlight.hide();
 +			controllerHighlight.hide();
 +		}
 +
 +		overviewText.setTime(time * 3 + 2, 15);
 +		overviewText.redrawMovieWorld();
 +
 +		refreshDisplay();
 +	}
 +
 +	if (shouldQuit())
 +		return;
 +
 +	highlight.hide();
 +	_cursor->hide();
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(new MainMenu());
 +	_gfx->updateDisplay();
 +	((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	_gfx->doFadeInSync();
 +
 +	_saveRequested = false;
 +	_loadRequested = false;
 +}
 +
 +void PegasusEngine::showTempScreen(const Common::String &fileName) {
 +	_gfx->doFadeOutSync();
 +
 +	Picture picture(0);
 +	picture.initFromPICTFile(fileName);
 +	picture.setDisplayOrder(kMaxAvailableOrder);
 +	picture.startDisplaying();
 +	picture.show();
 +	_gfx->updateDisplay();
 +
 +	_gfx->doFadeInSync();
 +
 +	// Wait for the next event
 +	bool done = false;
 +	while (!shouldQuit() && !done) {
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event)) {
 +			switch (event.type) {
 +			case Common::EVENT_LBUTTONUP:
 +			case Common::EVENT_RBUTTONUP:
 +			case Common::EVENT_KEYDOWN:
 +				done = true;
 +				break;
 +			default:
 +				break;
 +			}
 +		}
 +
 +		_system->delayMillis(10);
 +	}
 +}
 +
 +void PegasusEngine::refreshDisplay() {
 +	giveIdleTime();
 +	_gfx->updateDisplay();
 +}
 +
 +void PegasusEngine::resetEnergyDeathReason() {
 +	switch (getCurrentNeighborhoodID()) {
 +	case kMarsID:
 +		_deathReason = kDeathArrestedInMars;
 +		break;
 +	case kNoradAlphaID:
 +	case kNoradDeltaID:
 +		_deathReason = kDeathArrestedInNorad;
 +		break;
 +	case kWSCID:
 +		_deathReason = kDeathArrestedInWSC;
 +		break;
 +	default:
 +		_deathReason = kDeathStranded;
 +		break;
 +	}
 +}
 +
 +bool PegasusEngine::playerHasItem(const Item *item) {
 +	return playerHasItemID(item->getObjectID());
 +}
 +
 +bool PegasusEngine::playerHasItemID(const ItemID itemID) {
 +	return itemInInventory(itemID) || itemInBiochips(itemID);
 +}
 +
 +InventoryItem *PegasusEngine::getCurrentInventoryItem() {
 +	if (g_interface)
 +		return g_interface->getCurrentInventoryItem();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInInventory(InventoryItem *item) {
 +	return _items.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInInventory(ItemID id) {
 +	return _items.itemInInventory(id);
 +}
 +
 +BiochipItem *PegasusEngine::getCurrentBiochip() {
 +	if (g_interface)
 +		return g_interface->getCurrentBiochip();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInBiochips(BiochipItem *item) {
 +	return _biochips.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInBiochips(ItemID id) {
 +	return _biochips.itemInInventory(id);
 +}
 +
 +bool PegasusEngine::playerAlive() {
 +	return (_shellNotification.getNotificationFlags() & kPlayerDiedFlag) == 0;
 +}
 +
 +Common::String PegasusEngine::getBriefingMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getBriefingMovie();
 +
 +	return Common::String();
 +}
 +
 +Common::String PegasusEngine::getEnvScanMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getEnvScanMovie();
 +
 +	return Common::String();
 +}
 +
 +uint PegasusEngine::getNumHints() {
 +	if (_neighborhood)
 +		return _neighborhood->getNumHints();
 +
 +	return 0;
 +}
 +
 +Common::String PegasusEngine::getHintMovie(uint hintNum) {
 +	if (_neighborhood)
 +		return _neighborhood->getHintMovie(hintNum);
 +
 +	return Common::String();
 +}
 +
 +bool PegasusEngine::canSolve() {
 +	if (_neighborhood)
 +		return _neighborhood->canSolve();
 +
 +	return false;
 +}
 +
 +void PegasusEngine::prepareForAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->prepareForAIHint(movieName);
 +}
 +
 +void PegasusEngine::cleanUpAfterAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->cleanUpAfterAIHint(movieName);
 +}
 +
 +void PegasusEngine::jumpToNewEnvironment(const NeighborhoodID neighborhoodID, const RoomID roomID, const DirectionConstant direction) {
 +	GameState.setNextLocation(neighborhoodID, roomID, direction);
 +	_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
 +}
 +
 +void PegasusEngine::checkFlashlight() {
 +	if (_neighborhood)
 +		_neighborhood->checkFlashlight();
 +}
 +
 +bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y) {
 +	bool skipped = false;
 +
 +	while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, x, y);
 +		}
 +
 +		Input input;
 +		InputDevice.getInput(input, kFilterAllInput);
 +		if (input.anyInput() || _saveRequested || _loadRequested)
 +			skipped = true;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	return skipped;
 +}
 +
 +void PegasusEngine::die(const DeathReason reason) {
 +	Input dummy;
 +	if (isDragging())
 +		_itemDragger.stopTracking(dummy);
 +
 +	_deathReason = reason;
 +	_shellNotification.setNotificationFlags(kPlayerDiedFlag, kPlayerDiedFlag);
 +}
 +
 +void PegasusEngine::doDeath() {
 +	_gfx->doFadeOutSync();
 +	throwAwayEverything();
 +	useMenu(new DeathMenu(_deathReason));
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +}
 +
 +void PegasusEngine::throwAwayEverything() {
 +	if (_items.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentInventoryItem()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	if (_biochips.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentBiochip()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	useMenu(0);
 +	useNeighborhood(0);
 +
 +	delete g_interface;
 +	g_interface = 0;
 +}
 +
 +void PegasusEngine::processShell() {
 +	checkCallBacks();
 +	checkNotifications();
 +	InputHandler::pollForInput();
 +	refreshDisplay();
 +}
 +
 +void PegasusEngine::createInterface() {
 +	if (!g_interface)
 +		new Interface();
 +
 +	g_interface->createInterface();
 +}
 +
 +void PegasusEngine::setGameMode(const GameMode newMode) {
 +	if (newMode != _gameMode && canSwitchGameMode(newMode, _gameMode)) {
 +		switchGameMode(newMode, _gameMode);
 +		_gameMode = newMode;
 +	}
 +}
 +
 +void PegasusEngine::switchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	// Start raising panels before lowering panels, to give the activating panel time
 +	// to set itself up without cutting into the lowering panel's animation time.
 +	
 +	if (_switchModesSync) {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawerSync();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawerSync();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawerSync();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawerSync();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	} else {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawer();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawer();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawer();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawer();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	}
 +}
 +
 +bool PegasusEngine::canSwitchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	if (newMode == kModeInventoryPick && oldMode == kModeBiochipPick)
 +		return false;
 +	if (newMode == kModeBiochipPick && oldMode == kModeInventoryPick)
 +		return false;
 +	return true;
 +}
 +
 +bool PegasusEngine::itemInLocation(const ItemID itemID, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 +	NeighborhoodID itemNeighborhood;
 +	RoomID itemRoom;
 +	DirectionConstant itemDirection;
 +	
 +	Item *item = g_allItems.findItemByID(itemID);
 +	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 +
 +	return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
 +}
 +
 +InventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	do {
 +		if (g_interface)
 +			result = g_interface->addInventoryItem(item);
 +		else
 +			result = _items.addItem(item);
 +
 +		if (result == kTooMuchWeight)
 +			destroyInventoryItem(pickItemToDestroy());
 +	} while (result != kInventoryOK);
 +
 +	GameState.setTakenItem(item, true);
 +	if (g_neighborhood)
 +			g_neighborhood->pickedUpItem(item);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 +	delete _neighborhood;
 +	_neighborhood = neighborhood;
 +
 +	if (_neighborhood) {
 +		InputHandler::setInputHandler(_neighborhood);
 +		_neighborhood->init();
 +		_neighborhood->moveNavTo(kNavAreaLeft, kNavAreaTop);
 +		g_interface->setDate(_neighborhood->getDateResID());
 +	} else {
 +		InputHandler::setInputHandler(this);
 +	}
 +}
 +
 +void PegasusEngine::performJump(NeighborhoodID neighborhoodID) {
 +	if (_neighborhood)
 +		useNeighborhood(0);
 +
 +	// Sub chase is special
 +	if (neighborhoodID == kNoradSubChaseID) {
 +		throwAwayEverything();
 +		doSubChase();
 +
 +		if (shouldQuit())
 +			return;
 +
 +		neighborhoodID = kNoradDeltaID;
 +		GameState.setNextRoom(kNorad41);
 +		GameState.setNextDirection(kEast);
 +	}
 +
 +	Neighborhood *neighborhood;
 +	makeNeighborhood(neighborhoodID, neighborhood);
 +	useNeighborhood(neighborhood);
 +
 +	// Update the CD variable (used just for saves currently)
 +	_currentCD = getNeighborhoodCD(neighborhoodID);
 +}
 +
 +void PegasusEngine::startNeighborhood() {
 +	if (g_interface && _currentItemID != kNoItemID)
 +		g_interface->setCurrentInventoryItemID(_currentItemID);
 +	
 +	if (g_interface && _currentBiochipID != kNoItemID)
 +		g_interface->setCurrentBiochipID(_currentBiochipID);
 +	
 +	setGameMode(kModeNavigation);
 +	
 +	if (_neighborhood)
 +		_neighborhood->start();
 +}
 +
 +void PegasusEngine::startNewGame() {
 +	// WORKAROUND: The original game ignored the menu difficulty
 +	// setting. We're going to pass it through here so that
 +	// the menu actually makes sense now.
 +	bool isWalkthrough = GameState.getWalkthroughMode();
 +	GameState.resetGameState();
 +	GameState.setWalkthroughMode(isWalkthrough);
 +
 +	// TODO: Enable erase
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +	_gfx->updateDisplay();
 +
 +	createInterface();
 +
 +	if (isDemo()) {
 +		setLastEnergyValue(kFullEnergy);
 +		jumpToNewEnvironment(kPrehistoricID, kPrehistoric02, kSouth);
 +		GameState.setPrehistoricSeenTimeStream(false);
 +		GameState.setPrehistoricSeenFlyer1(false);
 +		GameState.setPrehistoricSeenFlyer2(false);
 +		GameState.setPrehistoricSeenBridgeZoom(false);
 +		GameState.setPrehistoricBreakerThrown(false);
 +	} else {
 +		jumpToNewEnvironment(kCaldoriaID, kCaldoria00, kEast);
 +	}
 +
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +
 +	BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
 +	addItemToBiochips(biochip);
 +
 +	if (isDemo()) {
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
 +		addItemToBiochips(biochip);
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
 +		addItemToBiochips(biochip);
 +		InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
 +		addItemToInventory(item);
 +		item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
 +		addItemToInventory(item);
 +		_currentItemID = kJourneymanKey;
 +	} else {
 +		_currentItemID = kNoItemID;
 +	}
 +
 +	_currentBiochipID = kAIBiochip;
 +
 +	// Clear jump notification flags and just perform the jump...
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	
 +	performJump(GameState.getNextNeighborhood());
 +	
 +	startNeighborhood();
 +}
 +
 +void PegasusEngine::makeNeighborhood(NeighborhoodID neighborhoodID, Neighborhood *&neighborhood) {
 +	// TODO: CD check
 +
 +	switch (neighborhoodID) {
 +	case kCaldoriaID:
 +		neighborhood = new Caldoria(g_AIArea, this);
 +		break;
 +	case kMarsID:
 +		neighborhood = new Mars(g_AIArea, this);
 +		break;
 +	case kPrehistoricID:
 +		neighborhood = new Prehistoric(g_AIArea, this);
 +		break;
 +	case kFullTSAID:
 +		neighborhood = new FullTSA(g_AIArea, this);
 +		break;
 +	case kTinyTSAID:
 +		neighborhood = new TinyTSA(g_AIArea, this);
 +		break;
 +	case kWSCID:
 +		neighborhood = new WSC(g_AIArea, this);
 +		break;
 +	case kNoradAlphaID:
 +		neighborhood = new NoradAlpha(g_AIArea, this);
 +		break;
 +	case kNoradDeltaID:
 +		createInterface();
 +		neighborhood = new NoradDelta(g_AIArea, this);
 +		break;
 +	default:
 +		error("Unknown neighborhood %d", neighborhoodID);
 +	}
 +}
 +
 +bool PegasusEngine::wantsCursor() {
 +	return _gameMenu == 0;
 +}
 +
 +void PegasusEngine::updateCursor(const Common::Point, const Hotspot *cursorSpot) {	
 +	if (_itemDragger.isTracking()) {
 +		_cursor->setCurrentFrameIndex(5);
 +	} else {
 +		if (!cursorSpot) {
 +			_cursor->setCurrentFrameIndex(0);
 +		} else {
 +			uint32 id = cursorSpot->getObjectID();
 +
 +			switch (id) {
 +			case kCurrentItemSpotID:
 +				if (countInventoryItems() != 0)
 +					_cursor->setCurrentFrameIndex(4);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +				break;
 +			default:
 +				HotSpotFlags flags = cursorSpot->getHotspotFlags();
 +
 +				if (flags & kZoomInSpotFlag)
 +					_cursor->setCurrentFrameIndex(1);
 +				else if (flags & kZoomOutSpotFlag)
 +					_cursor->setCurrentFrameIndex(2);
 +				else if (flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag))
 +					_cursor->setCurrentFrameIndex(4);
 +				else if (flags & kJMPClickingSpotFlags)
 +					_cursor->setCurrentFrameIndex(3);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +			}
 +		}
 +	}
 +}
 +
 +void PegasusEngine::toggleInventoryDisplay() {
 +	if (_gameMode == kModeInventoryPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeInventoryPick);
 +}
 +
 +void PegasusEngine::toggleBiochipDisplay() {
 +	if (_gameMode == kModeBiochipPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeBiochipPick);
 +}
 +
 +void PegasusEngine::showInfoScreen() {	
 +	if (g_neighborhood) {
 +		// Break the input handler chain...
 +		_savedHandler = InputHandler::getCurrentHandler();
 +		InputHandler::setInputHandler(this);
 +		
 +		Picture *pushPicture = ((Neighborhood *)g_neighborhood)->getTurnPushPicture();
 +		
 +		_bigInfoMovie.shareSurface(pushPicture);
 +		_smallInfoMovie.shareSurface(pushPicture);
 +
 +		g_neighborhood->hideNav();
 +
 +		_smallInfoMovie.initFromMovieFile("Images/Items/Info Right Movie");
 +		_smallInfoMovie.setDisplayOrder(kInfoSpinOrder);
 +		_smallInfoMovie.moveElementTo(kNavAreaLeft + 304, kNavAreaTop + 8);
 +		_smallInfoMovie.moveMovieBoxTo(304, 8);
 +		_smallInfoMovie.startDisplaying();
 +		_smallInfoMovie.show();
 +
 +		TimeValue startTime, stopTime;
 +		g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +		_smallInfoMovie.setSegment(startTime, stopTime);
 +		_smallInfoMovie.setTime(startTime);
 +		_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +		_bigInfoMovie.initFromMovieFile("Images/Items/Info Left Movie");
 +		_bigInfoMovie.setDisplayOrder(kInfoBackgroundOrder);
 +		_bigInfoMovie.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +		_bigInfoMovie.startDisplaying();
 +		_bigInfoMovie.show();
 +		_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +
 +		_bigInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.start();
 +	}
 +}
 +
 +void PegasusEngine::hideInfoScreen() {
 +	if (g_neighborhood) {
 +		InputHandler::setInputHandler(_savedHandler);
 +
 +		_bigInfoMovie.hide();
 +		_bigInfoMovie.stopDisplaying();
 +		_bigInfoMovie.releaseMovie();
 +
 +		_smallInfoMovie.hide();
 +		_smallInfoMovie.stopDisplaying();
 +		_smallInfoMovie.stop();
 +		_smallInfoMovie.releaseMovie();
 +
 +		g_neighborhood->showNav();
 +	}
 +}
 +
 +void PegasusEngine::raiseInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawer();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawer();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawer();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawer();
 +}
 +
 +void PegasusEngine::raiseInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::toggleInfo() {
 +	if (_gameMode == kModeInfoScreen)
 +		setGameMode(kModeNavigation);
 +	else if (_gameMode == kModeNavigation)
 +		setGameMode(kModeInfoScreen);
 +}
 +
 +void PegasusEngine::dragTerminated(const Input &) {
 +	Hotspot *finalSpot = _itemDragger.getLastHotspot();
 +	InventoryResult result;
 +
 +	if (_dragType == kDragInventoryPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kInventoryDropSpotID)
 +			result = addItemToInventory((InventoryItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragBiochipPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kBiochipDropSpotID)
 +			result = addItemToBiochips((BiochipItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragInventoryUse) {
 +		if (finalSpot && (finalSpot->getHotspotFlags() & kDropItemSpotFlag) != 0) {
 +			// *** Need to decide on a case by case basis what to do here.
 +			// the crowbar should break the cover off the Mars reactor if its frozen, the
 +			// global transport card should slide through the slot, the oxygen mask should
 +			// attach to the filling station, and so on...
 +			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
 +			delete _draggingSprite;
 +		} else {
 +			autoDragItemIntoInventory(_draggingItem, _draggingSprite);
 +		}
 +	}
 +
 +	_dragType = kDragNoDrag;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +
 +void PegasusEngine::dragItem(const Input &input, Item *item, DragType type) {	
 +	_draggingItem = item;
 +	_dragType = type;
 +
 +	// Create the sprite.
 +	_draggingSprite = _draggingItem->getDragSprite(kDraggingSpriteID);
 +	Common::Point where;
 +	input.getInputLocation(where);
 +	Common::Rect r1;
 +	_draggingSprite->getBounds(r1);
 +	r1 = Common::Rect::center(where.x, where.y, r1.width(), r1.height());
 +	_draggingSprite->setBounds(r1);
 +
 +	// Set up drag constraints.
 +	DisplayElement *navMovie = _gfx->findDisplayElement(kNavMovieID);
 +	Common::Rect r2;
 +	navMovie->getBounds(r2);
 +	r2.left -= r1.width() / 3;
 +	r2.right += r1.width() / 3;
 +	r2.top -= r1.height() / 3;
 +	r2.bottom += r2.height() / 3;
 +
 +	r1 = Common::Rect(-30000, -30000, 30000, 30000);
 +	_itemDragger.setDragConstraints(r2, r1);
 +
 +	// Start dragging.
 +	_draggingSprite->setDisplayOrder(kDragSpriteOrder);
 +	_draggingSprite->startDisplaying();
 +	_draggingSprite->show();
 +	_itemDragger.setDragSprite(_draggingSprite);
 +	_itemDragger.setNextHandler(_neighborhood);
 +	_itemDragger.startTracking(input);
 +
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +}
 +
 +void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_gameMode == kModeInfoScreen) {
 +		if (JMPPPInput::isToggleAIMiddleInput(input)) {
 +			LowerClientSignature middleOwner = g_AIArea->getMiddleAreaOwner();
 +			g_AIArea->toggleMiddleAreaOwner();
 +
 +			if (middleOwner != g_AIArea->getMiddleAreaOwner()) {
 +				_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +				_smallInfoMovie.stop();
 +				_smallInfoMovie.setFlags(0);
 +
 +				TimeValue startTime, stopTime;
 +				g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +				_smallInfoMovie.setSegment(startTime, stopTime);
 +				_smallInfoMovie.setTime(startTime);
 +				_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +				_bigInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.start();
 +			}
 +		}
 +	} else {
 +		if (JMPPPInput::isRaiseInventoryInput(input))
 +			toggleInventoryDisplay();
 +
 +		if (JMPPPInput::isRaiseBiochipsInput(input))
 +			toggleBiochipDisplay();
 +
 +		if (JMPPPInput::isTogglePauseInput(input) && _neighborhood)
 +			pauseMenu(!isPaused());
 +	}
 +
 +	if (JMPPPInput::isToggleInfoInput(input))
 +		toggleInfo();
 +}
 +
 +void PegasusEngine::activateHotspots() {
 +	if (_gameMode == kModeInfoScreen) {
 +		g_allHotspots.activateOneHotspot(kInfoReturnSpotID);
 +	} else {
 +		// Set up hot spots.
 +		if (_dragType == kDragInventoryPickup)
 +			g_allHotspots.activateOneHotspot(kInventoryDropSpotID);
 +		else if (_dragType == kDragBiochipPickup)
 +			g_allHotspots.activateOneHotspot(kBiochipDropSpotID);
 +		else if (_dragType == kDragNoDrag)
 +			g_allHotspots.activateMaskedHotspots(kShellSpotFlag);
 +	}
 +}
 +
 +bool PegasusEngine::isClickInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_cursor->isVisible() && cursorSpot)
 +		return JMPPPInput::isClickInput(input);
 +	else
 +		return false;
 +}
 +
 +InputBits PegasusEngine::getClickFilter() {
 +	return JMPPPInput::getClickInputFilter();
 +}
 +
 +void PegasusEngine::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 +	if (clickedSpot->getObjectID() == kCurrentItemSpotID) {
 +		InventoryItem *currentItem = getCurrentInventoryItem();
 +		if (currentItem) {
 +			removeItemFromInventory(currentItem);
 +			dragItem(input, currentItem, kDragInventoryUse);
 +		}
 +	} else if (clickedSpot->getObjectID() == kInfoReturnSpotID) {
 +		toggleInfo();
 +	}
 +}
 +
 +InventoryResult PegasusEngine::removeItemFromInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	if (g_interface)
 +		result = g_interface->removeInventoryItem(item);
 +	else
 +		result = _items.removeItem(item);
 +
 +	// This should never happen
 +	assert(result == kInventoryOK);
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromInventory() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromInventory();
 +	else
 +		_items.removeAllItems();
 +}
 +
 +/////////////////////////////////////////////
 +//
 +// Biochip handling.
 +
 +// Adding biochips to the biochip drawer is a little funny, because of two things:
 +//      --  We get the map biochip and pegasus biochip at the same time by dragging
 +//          one sprite in TSA
 +//      --  We can drag in more than one copy of the various biochips.
 +// Because of this we need to make sure that no more than one copy of each biochip
 +// is ever added.
 +
 +InventoryResult PegasusEngine::addItemToBiochips(BiochipItem *biochip) {
 +	InventoryResult result;
 +
 +	if (g_interface)
 +		result = g_interface->addBiochip(biochip);
 +	else
 +		result = _biochips.addItem(biochip);
 +
 +	// This can never happen
 +	assert(result == kInventoryOK);
 +
 +	GameState.setTakenItem(biochip, true);
 +
 +	if (g_neighborhood)
 +		g_neighborhood->pickedUpItem(biochip);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromBiochips() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromBiochips();
 +	else
 +		_biochips.removeAllItems();
 +}
 +
 +void PegasusEngine::setSoundFXLevel(uint16 fxLevel) {
 +	_FXLevel = fxLevel;
 +	if (_neighborhood)
 +		_neighborhood->setSoundFXLevel(fxLevel);
 +	if (g_AIArea)
 +		g_AIArea->setAIVolume(fxLevel);
 +}
 +
 +void PegasusEngine::setAmbienceLevel(uint16 ambientLevel) {
 +	_ambientLevel = ambientLevel;
 +	if (_neighborhood)
 +		_neighborhood->setAmbienceLevel(ambientLevel);
 +}
 +
 +void PegasusEngine::pauseMenu(bool menuUp) {
 +	if (menuUp) {
 +		pauseEngine(true);
 +		_screenDimmer.startDisplaying();
 +		_screenDimmer.show();
 +		_gfx->updateDisplay();
 +		useMenu(new PauseMenu());
 +	} else {
 +		pauseEngine(false);
 +		_screenDimmer.hide();
 +		_screenDimmer.stopDisplaying();
 +		useMenu(0);
 +		g_AIArea->checkMiddleArea();
 +	}
 +}
 +
 +void PegasusEngine::autoDragItemIntoRoom(Item *item, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start, stop;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Hotspot *dropSpot = _neighborhood->getItemScreenSpot(item, draggingSprite);
 +
 +	if (dropSpot) {
 +		dropSpot->getCenter(stop.x, stop.y);
 +	} else {
 +		stop.x = kNavAreaLeft + 256;
 +		stop.y = kNavAreaTop + 128;
 +	}
 +
 +	Common::Rect bounds;
 +	draggingSprite->getBounds(bounds);
 +	stop.x -= bounds.width() >> 1;
 +	stop.y -= bounds.height() >> 1;
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	_neighborhood->dropItemIntoRoom(_draggingItem, dropSpot);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Common::Rect r;
 +	draggingSprite->getBounds(r);
 +
 +	Common::Point stop((76 + 172 - r.width()) / 2, 334 - (2 * r.height() / 3));
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	addItemToInventory((InventoryItem *)_draggingItem);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +NeighborhoodID PegasusEngine::getCurrentNeighborhoodID() const {
 +	if (_neighborhood)
 +		return _neighborhood->getObjectID();
 +
 +	return kNoNeighborhoodID;
 +}
 +
 +void PegasusEngine::pauseEngineIntern(bool pause) {
 +	Engine::pauseEngineIntern(pause);
 +
 +	if (pause) {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->pause();
 +	} else {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->resume();
 +	}
 +}
 +
 +uint PegasusEngine::getRandomBit() {
 +	return _rnd->getRandomBit();
 +}
 +
 +uint PegasusEngine::getRandomNumber(uint max) {
 +	return _rnd->getRandomNumber(max);
 +}
 +
 +void PegasusEngine::shuffleArray(int32 *arr, int32 count) {	
 +	if (count > 1) {
 +		for (int32 i = 1; i < count; ++i) {
 +			int32 j = _rnd->getRandomNumber(i);
 +			if (j != i)
 +				SWAP(arr[i], arr[j]);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::playEndMessage() {
 +	if (g_interface) {
 +		allowInput(false);
 +		g_interface->playEndMessage();
 +		allowInput(true);
 +	}
 +
 +	die(kPlayerWonGame);
 +}
 +
 +void PegasusEngine::doSubChase() {
 +	static const uint32 endTime = 133200 * 1000 / 600;
 +
 +	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie"))
 +		error("Failed to load sub chase");
 +
 +	while (!shouldQuit() && !video->endOfVideo() && video->getTime() < endTime) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, 0, 0);
 +		}
 +
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event))
 +			;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	delete video;
 +}
 +
 +void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y) {
 +	// Scale up the frame doing some simple scaling
 +	Graphics::Surface scaledFrame;
 +	scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
 +	const byte *src = (const byte *)frame->pixels;
 +	byte *dst1 = (byte *)scaledFrame.pixels;
 +	byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
 +
 +	for (int i = 0; i < frame->h; i++) {
 +		for (int j = 0; j < frame->w; j++) {
 +			memcpy(dst1, src, frame->format.bytesPerPixel);
 +			dst1 += frame->format.bytesPerPixel;
 +			memcpy(dst1, src, frame->format.bytesPerPixel);
 +			dst1 += frame->format.bytesPerPixel;
 +			memcpy(dst2, src, frame->format.bytesPerPixel);
 +			dst2 += frame->format.bytesPerPixel;
 +			memcpy(dst2, src, frame->format.bytesPerPixel);
 +			dst2 += frame->format.bytesPerPixel;
 +			src += frame->format.bytesPerPixel;
 +		}
 +
 +		src += frame->pitch - frame->format.bytesPerPixel * frame->w;
 +		dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
 +		dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
 +	}
 +
 +	_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
 +	_system->updateScreen();
 +	scaledFrame.free();
 +}
 +
 +void PegasusEngine::destroyInventoryItem(const ItemID itemID) {
 +	InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
 +
 +	ItemExtraEntry entry;
 +
 +	switch (itemID) {
 +	case kAirMask:
 +		item->findItemExtra(kRemoveAirMask, entry);
 +		item->setItemRoom(kMarsID, kMars49, kSouth);
 +		break;
 +	case kArgonCanister:
 +		item->findItemExtra(kRemoveArgon, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	case kCrowbar:
 +		item->findItemExtra(kRemoveCrowbar, entry);
 +		item->setItemRoom(kMarsID, kMars34, kSouth);
 +		break;
 +	case kJourneymanKey:
 +		item->findItemExtra(kRemoveJourneymanKey, entry);
 +		item->setItemRoom(kFullTSAID, kTSA22Red, kEast);
 +		break;
 +	case kMarsCard:
 +		item->findItemExtra(kRemoveMarsCard, entry);
 +		item->setItemRoom(kMarsID, kMars31South, kSouth);
 +		break;
 +	case kNitrogenCanister:
 +		item->findItemExtra(kRemoveNitrogen, entry);
 +		item->setItemRoom(kWSCID, kWSC02Messages, kSouth);
 +		break;
 +	case kOrangeJuiceGlassEmpty:
 +		item->findItemExtra(kRemoveGlass, entry);
 +		item->setItemRoom(kCaldoriaID, kCaldoriaReplicator, kNorth);
 +		break;
 +	case kPoisonDart:
 +		item->findItemExtra(kRemoveDart, entry);
 +		item->setItemRoom(kWSCID, kWSC01, kWest);
 +		break;
 +	case kSinclairKey:
 +		item->findItemExtra(kRemoveSinclairKey, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	default:
 +		return;
 +	}
 +
 +	g_interface->setCurrentInventoryItemID(itemID);
 +	g_AIArea->playAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
 +	removeItemFromInventory(item);
 +}
 +
 +ItemID PegasusEngine::pickItemToDestroy() {
 +/*
 +	Must pick an item to destroy
 +	
 +	Part I: Polite -- try to find an item that's been used
 +	Part II: Desperate -- return the first available item.
 +*/
 +
 +	// Polite:
 +	if (playerHasItemID(kOrangeJuiceGlassEmpty))
 +		return kOrangeJuiceGlassEmpty;
 +	if (playerHasItemID(kPoisonDart)) {
 +		if (GameState.getCurrentNeighborhood() != kWSCID ||
 +				GameState.getWSCAnalyzedDart())
 +			return kPoisonDart;
 +	}
 +	if (playerHasItemID(kJourneymanKey)) {
 +		if (GameState.getTSAState() >= kTSAPlayerGotHistoricalLog &&
 +				GameState.getTSAState() != kPlayerOnWayToPrehistoric &&
 +				GameState.getTSAState() != kPlayerWentToPrehistoric)
 +			return kJourneymanKey;
 +	}
 +	if (playerHasItemID(kMarsCard)) {
 +		if (GameState.getCurrentNeighborhood() != kMarsID || GameState.getMarsArrivedBelow())
 +			return kMarsCard;
 +	}
 +
 +	// Don't want to deal with deleting the sinclair key and argon canister, since it's
 +	// impossible to pick them up one at a time.
 +
 +	if (playerHasItemID(kNitrogenCanister)) {
 +		if (GameState.getScoringGotCardBomb() && GameState.getCurrentNeighborhood() != kMarsID)
 +			return kNitrogenCanister;
 +	}
 +	if (playerHasItemID(kCrowbar)) {
 +		if (GameState.getCurrentNeighborhood() == kWSCID) {
 +			if (GameState.getCurrentRoom() >= kWSC62)
 +				return kCrowbar;
 +		} else if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (GameState.getScoringGotCardBomb())
 +				return kCrowbar;
 +		} else
 +			return kCrowbar;
 +	}
 +	if (playerHasItemID(kAirMask)) {
 +		if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (g_neighborhood->getAirQuality(GameState.getCurrentRoom()) == kAirQualityGood)
 +				return kAirMask;
 +		} else if (GameState.getCurrentNeighborhood() != kNoradAlphaID &&
 +				GameState.getCurrentNeighborhood() != kNoradDeltaID) {
 +			return kAirMask;
 +		}
 +	}
 +
 +	// Desperate:
 +	if (playerHasItemID(kPoisonDart))
 +		return kPoisonDart;
 +	if (playerHasItemID(kJourneymanKey))
 +		return kJourneymanKey;
 +	if (playerHasItemID(kMarsCard))
 +		return kMarsCard;
 +	if (playerHasItemID(kNitrogenCanister))
 +		return kNitrogenCanister;
 +	if (playerHasItemID(kCrowbar))
 +		return kCrowbar;
 +	if (playerHasItemID(kAirMask))
 +		return kAirMask;
 +
 +	// Should never get this far...
 +	error("Could not find item to delete");
 +
 +	return kNoItemID;
 +}
 +
 +uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const {
 +	switch (neighborhood) {
 +	case kCaldoriaID:
 +	case kNoradAlphaID:
 +	case kNoradSubChaseID:
 +		return 1;
 +	case kFullTSAID:
 +	case kPrehistoricID:
 +		return 2;
 +	case kMarsID:
 +		return 3;
 +	case kWSCID:
 +	case kNoradDeltaID:
 +		return 4;
 +	case kTinyTSAID:
 +		// Tiny TSA exists on three of the CD's, so just continue
 +		// with the CD we're on
 +		return _currentCD;
 +	}
 +
 +	// Can't really happen, but it's a good fallback anyway :P
 +	return 1;
 +}
 +
 +} // End of namespace Pegasus


Commit: b5238756e26ea3460b315af5737636db09fe30da
    https://github.com/scummvm/scummvm/commit/b5238756e26ea3460b315af5737636db09fe30da
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-06-15T22:47:36-07:00

Commit Message:
PEGASUS: Make sure we check the pixel format of video frames

Changed paths:
    engines/pegasus/movie.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index b7c025a..5d393de 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -93,6 +93,14 @@ void Movie::redrawMovieWorld() {
 		if (!frame)
 			return;
 
+		// Make sure we have a surface in the current pixel format
+		Graphics::Surface *convertedFrame = 0;
+
+		if (frame->format != g_system->getScreenFormat()) {
+			convertedFrame = frame->convertTo(g_system->getScreenFormat());
+			frame = convertedFrame;
+		}
+
 		// Copy to the surface using _movieBox
 		uint16 width = MIN<int>(frame->w, _movieBox.width());
 		uint16 height = MIN<int>(frame->h, _movieBox.height());
@@ -100,6 +108,11 @@ void Movie::redrawMovieWorld() {
 		for (uint16 y = 0; y < height; y++)
 			memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
 
+		if (convertedFrame) {
+			convertedFrame->free();
+			delete convertedFrame;
+		}
+
 		triggerRedraw();
 	}
 }


Commit: 915a8399c910fb5c8e35de58857ce1577c1a0151
    https://github.com/scummvm/scummvm/commit/915a8399c910fb5c8e35de58857ce1577c1a0151
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-06-15T22:48:39-07:00

Commit Message:
PEGASUS: Don't manually close the load/save dialogs

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 43ffc4c..401a922 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -348,8 +348,6 @@ Common::Error PegasusEngine::showLoadDialog() {
 		result = Common::kUserCanceled;
 	}
 
-	slc.close();
-
 	return result;
 }
 
@@ -374,8 +372,6 @@ Common::Error PegasusEngine::showSaveDialog() {
 		result = Common::kUserCanceled;
 	}
 
-	slc.close();
-
 	return result;
 }
 


Commit: 91efe792d5b231752dd16888729a94f323363fa0
    https://github.com/scummvm/scummvm/commit/91efe792d5b231752dd16888729a94f323363fa0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-06-24T06:37:53-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A backends/platform/dingux/scummvm.png
  A engines/gob/detection/detection.cpp
  A engines/gob/detection/tables.h
  A engines/gob/detection/tables_adi2.h
  A engines/gob/detection/tables_adi4.h
  A engines/gob/detection/tables_adibou.h
  A engines/gob/detection/tables_ajworld.h
  A engines/gob/detection/tables_bargon.h
  A engines/gob/detection/tables_dynasty.h
  A engines/gob/detection/tables_fallback.h
  A engines/gob/detection/tables_fascin.h
  A engines/gob/detection/tables_geisha.h
  A engines/gob/detection/tables_gob1.h
  A engines/gob/detection/tables_gob2.h
  A engines/gob/detection/tables_gob3.h
  A engines/gob/detection/tables_inca2.h
  A engines/gob/detection/tables_lit.h
  A engines/gob/detection/tables_littlered.h
  A engines/gob/detection/tables_playtoons.h
  A engines/gob/detection/tables_urban.h
  A engines/gob/detection/tables_ween.h
  A engines/gob/detection/tables_woodruff.h
  A engines/gob/save/saveload_ajworld.cpp
  R engines/gob/detection.cpp
  R engines/gob/detection_tables.h
    backends/graphics/graphics.h
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/opengl/opengl-graphics.h
    backends/graphics/surfacesdl/surfacesdl-graphics.cpp
    backends/graphics/surfacesdl/surfacesdl-graphics.h
    backends/graphics/wincesdl/wincesdl-graphics.cpp
    backends/graphics/wincesdl/wincesdl-graphics.h
    backends/modular-backend.cpp
    backends/modular-backend.h
    backends/platform/android/android.cpp
    backends/platform/android/android.h
    backends/platform/android/gfx.cpp
    backends/platform/bada/system.cpp
    backends/platform/dc/dc.h
    backends/platform/dc/dcmain.cpp
    backends/platform/dc/display.cpp
    backends/platform/dingux/README.DINGUX
    backends/platform/dingux/dingux.mk
    backends/platform/ds/arm9/source/osystem_ds.cpp
    backends/platform/ds/arm9/source/osystem_ds.h
    backends/platform/iphone/osys_main.cpp
    backends/platform/iphone/osys_main.h
    backends/platform/iphone/osys_video.mm
    backends/platform/n64/osys_n64.h
    backends/platform/n64/osys_n64_base.cpp
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Gs2dScreen.h
    backends/platform/ps2/ps2time.cpp
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    backends/platform/psp/default_display_client.cpp
    backends/platform/psp/default_display_client.h
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/osys_psp.cpp
    backends/platform/psp/osys_psp.h
    backends/platform/sdl/sdl.cpp
    backends/platform/wii/osystem.cpp
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_gfx.cpp
    backends/platform/wince/wince-sdl.cpp
    backends/vkeybd/virtual-keyboard-gui.cpp
    common/coroutines.cpp
    common/coroutines.h
    common/system.h
    configure
    engines/cge/cge_main.cpp
    engines/cge/vga13h.cpp
    engines/drascula/interface.cpp
    engines/gob/draw.h
    engines/gob/draw_fascin.cpp
    engines/gob/draw_v2.cpp
    engines/gob/game.cpp
    engines/gob/game.h
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/hotspots.cpp
    engines/gob/hotspots.h
    engines/gob/inter.cpp
    engines/gob/inter_littlered.cpp
    engines/gob/module.mk
    engines/gob/save/saveload.h
    engines/gob/sound/sound.cpp
    engines/gob/sound/soundblaster.cpp
    engines/gob/surface.cpp
    engines/gob/surface.h
    engines/groovie/graphics.cpp
    engines/groovie/resource.cpp
    engines/groovie/roq.cpp
    engines/groovie/script.cpp
    engines/hugo/display.cpp
    engines/hugo/file.cpp
    engines/hugo/file.h
    engines/hugo/hugo.cpp
    engines/hugo/parser.cpp
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/data/cursor.cpp
    engines/lastexpress/graphics.cpp
    engines/made/pmvplayer.cpp
    engines/made/screen.cpp
    engines/made/screen.h
    engines/made/screenfx.cpp
    engines/made/scriptfuncs.cpp
    engines/mohawk/cursors.cpp
    engines/mohawk/myst_graphics.cpp
    engines/mohawk/riven_graphics.cpp
    engines/mohawk/video.cpp
    engines/saga/actor_path.cpp
    engines/saga/introproc_ihnm.cpp
    engines/saga/introproc_saga2.cpp
    engines/sci/console.cpp
    engines/sci/console.h
    engines/sci/detection_tables.h
    engines/sci/engine/features.cpp
    engines/sci/engine/file.cpp
    engines/sci/engine/gc.cpp
    engines/sci/engine/gc.h
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kevent.cpp
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kgraphics32.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/kparse.cpp
    engines/sci/engine/kpathing.cpp
    engines/sci/engine/kscripts.cpp
    engines/sci/engine/kstring.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/object.cpp
    engines/sci/engine/object.h
    engines/sci/engine/savegame.cpp
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/scriptdebug.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/segment.cpp
    engines/sci/engine/segment.h
    engines/sci/engine/selector.h
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/vm_types.cpp
    engines/sci/engine/vm_types.h
    engines/sci/graphics/animate.cpp
    engines/sci/graphics/cursor.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/maciconbar.cpp
    engines/sci/graphics/menu.cpp
    engines/sci/graphics/paint16.cpp
    engines/sci/graphics/text32.cpp
    engines/sci/resource.cpp
    engines/sci/sci.cpp
    engines/sci/sound/soundcmd.cpp
    engines/scumm/gfx.cpp
    engines/scumm/he/logic/football.cpp
    engines/scumm/insane/insane_scenes.cpp
    engines/sword1/animation.cpp
    engines/sword2/animation.cpp
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/gfx/graphicengine.cpp
    engines/sword25/gfx/image/renderedimage.cpp
    engines/teenagent/scene.cpp
    engines/teenagent/teenagent.cpp
    engines/testbed/graphics.cpp
    engines/toltecs/menu.cpp
    engines/toltecs/render.cpp
    engines/toltecs/screen.cpp
    engines/toltecs/toltecs.cpp
    engines/toon/movie.cpp
    graphics/VectorRendererSpec.cpp
    graphics/cursorman.cpp
    graphics/cursorman.h
    graphics/pixelformat.h
    gui/ThemeEngine.cpp





Commit: 3860f341365a59ff96ec41e61e3952be01915b40
    https://github.com/scummvm/scummvm/commit/3860f341365a59ff96ec41e61e3952be01915b40
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-07-05T17:36:34-07:00

Commit Message:
PEGASUS: Implement screen fading

This does linear instead of gamma for speed and complexity reasons.

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/menu.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/transition.cpp
    engines/pegasus/transition.h



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 175f15e..8d0347e 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -30,6 +30,7 @@
 
 #include "pegasus/elements.h"
 #include "pegasus/graphics.h"
+#include "pegasus/transition.h"
 
 namespace Pegasus {
 
@@ -46,10 +47,13 @@ GraphicsManager::GraphicsManager(PegasusEngine *vm) : _vm(vm) {
 	_modifiedScreen = false;
 	_curSurface = &_workArea;
 	_erase = false;
+	_updatesEnabled = true;
+	_screenFader = new ScreenFader();
 }
 	
 GraphicsManager::~GraphicsManager() {
 	_workArea.free();
+	delete _screenFader;
 }
 
 void GraphicsManager::invalRect(const Common::Rect &rect) {
@@ -175,7 +179,7 @@ void GraphicsManager::updateDisplay() {
 		_dirtyRect = Common::Rect();
 	}
 
-	if (screenDirty || _modifiedScreen)
+	if (_updatesEnabled && (screenDirty || _modifiedScreen))
 		g_system->updateScreen();
 
 	_modifiedScreen = false;
@@ -200,19 +204,14 @@ DisplayElement *GraphicsManager::findDisplayElement(const DisplayElementID id) {
 	return 0;
 }
 
-void GraphicsManager::doFadeOutSync(const TimeValue, const TimeValue, uint32 color) {
-	if (color == 0)
-		color = g_system->getScreenFormat().RGBToColor(0, 0, 0);
-
-	// HACK: Until fading out is done, white-out the screen here
-	Graphics::Surface *screen = g_system->lockScreen();
-	screen->fillRect(Common::Rect(0, 0, 640, 480), color);
-	g_system->unlockScreen();
-	g_system->updateScreen();
+void GraphicsManager::doFadeOutSync(const TimeValue time, const TimeScale scale, uint32 color) {
+	_updatesEnabled = false;
+	_screenFader->doFadeOutSync(time, scale, color == 0);
 }
 
-void GraphicsManager::doFadeInSync(const TimeValue, const TimeValue, uint32) {
-	// TODO
+void GraphicsManager::doFadeInSync(const TimeValue time, const TimeScale scale, uint32 color) {
+	_screenFader->doFadeInSync(time, scale, color == 0);
+	_updatesEnabled = true;
 }
 
 void GraphicsManager::markCursorAsDirty() {
@@ -333,5 +332,15 @@ void GraphicsManager::enableErase() {
 void GraphicsManager::disableErase() {
 	_erase = false;
 }
-	
+
+void GraphicsManager::enableUpdates() {
+	_updatesEnabled = true;
+	_screenFader->setFaderValue(100);
+}
+
+void GraphicsManager::disableUpdates() {
+	_updatesEnabled = false;
+	_screenFader->setFaderValue(0);
+}
+
 } // End of namespace Pegasus
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 5023044..2d66cd9 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -40,6 +40,7 @@ namespace Pegasus {
 class Cursor;
 class DisplayElement;
 class PegasusEngine;
+class ScreenFader;
 
 class GraphicsManager {
 friend class Cursor;
@@ -61,6 +62,8 @@ public:
 	void shakeTheWorld(TimeValue time, TimeScale scale);
 	void enableErase();
 	void disableErase();
+	void enableUpdates();
+	void disableUpdates();
 
 	// These default to black
 	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
@@ -82,6 +85,9 @@ private:
 	static const int kMaxShakeOffsets = 17;
 	Common::Point _shakeOffsets[kMaxShakeOffsets];
 	void newShakePoint(int32 index1, int32 index2, int32 maxRadius);
+
+	bool _updatesEnabled;
+	ScreenFader *_screenFader;
 };
 
 } // End of namespace Pegasus
diff --git a/engines/pegasus/menu.cpp b/engines/pegasus/menu.cpp
index 5d90f62..5076abd 100644
--- a/engines/pegasus/menu.cpp
+++ b/engines/pegasus/menu.cpp
@@ -237,10 +237,7 @@ void MainMenu::startMainMenuLoop() {
 
 	_menuLoop.loopSound();
 	spec.makeTwoKnotFaderSpec(30, 0, 0, 30, 255);
-
-	// FIXME: Should be sync, but it's a pain to use the main menu right now
-	// with this one.
-	_menuFader.startFader(spec);
+	_menuFader.startFaderSync(spec);
 }
 
 void MainMenu::stopMainMenuLoop() {
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 0e5868c..817a24a 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -204,17 +204,24 @@ void Caldoria::start() {
 		if (!pullbackMovie->loadFile("Images/Caldoria/Pullback.movie"))
 			error("Could not load pullback movie");
 
-		bool skipped = false;
-		Input input;
-
+		// Draw the first frame so we can fade to it
+		pullbackMovie->pauseVideo(true);
+		const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
+		assert(frame);
+		assert(frame->format == g_system->getScreenFormat());
+		g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
 		_vm->_gfx->doFadeInSync(kTwoSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
+		pullbackMovie->pauseVideo(false);
 
 		bool saveAllowed = _vm->swapSaveAllowed(false);
 		bool openAllowed = _vm->swapLoadAllowed(false);
 
+		bool skipped = false;
+		Input input;
+
 		while (!_vm->shouldQuit() && !pullbackMovie->endOfVideo()) {
 			if (pullbackMovie->needsUpdate()) {
-				const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
+				frame = pullbackMovie->decodeNextFrame();
 
 				if (frame) {
 					g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
@@ -233,6 +240,9 @@ void Caldoria::start() {
 
 		delete pullbackMovie;
 
+		if (_vm->shouldQuit())
+			return;
+
 		_vm->swapSaveAllowed(saveAllowed);
 		_vm->swapLoadAllowed(openAllowed);
 
@@ -240,11 +250,8 @@ void Caldoria::start() {
 
 		if (!skipped) {
 			uint32 white = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
-
 			_vm->_gfx->doFadeOutSync(kThreeSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond, white);
-
 			g_system->delayMillis(3 * 1000 / 2);
-
 			getExtraEntry(kCaldoria00WakeUp1, entry);
 			_navMovie.setTime(entry.movieStart);
 			_navMovie.redrawMovieWorld();
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 401a922..04b6f36 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -1479,6 +1479,7 @@ void PegasusEngine::startNewGame() {
 	_gfx->doFadeOutSync();
 	useMenu(0);
 	_gfx->updateDisplay();
+	_gfx->enableUpdates();
 
 	createInterface();
 
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
index 24e9aaf..0de63d6 100644
--- a/engines/pegasus/transition.cpp
+++ b/engines/pegasus/transition.cpp
@@ -24,43 +24,92 @@
  */
 
 #include "common/system.h"
+#include "graphics/surface.h"
 
 #include "pegasus/transition.h"
 
 namespace Pegasus {
 
 ScreenFader::ScreenFader() {
-	_fadeTarget = getBlack();
+	_isBlack = true;
 	// Initially, assume screens are on at full brightness.
 	Fader::setFaderValue(100);
+	_screen = new Graphics::Surface();
 }
 
-void ScreenFader::doFadeOutSync(const TimeValue duration, const TimeValue scale, const uint32 fadeTarget) {
-	_fadeTarget = fadeTarget;
+ScreenFader::~ScreenFader() {
+	_screen->free();
+	delete _screen;
+}
+
+void ScreenFader::doFadeOutSync(const TimeValue duration, const TimeValue scale, bool isBlack) {
+	_isBlack = isBlack;
+	_screen->copyFrom(*g_system->lockScreen());
+	g_system->unlockScreen();
 
 	FaderMoveSpec spec;
 	spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 0);
 	startFaderSync(spec);
+
+	_screen->free();
 }
 
-void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale, const uint32 fadeTarget) {
-	_fadeTarget = fadeTarget;
+void ScreenFader::doFadeInSync(const TimeValue duration, const TimeValue scale, bool isBlack) {
+	_isBlack = isBlack;
+	_screen->copyFrom(*g_system->lockScreen());
+	g_system->unlockScreen();
 
 	FaderMoveSpec spec;
 	spec.makeTwoKnotFaderSpec(scale, 0, getFaderValue(), duration, 100);
 	startFaderSync(spec);
+
+	_screen->free();
 }
 
 void ScreenFader::setFaderValue(const int32 value) {
 	if (value != getFaderValue()) {
 		Fader::setFaderValue(value);
 
-		// TODO: Gamma fading
+		if (_screen->pixels) {
+			// The original game does a gamma fade here using the Mac API. In order to do
+			// that, it would require an immense amount of CPU processing. This does a
+			// linear fade instead, which looks fairly well, IMO.
+			Graphics::Surface *screen = g_system->lockScreen();
+
+			for (uint y = 0; y < _screen->h; y++) {
+				for (uint x = 0; x < _screen->w; x++) {
+					if (_screen->format.bytesPerPixel == 2)
+						WRITE_UINT16(screen->getBasePtr(x, y), fadePixel(READ_UINT16(_screen->getBasePtr(x, y)), value));
+					else
+						WRITE_UINT32(screen->getBasePtr(x, y), fadePixel(READ_UINT32(_screen->getBasePtr(x, y)), value));
+				}
+			}
+
+			g_system->unlockScreen();
+			g_system->updateScreen();
+		}
 	}
 }
 
-uint32 ScreenFader::getBlack() {
-	return g_system->getScreenFormat().RGBToColor(0, 0, 0);
+static inline byte fadeComponent(byte comp, int32 percent) {
+	return comp * percent / 100;
+}
+
+uint32 ScreenFader::fadePixel(uint32 color, int32 percent) const {
+	byte r, g, b;
+	g_system->getScreenFormat().colorToRGB(color, r, g, b);
+
+	if (_isBlack) {
+		r = fadeComponent(r, percent);
+		g = fadeComponent(g, percent);
+		b = fadeComponent(b, percent);
+	} else {
+		r = 0xFF - fadeComponent(0xFF - r, percent);
+		g = 0xFF - fadeComponent(0xFF - g, percent);
+		b = 0xFF - fadeComponent(0xFF - b, percent);
+	}
+
+	return g_system->getScreenFormat().RGBToColor(r, g, b);
 }
 
 Transition::Transition(const DisplayElementID id) : FaderAnimation(id) {
diff --git a/engines/pegasus/transition.h b/engines/pegasus/transition.h
index 5f2b797..a516d58 100644
--- a/engines/pegasus/transition.h
+++ b/engines/pegasus/transition.h
@@ -28,23 +28,26 @@
 
 #include "pegasus/fader.h"
 
+namespace Graphics {
+struct Surface;
+}
+
 namespace Pegasus {
 
 class ScreenFader : public Fader {
 public:
 	ScreenFader();
-	virtual ~ScreenFader() {}
+	virtual ~ScreenFader();
 	
-	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
-	void doFadeInSync(const TimeValue = kHalfSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, const uint32 = getBlack());
-
-	void setFaderValue(const int32);	
+	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, bool isBlack = true);
+	void doFadeInSync(const TimeValue = kHalfSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, bool isBlack = true);
 
-protected:
-	uint32 _fadeTarget;
+	void setFaderValue(const int32);
 
 private:
-	static uint32 getBlack();
+	bool _isBlack;
+	uint32 fadePixel(uint32 color, int32 percent) const;
+	Graphics::Surface *_screen;
 };
 
 // Transitions are faders that range over [0,1000], which makes their


Commit: b625df161248582f5f0eb6b011029922aa4c84f0
    https://github.com/scummvm/scummvm/commit/b625df161248582f5f0eb6b011029922aa4c84f0
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-07-05T17:41:01-07:00

Commit Message:
PEGASUS: Cleanup doFadeOutSync/doFadeInSync calls

Changed paths:
    engines/pegasus/graphics.cpp
    engines/pegasus/graphics.h
    engines/pegasus/neighborhood/caldoria/caldoria.cpp



diff --git a/engines/pegasus/graphics.cpp b/engines/pegasus/graphics.cpp
index 8d0347e..1712ed5 100644
--- a/engines/pegasus/graphics.cpp
+++ b/engines/pegasus/graphics.cpp
@@ -204,13 +204,13 @@ DisplayElement *GraphicsManager::findDisplayElement(const DisplayElementID id) {
 	return 0;
 }
 
-void GraphicsManager::doFadeOutSync(const TimeValue time, const TimeScale scale, uint32 color) {
+void GraphicsManager::doFadeOutSync(const TimeValue time, const TimeScale scale, bool isBlack) {
 	_updatesEnabled = false;
-	_screenFader->doFadeOutSync(time, scale, color == 0);
+	_screenFader->doFadeOutSync(time, scale, isBlack);
 }
 
-void GraphicsManager::doFadeInSync(const TimeValue time, const TimeScale scale, uint32 color) {
-	_screenFader->doFadeInSync(time, scale, color == 0);
+void GraphicsManager::doFadeInSync(const TimeValue time, const TimeScale scale, bool isBlack) {
+	_screenFader->doFadeInSync(time, scale, isBlack);
 	_updatesEnabled = true;
 }
 
diff --git a/engines/pegasus/graphics.h b/engines/pegasus/graphics.h
index 2d66cd9..799f996 100644
--- a/engines/pegasus/graphics.h
+++ b/engines/pegasus/graphics.h
@@ -66,8 +66,8 @@ public:
 	void disableUpdates();
 
 	// These default to black
-	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
-	void doFadeInSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, uint32 color = 0);
+	void doFadeOutSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, bool isBlack = true);
+	void doFadeInSync(const TimeValue = kOneSecondPerThirtyTicks, const TimeScale = kThirtyTicksPerSecond, bool isBlack = true);
 
 protected:
 	void markCursorAsDirty();
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 817a24a..ce62b17 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -249,15 +249,14 @@ void Caldoria::start() {
 		ExtraTable::Entry entry;
 
 		if (!skipped) {
-			uint32 white = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
-			_vm->_gfx->doFadeOutSync(kThreeSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond, white);
+			_vm->_gfx->doFadeOutSync(kThreeSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond, false);
 			g_system->delayMillis(3 * 1000 / 2);
 			getExtraEntry(kCaldoria00WakeUp1, entry);
 			_navMovie.setTime(entry.movieStart);
 			_navMovie.redrawMovieWorld();
 			_navMovie.show();
 			_vm->refreshDisplay();
-			_vm->_gfx->doFadeInSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond, white);
+			_vm->_gfx->doFadeInSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond, false);
 		} else {
 			getExtraEntry(kCaldoria00WakeUp1, entry);
 			_navMovie.setTime(entry.movieStart);


Commit: 7a49b3669a0e18210a2f5409cb35da735f549b11
    https://github.com/scummvm/scummvm/commit/7a49b3669a0e18210a2f5409cb35da735f549b11
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-20T17:42:22-07:00

Commit Message:
PEGASUS: Optimize the nearest neighbor frame scaling a bit

Hopefully should improve performance on lower end systems

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 04b6f36..0e426a2 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -2106,31 +2106,40 @@ void PegasusEngine::doSubChase() {
 	delete video;
 }
 
+template<typename PixelInt>
+static void scaleFrame(const PixelInt *src, PixelInt *dst, int w, int h, int srcPitch) {
+	assert((srcPitch % sizeof(PixelInt)) == 0); // sanity check; allows some simpler code
+
+	PixelInt *dst1 = dst;
+	PixelInt *dst2 = dst + w * 2;
+
+	int srcInc = (srcPitch / sizeof(PixelInt)) - w;
+	int dstInc = w * 2;
+
+	while (h--) {
+		for (int x = 0; x < w; x++) {
+			PixelInt pixel = *src++;
+			*dst1++ = pixel;
+			*dst1++ = pixel;
+			*dst2++ = pixel;
+			*dst2++ = pixel;
+		}
+
+		src += srcInc;
+		dst1 += dstInc;
+		dst2 += dstInc;
+	}
+}
+
 void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y) {
 	// Scale up the frame doing some simple scaling
 	Graphics::Surface scaledFrame;
 	scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
-	const byte *src = (const byte *)frame->pixels;
-	byte *dst1 = (byte *)scaledFrame.pixels;
-	byte *dst2 = (byte *)scaledFrame.pixels + scaledFrame.pitch;
-
-	for (int i = 0; i < frame->h; i++) {
-		for (int j = 0; j < frame->w; j++) {
-			memcpy(dst1, src, frame->format.bytesPerPixel);
-			dst1 += frame->format.bytesPerPixel;
-			memcpy(dst1, src, frame->format.bytesPerPixel);
-			dst1 += frame->format.bytesPerPixel;
-			memcpy(dst2, src, frame->format.bytesPerPixel);
-			dst2 += frame->format.bytesPerPixel;
-			memcpy(dst2, src, frame->format.bytesPerPixel);
-			dst2 += frame->format.bytesPerPixel;
-			src += frame->format.bytesPerPixel;
-		}
 
-		src += frame->pitch - frame->format.bytesPerPixel * frame->w;
-		dst1 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-		dst2 += scaledFrame.pitch * 2 - scaledFrame.format.bytesPerPixel * scaledFrame.w;
-	}
+	if (frame->format.bytesPerPixel == 2)
+		scaleFrame<uint16>((uint16 *)frame->pixels, (uint16 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
+	else
+		scaleFrame<uint32>((uint32 *)frame->pixels, (uint32 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
 
 	_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
 	_system->updateScreen();


Commit: bb1e60e8b2f3bba06ae3b089097f94ea82a70c8a
    https://github.com/scummvm/scummvm/commit/bb1e60e8b2f3bba06ae3b089097f94ea82a70c8a
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-26T13:12:25-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Conflicts:
	AUTHORS
	devtools/credits.pl
	gui/credits.h

Changed paths:
  A devtools/create_project/msvc11/create_project.sln
  A devtools/create_project/msvc11/create_project.vcxproj
  A devtools/create_project/msvc11/create_project.vcxproj.filters
  A dists/msvc11/create_msvc11.bat
  A dists/msvc11/readme.txt
  A doc/da/HurtigStart
  A engines/gob/backbuffer.cpp
  A engines/gob/backbuffer.h
  A engines/gob/detection/tables_onceupon.h
  A engines/gob/pregob/gctfile.cpp
  A engines/gob/pregob/gctfile.h
  A engines/gob/pregob/onceupon/abracadabra.cpp
  A engines/gob/pregob/onceupon/abracadabra.h
  A engines/gob/pregob/onceupon/babayaga.cpp
  A engines/gob/pregob/onceupon/babayaga.h
  A engines/gob/pregob/onceupon/brokenstrings.h
  A engines/gob/pregob/onceupon/chargenchild.cpp
  A engines/gob/pregob/onceupon/chargenchild.h
  A engines/gob/pregob/onceupon/onceupon.cpp
  A engines/gob/pregob/onceupon/onceupon.h
  A engines/gob/pregob/onceupon/palettes.h
  A engines/gob/pregob/onceupon/parents.cpp
  A engines/gob/pregob/onceupon/parents.h
  A engines/gob/pregob/onceupon/stork.cpp
  A engines/gob/pregob/onceupon/stork.h
  A engines/gob/pregob/onceupon/title.cpp
  A engines/gob/pregob/onceupon/title.h
  A engines/gob/pregob/pregob.cpp
  A engines/gob/pregob/pregob.h
  A engines/gob/pregob/seqfile.cpp
  A engines/gob/pregob/seqfile.h
  A engines/gob/pregob/txtfile.cpp
  A engines/gob/pregob/txtfile.h
  A gui/saveload-dialog.cpp
  A gui/saveload-dialog.h
  A gui/themes/scummmodern/grid.bmp
  A gui/themes/scummmodern/list.bmp
  A video/theora_decoder.cpp
  A video/theora_decoder.h
  R engines/sword25/fmv/theora_decoder.cpp
  R engines/sword25/fmv/theora_decoder.h
    AUTHORS
    NEWS
    README
    audio/audiostream.cpp
    audio/audiostream.h
    audio/decoders/adpcm.cpp
    audio/decoders/adpcm_intern.h
    audio/decoders/qdm2.cpp
    audio/decoders/quicktime.cpp
    audio/mixer.h
    backends/events/gph/gph-events.cpp
    backends/events/gph/gph-events.h
    backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp
    backends/graphics/gph/gph-graphics.cpp
    backends/graphics/opengl/opengl-graphics.cpp
    backends/graphics/openpandora/op-graphics.cpp
    backends/graphics/openpandora/op-graphics.h
    backends/platform/android/android.mk
    backends/platform/android/texture.cpp
    backends/platform/bada/system.cpp
    backends/platform/dc/vmsave.cpp
    backends/platform/ds/arm9/source/gbampsave.cpp
    backends/platform/ds/arm9/source/gbampsave.h
    backends/platform/gph/gph-backend.cpp
    backends/platform/gph/gph-main.cpp
    backends/platform/gph/gph.h
    backends/platform/maemo/debian/changelog
    backends/platform/maemo/debian/control
    backends/platform/maemo/debian/rules
    backends/platform/maemo/maemo.cpp
    backends/platform/n64/framfs_save_manager.h
    backends/platform/n64/pakfs_save_manager.h
    backends/platform/openpandora/op-backend.cpp
    backends/platform/openpandora/op-sdl.h
    backends/platform/ps2/savefilemgr.cpp
    backends/platform/ps2/savefilemgr.h
    backends/platform/psp/README.PSP
    backends/platform/webos/webos.cpp
    backends/platform/webos/webos.h
    backends/platform/wii/osystem.cpp
    backends/platform/wii/osystem.h
    backends/platform/wii/osystem_gfx.cpp
    backends/saves/default/default-saves.cpp
    backends/saves/default/default-saves.h
    backends/saves/windows/windows-saves.cpp
    backends/timer/default/default-timer.cpp
    backends/timer/default/default-timer.h
    base/commandLine.cpp
    base/internal_version.h
    base/plugins.h
    common/endian.h
    common/keyboard.h
    common/quicktime.h
    common/savefile.h
    common/winexe_pe.cpp
    common/xmlparser.cpp
    common/zlib.cpp
    common/zlib.h
    configure
    devtools/README
    devtools/create_drascula/staticdata.h
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/games.cpp
    devtools/create_kyradat/tables.cpp
    devtools/create_project/create_project.cpp
    devtools/create_project/create_project.h
    devtools/create_project/msbuild.cpp
    devtools/create_project/scripts/postbuild.cmd
    devtools/create_project/visualstudio.cpp
    devtools/create_project/xcode.cpp
    devtools/create_teenagent/create_teenagent.cpp
    devtools/credits.pl
    devtools/scumm-md5.txt
    dists/android/AndroidManifest.xml
    dists/android/plugin-manifest.xml
    dists/engine-data/drascula.dat
    dists/engine-data/kyra.dat
    dists/engine-data/teenagent.dat
    dists/gph/README-GPH
    dists/gph/scummvm.ini
    dists/iphone/Info.plist
    dists/irix/scummvm.spec
    dists/macosx/Info.plist
    dists/openpandora/PXML.xml
    dists/openpandora/README-OPENPANDORA
    dists/openpandora/README-PND.txt
    dists/openpandora/index.html
    dists/redhat/scummvm-tools.spec
    dists/redhat/scummvm.spec
    dists/redhat/scummvm.spec.in
    dists/scummvm.rc
    dists/scummvm.rc.in
    dists/slackware/scummvm.SlackBuild
    dists/wii/meta.xml
    dists/win32/scummvm.nsi
    doc/cz/PrectiMe
    doc/de/Liesmich
    doc/de/Neues
    doc/se/LasMig
    engines/advancedDetector.cpp
    engines/advancedDetector.h
    engines/agi/detection.cpp
    engines/agos/animation.cpp
    engines/agos/animation.h
    engines/agos/event.cpp
    engines/agos/saveload.cpp
    engines/cge/bitmap.cpp
    engines/cge/cge.cpp
    engines/cge/cge.h
    engines/cge/cge_main.cpp
    engines/cge/cge_main.h
    engines/cge/detection.cpp
    engines/cge/events.cpp
    engines/cge/events.h
    engines/cge/fileio.cpp
    engines/cge/sound.cpp
    engines/cge/vga13h.cpp
    engines/cge/vga13h.h
    engines/cge/vmenu.cpp
    engines/cge/vmenu.h
    engines/cine/anim.cpp
    engines/cine/anim.h
    engines/cine/bg_list.cpp
    engines/cine/cine.cpp
    engines/cine/detection_tables.h
    engines/cine/gfx.cpp
    engines/cine/gfx.h
    engines/cine/main_loop.cpp
    engines/cine/saveload.cpp
    engines/cine/script_fw.cpp
    engines/cine/sound.cpp
    engines/cine/various.cpp
    engines/cine/various.h
    engines/composer/composer.cpp
    engines/cruise/detection.cpp
    engines/draci/detection.cpp
    engines/dreamweb/detection.cpp
    engines/dreamweb/detection_tables.h
    engines/dreamweb/dreamweb.h
    engines/dreamweb/stubs.cpp
    engines/gob/anifile.cpp
    engines/gob/anifile.h
    engines/gob/aniobject.cpp
    engines/gob/aniobject.h
    engines/gob/cmpfile.cpp
    engines/gob/cmpfile.h
    engines/gob/decfile.cpp
    engines/gob/detection/detection.cpp
    engines/gob/detection/tables.h
    engines/gob/detection/tables_ajworld.h
    engines/gob/detection/tables_fallback.h
    engines/gob/detection/tables_geisha.h
    engines/gob/draw.cpp
    engines/gob/draw.h
    engines/gob/draw_fascin.cpp
    engines/gob/draw_playtoons.cpp
    engines/gob/draw_v2.cpp
    engines/gob/game.cpp
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/init.cpp
    engines/gob/inter_bargon.cpp
    engines/gob/inter_geisha.cpp
    engines/gob/inter_v5.cpp
    engines/gob/minigames/geisha/penetration.cpp
    engines/gob/module.mk
    engines/gob/rxyfile.cpp
    engines/gob/rxyfile.h
    engines/gob/sound/sound.cpp
    engines/gob/sound/sound.h
    engines/gob/sound/soundblaster.cpp
    engines/gob/sound/soundblaster.h
    engines/gob/surface.cpp
    engines/gob/surface.h
    engines/gob/util.cpp
    engines/gob/util.h
    engines/gob/video.cpp
    engines/gob/video.h
    engines/groovie/saveload.cpp
    engines/hugo/detection.cpp
    engines/kyra/detection_tables.h
    engines/kyra/eobcommon.cpp
    engines/kyra/eobcommon.h
    engines/kyra/screen.cpp
    engines/kyra/screen.h
    engines/kyra/screen_eob.cpp
    engines/kyra/screen_lol.cpp
    engines/kyra/screen_lol.h
    engines/kyra/sound_intern.h
    engines/kyra/sound_midi.cpp
    engines/kyra/sound_towns.cpp
    engines/kyra/staticres.cpp
    engines/lastexpress/data/animation.cpp
    engines/lastexpress/data/cursor.cpp
    engines/lastexpress/data/font.cpp
    engines/lastexpress/data/scene.cpp
    engines/lastexpress/data/sequence.cpp
    engines/lastexpress/data/sequence.h
    engines/lastexpress/data/snd.cpp
    engines/lastexpress/data/subtitle.cpp
    engines/lastexpress/debug.cpp
    engines/lastexpress/detection.cpp
    engines/lastexpress/entities/abbot.cpp
    engines/lastexpress/entities/abbot.h
    engines/lastexpress/entities/alexei.cpp
    engines/lastexpress/entities/alexei.h
    engines/lastexpress/entities/alouan.cpp
    engines/lastexpress/entities/alouan.h
    engines/lastexpress/entities/anna.cpp
    engines/lastexpress/entities/anna.h
    engines/lastexpress/entities/august.cpp
    engines/lastexpress/entities/august.h
    engines/lastexpress/entities/boutarel.cpp
    engines/lastexpress/entities/boutarel.h
    engines/lastexpress/entities/chapters.cpp
    engines/lastexpress/entities/chapters.h
    engines/lastexpress/entities/cooks.cpp
    engines/lastexpress/entities/cooks.h
    engines/lastexpress/entities/coudert.cpp
    engines/lastexpress/entities/coudert.h
    engines/lastexpress/entities/entity.cpp
    engines/lastexpress/entities/entity.h
    engines/lastexpress/entities/entity39.cpp
    engines/lastexpress/entities/entity39.h
    engines/lastexpress/entities/entity_intern.h
    engines/lastexpress/entities/francois.cpp
    engines/lastexpress/entities/francois.h
    engines/lastexpress/entities/gendarmes.cpp
    engines/lastexpress/entities/gendarmes.h
    engines/lastexpress/entities/hadija.cpp
    engines/lastexpress/entities/hadija.h
    engines/lastexpress/entities/ivo.cpp
    engines/lastexpress/entities/ivo.h
    engines/lastexpress/entities/kahina.cpp
    engines/lastexpress/entities/kahina.h
    engines/lastexpress/entities/kronos.cpp
    engines/lastexpress/entities/kronos.h
    engines/lastexpress/entities/mahmud.cpp
    engines/lastexpress/entities/mahmud.h
    engines/lastexpress/entities/max.cpp
    engines/lastexpress/entities/max.h
    engines/lastexpress/entities/mertens.cpp
    engines/lastexpress/entities/mertens.h
    engines/lastexpress/entities/milos.cpp
    engines/lastexpress/entities/milos.h
    engines/lastexpress/entities/mmeboutarel.cpp
    engines/lastexpress/entities/mmeboutarel.h
    engines/lastexpress/entities/pascale.cpp
    engines/lastexpress/entities/pascale.h
    engines/lastexpress/entities/rebecca.cpp
    engines/lastexpress/entities/rebecca.h
    engines/lastexpress/entities/salko.cpp
    engines/lastexpress/entities/salko.h
    engines/lastexpress/entities/servers0.cpp
    engines/lastexpress/entities/servers0.h
    engines/lastexpress/entities/servers1.cpp
    engines/lastexpress/entities/servers1.h
    engines/lastexpress/entities/sophie.cpp
    engines/lastexpress/entities/sophie.h
    engines/lastexpress/entities/tables.cpp
    engines/lastexpress/entities/tables.h
    engines/lastexpress/entities/tatiana.cpp
    engines/lastexpress/entities/tatiana.h
    engines/lastexpress/entities/train.cpp
    engines/lastexpress/entities/train.h
    engines/lastexpress/entities/vassili.cpp
    engines/lastexpress/entities/vassili.h
    engines/lastexpress/entities/verges.cpp
    engines/lastexpress/entities/verges.h
    engines/lastexpress/entities/vesna.cpp
    engines/lastexpress/entities/vesna.h
    engines/lastexpress/entities/yasmin.cpp
    engines/lastexpress/entities/yasmin.h
    engines/lastexpress/fight/fight.cpp
    engines/lastexpress/fight/fighter.cpp
    engines/lastexpress/fight/fighter.h
    engines/lastexpress/game/action.cpp
    engines/lastexpress/game/beetle.cpp
    engines/lastexpress/game/beetle.h
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/game/entities.h
    engines/lastexpress/game/inventory.cpp
    engines/lastexpress/game/inventory.h
    engines/lastexpress/game/logic.cpp
    engines/lastexpress/game/logic.h
    engines/lastexpress/game/object.cpp
    engines/lastexpress/game/savegame.cpp
    engines/lastexpress/game/savegame.h
    engines/lastexpress/game/savepoint.cpp
    engines/lastexpress/game/savepoint.h
    engines/lastexpress/game/scenes.cpp
    engines/lastexpress/game/scenes.h
    engines/lastexpress/game/state.cpp
    engines/lastexpress/game/state.h
    engines/lastexpress/helpers.h
    engines/lastexpress/lastexpress.cpp
    engines/lastexpress/menu/menu.cpp
    engines/lastexpress/resource.cpp
    engines/lastexpress/resource.h
    engines/lastexpress/shared.h
    engines/lastexpress/sound/entry.cpp
    engines/lastexpress/sound/queue.cpp
    engines/lastexpress/sound/queue.h
    engines/lastexpress/sound/sound.cpp
    engines/lure/surface.cpp
    engines/mohawk/detection.cpp
    engines/mohawk/detection_tables.h
    engines/mohawk/livingbooks.cpp
    engines/mohawk/livingbooks.h
    engines/mohawk/myst.cpp
    engines/mohawk/myst_graphics.cpp
    engines/mohawk/myst_graphics.h
    engines/mohawk/myst_stacks/dni.cpp
    engines/mohawk/myst_stacks/intro.cpp
    engines/mohawk/riven.cpp
    engines/mohawk/video.cpp
    engines/mohawk/video.h
    engines/parallaction/disk_br.cpp
    engines/parallaction/disk_ns.cpp
    engines/parallaction/graphics.cpp
    engines/parallaction/graphics.h
    engines/parallaction/sound_ns.cpp
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h
    engines/pegasus/surface.cpp
    engines/pegasus/surface.h
    engines/queen/queen.cpp
    engines/saga/detection.cpp
    engines/saga/introproc_saga2.cpp
    engines/saga/shorten.cpp
    engines/savestate.h
    engines/sci/console.cpp
    engines/sci/detection.cpp
    engines/sci/detection_tables.h
    engines/sci/engine/file.cpp
    engines/sci/engine/kernel.cpp
    engines/sci/engine/kernel.h
    engines/sci/engine/kernel_tables.h
    engines/sci/engine/kfile.cpp
    engines/sci/engine/kgraphics.cpp
    engines/sci/engine/kgraphics32.cpp
    engines/sci/engine/klists.cpp
    engines/sci/engine/kmath.cpp
    engines/sci/engine/kmisc.cpp
    engines/sci/engine/ksound.cpp
    engines/sci/engine/kvideo.cpp
    engines/sci/engine/message.cpp
    engines/sci/engine/script.cpp
    engines/sci/engine/script.h
    engines/sci/engine/script_patches.cpp
    engines/sci/engine/seg_manager.cpp
    engines/sci/engine/seg_manager.h
    engines/sci/engine/state.cpp
    engines/sci/engine/state.h
    engines/sci/engine/vm.cpp
    engines/sci/engine/vm.h
    engines/sci/engine/workarounds.cpp
    engines/sci/graphics/font.cpp
    engines/sci/graphics/frameout.cpp
    engines/sci/graphics/frameout.h
    engines/sci/graphics/palette.cpp
    engines/sci/graphics/palette.h
    engines/sci/graphics/screen.cpp
    engines/sci/graphics/screen.h
    engines/sci/graphics/view.cpp
    engines/sci/sci.cpp
    engines/sci/sound/audio.cpp
    engines/sci/sound/soundcmd.cpp
    engines/sci/video/robot_decoder.cpp
    engines/sci/video/robot_decoder.h
    engines/sci/video/seq_decoder.cpp
    engines/sci/video/seq_decoder.h
    engines/scumm/detection.cpp
    engines/scumm/he/animation_he.cpp
    engines/scumm/scumm-md5.h
    engines/sword1/animation.cpp
    engines/sword1/animation.h
    engines/sword1/detection.cpp
    engines/sword1/logic.cpp
    engines/sword1/objectman.cpp
    engines/sword1/objectman.h
    engines/sword1/sound.cpp
    engines/sword2/animation.cpp
    engines/sword2/animation.h
    engines/sword2/function.cpp
    engines/sword25/fmv/movieplayer.cpp
    engines/sword25/fmv/movieplayer.h
    engines/sword25/module.mk
    engines/sword25/sfx/soundengine.cpp
    engines/sword25/util/pluto/pluto.cpp
    engines/teenagent/callbacks.cpp
    engines/teenagent/detection.cpp
    engines/teenagent/resources.cpp
    engines/teenagent/teenagent.cpp
    engines/testbed/graphics.cpp
    engines/testbed/testsuite.cpp
    engines/tinsel/detection.cpp
    engines/tinsel/detection_tables.h
    engines/tinsel/dialogs.cpp
    engines/tinsel/dialogs.h
    engines/tinsel/drives.cpp
    engines/tinsel/handle.cpp
    engines/tinsel/music.cpp
    engines/tinsel/pcode.cpp
    engines/tinsel/saveload.cpp
    engines/tinsel/scene.h
    engines/tinsel/sound.cpp
    engines/tinsel/tinlib.cpp
    engines/tinsel/tinsel.h
    engines/toltecs/detection.cpp
    engines/toon/anim.cpp
    engines/toon/anim.h
    engines/toon/audio.cpp
    engines/toon/character.cpp
    engines/toon/detection.cpp
    engines/toon/font.cpp
    engines/toon/font.h
    engines/toon/hotspot.cpp
    engines/toon/hotspot.h
    engines/toon/movie.cpp
    engines/toon/movie.h
    engines/toon/picture.cpp
    engines/toon/picture.h
    engines/toon/script_func.cpp
    engines/toon/toon.cpp
    engines/toon/toon.h
    engines/touche/detection.cpp
    engines/tsage/blue_force/blueforce_dialogs.cpp
    engines/tsage/blue_force/blueforce_scenes9.cpp
    engines/tsage/converse.cpp
    engines/tsage/detection.cpp
    engines/tsage/detection_tables.h
    engines/tsage/dialogs.cpp
    engines/tsage/globals.cpp
    engines/tsage/globals.h
    engines/tsage/graphics.cpp
    engines/tsage/graphics.h
    engines/tsage/ringworld/ringworld_dialogs.cpp
    engines/tsage/ringworld/ringworld_logic.cpp
    engines/tsage/ringworld/ringworld_scenes5.cpp
    engines/tsage/ringworld2/ringworld2_dialogs.cpp
    engines/tsage/ringworld2/ringworld2_speakers.h
    engines/tsage/user_interface.cpp
    engines/tucker/sequences.cpp
    graphics/decoders/bmp.cpp
    graphics/decoders/image_decoder.h
    graphics/decoders/png.cpp
    graphics/decoders/png.h
    graphics/fonts/ttf.cpp
    graphics/fonts/ttf.h
    graphics/iff.cpp
    gui/ThemeEngine.cpp
    gui/ThemeEngine.h
    gui/Tooltip.cpp
    gui/credits.h
    gui/gui-manager.cpp
    gui/module.mk
    gui/saveload.cpp
    gui/saveload.h
    gui/themes/default.inc
    gui/themes/scummclassic.zip
    gui/themes/scummclassic/THEMERC
    gui/themes/scummclassic/classic_layout.stx
    gui/themes/scummclassic/classic_layout_lowres.stx
    gui/themes/scummmodern.zip
    gui/themes/scummmodern/THEMERC
    gui/themes/scummmodern/scummmodern_gfx.stx
    gui/themes/scummmodern/scummmodern_layout.stx
    gui/themes/scummmodern/scummmodern_layout_lowres.stx
    gui/themes/translations.dat
    gui/widget.cpp
    gui/widget.h
    po/POTFILES
    po/ca_ES.po
    po/cs_CZ.po
    po/da_DA.po
    po/de_DE.po
    po/es_ES.po
    po/eu.po
    po/fr_FR.po
    po/hu_HU.po
    po/it_IT.po
    po/nb_NO.po
    po/nn_NO.po
    po/pl_PL.po
    po/pt_BR.po
    po/ru_RU.po
    po/scummvm.pot
    po/se_SE.po
    po/uk_UA.po
    ports.mk
    video/avi_decoder.cpp
    video/avi_decoder.h
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/coktel_decoder.cpp
    video/coktel_decoder.h
    video/dxa_decoder.cpp
    video/dxa_decoder.h
    video/flic_decoder.cpp
    video/flic_decoder.h
    video/module.mk
    video/psx_decoder.cpp
    video/psx_decoder.h
    video/qt_decoder.cpp
    video/qt_decoder.h
    video/smk_decoder.cpp
    video/smk_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h



diff --cc AUTHORS
index e13de73,02c805b..e2c28b4
--- a/AUTHORS
+++ b/AUTHORS
@@@ -600,6 -599,10 +602,13 @@@ Special thanks t
     Broken Sword 2.5 team for providing sources of their engine and their
     great support.
  
+    Neil Dodwell and David Dew from Creative Reality for providing the source
+    of Dreamweb and for their tremendous support.
+ 
+    Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe
+    Avalon for providing full source code for Soltys and letting us to
+    redistribute the game.
+ 
 +   Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing
 +   the source code of The Journeyman Project: Pegasus Prime.
 +
diff --cc devtools/credits.pl
index db69756,6a4b97b..5cfa498
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@@ -1132,9 -1133,13 +1137,17 @@@ begin_credits("Credits")
      "support.");
  
  	add_paragraph(
+     "Neil Dodwell and David Dew from Creative Reality for providing the source ".
+     "of Dreamweb and for their tremendous support.");
+ 
+ 	add_paragraph(
+     "Janusz Wiśniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon ".
+     "for providing full source code for Sołtys and letting us to redistribute the game.");
+ 
++	add_paragraph(
 +    "Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for ".
 +    "providing the source code of The Journeyman Project: Pegasus Prime.");
 +
  	end_section();
  
  end_credits();
diff --cc engines/pegasus/movie.cpp
index 5d393de,0000000..fc722e5
mode 100644,000000..100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@@ -1,264 -1,0 +1,262 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/system.h"
 +#include "graphics/surface.h"
 +#include "video/qt_decoder.h"
 +#include "video/video_decoder.h"
 +
 +#include "pegasus/movie.h"
 +
 +namespace Pegasus {
 +
 +Movie::Movie(const DisplayElementID id) : Animation(id) {
 +	_video = 0;
 +	setScale(600);
 +}
 +
 +Movie::~Movie() {
 +	releaseMovie();
 +}
 +
 +// *** Make sure this will stop displaying the movie.
 +
 +void Movie::releaseMovie() {
 +	if (_video) {
 +		delete _video;
 +		_video = 0;
 +		disposeAllCallBacks();
 +		deallocateSurface();
 +	}
 +
 +	setBounds(Common::Rect(0, 0, 0, 0));
 +}
 +
 +void Movie::initFromMovieFile(const Common::String &fileName, bool transparent) {
 +	_transparent = transparent;
 +
 +	releaseMovie();
 +	_video = new Video::QuickTimeDecoder();
 +	if (!_video->loadFile(fileName)) {
 +		// Replace any colon with an underscore, since only Mac OS X
 +		// supports that. See PegasusEngine::detectOpeningClosingDirectory()
 +		// for more info.
 +		Common::String newName(fileName);
 +		if (newName.contains(':'))
 +			for (uint i = 0; i < newName.size(); i++)
 +				if (newName[i] == ':')
 +					newName.setChar('_', i);
 +
 +		if (!_video->loadFile(newName))
 +			error("Could not load video '%s'", fileName.c_str());
 +	}
 +
- 	_video->pauseVideo(true);
- 
 +	Common::Rect bounds(0, 0, _video->getWidth(), _video->getHeight());
 +	sizeElement(_video->getWidth(), _video->getHeight());
 +	_movieBox = bounds;
 +
 +	if (!isSurfaceValid())
 +		allocateSurface(bounds);
 +
 +	setStart(0, getScale());
- 	setStop(_video->getDuration() * getScale() / 1000, getScale());
++	setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale());
 +}
 +
 +void Movie::redrawMovieWorld() {
 +	if (_video && _video->needsUpdate()) {
 +		const Graphics::Surface *frame = _video->decodeNextFrame();
 +
 +		if (!frame)
 +			return;
 +
 +		// Make sure we have a surface in the current pixel format
 +		Graphics::Surface *convertedFrame = 0;
 +
 +		if (frame->format != g_system->getScreenFormat()) {
 +			convertedFrame = frame->convertTo(g_system->getScreenFormat());
 +			frame = convertedFrame;
 +		}
 +
 +		// Copy to the surface using _movieBox
 +		uint16 width = MIN<int>(frame->w, _movieBox.width());
 +		uint16 height = MIN<int>(frame->h, _movieBox.height());
 +
 +		for (uint16 y = 0; y < height; y++)
 +			memcpy((byte *)_surface->getBasePtr(_movieBox.left, _movieBox.top + y), (const byte *)frame->getBasePtr(0, y), width * frame->format.bytesPerPixel);
 +
 +		if (convertedFrame) {
 +			convertedFrame->free();
 +			delete convertedFrame;
 +		}
 +
 +		triggerRedraw();
 +	}
 +}
 +
 +void Movie::draw(const Common::Rect &r) {	
 +	Common::Rect worldBounds = _movieBox;
 +	Common::Rect elementBounds;
 +	getBounds(elementBounds);
 +
 +	worldBounds.moveTo(elementBounds.left, elementBounds.top);
 +	Common::Rect r1 = r.findIntersectingRect(worldBounds);
 +
 +	Common::Rect r2 = r1;
 +	r2.translate(_movieBox.left - elementBounds.left, _movieBox.top - elementBounds.top);
 +	drawImage(r2, r1);
 +}
 +
 +void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 +	_movieBox.moveTo(h, v);
 +}
 +
 +void Movie::setVolume(uint16 volume) {
 +	if (_video)
 +		_video->setVolume(MIN<uint>(volume, 0xFF));
 +}
 +
 +void Movie::setTime(const TimeValue time, const TimeScale scale) {
 +	if (_video) {
 +		// Don't go past the ends of the movie
 +		Common::Rational timeFrac = Common::Rational(time, ((scale == 0) ? getScale() : scale));
 +
 +		if (timeFrac < Common::Rational(_startTime, _startScale))
 +			timeFrac = Common::Rational(_startTime, _startScale);
 +		else if (timeFrac >= Common::Rational(_stopTime, _stopScale))
 +			return;
 +
- 		_video->seekToTime(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator()));
++		_video->seek(Audio::Timestamp(0, timeFrac.getNumerator(), timeFrac.getDenominator()));
 +		_time = timeFrac;
 +		_lastMillis = 0;
 +	}
 +}
 +
 +void Movie::setRate(const Common::Rational rate) {
 +	if (rate != 1 && rate != 0) {
 +		warning("Cannot set movie rate");
 +		start();
 +		return;
 +	}
 +
 +	TimeBase::setRate(rate);
 +}
 +
 +void Movie::start() {
- 	if (_video && _video->isPaused())
- 		_video->pauseVideo(false);
++	if (_video)
++		_video->start();
 +
 +	TimeBase::start();
 +}
 +
 +void Movie::stop() {
- 	if (_video && !_video->isPaused())
- 		_video->pauseVideo(true);
++	if (_video)
++		_video->stop();
 +
 +	TimeBase::stop();
 +}
 +
 +void Movie::resume() {
 +	if (_video)
 +		_video->pauseVideo(false);
 +
 +	TimeBase::resume();
 +}
 +
 +void Movie::pause() {
 +	if (_video)
 +		_video->pauseVideo(true);
 +
 +	TimeBase::pause();
 +}
 +
 +TimeValue Movie::getDuration(const TimeScale scale) const {
 +	// Unlike TimeBase::getDuration(), this returns the whole duration of the movie
 +	// The original source has a TODO to make this behave like TimeBase::getDuration(),
 +	// but the problem is that too much code requires this function to behave this way...
 +
 +	if (_video)
- 		return _video->getDuration() * ((scale == 0) ? getScale() : scale) / 1000;
++		return _video->getDuration().convertToFramerate(((scale == 0) ? getScale() : scale)).totalNumberOfFrames();
 +
 +	return 0;
 +}
 +
 +void Movie::updateTime() {
 +	// The reason why we overrode TimeBase's updateTime():
 +	// Again, avoiding timers and handling it here
 +	if (_video && !_video->isPaused()) {
 +		redrawMovieWorld();
 +
 +		uint32 startTime = _startTime * getScale() / _startScale;
 +		uint32 stopTime = _stopTime * getScale() / _stopScale;
 +		uint32 actualTime = CLIP<int>(_video->getTime() * getScale() / 1000, startTime, stopTime);
 +		_time = Common::Rational(actualTime, getScale());
 +	}
 +}
 +
 +GlowingMovie::GlowingMovie(const DisplayElementID id) : Movie(id) {
 +	_glowing = false;
 +}
 +
 +void GlowingMovie::draw(const Common::Rect &r) {
 +	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
 +	// never fall off the screen.
 +	if (_glowing) {
 +		Common::Rect bounds;
 +		getBounds(bounds);
 +
 +		copyToCurrentPortTransparentGlow(_movieBox, bounds);
 +	} else {
 +		Movie::draw(r);
 +	}
 +}
 +
 +void GlowingMovie::setBounds(const Common::Rect &r) {
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +
 +	if (r != bounds) {
 +		// Avoid Movie::setBounds.
 +		// clone2727 asks why, but goes along with it
 +		Animation::setBounds(r);
 +	}
 +}
 +
 +ScalingMovie::ScalingMovie(const DisplayElementID id) : GlowingMovie(id) {
 +}
 +
 +void ScalingMovie::draw(const Common::Rect &) {
 +	// Make sure the rectangles are clipped properly, OR guarantee that _bounds will
 +	// never fall off the screen.
 +
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +
 +	if (_glowing)
 +		scaleTransparentCopyGlow(_movieBox, bounds);
 +	else
 +		scaleTransparentCopy(_movieBox, bounds);
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/movie.h
index 593442f,0000000..efe4a7c
mode 100644,000000..100644
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@@ -1,103 -1,0 +1,103 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#ifndef PEGASUS_MOVIE_H
 +#define PEGASUS_MOVIE_H
 +
 +#include "common/str.h"
 +
 +#include "pegasus/elements.h"
 +#include "pegasus/surface.h"
 +
 +namespace Video {
- 	class SeekableVideoDecoder;
++class VideoDecoder;
 +}
 +
 +namespace Pegasus {
 +
 +class Movie : public Animation, public PixelImage {
 +public:
 +	Movie(const DisplayElementID);
 +	virtual ~Movie();
 +
 +	virtual void initFromMovieFile(const Common::String &fileName, bool transparent = false);
 +
 +	bool isMovieValid() { return _video != 0; }
 +
 +	virtual void releaseMovie();
 +
 +	virtual void draw(const Common::Rect &);
 +	virtual void redrawMovieWorld();
 +
 +	virtual void setTime(const TimeValue, const TimeScale = 0);
 +
 +	virtual void setRate(const Common::Rational);
 +
 +	virtual void start();
 +	virtual void stop();
 +	virtual void resume();
 +	virtual void pause();
 +
 +	virtual void moveMovieBoxTo(const CoordType, const CoordType);
 +
 +	virtual TimeValue getDuration(const TimeScale = 0) const;
 +
 +	// *** HACK ALERT
- 	Video::SeekableVideoDecoder *getMovie() { return _video; }
++	Video::VideoDecoder *getMovie() { return _video; }
 +	void setVolume(uint16);
 +
 +protected:
 +	void updateTime();
 +
- 	Video::SeekableVideoDecoder *_video;
++	Video::VideoDecoder *_video;
 +	Common::Rect _movieBox;
 +};
 +
 +class GlowingMovie : public Movie {
 +public:
 +	GlowingMovie(DisplayElementID);
 +	virtual ~GlowingMovie() {}
 +
 +	virtual void draw(const Common::Rect &);
 +
 +	void setBounds(const Common::Rect &);
 +
 +	void setGlowing(const bool glowing) { _glowing = glowing; }
 +
 +protected:
 +	bool _glowing;
 +};
 +
 +class ScalingMovie : public GlowingMovie {
 +public:
 +	ScalingMovie(DisplayElementID);
 +	virtual ~ScalingMovie() {}
 +
 +	virtual void draw(const Common::Rect &);
 +};
 +
 +} // End of namespace Pegasus
 +
 +#endif
diff --cc engines/pegasus/neighborhood/caldoria/caldoria.cpp
index ce62b17,0000000..a6806d5
mode 100644,000000..100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@@ -1,1970 -1,0 +1,1970 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/system.h"
 +#include "video/qt_decoder.h"
 +
 +#include "pegasus/cursor.h"
 +#include "pegasus/energymonitor.h"
 +#include "pegasus/gamestate.h"
 +#include "pegasus/interface.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/ai/ai_area.h"
 +#include "pegasus/items/biochips/biochipitem.h"
 +#include "pegasus/neighborhood/caldoria/caldoria.h"
 +#include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
 +#include "pegasus/neighborhood/caldoria/caldoriabomb.h"
 +#include "pegasus/neighborhood/caldoria/caldoriamessages.h"
 +#include "pegasus/neighborhood/caldoria/caldoriamirror.h"
 +#include "pegasus/neighborhood/tsa/fulltsa.h"
 +
 +namespace Pegasus {
 +
 +static const int16 kVidPhoneAngle = 30;
 +static const int16 kReplicatorAngle = 50;
 +static const int16 kDrawersAngle = -30;
 +static const int16 kCaldoria53Angle = 45;
 +static const int16 kCaldoria55Angle = -45;
 +
 +static const TimeValue kSinclairInterruptionTime1 = 2955;
 +static const TimeValue kSinclairInterruptionTime2 = 6835;
 +static const TimeValue kSinclairInterruptionTime3 = 9835;
 +static const TimeValue kSinclairInterruptionTime4 = 12555;
 +
 +static const InputBits kPullbackInterruptFilter = kFilterAllInput;
 +static const InputBits kRecalibrationInterruptFilter = kFilterAllInput;
 +
 +static const TimeValue kCaldoriaReplicatorIntroIn = 4933;
 +static const TimeValue kCaldoriaReplicatorIntroOut = 6557;
 +
 +static const TimeValue kCaldoriaReplicatorWrongChoiceIn = 6557;
 +static const TimeValue kCaldoriaReplicatorWrongChoiceOut = 8586;
 +
 +static const TimeValue kCaldoriaReplicatorOJChoiceIn = 8586;
 +static const TimeValue kCaldoriaReplicatorOJChoiceOut = 11687;
 +
 +static const TimeValue kCaldoriaMessagesIntroIn = 11687;
 +static const TimeValue kCaldoriaMessagesIntroOut = 13641;
 +
 +static const TimeValue kCaldoriaFirstMessageIn = 13641;
 +static const TimeValue kCaldoriaFirstMessageOut = 14203;
 +
 +static const TimeValue kCaldoriaSecondMessageIn = 14203;
 +static const TimeValue kCaldoriaSecondMessageOut = 14750;
 +
 +static const TimeValue kCaldoriaDoorCloseIn = 14750;
 +static const TimeValue kCaldoriaDoorCloseOut = 15472;
 +
 +static const TimeValue kCaldoriaElevatorCloseIn = 15472;
 +static const TimeValue kCaldoriaElevatorCloseOut = 16336;
 +
 +static const TimeValue kCaldoriaShowerCloseIn = 16336;
 +static const TimeValue kCaldoriaShowerCloseOut = 17101;
 +
 +static const TimeValue kCaldoriaGTDoorCloseIn = 17101;
 +static const TimeValue kCaldoriaGTDoorCloseOut = 18523;
 +
 +static const TimeValue kCaldoriaNobodyHomeIn = 18523;
 +static const TimeValue kCaldoriaNobodyHomeOut = 21469;
 +
 +static const TimeValue kCaldoriaNoOtherFloorIn = 21469;
 +static const TimeValue kCaldoriaNoOtherFloorOut = 28013;
 +
 +static const TimeValue kCaldoria4DInstructionsIn = 28013;
 +static const TimeValue kCaldoria4DInstructionsOut = 29730;
 +
 +static const TimeValue kCaldoriaDrinkOJIn = 33910;
 +static const TimeValue kCaldoriaDrinkOJOut = 35846;
 +
 +static const TimeValue kCaldoriaNoOtherDestinationIn = 35846;
 +static const TimeValue kCaldoriaNoOtherDestinationOut = 37877;
 +
 +static const TimeValue kCaldoriaUhghIn = 37877;
 +static const TimeValue kCaldoriaUhghOut = 38025;
 +
 +static const TimeValue kCaldoriaSinclairShootsOSIn = 38025;
 +static const TimeValue kCaldoriaSinclairShootsOSOut = 40649;
 +
 +static const TimeValue kCaldoriaScreamingAfterIn = 40649;
 +static const TimeValue kCaldoriaScreamingAfterOut = 47661;
 +
 +static const TimeValue k4FloorTime = 0;
 +
 +static const TimeValue k4To1Start = 40;
 +static const TimeValue k4To1Stop = 7720;
 +
 +static const TimeValue k4To5Start = 7720;
 +static const TimeValue k4To5Stop = 10280;
 +
 +static const TimeValue k4To2Time = 10280;
 +
 +static const TimeValue k4To3Time = 10320;
 +
 +static const TimeValue k1FloorTime = 10360;
 +
 +static const TimeValue k1To4Start = 10400;
 +static const TimeValue k1To4Stop = 18080;
 +
 +static const TimeValue k1To5Start = 18080;
 +static const TimeValue k1To5Stop = 28320;
 +
 +static const TimeValue k1To2Time = 28320;
 +
 +static const TimeValue k1To3Time = 28360;
 +
 +static const TimeValue k5FloorTime = 28400;
 +
 +static const TimeValue k5To1Start = 28440;
 +static const TimeValue k5To1Stop = 38680;
 +
 +static const TimeValue k5To4Start = 38680;
 +static const TimeValue k5To4Stop = 41240;
 +
 +static const TimeValue k5To2Time = 41240;
 +
 +static const TimeValue k5To3Time = 41280;
 +
 +// FuseFunction functions...
 +
 +const NotificationFlags kSinclairLoopDoneFlag = kLastNeighborhoodNotificationFlag << 1;
 +
 +void doorBombTimerExpiredFunction(FunctionPtr *, void *caldoria) {
 +	((Caldoria *)caldoria)->doorBombTimerExpired();
 +}
 +
 +void sinclairTimerExpiredFunction(FunctionPtr *, void *caldoria) {
 +	((Caldoria *)caldoria)->sinclairTimerExpired();
 +}
 +
 +SinclairCallBack::SinclairCallBack(Caldoria *caldoria) {
 +	_caldoria = caldoria;
 +}
 +
 +void SinclairCallBack::callBack() {
 +	_caldoria->checkInterruptSinclair();
 +}
 +
 +Caldoria::Caldoria(InputHandler* nextHandler, PegasusEngine *owner)
 +		: Neighborhood(nextHandler, owner, "Caldoria", kCaldoriaID), _sinclairInterrupt(this) {
 +	setIsItemTaken(kKeyCard);
 +	setIsItemTaken(kOrangeJuiceGlassEmpty);
 +	GameState.setTakenItemID(kOrangeJuiceGlassFull, GameState.isTakenItemID(kOrangeJuiceGlassEmpty));
 +	_zoomOutSpot = 0;
 +	_gunSprite = 0;
 +}
 +
 +Caldoria::~Caldoria() {
 +	_sinclairInterrupt.releaseCallBack();
 +}
 +
 +void Caldoria::init() {
 +	Neighborhood::init();
 +
 +	// We need this notification flag as well.
 +	_neighborhoodNotification.notifyMe(this, kSinclairLoopDoneFlag, kSinclairLoopDoneFlag);
 +
 +	_sinclairInterrupt.initCallBack(&_navMovie, kCallBackAtTime);
 +
 +	forceStridingStop(kCaldoria55, kSouth, kAltCaldoriaSinclairDown);
 +	forceStridingStop(kCaldoria50, kNorth, kAltCaldoriaSinclairDown);
 +}
 +
 +void Caldoria::start() {	
 +	g_energyMonitor->stopEnergyDraining();
 +
 +	if (!GameState.getCaldoriaSeenPullback()) {
 +		_vm->_gfx->doFadeOutSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
 +
 +		g_system->delayMillis(2 * 1000);
 +
 +		Video::VideoDecoder *pullbackMovie = new Video::QuickTimeDecoder();
 +
 +		if (!pullbackMovie->loadFile("Images/Caldoria/Pullback.movie"))
 +			error("Could not load pullback movie");
 +
 +		// Draw the first frame so we can fade to it
- 		pullbackMovie->pauseVideo(true);
 +		const Graphics::Surface *frame = pullbackMovie->decodeNextFrame();
 +		assert(frame);
 +		assert(frame->format == g_system->getScreenFormat());
 +		g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
 +		_vm->_gfx->doFadeInSync(kTwoSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond);
- 		pullbackMovie->pauseVideo(false);
 +
 +		bool saveAllowed = _vm->swapSaveAllowed(false);
 +		bool openAllowed = _vm->swapLoadAllowed(false);
 +
 +		bool skipped = false;
 +		Input input;
 +
++		pullbackMovie->start();
++
 +		while (!_vm->shouldQuit() && !pullbackMovie->endOfVideo()) {
 +			if (pullbackMovie->needsUpdate()) {
 +				frame = pullbackMovie->decodeNextFrame();
 +
 +				if (frame) {
 +					g_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 64, 112, frame->w, frame->h);
 +					g_system->updateScreen();
 +				}
 +			}
 +
 +			InputDevice.getInput(input, kPullbackInterruptFilter);
 +			if (input.anyInput() || _vm->saveRequested() || _vm->loadRequested()) {
 +				skipped = true;
 +				break;
 +			}
 +
 +			g_system->delayMillis(10);
 +		}
 +
 +		delete pullbackMovie;
 +
 +		if (_vm->shouldQuit())
 +			return;
 +
 +		_vm->swapSaveAllowed(saveAllowed);
 +		_vm->swapLoadAllowed(openAllowed);
 +
 +		ExtraTable::Entry entry;
 +
 +		if (!skipped) {
 +			_vm->_gfx->doFadeOutSync(kThreeSeconds * kFifteenTicksPerSecond, kFifteenTicksPerSecond, false);
 +			g_system->delayMillis(3 * 1000 / 2);
 +			getExtraEntry(kCaldoria00WakeUp1, entry);
 +			_navMovie.setTime(entry.movieStart);
 +			_navMovie.redrawMovieWorld();
 +			_navMovie.show();
 +			_vm->refreshDisplay();
 +			_vm->_gfx->doFadeInSync(kOneSecond * kFifteenTicksPerSecond, kFifteenTicksPerSecond, false);
 +		} else {
 +			getExtraEntry(kCaldoria00WakeUp1, entry);
 +			_navMovie.setTime(entry.movieStart);
 +			_navMovie.redrawMovieWorld();
 +			_navMovie.show();
 +		}
 +
 +		GameState.setCaldoriaSeenPullback(true);
 +	}
 +
 +	Neighborhood::start();
 +}
 +
 +void Caldoria::flushGameState() {
 +	GameState.setCaldoriaFuseTimeLimit(_utilityFuse.getTimeRemaining());
 +}
 +
 +class AIBombActiveCondition : public AICondition {
 +public:
 +	AIBombActiveCondition() {}
 +
 +	bool fireCondition();
 +};
 +
 +// Return true if player is on 53 east and Sinclair is shot.
 +bool AIBombActiveCondition::fireCondition() {
 +	return GameState.getCurrentRoom() == kCaldoria53 && GameState.getCurrentDirection() == kEast &&
 +			GameState.getCaldoriaSinclairShot();
 +}
 +
 +void Caldoria::setUpAIRules() {
 +	Neighborhood::setUpAIRules();
 +
 +	if (g_AIArea) {
 +		if (GameState.allTimeZonesFinished()) {
 +			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X49NB1", false);
 +			AILocationCondition *locCondition = new AILocationCondition(1);
 +			locCondition->addLocation(MakeRoomView(kCaldoria49, kNorth));
 +			AIRule *rule = new AIRule(locCondition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +
 +			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X56EH1", false);
 +			AIBombActiveCondition *activeCondition = new AIBombActiveCondition();
 +			rule = new AIRule(activeCondition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +		} else {
 +			AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XAB2", false);
 +			AITimerCondition *timerCondition = new AITimerCondition(kLateWarning3TimeLimit, 1, true);
 +			AILocationCondition *locCondition = new AILocationCondition(1);
 +			locCondition->addLocation(MakeRoomView(kCaldoria44, kEast));
 +			AINotCondition *notCondition = new AINotCondition(locCondition);
 +			AIAndCondition *andCondition = new AIAndCondition(timerCondition, notCondition);
 +			AIRule *rule = new AIRule(andCondition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +
 +			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XAB1", false);
 +			timerCondition = new AITimerCondition(kLateWarning2TimeLimit, 1, true);
 +			locCondition = new AILocationCondition(1);
 +			locCondition->addLocation(MakeRoomView(kCaldoria44, kEast));
 +			notCondition = new AINotCondition(locCondition);
 +			andCondition = new AIAndCondition(timerCondition, notCondition);
 +			rule = new AIRule(andCondition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +
 +			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/XA44EB", false);
 +			locCondition = new AILocationCondition(3);
 +			locCondition->addLocation(MakeRoomView(kCaldoria01, kNorth));
 +			locCondition->addLocation(MakeRoomView(kCaldoria01, kEast));
 +			locCondition->addLocation(MakeRoomView(kCaldoria01, kSouth));
 +			rule = new AIRule(locCondition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +			
 +			messageAction = new AIPlayMessageAction("Images/AI/Caldoria/X42WH1", false);
 +			AICondition *condition = makeLocationAndDoesntHaveItemCondition(kCaldoria44, kEast, kKeyCard);
 +			rule = new AIRule(condition, messageAction);
 +			g_AIArea->addAIRule(rule);
 +			
 +			AIActivateRuleAction *ruleAction = new AIActivateRuleAction(rule);
 +			locCondition = new AILocationCondition(1);
 +			locCondition->addLocation(MakeRoomView(kCaldoria42, kEast));
 +			rule = new AIRule(locCondition, ruleAction);
 +			g_AIArea->addAIRule(rule);
 +		}
 + 	}
 +}
 +
 +uint16 Caldoria::getDateResID() const {
 +	return kDate2318ID;
 +}
 +
 +TimeValue Caldoria::getViewTime(const RoomID room, const DirectionConstant direction) {
 +	ExtraTable::Entry extra;	
 +	uint32 extraID = 0xffffffff;
 +
 +	switch (room) {
 +	case kCaldoria00:
 +		if (direction == kEast && _privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag))
 +			extraID = k4DEnvironOpenView;
 +		break;
 +	case kCaldoriaDrawers:
 +		if (direction == kNorth && _privateFlags.getFlag(kCaldoriaPrivateRightDrawerOpenFlag)) {
 +			if (GameState.isTakenItemID(kKeyCard))
 +				extraID = kRightDrawerOpenViewNoKeys;
 +			else
 +				extraID = kRightDrawerOpenViewWithKeys;
 +		}
 +		break;
 +	case kCaldoria16:
 +		if (direction == kSouth && GameState.getCaldoriaSeenSinclairInElevator())
 +			extraID = kCaldoria16SouthViewWithElevator;
 +		break;
 +	case kCaldoriaReplicator:
 +		if (GameState.getCaldoriaMadeOJ() && !(GameState.isTakenItemID(kOrangeJuiceGlassEmpty) || GameState.isTakenItemID(kOrangeJuiceGlassFull)))
 +			extraID = kReplicatorNorthViewWithOJ;
 +		break;
 +	case kCaldoriaKiosk:
 +	case kCaldoriaBinoculars:
 +		return 0xffffffff;
 +	case kCaldoria48:
 +		if (direction == kNorth && GameState.getCaldoriaRoofDoorOpen())
 +			extraID = kCa48NorthExplosion;
 +		break;
 +	}
 +
 +	if (extraID == 0xffffffff)
 +		return Neighborhood::getViewTime(room, direction);
 +
 +	getExtraEntry(extraID, extra);
 +	return extra.movieEnd - 1;
 +}
 +
 +void Caldoria::startSpotOnceOnly(TimeValue startTime, TimeValue stopTime) {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kCaldoria13, kEast):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen13CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen13CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria14, kEast):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen14CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen14CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria18, kWest):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen18CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen18CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria23, kSouth):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen23CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen23CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria33, kSouth):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen33CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen33CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria36, kNorth):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen36CarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen36CarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria41, kNorth):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41NorthCarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen41NorthCarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria41, kEast):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41EastCarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen41EastCarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria41, kWest):
 +		if (!_privateFlags.getFlag(kCaldoriaPrivateSeen41WestCarFlag) && _vm->getRandomBit() == 0) {
 +			_privateFlags.setFlag(kCaldoriaPrivateSeen41WestCarFlag, true);
 +			Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		}
 +		break;
 +	default:
 +		Neighborhood::startSpotOnceOnly(startTime, stopTime);
 +		break;
 +	}
 +}
 +
 +void Caldoria::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &entry) {	
 +	Neighborhood::findSpotEntry(room, direction, flags, entry);
 +
 +	switch (room) {
 +	case kCaldoria00:
 +		if (direction == kEast && (!GameState.getCaldoriaINNAnnouncing() || GameState.getCaldoriaSeenINN()))
 +			entry.clear();
 +		break;
 +	case kCaldoriaVidPhone:
 +		if (direction == kNorth && GameState.getCaldoriaSeenMessages())
 +			entry.clear();
 +		break;
 +	case kCaldoria44:
 +		if (direction == kEast && GameState.getLastRoom() != kCaldoria42)
 +			entry.clear();
 +		break;
 +	}
 +}
 +
 +void Caldoria::startExitMovie(const ExitTable::Entry &exitEntry) {
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria05:
 +	case kCaldoria07:
 +		if (GameState.getCurrentDirection() == kWest)
 +			closeCroppedMovie();
 +		// fall through
 +	case kCaldoria11:
 +		if (GameState.getCurrentDirection() == kEast)
 +			closeCroppedMovie();
 +		break;
 +	case kCaldoria13:
 +	case kCaldoria14:
 +		if (GameState.getCurrentDirection() == kNorth)
 +			closeCroppedMovie();
 +		break;
 +	}
 +
 +	Neighborhood::startExitMovie(exitEntry);
 +}
 +
 +void Caldoria::startZoomMovie(const ZoomTable::Entry &zoomEntry) {
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria12:
 +		if (GameState.getCurrentDirection() == kNorth)
 +			closeCroppedMovie();
 +		break;
 +	}
 +
 +	Neighborhood::startZoomMovie(zoomEntry);
 +}
 +
 +void Caldoria::startDoorOpenMovie(const TimeValue startTime, const TimeValue stopTime) {
 +	if (GameState.getCurrentRoom() == kCaldoria27 || GameState.getCurrentRoom() == kCaldoria28 || GameState.getCurrentRoom() == kCaldoria45)
 +		// Must be opening elevator door.
 +		closeCroppedMovie();
 +
 +	if (GameState.getCurrentRoom() == kCaldoria44 && GameState.getLastRoom() != kCaldoria42)
 +		startExtraSequence(kArriveAtCaldoriaFromTSA, kDoorOpenCompletedFlag, false);
 +	else
 +		Neighborhood::startDoorOpenMovie(startTime, stopTime);
 +}
 +
 +void Caldoria::startTurnPush(const TurnDirection turnDirection, const TimeValue newViewTime, const DirectionConstant destDirection) {
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria05:
 +	case kCaldoria07:
 +		if (GameState.getCurrentDirection() == kWest)
 +			closeCroppedMovie();
 +		break;
 +	case kCaldoria11:
 +		if (GameState.getCurrentDirection() == kEast)
 +			closeCroppedMovie();
 +		break;
 +	case kCaldoria12:
 +	case kCaldoria13:
 +	case kCaldoria14:
 +	case kCaldoria27:
 +	case kCaldoria28:
 +	case kCaldoria45:
 +		if (GameState.getCurrentDirection() == kNorth)
 +			closeCroppedMovie();
 +		break;
 +	case kCaldoria48:
 +		if (_croppedMovie.isSurfaceValid())
 +			closeCroppedMovie();
 +		break;
 +	}
 +
 +	Neighborhood::startTurnPush(turnDirection, newViewTime, destDirection);
 +}
 +
 +void Caldoria::bumpIntoWall() {
 +	requestSpotSound(kCaldoriaUhghIn, kCaldoriaUhghOut, kFilterNoInput, 0);
 +	Neighborhood::bumpIntoWall();
 +}
 +
 +void Caldoria::closeDoorOffScreen(const RoomID room, const DirectionConstant direction) {
 +	switch (room) {
 +	case kCaldoria08:
 +		if (direction == kNorth)
 +			playSpotSoundSync(kCaldoriaShowerCloseIn, kCaldoriaShowerCloseOut);
 +		else
 +			playSpotSoundSync(kCaldoriaDoorCloseIn, kCaldoriaDoorCloseOut);
 +		break;
 +	case kCaldoria09:
 +		playSpotSoundSync(kCaldoriaShowerCloseIn, kCaldoriaShowerCloseOut);
 +		break;
 +	case kCaldoria16:
 +	case kCaldoria38:
 +	case kCaldoria46:
 +	case kCaldoria27:
 +	case kCaldoria28:
 +	case kCaldoria45:
 +		playSpotSoundSync(kCaldoriaElevatorCloseIn, kCaldoriaElevatorCloseOut);
 +		break;
 +	case kCaldoria44:
 +	case kCaldoria42:
 +		if (GameState.getCurrentRoom() == kCaldoria42)
 +			playSpotSoundSync(kCaldoriaGTDoorCloseIn, kCaldoriaGTDoorCloseOut);
 +		break;
 +	default:
 +		playSpotSoundSync(kCaldoriaDoorCloseIn, kCaldoriaDoorCloseOut);
 +		break;
 +	}
 +}
 +
 +int16 Caldoria::getStaticCompassAngle(const RoomID room, const DirectionConstant dir) {
 +	int16 result = Neighborhood::getStaticCompassAngle(room, dir);
 +
 +	switch (room) {
 +	case kCaldoriaVidPhone:
 +		result += kVidPhoneAngle;
 +		break;
 +	case kCaldoriaReplicator:
 +		result += kReplicatorAngle;
 +		break;
 +	case kCaldoriaDrawers:
 +		result += kDrawersAngle;
 +		break;
 +	case kCaldoria53:
 +		result += kCaldoria53Angle;
 +		break;
 +	case kCaldoria55:
 +		result += kCaldoria55Angle;
 +		break;
 +	}
 +
 +	return result;
 +}
 +
 +void Caldoria::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
 +	Neighborhood::getExitCompassMove(exitEntry, compassMove);
 +
 +	switch (MakeRoomView(exitEntry.room, exitEntry.direction)) {
 +	case MakeRoomView(kCaldoria08, kNorth):
 +	case MakeRoomView(kCaldoria09, kSouth):
 +		compassMove.insertFaderKnot((exitEntry.movieStart + exitEntry.movieEnd) >> 1, compassMove.getNthKnotValue(0) + 30);
 +		break;
 +	case MakeRoomView(kCaldoria10, kEast):
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 4 * kCaldoriaFrameDuration, 90);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 19 * kCaldoriaFrameDuration, -90);
 +		break;
 +	case MakeRoomView(kCaldoria42, kWest):
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, -90, exitEntry.movieEnd, 90);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 3 * kCaldoriaFrameDuration, -90);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 33 * kCaldoriaFrameDuration, 90);
 +		break;
 +	case MakeRoomView(kCaldoria54, kEast):
 +		if (getCurrentAlternate() != kAltCaldoriaSinclairDown) {
 +			compassMove.insertFaderKnot(exitEntry.movieStart + 16 * kCaldoriaFrameDuration, 135);
 +			compassMove.insertFaderKnot(exitEntry.movieEnd, 135);
 +		}
 +		break;
 +	case MakeRoomView(kCaldoria55, kNorth):
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), exitEntry.movieStart, 315, exitEntry.movieEnd, 270);
 +		break;
 +	}
 +}
 +
 +void Caldoria::getZoomCompassMove(const ZoomTable::Entry &zoomEntry, FaderMoveSpec &compassMove) {
 +	Neighborhood::getZoomCompassMove(zoomEntry, compassMove);
 +
 +	switch (zoomEntry.hotspot) {
 +	case kCaBathroomToiletSpotID:
 +		compassMove.insertFaderKnot(zoomEntry.movieStart + 4 * kCaldoriaFrameDuration, 90);
 +		compassMove.insertFaderKnot(zoomEntry.movieStart + 19 * kCaldoriaFrameDuration, -90);
 +		compassMove.insertFaderKnot(zoomEntry.movieEnd, -90);
 +		break;
 +	}
 +}
 +
 +void Caldoria::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
 +	switch (entry.extra) {
 +	case kCaldoria00WakeUp1:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 180);
 +		compassMove.insertFaderKnot(entry.movieStart + 1000, 90);
 +		compassMove.insertFaderKnot(entry.movieStart + 1640, 120);
 +		compassMove.insertFaderKnot(entry.movieStart + 2240, 135);
 +		compassMove.insertFaderKnot(entry.movieStart + 2640, 180);
 +		break;
 +	case kCaldoria00WakeUp2:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 180, entry.movieEnd, 90);
 +		compassMove.insertFaderKnot(entry.movieStart + 560, 90);
 +		break;
 +	case kCaldoria56BombStage1:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 10);
 +		compassMove.insertFaderKnot(entry.movieStart + 31 * kCaldoriaFrameDuration, 60);
 +		compassMove.insertFaderKnot(entry.movieStart + 49 * kCaldoriaFrameDuration, 60);
 +		compassMove.insertFaderKnot(entry.movieStart + 66 * kCaldoriaFrameDuration, 10);
 +		break;
 +	case kCaldoria56BombStage7:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 10, entry.movieEnd, 90);
 +		compassMove.insertFaderKnot(entry.movieStart + 131 * kCaldoriaFrameDuration, 10);
 +		compassMove.insertFaderKnot(entry.movieStart + 148 * kCaldoriaFrameDuration, 60);
 +		compassMove.insertFaderKnot(entry.movieStart + 165 * kCaldoriaFrameDuration, 60);
 +		compassMove.insertFaderKnot(entry.movieEnd - 5 * kCaldoriaFrameDuration, 90);
 +		break;
 +	default:
 +		Neighborhood::getExtraCompassMove(entry, compassMove);
 +		break;
 +	}
 +}
 +
 +void Caldoria::loadAmbientLoops() {
 +	RoomID room = GameState.getCurrentRoom();
 +
 +	if (room == kCaldoria00 && GameState.getCaldoriaWokenUp())
 +		loadLoopSound1("Sounds/Caldoria/Apartment Music.AIFF", 0x100 / 4);
 +	else if (room >= kCaldoria01 && room <= kCaldoria14)
 +		loadLoopSound1("Sounds/Caldoria/Apartment Music.AIFF", 0x100 / 4);
 +	else if (room == kCaldoria27 || room == kCaldoria28 || room == kCaldoria45)
 +		loadLoopSound1("Sounds/Caldoria/Elevator Loop.AIFF", 0x100 / 5);
 +	else if (room == kCaldoria44)
 +		loadLoopSound1("Sounds/Caldoria/TSA Hum Loop.AIFF");
 +	else if (room >= kCaldoria15 && room <= kCaldoria48)
 +		loadLoopSound1("Sounds/Caldoria/Industrial Nuage.aiff", 2 * 0x100 / 3);
 +	else if (room >= kCaldoria49 && room <= kCaldoria56)
 +		loadLoopSound1("Sounds/Caldoria/A50NLB00.22K.AIFF", 0x100 / 4);
 +}
 +
 +void Caldoria::checkContinuePoint(const RoomID room, const DirectionConstant direction) {
 +	switch (MakeRoomView(room, direction)) {
 +	case MakeRoomView(kCaldoria06, kSouth):
 +	case MakeRoomView(kCaldoria13, kNorth):
 +	case MakeRoomView(kCaldoria16, kSouth):
 +	case MakeRoomView(kCaldoria38, kEast):
 +	case MakeRoomView(kCaldoria38, kWest):
 +	case MakeRoomView(kCaldoria40, kNorth):
 +	case MakeRoomView(kCaldoria44, kEast):
 +	case MakeRoomView(kCaldoria48, kNorth):
 +	case MakeRoomView(kCaldoria49, kNorth):
 +		makeContinuePoint();
 +		break;
 +	}
 +}
 +
 +void Caldoria::spotCompleted() {
 +	Neighborhood::spotCompleted();
 +	if (GameState.getCurrentRoom() == kCaldoriaBinoculars)
 +		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
 +}
 +
 +void Caldoria::arriveAt(const RoomID room, const DirectionConstant direction) {
 +	switch (room) {
 +	case kCaldoria56:
 +		if (!GameState.getCaldoriaGunAimed())
 +			// Fall through...
 +	case kCaldoria49:
 +	case kCaldoria50:
 +	case kCaldoria51:
 +	case kCaldoria52:
 +	case kCaldoria53:
 +	case kCaldoria54:
 +	case kCaldoria55:
 +		if (GameState.getCaldoriaSinclairShot())
 +			setCurrentAlternate(kAltCaldoriaSinclairDown);
 +		break;
 +	}
 +
 +	Neighborhood::arriveAt(room, direction);
 +	Input dummy;
 +
 +	switch (room) {
 +	case kCaldoria00:
 +		arriveAtCaldoria00();
 +		break;
 +	case kCaldoria05:
 +		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
 +			loopCroppedMovie("Images/Caldoria/A05 Light Loop", kCaldoriaA05LightLoopLeft, kCaldoriaA05LightLoopTop);
 +		break;
 +	case kCaldoria07:
 +		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
 +			loopCroppedMovie("Images/Caldoria/A07 Light Loop", kCaldoriaA07LightLoopLeft, kCaldoriaA07LightLoopTop);
 +		break;
 +	case kCaldoria09:
 +		_lastExtra = 0xffffffff;
 +		break;
 +	case kCaldoriaToilet:
 +		GameState.setScoringReadPaper(true);
 +		break;
 +	case kCaldoriaReplicator:
 +		setCurrentActivation(kActivateReplicatorReady);
 +		requestSpotSound(kCaldoriaReplicatorIntroIn, kCaldoriaReplicatorIntroOut, kFilterNoInput, 0);
 +		break;
 +	case kCaldoria11:
 +		setCurrentAlternate(kAltCaldoriaNormal);
 +		if (direction == kEast && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A11 Message Machine Loop", kCaldoria11MessageLoopLeft, kCaldoria11MessageLoopTop);
 +		break;
 +	case kCaldoria12:
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A12 Message Machine Loop", kCaldoria12MessageLoopLeft, kCaldoria12MessageLoopTop);
 +		break;
 +	case kCaldoriaDrawers:
 +		setCurrentActivation(kActivateDrawersClosed);
 +		break;
 +	case kCaldoria13:
 +		GameState.setCaldoriaINNAnnouncing(true);
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A13 Message Machine Loop", kCaldoria13MessageLoopLeft, kCaldoria13MessageLoopTop);
 +		break;
 +	case kCaldoria14:
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A14 Message Machine Loop", kCaldoria14MessageLoopLeft, kCaldoria14MessageLoopTop);
 +		break;
 +	case kCaldoria08:
 +		if (direction == kWest)
 +			setCurrentActivation(kActivateMirrorReady);
 +		// Fall through...
 +	case kCaldoria15:
 +		GameState.setCaldoriaINNAnnouncing(true);
 +		break;
 +	case kCaldoria27:
 +	case kCaldoria28:
 +	case kCaldoria45:
 +		if (GameState.getCurrentDirection() == kNorth)
 +			openDoor();
 +		break;
 +	case kCaldoriaBinoculars:
 +		GameState.setScoringLookThroughTelescope(true);
 +		break;
 +	case kCaldoriaKiosk:
 +		GameState.setScoringSawCaldoriaKiosk(true);
 +		startExtraSequenceSync(kCaldoriaKioskVideo, kFilterAllInput);
 +		downButton(dummy);
 +		break;
 +	case kCaldoria44:
 +		arriveAtCaldoria44();
 +		break;
 +	case kCaldoria49:
 +		arriveAtCaldoria49();
 +		break;
 +	case kCaldoria53:
 +		if (direction == kEast && !GameState.getCaldoriaSinclairShot())
 +			zoomToSinclair();
 +		break;
 +	case kCaldoria50:
 +		if (direction == kNorth && !GameState.getCaldoriaSinclairShot())
 +			setUpSinclairLoops();
 +		break;
 +	case kCaldoria54:
 +		if (direction == kSouth && !GameState.getCaldoriaSinclairShot())
 +			setUpSinclairLoops();
 +		break;
 +	case kCaldoria56:
 +		arriveAtCaldoria56();
 +		break;
 +	case kCaldoriaDeathRoom:
 +		arriveAtCaldoriaDeath();
 +		break;
 +	}
 +
 +	checkSinclairShootsOS();
 +	setUpRoofTop();
 +}
 +
 +void Caldoria::doAIRecalibration() {
 +	GameState.setCaldoriaDidRecalibration(true);
 +
 +	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB1", true, kRecalibrationInterruptFilter))
 +		return;
 +
 +	g_interface->calibrateEnergyBar();
 +	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB4", true, kRecalibrationInterruptFilter))
 +		return;
 +
 +	g_interface->raiseInventoryDrawerSync();
 +	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB6", true, kRecalibrationInterruptFilter)) {
 +		g_interface->lowerInventoryDrawerSync();
 +		return;
 +	}
 +
 +	g_interface->lowerInventoryDrawerSync();
 +	g_interface->raiseBiochipDrawerSync();
 +
 +	if (!g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB5", true, kRecalibrationInterruptFilter)) {
 +		g_interface->lowerBiochipDrawerSync();
 +		return;
 +	}
 +
 +	g_interface->lowerBiochipDrawerSync();
 +
 +	g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Caldoria/XA01EB8", false, kRecalibrationInterruptFilter);
 +}
 +
 +void Caldoria::arriveAtCaldoria00() {
 +	if (GameState.getCurrentDirection() == kEast) {
 +		if (GameState.getCaldoriaWokenUp()) {
 +			if (!GameState.getCaldoriaDidRecalibration())
 +				doAIRecalibration();
 +			setCurrentActivation(kActivate4DClosed);
 +		} else {
 +			// Good morning, sleeping beauty
 +			ExtraTable::Entry extra;
 +			getExtraEntry(kCaldoria00WakeUp1, extra);
 +
 +			if (_navMovie.getTime() != extra.movieStart) {
 +				_navMovie.setTime(extra.movieStart);
 +				_navMovie.redrawMovieWorld();
 +			}
 +
 +			startExtraSequenceSync(kCaldoria00WakeUp1, kFilterNoInput);
 +			GameState.setCaldoriaWokenUp(true);
 +			playCroppedMovieOnce("Images/Caldoria/VidPhone.movie", kCaldoriaVidPhoneLeft, kCaldoriaVidPhoneTop, kFilterAllInput);
 +			startExtraSequence(kCaldoria00WakeUp2, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +	}
 +}
 +
 +bool Caldoria::wantsCursor() {
 +	return GameState.getCaldoriaDidRecalibration();
 +}
 +
 +void Caldoria::arriveAtCaldoria44() {
 +	if (GameState.getLastNeighborhood() != kCaldoriaID) {
 +		openDoor();
 +	} else {
 +		setCurrentActivation(kActivateReadyForCard);
 +		loopExtraSequence(kCaldoriaTransporterArrowLoop, 0);
 +	}
 +}
 +
 +void Caldoria::arriveAtCaldoria49() {
 +	if (GameState.getLastRoom() == kCaldoria48)
 +		setCurrentAlternate(kAltCaldoriaNormal);
 +
 +	// Need to force the loop to play.
 +	if (GameState.getCurrentDirection() == kNorth) {
 +		GameState.setCaldoriaFuseTimeLimit(kSinclairShootsTimeLimit);
 +		startExtraSequence(kCa49NorthVoiceAnalysis, kExtraCompletedFlag, kFilterNoInput);
 +	}
 +}
 +
 +void Caldoria::arriveAtCaldoria56() {
 +	if (!GameState.getCaldoriaBombDisarmed()) {
 +		_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, true);
 +
 +		if (GameState.getCurrentDirection() == kNorth) {
 +			turnRight();
 +		} else if (GameState.getCurrentDirection() == kSouth) {
 +			turnLeft();
 +		} else if (GameState.getCurrentDirection() == kEast) {
 +			_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, false);
 +			newInteraction(kCaldoriaBombInteractionID);
 +		}
 +	}
 +}
 +
 +void Caldoria::arriveAtCaldoriaDeath() {
 +	if (GameState.getLastRoom() == kCaldoria49) {
 +		if (GameState.getCaldoriaSinclairShot()) {
 +			die(kDeathNuclearExplosion);
 +		} else {
 +			playSpotSoundSync(kCaldoriaSinclairShootsOSIn, kCaldoriaSinclairShootsOSOut);
 +			playSpotSoundSync(kCaldoriaScreamingAfterIn, kCaldoriaScreamingAfterOut);
 +			die(kDeathSinclairShotDelegate);
 +		}
 +	} else {
 +		die(kDeathShotBySinclair);
 +	}
 +}
 +
 +void Caldoria::setUpRoofTop() {
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria48:
 +		if (GameState.getCurrentDirection() == kNorth) {
 +			if (GameState.getCaldoriaRoofDoorOpen()) {
 +				setCurrentAlternate(kAltCaldoriaRoofDoorBlown);
 +			} else if (GameState.getCaldoriaDoorBombed()) {
 +				// Long enough for AI hints...?
 +				_utilityFuse.primeFuse(kCardBombCountDownTime);
 +				_utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
 +				_utilityFuse.lightFuse();
 +
 +				loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
 +			} else {
 +				setCurrentActivation(kActivateRoofSlotEmpty);
 +			}
 +		}
 +		break;
 +	case kCaldoria56:
 +		if (GameState.getCurrentDirection() == kEast && GameState.getCaldoriaGunAimed())
 +			startExtraSequence(kCa53EastShootSinclair, kExtraCompletedFlag, false);
 +		else
 +			// Fall through...
 +	case kCaldoria49:
 +	case kCaldoria50:
 +	case kCaldoria51:
 +	case kCaldoria52:
 +	case kCaldoria53:
 +	case kCaldoria54:
 +	case kCaldoria55:
 +		if (!GameState.getCaldoriaSinclairShot()) {
 +			if (GameState.getCaldoriaSawVoiceAnalysis() && !_utilityFuse.isFuseLit()) {
 +				_utilityFuse.primeFuse(GameState.getCaldoriaFuseTimeLimit());
 +				_utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void *)this);
 +				_utilityFuse.lightFuse();
 +			}
 +		} else {
 +			setCurrentAlternate(kAltCaldoriaSinclairDown);
 +		}
 +		break;
 +	}
 +}
 +
 +void Caldoria::downButton(const Input &input) {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kCaldoria01, kEast):
 +		GameState.setCaldoriaWokenUp(true);
 +		startExtraSequence(kCaldoria00SitDown, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	default:
 +		Neighborhood::downButton(input);
 +		break;
 +	}
 +}
 +
 +void Caldoria::turnTo(const DirectionConstant direction) {
 +	Neighborhood::turnTo(direction);
 +
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria00:
 +		if (direction == kEast)
 +			setCurrentActivation(kActivate4DClosed);
 +		break;
 +	case kCaldoria01:
 +		if (direction == kEast) {
 +			GameState.setCaldoriaWokenUp(true);
 +			startExtraSequence(kCaldoria00SitDown, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	case kCaldoria05:
 +		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
 +			loopCroppedMovie("Images/Caldoria/A05 Light Loop", kCaldoriaA05LightLoopLeft, kCaldoriaA05LightLoopTop);
 +		break;
 +	case kCaldoria07:
 +		if (direction == kWest && GameState.getCaldoriaINNAnnouncing())
 +			loopCroppedMovie("Images/Caldoria/A07 Light Loop", kCaldoriaA07LightLoopLeft, kCaldoriaA07LightLoopTop);
 +		break;
 +	case kCaldoria08:
 +		if (direction == kWest)
 +			setCurrentActivation(kActivateMirrorReady);
 +		break;
 +	case kCaldoria09:
 +		_lastExtra = 0xffffffff;
 +		break;
 +	case kCaldoria11:
 +		if (direction == kEast && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A11 Message Machine Loop", kCaldoria11MessageLoopLeft, kCaldoria11MessageLoopTop);
 +		break;
 +	case kCaldoria12:
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A12 Message Machine Loop", kCaldoria12MessageLoopLeft, kCaldoria12MessageLoopTop);
 +		break;
 +	case kCaldoria13:
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A13 Message Machine Loop", kCaldoria13MessageLoopLeft, kCaldoria13MessageLoopTop);
 +		break;
 +	case kCaldoria14:
 +		if (direction == kNorth && !GameState.getCaldoriaSeenMessages())
 +			loopCroppedMovie("Images/Caldoria/A14 Message Machine Loop", kCaldoria14MessageLoopLeft, kCaldoria14MessageLoopTop);
 +		break;
 +	case kCaldoria27:
 +	case kCaldoria28:
 +	case kCaldoria45:
 +		if (direction == kNorth)
 +			openElevatorMovie();
 +		else
 +			closeCroppedMovie();
 +		break;
 +	case kCaldoria48:
 +		if (direction == kNorth && !GameState.getCaldoriaDoorBombed())
 +			setCurrentActivation(kActivateRoofSlotEmpty);
 +		break;
 +	case kCaldoria53:
 +		if (GameState.getCurrentDirection() == kEast && !GameState.getCaldoriaSinclairShot())
 +			zoomToSinclair();
 +		break;
 +	case kCaldoria50:
 +		if (direction == kNorth && !GameState.getCaldoriaSinclairShot())
 +			setUpSinclairLoops();
 +		break;
 +	case kCaldoria54:
 +		if (direction == kSouth && !GameState.getCaldoriaSinclairShot())
 +			setUpSinclairLoops();
 +		break;
 +	case kCaldoria56:
 +		if (_privateFlags.getFlag(kCaldoriaPrivateZoomingToBombFlag)) {
 +			_privateFlags.setFlag(kCaldoriaPrivateZoomingToBombFlag, false);
 +			newInteraction(kCaldoriaBombInteractionID);
 +		} else if (GameState.getCaldoriaBombDisarmed()) {
 +			_vm->playEndMessage();
 +		}
 +		break;
 +	}
 +
 +	checkSinclairShootsOS();
 +}
 +
 +void Caldoria::zoomTo(const Hotspot *zoomOutSpot) {
 +	// Need to set _zoomOutSpot here because we may come through
 +	// this function another way, say by pressing the down arrow,
 +	// that doesn't involve the ClickInHotSpot function.
 +	_zoomOutSpot = zoomOutSpot;
 +
 +	if (zoomOutSpot->getObjectID() == kCaldoriaDrawersOutSpotID) {
 +		if (_privateFlags.getFlag(kCaloriaPrivateLeftDrawerOpenFlag)) {
 +			_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, false);
 +			startExtraSequence(kLeftDrawerClose, kExtraCompletedFlag, kFilterNoInput);
 +		} else if (_privateFlags.getFlag(kCaldoriaPrivateRightDrawerOpenFlag)) {
 +			_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
 +			if (GameState.isTakenItemID(kKeyCard))
 +				startExtraSequence(kRightDrawerCloseNoKeys, kExtraCompletedFlag, false);
 +			else
 +				startExtraSequence(kRightDrawerCloseWithKeys, kExtraCompletedFlag, false);
 +		} else {
 +			Neighborhood::zoomTo(zoomOutSpot);
 +		}
 +	} else {
 +		Neighborhood::zoomTo(zoomOutSpot);
 +	}
 +}
 +
 +void Caldoria::setUpSinclairLoops() {
 +	_navMovie.stop();
 +	scheduleNavCallBack(kSinclairLoopDoneFlag);
 +	_sinclairLoopCount = 0;
 +	_numSinclairLoops = 2;
 +	_navMovie.start();
 +}
 +
 +void Caldoria::zoomToSinclair() {	
 +	_utilityFuse.stopFuse();
 +	_privateFlags.setFlag(kCaldoriaPrivateReadyToShootFlag, true);
 +	setCurrentActivation(kActivateZoomedOnSinclair);
 +
 +	ExtraTable::Entry entry;
 +	getExtraEntry(kCa53EastZoomToSinclair, entry);
 +	_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime1, _navMovie.getScale());
 +	startExtraSequence(kCa53EastZoomToSinclair, kExtraCompletedFlag, kFilterAllInput);
 +}
 +
 +void Caldoria::receiveNotification(Notification *notification, const NotificationFlags flags) {	
 +	Neighborhood::receiveNotification(notification, flags);
 +
 +	if ((flags & kExtraCompletedFlag) != 0) {
 +		InventoryItem *item;
 +		_interruptionFilter = kFilterAllInput;
 +
 +		switch (_lastExtra) {
 +		case kCaldoria00WakeUp2:
 +			makeContinuePoint();
 +			// Force ArriveAt to do its thing...
 +			GameState.setCurrentRoom(kNoRoomID);
 +			arriveAt(kCaldoria00, kEast);
 +			break;
 +		case k4DEnvironOpenToINN:
 +			GameState.setCaldoriaSeenINN(true);
 +			GameState.setScoringSawINN(true);
 +			// Fall through to k4DEnvironOpen...
 +		case k4DEnvironOpen:
 +			_privateFlags.setFlag(kCaldoriaPrivate4DSystemOpenFlag, true);
 +			setCurrentActivation(kActivate4DOpen);
 +			newInteraction(kCaldoria4DInteractionID);
 +			break;
 +		case kCaldoriaShowerUp:
 +			GameState.setScoringTookShower(true);
 +			GameState.setCaldoriaDoneHygiene(true);
 +			break;
 +		case kLeftDrawerClose:
 +		case kRightDrawerCloseNoKeys:
 +		case kRightDrawerCloseWithKeys:
 +			if (_zoomOutSpot && _zoomOutSpot->getObjectID() == kCaldoriaDrawersOutSpotID) {
 +				Input input;
 +				clickInHotspot(input, _zoomOutSpot);
 +			}
 +			break;
 +		case kCreateOrangeJuice:
 +			setCurrentActivation(kActivateOJOnThePad);
 +			requestSpotSound(kCaldoriaReplicatorOJChoiceIn, kCaldoriaReplicatorOJChoiceOut, kFilterNoInput, 0);
 +			break;
 +		case kCaldoria00SitDown:
 +			arriveAt(kCaldoria00, kEast);
 +			break;
 +		case kCaldoria16ElevatorUp:
 +			startExtraSequence(kCaldoria16ElevatorDown, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kCaldoria16ElevatorDown:
 +			GameState.setCaldoriaSeenSinclairInElevator(true);
 +			_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
 +			openDoor();
 +			break;
 +		case kCaldoriaFourthToGround:
 +		case kCaldoriaRoofToGround:
 +			arriveAt(kCaldoria28, GameState.getCurrentDirection());
 +			break;
 +		case kCaldoriaFourthToRoof:
 +		case kCaldoriaGroundToRoof:
 +			arriveAt(kCaldoria45, GameState.getCurrentDirection());
 +			break;
 +		case kCaldoriaGroundToFourth:
 +		case kCaldoriaRoofToFourth:
 +			arriveAt(kCaldoria27, GameState.getCurrentDirection());
 +			break;
 +		case kCaGTCardSwipe:
 +			item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
 +			_vm->addItemToInventory(item);
 +			setCurrentActivation(kActivateReadyToTransport);
 +			break;
 +		case kCaGTFryTheFly:
 +		case kCaGTGoToTSA:
 +			_vm->jumpToNewEnvironment(kFullTSAID, kTSA00, kNorth);
 +			break;
 +		case kCaGTGoToTokyo:
 +			playDeathExtra(kCaGTArriveAtTokyo, kDeathUncreatedInCaldoria);
 +			break;
 +		case kCaGTGoToBeach:
 +			playDeathExtra(kCaGTArriveAtBeach, kDeathUncreatedInCaldoria);
 +			break;
 +		case kCa48NorthExplosion:
 +			// Current biochip must be the shield if we got here.
 +			_vm->getCurrentBiochip()->setItemState(kShieldNormal);
 +			break;
 +		case kBinocularsZoomInOnShip:
 +			setCurrentActivation(kActivateFocusedOnShip);
 +			break;
 +		case kCa49NorthVoiceAnalysis:
 +			_utilityFuse.primeFuse(kSinclairShootsTimeLimit);
 +			_utilityFuse.setFunctionPtr(&sinclairTimerExpiredFunction, (void*) this);
 +			_utilityFuse.lightFuse();
 +			GameState.setCaldoriaSawVoiceAnalysis(true);
 +			break;
 +		case kCa53EastZoomToSinclair:
 +			if (GameState.getCaldoriaSinclairShot()) {
 +				delete _gunSprite;
 +				_gunSprite = 0;
 +				startExtraSequence(kCa53EastShootSinclair, kExtraCompletedFlag, false);
 +			} else {
 +				playDeathExtra(kCa53EastDeath2, kDeathSinclairShotDelegate);
 +			}
 +			break;
 +		case kCa53EastShootSinclair:
 +			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kStunGun));
 +			startExtraSequence(kCa53EastZoomOutFromSinclair, kExtraCompletedFlag, false);
 +			GameState.setScoringStunnedSinclair(true);
 +			break;
 +		case kCa53EastZoomOutFromSinclair:
 +			setCurrentAlternate(kAltCaldoriaSinclairDown);
 +			updateViewFrame();
 +			makeContinuePoint();
 +			break;
 +		}
 +	} else if ((flags & kSpotSoundCompletedFlag) != 0) {
 +		switch (GameState.getCurrentRoom()) {
 +		case kCaldoria20:
 +		case kCaldoria21:
 +		case kCaldoria26:
 +		case kCaldoria29:
 +		case kCaldoria34:
 +		case kCaldoria35:
 +			updateViewFrame();
 +			break;
 +		case kCaldoria27:
 +		case kCaldoria28:
 +		case kCaldoria45:
 +			updateElevatorMovie();
 +			break;
 +		case kCaldoriaReplicator:
 +			emptyOJGlass();
 +			break;
 +		}
 +	} else if ((flags & kSinclairLoopDoneFlag) != 0) {
 +		if (++_sinclairLoopCount == _numSinclairLoops) {
 +			switch (GameState.getCurrentRoom()) {
 +			case kCaldoria50:
 +				playDeathExtra(kCa50SinclairShoots, kDeathShotBySinclair);
 +				break;
 +			case kCaldoria54:
 +				playDeathExtra(kCa54SouthDeath, kDeathShotBySinclair);
 +				break;
 +			}
 +		} else {
 +			_navMovie.stop();
 +			scheduleNavCallBack(kSinclairLoopDoneFlag);
 +			_navMovie.start();
 +		}
 +	}
 +
 +	g_AIArea->checkMiddleArea();
 +}
 +
 +InputBits Caldoria::getInputFilter() {
 +	InputBits result = Neighborhood::getInputFilter();
 +
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria00:
 +		if (_privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag))
 +			result &= ~kFilterAllDirections;
 +		break;
 +	case kCaldoriaBinoculars:
 +		if (getCurrentActivation() == kActivateNotFocusedOnShip)
 +			result &= ~(kFilterDownButton | kFilterDownAuto);
 +		break;
 +	case kCaldoria53:
 +		if (_privateFlags.getFlag(kCaldoriaPrivateReadyToShootFlag) && !GameState.getCaldoriaSinclairShot())
 +			result &= ~kFilterAllDirections;
 +		break;
 +	case kCaldoria48:
 +		if (GameState.getCaldoriaDoorBombed())
 +			result &= ~kFilterAllDirections;
 +	}
 +
 +	return result;
 +}
 +
 +void Caldoria::activateHotspots() {
 +	Neighborhood::activateHotspots();
 +
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoriaDrawers:
 +		if (getCurrentActivation() == kActivateRightOpen) {
 +			if (GameState.isTakenItemID(kKeyCard)) {
 +				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
 +				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
 +			} else {
 +				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
 +				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
 +			}
 +		}
 +	case kCaldoriaReplicator:
 +		if (GameState.getCaldoriaMadeOJ())
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaMakeOJSpotID);
 +		break;
 +	case kCaldoria27:
 +		if (GameState.isCurrentDoorOpen()) {
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator1);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator2);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator3);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator4);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator5);
 +		}
 +		break;
 +	case kCaldoria28:
 +		if (GameState.isCurrentDoorOpen()) {
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator1);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator2);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator3);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator4);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator5);
 +		}
 +		break;
 +	case kCaldoria45:
 +		if (GameState.isCurrentDoorOpen()) {
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator1);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator2);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator3);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator4);
 +			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator5);
 +		}
 +		break;
 +	}
 +}
 +
 +void Caldoria::clickInHotspot(const Input &input, const Hotspot *spot) {
 +	switch (spot->getObjectID()) {
 +	case kCa4DEnvironOpenSpotID:
 +		if (!GameState.getCaldoriaINNAnnouncing() || GameState.getCaldoriaSeenINN()) {
 +			startExtraSequence(k4DEnvironOpen, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			// This trick depends on the following sequences being in order in the
 +			// world movie:
 +			// k4DEnvironOpenToINN
 +			// k4DINNInterruption
 +			// k4DINNIntro
 +			// k4DINNMarkJohnson
 +			// k4DINNMeganLove
 +			// k4DINNFadeOut
 +			// k4DEnvironOpenFromINN
 +			loadLoopSound1("");
 +			loadLoopSound2("");
 +			startExtraLongSequence(k4DEnvironOpenToINN, k4DEnvironOpenFromINN, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	case kCa4DEnvironCloseSpotID:
 +		((Caldoria4DSystem *)_currentInteraction)->shutDown4DSystem();
 +		break;
 +	case kCaBathroomMirrorSpotID:
 +		newInteraction(kCaldoriaMirrorInteractionID);
 +		break;
 +	case kCaShowerSpotID:
 +		requestExtraSequence(kCaldoriaShowerTitle, 0, kFilterNoInput);
 +		requestExtraSequence(kCaldoriaShowerButton, 0, kFilterNoInput);
 +		requestExtraSequence(kCaldoriaShowerDown, 0, kFilterNoInput);
 +		requestExtraSequence(kCaldoriaShowerUp, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaLeftDrawerOpenSpotID:
 +		_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, true);
 +		setCurrentActivation(kActivateLeftOpen);
 +		startExtraSequence(kLeftDrawerOpen, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaLeftDrawerCloseSpotID:
 +		_privateFlags.setFlag(kCaloriaPrivateLeftDrawerOpenFlag, false);
 +		setCurrentActivation(kActivateDrawersClosed);
 +		startExtraSequence(kLeftDrawerClose, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaRightDrawerOpenSpotID:
 +		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, true);
 +		setCurrentActivation(kActivateRightOpen);
 +		if (GameState.isTakenItemID(kKeyCard))
 +			startExtraSequence(kRightDrawerOpenNoKeys, kExtraCompletedFlag, kFilterNoInput);
 +		else
 +			startExtraSequence(kRightDrawerOpenWithKeys, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaRightDrawerWithKeysCloseSpotID:
 +		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
 +		setCurrentActivation(kActivateDrawersClosed);
 +		startExtraSequence(kRightDrawerCloseWithKeys, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaRightDrawerNoKeysCloseSpotID:
 +		_privateFlags.setFlag(kCaldoriaPrivateRightDrawerOpenFlag, false);
 +		setCurrentActivation(kActivateDrawersClosed);
 +		startExtraSequence(kRightDrawerCloseNoKeys, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaMakeStickyBunsSpotID:
 +		requestSpotSound(kCaldoriaReplicatorWrongChoiceIn, kCaldoriaReplicatorWrongChoiceOut, kFilterNoInput, 0);
 +		break;
 +	case kCaldoriaMakeOJSpotID:
 +		GameState.setCaldoriaMadeOJ(true);
 +		startExtraSequence(kCreateOrangeJuice, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaBedroomVidPhoneActivationSpotID:
 +		newInteraction(kCaldoriaMessagesInteractionID);
 +		break;
 +	case kCaldoriaFourthFloorElevatorSpotID:
 +		if (!GameState.getCaldoriaSeenSinclairInElevator()) {
 +			startExtraSequence(kCaldoria16ElevatorUp, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
 +			openDoor();
 +		}
 +		break;
 +	case kCaldoriaGroundElevatorSpotID:
 +		_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
 +		openDoor();
 +		break;
 +	case kCaldoriaRoofElevatorSpotID:
 +		_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, true);
 +		openDoor();
 +		break;
 +	case kCaldoriaFourthFloorElevator1:
 +	case kCaldoriaFourthFloorElevator2:
 +	case kCaldoriaFourthFloorElevator3:
 +	case kCaldoriaFourthFloorElevator4:
 +	case kCaldoriaFourthFloorElevator5:
 +		// Assumes that elevator hot spots are consecutive.
 +		takeElevator(4, spot->getObjectID() - kCaldoriaFourthFloorElevator1 + 1);
 +		break;
 +	case kCaldoriaGroundElevator1:
 +	case kCaldoriaGroundElevator2:
 +	case kCaldoriaGroundElevator3:
 +	case kCaldoriaGroundElevator4:
 +	case kCaldoriaGroundElevator5:
 +		// Assumes that elevator hot spots are consecutive.
 +		takeElevator(1, spot->getObjectID() - kCaldoriaGroundElevator1 + 1);
 +		break;
 +	case kCaldoriaRoofElevator1:
 +	case kCaldoriaRoofElevator2:
 +	case kCaldoriaRoofElevator3:
 +	case kCaldoriaRoofElevator4:
 +	case kCaldoriaRoofElevator5:
 +		// Assumes that elevator hot spots are consecutive.
 +		takeElevator(5, spot->getObjectID() - kCaldoriaRoofElevator1 + 1);
 +		break;
 +	case kCaldoriaGTTokyoSpotID:
 +		startExtraSequence(kCaGTGoToTokyo, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaGTTSASpotID:
 +		GameState.setScoringGoToTSA(true);
 +		startExtraLongSequence(kCaGTFryTheFly, kCaGTGoToTSA, kExtraCompletedFlag, false);
 +		break;
 +	case kCaldoriaGTBeachSpotID:
 +		startExtraSequence(kCaGTGoToBeach, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaGTOtherSpotID:
 +		showExtraView(kCaGTOtherChoice);
 +		playSpotSoundSync(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut);
 +		showExtraView(kCaGTCardSwipe);
 +		break;
 +	case kCaldoriaZoomInOnShipSpotID:
 +		startExtraSequence(kBinocularsZoomInOnShip, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoriaRoofDoorSpotID:
 +		startExtraSequence(kCa48NorthRooftopClosed, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kCaldoria20DoorbellSpotID:
 +	case kCaldoria21DoorbellSpotID:
 +	case kCaldoria26DoorbellSpotID:
 +	case kCaldoria29DoorbellSpotID:
 +	case kCaldoria34DoorbellSpotID:
 +	case kCaldoria35DoorbellSpotID:
 +		clickOnDoorbell(spot->getObjectID());
 +		break;
 +	default:
 +		Neighborhood::clickInHotspot(input, spot);
 +		break;
 +	}
 +}
 +
 +void Caldoria::clickOnDoorbell(const HotSpotID doorBellSpotID) {
 +	uint32 extra;
 +	ExtraTable::Entry entry;
 +
 +	switch (doorBellSpotID) {
 +	case kCaldoria20DoorbellSpotID:
 +		extra = kCaldoria20Doorbell;
 +		break;
 +	case kCaldoria21DoorbellSpotID:
 +		extra = kCaldoria21Doorbell;
 +		break;
 +	case kCaldoria26DoorbellSpotID:
 +		extra = kCaldoria26Doorbell;
 +		break;
 +	case kCaldoria29DoorbellSpotID:
 +		extra = kCaldoria29Doorbell;
 +		break;
 +	case kCaldoria34DoorbellSpotID:
 +		extra = kCaldoria34Doorbell;
 +		break;
 +	case kCaldoria35DoorbellSpotID:
 +		extra = kCaldoria35Doorbell;
 +		break;
 +	default:
 +		error("Invalid doorbell hotspot");
 +	}
 +
 +	getExtraEntry(extra, entry);
 +	showViewFrame(entry.movieStart);
 +	requestSpotSound(kCaldoriaNobodyHomeIn, kCaldoriaNobodyHomeOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +}
 +
 +CanOpenDoorReason Caldoria::canOpenDoor(DoorTable::Entry &entry) {
 +	switch (GameState.getCurrentRoom()) {
 +	case kCaldoria16:
 +	case kCaldoria38:
 +	case kCaldoria46:
 +		if (GameState.getCurrentDirection() == kSouth && !_privateFlags.getFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag))
 +			return kCantOpenLocked;
 +		break;
 +	}
 +
 +	return Neighborhood::canOpenDoor(entry);
 +}
 +
 +void Caldoria::doorOpened() {
 +	Neighborhood::doorOpened();
 +	_privateFlags.setFlag(kCaldoriaPrivateCanOpenElevatorDoorFlag, false);
 +}
 +
 +GameInteraction *Caldoria::makeInteraction(const InteractionID interactionID) {
 +	switch (interactionID) {
 +	case kCaldoria4DInteractionID:
 +		return new Caldoria4DSystem(this);
 +	case kCaldoriaBombInteractionID:
 +		return new CaldoriaBomb(this, _vm);
 +	case kCaldoriaMessagesInteractionID:
 +		return new CaldoriaMessages(this, kCaldoriaMessagesNotificationID, _vm);
 +	case kCaldoriaMirrorInteractionID:
 +		return new CaldoriaMirror(this);
 +	}
 +
 +	return 0;
 +}
 +
 +void Caldoria::newInteraction(const InteractionID interactionID) {
 +	Neighborhood::newInteraction(interactionID);
 +
 +	if (!_currentInteraction) {
 +		if (_privateFlags.getFlag(kCaldoriaPrivate4DSystemOpenFlag)) {
 +			_privateFlags.setFlag(kCaldoriaPrivate4DSystemOpenFlag, false);
 +			setCurrentActivation(kActivate4DClosed);
 +			startExtraSequence(k4DEnvironClose, kExtraCompletedFlag, kFilterNoInput);
 +		} else if (GameState.getCaldoriaBombDisarmed()) {
 +			turnLeft();
 +		}
 +	}
 +}
 +
 +// Only called when trying to pick up an item and the player can't (because
 +// the inventory is too full or because the player lets go of the item before
 +// dropping it into the inventory).
 +Hotspot *Caldoria::getItemScreenSpot(Item *item, DisplayElement *element) {
 +	HotSpotID destSpotID = kNoHotSpotID;
 +	
 +	switch (item->getObjectID()) {
 +	case kKeyCard:
 +		destSpotID = kCaldoriaKeyCardSpotID;
 +		break;
 +	case kOrangeJuiceGlassEmpty:
 +	case kOrangeJuiceGlassFull:
 +		destSpotID = kCaldoriaOrangeJuiceSpotID;
 +		break;
 +	}
 +
 +	if (destSpotID == kNoHotSpotID)
 +		return Neighborhood::getItemScreenSpot(item, element);
 +
 +	return g_allHotspots.findHotspotByID(destSpotID);
 +}
 +
 +void Caldoria::pickedUpItem(Item *item) {
 +	switch (item->getObjectID()) {
 +	case kKeyCard:
 +		GameState.setScoringGotKeyCard(true);
 +		break;
 +	case kOrangeJuiceGlassFull:
 +		setCurrentActivation(kActivateReplicatorReady);
 +		requestSpotSound(kCaldoriaDrinkOJIn, kCaldoriaDrinkOJOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +		break;
 +	case kStunGun:
 +		GameState.setCaldoriaGunAimed(false);
 +		break;
 +	}
 +}
 +
 +void Caldoria::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {	
 +	switch (item->getObjectID()) {
 +	case kKeyCard:
 +		Neighborhood::dropItemIntoRoom(item, dropSpot);
 +		if (dropSpot->getObjectID() == kCaldoriaGTCardDropSpotID)
 +			startExtraSequence(kCaGTCardSwipe, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kOrangeJuiceGlassEmpty:
 +		Neighborhood::dropItemIntoRoom(item, dropSpot);
 +		if (dropSpot->getObjectID() == kCaldoriaOrangeJuiceDropSpotID) {
 +			GameState.setCaldoriaMadeOJ(false);
 +			startExtraSequence(kDisposeOrangeJuice, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	case kCardBomb:
 +		GameState.setCaldoriaDoorBombed(true);
 +		setCurrentActivation(kActivateHotSpotAlways);
 +		Neighborhood::dropItemIntoRoom(item, dropSpot);
 +		// Long enough for AI hints...?
 +		_utilityFuse.primeFuse(kCardBombCountDownTime);
 +		_utilityFuse.setFunctionPtr(&doorBombTimerExpiredFunction, (void *)this);
 +		_utilityFuse.lightFuse();
 +		GameState.setCaldoriaFuseTimeLimit(kCardBombCountDownTime);
 +		loopCroppedMovie("Images/Caldoria/A48 Bomb Loop", kCaldoria48CardBombLoopLeft, kCaldoria48CardBombLoopTop);
 +		GameState.setScoringUsedCardBomb(true);
 +		break;
 +	case kStunGun:
 +		GameState.setCaldoriaGunAimed(true);
 +		GameState.setCaldoriaSinclairShot(true);
 +		_gunSprite = item->getDragSprite(0);
 +		_gunSprite->setCurrentFrameIndex(1);
 +		_gunSprite->setDisplayOrder(kDragSpriteOrder);
 +		_gunSprite->moveElementTo(kCaldoriaGunSpriteLeft, kCaldoriaGunSpriteTop);
 +		_gunSprite->startDisplaying();
 +		_gunSprite->show();
 +		break;
 +	default:
 +		Neighborhood::dropItemIntoRoom(item, dropSpot);
 +		break;
 +	}
 +}
 +
 +void Caldoria::takeElevator(uint startFloor, uint endFloor) {
 +	_croppedMovie.stop();
 +	_croppedMovie.setSegment(0, _croppedMovie.getDuration());
 +
 +	switch (startFloor) {
 +	case 1:
 +		switch (endFloor) {
 +		case 1:
 +			// Do nothing.
 +			break;
 +		case 2:
 +			_croppedMovie.setTime(k1To2Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 3:
 +			_croppedMovie.setTime(k1To3Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 4:
 +			_croppedMovie.setSegment(k1To4Start, k1To4Stop);
 +			_croppedMovie.setTime(k1To4Start);
 +			startExtraSequence(kCaldoriaGroundToFourth, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		case 5:
 +			_croppedMovie.setSegment(k1To5Start, k1To5Stop);
 +			_croppedMovie.setTime(k1To5Start);
 +			startExtraSequence(kCaldoriaGroundToRoof, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		}
 +		break;
 +	case 4:
 +		switch (endFloor) {
 +		case 1:
 +			_croppedMovie.setSegment(k4To1Start, k4To1Stop);
 +			_croppedMovie.setTime(k4To1Start);
 +			startExtraSequence(kCaldoriaFourthToGround, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		case 2:
 +			_croppedMovie.setTime(k4To2Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 3:
 +			_croppedMovie.setTime(k4To3Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 4:
 +			// Do nothing.
 +			break;
 +		case 5:
 +			_croppedMovie.setSegment(k4To5Start, k4To5Stop);
 +			_croppedMovie.setTime(k4To5Start);
 +			startExtraSequence(kCaldoriaFourthToRoof, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		}
 +		break;
 +	case 5:
 +		switch (endFloor) {
 +		case 1:
 +			_croppedMovie.setSegment(k5To1Start, k5To1Stop);
 +			_croppedMovie.setTime(k5To1Start);
 +			startExtraSequence(kCaldoriaRoofToGround, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		case 2:
 +			_croppedMovie.setTime(k5To2Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 3:
 +			_croppedMovie.setTime(k5To3Time);
 +			requestSpotSound(kCaldoriaNoOtherDestinationIn, kCaldoriaNoOtherDestinationOut, kFilterNoInput, kSpotSoundCompletedFlag);
 +			break;
 +		case 4:
 +			_croppedMovie.setSegment(k5To4Start, k5To4Stop);
 +			_croppedMovie.setTime(k5To4Start);
 +			startExtraSequence(kCaldoriaRoofToFourth, kExtraCompletedFlag, false);
 +			_croppedMovie.start();
 +			break;
 +		case 5:
 +			// Do nothing.
 +			break;
 +		}
 +		break;
 +	};
 +}
 +
 +void Caldoria::updateElevatorMovie() {
 +	TimeValue time = 0xffffffff;
 +
 +	if (GameState.getCurrentDirection() == kNorth) {
 +		switch (GameState.getCurrentRoom()) {
 +		case kCaldoria27:
 +			time = k4FloorTime;
 +			break;
 +		case kCaldoria28:
 +			time = k1FloorTime;
 +			break;
 +		case kCaldoria45:
 +			time = k5FloorTime;
 +			break;
 +		}
 +	}
 +
 +	_croppedMovie.stop();
 +
 +	if (time == 0xffffffff) {
 +		_croppedMovie.hide();
 +	} else {
 +		_croppedMovie.stop();
 +		_croppedMovie.setSegment(0, _croppedMovie.getDuration());
 +		_croppedMovie.setTime(time);
 +		_croppedMovie.redrawMovieWorld();
 +		_croppedMovie.show();
 +		
 +		// *** Why do I need this?
 +		// clone2727: "don't ask me!"
 +		_navMovie.redrawMovieWorld();
 +	}
 +}
 +
 +void Caldoria::openElevatorMovie() {
 +	if (!_croppedMovie.isSurfaceValid())
 +		openCroppedMovie("Images/Caldoria/Caldoria Elevator.movie", kCaldoriaElevatorLeft, kCaldoriaElevatorTop);
 +
 +	updateElevatorMovie();
 +}
 +
 +void Caldoria::emptyOJGlass() {
 +	GameState.setTakenItemID(kOrangeJuiceGlassFull, false);
 +	GameState.setTakenItemID(kOrangeJuiceGlassEmpty, true);
 +	_vm->removeItemFromInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassFull));
 +	_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassEmpty));
 +}
 +
 +void Caldoria::doorBombTimerExpired() {
 +	closeCroppedMovie();
 +
 +	if (GameState.getShieldOn()) {
 +		_vm->getCurrentBiochip()->setItemState(kShieldCardBomb);
 +		setCurrentAlternate(kAltCaldoriaRoofDoorBlown);
 +		startExtraSequence(kCa48NorthExplosion, kExtraCompletedFlag, kFilterNoInput);
 +		GameState.setScoringShieldedCardBomb(true);
 +		GameState.setCaldoriaDoorBombed(false);
 +		GameState.setCaldoriaRoofDoorOpen(true);
 +	} else {
 +		playDeathExtra(kCa48NorthExplosionDeath, kDeathCardBomb);
 +	}
 +}
 +
 +void Caldoria::sinclairTimerExpired() {
 +	_privateFlags.setFlag(kCaldoriaPrivateSinclairTimerExpiredFlag, true);
 +	checkSinclairShootsOS();
 +}
 +
 +void Caldoria::checkSinclairShootsOS() {
 +	if (_privateFlags.getFlag(kCaldoriaPrivateSinclairTimerExpiredFlag))
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kCaldoria49, kNorth):
 +		case MakeRoomView(kCaldoria49, kSouth):
 +		case MakeRoomView(kCaldoria49, kEast):
 +		case MakeRoomView(kCaldoria49, kWest):
 +		case MakeRoomView(kCaldoria50, kSouth):
 +		case MakeRoomView(kCaldoria50, kEast):
 +		case MakeRoomView(kCaldoria50, kWest):
 +		case MakeRoomView(kCaldoria51, kNorth):
 +		case MakeRoomView(kCaldoria51, kSouth):
 +		case MakeRoomView(kCaldoria51, kWest):
 +		case MakeRoomView(kCaldoria52, kNorth):
 +		case MakeRoomView(kCaldoria52, kSouth):
 +		case MakeRoomView(kCaldoria52, kWest):
 +		case MakeRoomView(kCaldoria53, kNorth):
 +		case MakeRoomView(kCaldoria53, kSouth):
 +		case MakeRoomView(kCaldoria53, kWest):
 +		case MakeRoomView(kCaldoria54, kNorth):
 +		case MakeRoomView(kCaldoria54, kEast):
 +		case MakeRoomView(kCaldoria54, kWest):
 +			playSpotSoundSync(kCaldoriaSinclairShootsOSIn, kCaldoriaSinclairShootsOSOut);
 +			playSpotSoundSync(kCaldoriaScreamingAfterIn, kCaldoriaScreamingAfterOut);
 +			die(kDeathSinclairShotDelegate);
 +			break;
 +		}
 +}
 +
 +void Caldoria::checkInterruptSinclair() {
 +	if (GameState.getCaldoriaSinclairShot()) {
 +		_navMovie.stop();
 +		_neighborhoodNotification.setNotificationFlags(kExtraCompletedFlag, kExtraCompletedFlag);
 +		g_AIArea->unlockAI();
 +	} else {
 +		uint32 currentTime = _navMovie.getTime();
 +
 +		ExtraTable::Entry entry;
 +		getExtraEntry(kCa53EastZoomToSinclair, entry);
 +
 +		if (currentTime < entry.movieStart + kSinclairInterruptionTime2)
 +			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime2,
 +					_navMovie.getScale());
 +		else if (currentTime < entry.movieStart + kSinclairInterruptionTime3)
 +			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime3,
 +					_navMovie.getScale());
 +		else if (currentTime < entry.movieStart + kSinclairInterruptionTime4)
 +			_sinclairInterrupt.scheduleCallBack(kTriggerTimeFwd, entry.movieStart + kSinclairInterruptionTime4,
 +					_navMovie.getScale());
 +	}
 +}
 +
 +Common::String Caldoria::getBriefingMovie() {
 +	Common::String movieName = Neighborhood::getBriefingMovie();
 +
 +	if (movieName.empty()) {
 +		if (GameState.allTimeZonesFinished())
 +			return "Images/AI/Caldoria/XA02";
 +
 +		return "Images/AI/Caldoria/XA01";
 +	}
 +
 +	return movieName;
 +}
 +
 +Common::String Caldoria::getEnvScanMovie() {	
 +	Common::String movieName = Neighborhood::getEnvScanMovie();
 +
 +	if (movieName.empty()) {
 +		RoomID room = GameState.getCurrentRoom();
 +
 +		if (room >= kCaldoria00 && room <= kCaldoria14) {
 +			// Inside apartment.
 +			if (GameState.getCaldoriaDoneHygiene())
 +				return "Images/AI/Caldoria/XAE2";
 +
 +			return "Images/AI/Caldoria/XAE1";
 +		} else if (room >= kCaldoria15 && room <= kCaldoria48) {
 +			// Wandering the halls...
 +			return "Images/AI/Caldoria/XAE3";
 +		} else {
 +			// Must be the roof.
 +			return "Images/AI/Caldoria/XAEH2";
 +		}
 +	}
 +
 +	return movieName;
 +}
 +
 +uint Caldoria::getNumHints() {
 +	uint numHints = Neighborhood::getNumHints();
 +
 +	if (numHints == 0) {
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kCaldoria44, kEast):
 +			if (!GameState.isTakenItemID(kKeyCard) && GameState.getOpenDoorRoom() == kNoRoomID)
 +				numHints = 1;
 +			break;
 +		case MakeRoomView(kCaldoria48, kNorth):
 +			if (!GameState.getCaldoriaRoofDoorOpen()) {
 +				if (_croppedMovie.isRunning()) // Bomb must be looping.
 +					numHints = 3;
 +				else if (GameState.isTakenItemID(kCardBomb))
 +					numHints = 1;
 +			}
 +			break;
 +		case MakeRoomView(kCaldoria49, kEast):
 +		case MakeRoomView(kCaldoria54, kEast):
 +			numHints = 1;
 +			break;
 +		case MakeRoomView(kCaldoria49, kNorth):
 +			numHints = 1;
 +			break;
 +		}
 +	}
 +	
 +	return numHints;
 +}
 +
 +Common::String Caldoria::getHintMovie(uint hintNum) {
 +	Common::String movieName = Neighborhood::getHintMovie(hintNum);
 +
 +	if (movieName.empty()) {
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kCaldoria44, kEast):
 +			return "Images/AI/Caldoria/X42WH2";
 +		case MakeRoomView(kCaldoria48, kNorth):
 +			if (_croppedMovie.isRunning()) { // Bomb must be looping.
 +				if (hintNum == 1)
 +					return "Images/AI/Caldoria/X48ND1";
 +				else if (hintNum == 2)
 +					return "Images/AI/Caldoria/X48ND2";
 +				else if (GameState.isTakenItemID(kShieldBiochip))
 +					return "Images/AI/Caldoria/X48ND3";
 +
 +				// *** Doesn't work yet, need global movies.
 +				break;
 +			} 
 +
 +			return "Images/AI/Globals/XGLOB1A";
 +		case MakeRoomView(kCaldoria49, kEast):
 +		case MakeRoomView(kCaldoria54, kEast):
 +			return "Images/AI/Caldoria/X49E";
 +		case MakeRoomView(kCaldoria49, kNorth):
 +			return "Images/AI/Caldoria/X49NB2";
 +		}
 +	}
 +
 +	return movieName;
 +}
 +
 +void Caldoria::updateCursor(const Common::Point where, const Hotspot *cursorSpot) {
 +	if (cursorSpot) {
 +		switch (cursorSpot->getObjectID()) {
 +		case kCa4DEnvironCloseSpotID:
 +			_vm->_cursor->setCurrentFrameIndex(2);
 +			return;
 +		case kCaldoriaKioskSpotID:
 +			_vm->_cursor->setCurrentFrameIndex(3);
 +			return;
 +		}
 +	}
 +
 +	Neighborhood::updateCursor(where, cursorSpot);
 +}
 +
 +Common::String Caldoria::getNavMovieName() {
 +	return "Images/Caldoria/Caldoria.movie";
 +}
 +
 +Common::String Caldoria::getSoundSpotsName() {
 +	return "Sounds/Caldoria/Caldoria Spots";
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/neighborhood/mars/mars.cpp
index c950a85,0000000..816a13f
mode 100644,000000..100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@@ -1,3749 -1,0 +1,3753 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/events.h"
 +#include "video/qt_decoder.h"
 +
 +#include "pegasus/cursor.h"
 +#include "pegasus/energymonitor.h"
 +#include "pegasus/gamestate.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/ai/ai_area.h"
 +#include "pegasus/items/biochips/opticalchip.h"
 +#include "pegasus/items/biochips/shieldchip.h"
 +#include "pegasus/items/inventory/airmask.h"
 +#include "pegasus/neighborhood/mars/mars.h"
 +
 +namespace Pegasus {
 +
 +// This should really be 22.5.
 +// Probably no one will know the difference.
 +static const int16 kMarsShieldPanelOffsetAngle = 22;
 +
 +static const CanMoveForwardReason kCantMoveRobotBlocking = kCantMoveLastReason + 1;
 +
 +static const NotificationFlags kTimeForCanyonChaseFlag = kLastNeighborhoodNotificationFlag << 1;
 +static const NotificationFlags kExplosionFinishedFlag = kTimeForCanyonChaseFlag << 1;
 +static const NotificationFlags kTimeToTransportFlag = kExplosionFinishedFlag << 1;
 +
 +static const NotificationFlags kMarsNotificationFlags = kTimeForCanyonChaseFlag |
 +													kExplosionFinishedFlag |
 +													kTimeToTransportFlag;
 +
 +static const TimeValue kLittleExplosionStart = 0 * 40;
 +static const TimeValue kLittleExplosionStop = 24 * 40;
 +
 +static const TimeValue kBigExplosionStart = 24 * 40;
 +static const TimeValue kBigExplosionStop = 62 * 40;
 +
 +enum {
 +	kMaze007RobotLoopingEvent,
 +	kMaze015RobotLoopingEvent,
 +	kMaze101RobotLoopingEvent,
 +	kMaze104RobotLoopingEvent,
 +	kMaze133RobotLoopingEvent,
 +	kMaze136RobotLoopingEvent,
 +	kMaze184RobotLoopingEvent
 +};
 +
 +enum {
 +	kMaze007RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
 +	kMaze015RobotLoopingTime = (64 + 93) * kMarsFrameDuration,
 +	kMaze101RobotLoopingTime = (64 + 45) * kMarsFrameDuration,
 +	kMaze104RobotLoopingTime = 96 * kMarsFrameDuration,
 +	kMaze133RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
 +	kMaze136RobotLoopingTime = (64 + 96) * kMarsFrameDuration,
 +	kMaze184RobotLoopingTime = 96 * kMarsFrameDuration
 +};
 +
 +// I've made a couple macros for these rects so we don't
 +// have to globally construct them or whatnot
 +#define kShuttleEnergyBeamBounds Common::Rect(24, 27, 24 + 112, 27 + 46)
 +#define kShuttleGravitonBounds Common::Rect(24, 73, 24 + 112, 73 + 30)
 +#define kShuttleTractorBounds Common::Rect(24, 103, 24 + 112, 103 + 30)
 +#define kShuttleTransportBounds Common::Rect(484, 353, 89 + 484, 79 + 353)
 +
 +void robotTimerExpiredFunction(FunctionPtr *, void *mars) {
 +	((Mars *)mars)->robotTiredOfWaiting();
 +}
 +
 +void lockThawTimerExpiredFunction(FunctionPtr *, void *mars) {
 +	((Mars *)mars)->lockThawed();
 +}
 +
 +void bombTimerExpiredFunction(FunctionPtr *, void *mars) {
 +	((Mars *)mars)->didntFindBomb();
 +}
 +
 +void bombTimerExpiredInGameFunction(FunctionPtr *, void *mars) {
 +	((Mars *)mars)->bombExplodesInGame();
 +}
 +
 +void airStageExpiredFunction(FunctionPtr *, void *mars) {
 +	((Mars *)mars)->airStageExpired();
 +}
 +
 +void marsTimerFunction(FunctionPtr *, void *event) {
 +	((MarsTimerEvent *)event)->mars->marsTimerExpired(*(MarsTimerEvent *)event);
 +}
 +
 +Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextHandler, owner, "Mars", kMarsID),
 +		_guessObject(kNoDisplayElement), _undoPict(kNoDisplayElement), _guessHistory(kNoDisplayElement),
 +		_choiceHighlight(kNoDisplayElement), _shuttleInterface1(kNoDisplayElement), _shuttleInterface2(kNoDisplayElement),
 +		_shuttleInterface3(kNoDisplayElement), _shuttleInterface4(kNoDisplayElement), _canyonChaseMovie(kNoDisplayElement),
 +		_leftShuttleMovie(kNoDisplayElement), _rightShuttleMovie(kNoDisplayElement), _lowerLeftShuttleMovie(kNoDisplayElement),
 +		_lowerRightShuttleMovie(kNoDisplayElement), _centerShuttleMovie(kNoDisplayElement),
 +		_upperLeftShuttleMovie(kNoDisplayElement), _upperRightShuttleMovie(kNoDisplayElement),
 +		_leftDamageShuttleMovie(kNoDisplayElement), _rightDamageShuttleMovie(kNoDisplayElement), _explosions(kNoDisplayElement),
 +		_planetMovie(kNoDisplayElement), _junk(kNoDisplayElement), _energyChoiceSpot(kShuttleEnergySpotID),
 +		_gravitonChoiceSpot(kShuttleGravitonSpotID), _tractorChoiceSpot(kShuttleTractorSpotID),
 +		_shuttleViewSpot(kShuttleViewSpotID), _shuttleTransportSpot(kShuttleTransportSpotID) {
 +	_noAirFuse.setFunctionPtr(&airStageExpiredFunction, this);
 +	setIsItemTaken(kMarsCard);
 +	setIsItemTaken(kAirMask);
 +	setIsItemTaken(kCrowbar);
 +	setIsItemTaken(kCardBomb);
 +}
 +
 +Mars::~Mars() {
 +	g_allHotspots.remove(&_energyChoiceSpot);
 +	g_allHotspots.remove(&_gravitonChoiceSpot);
 +	g_allHotspots.remove(&_tractorChoiceSpot);
 +	g_allHotspots.remove(&_shuttleViewSpot);
 +	g_allHotspots.remove(&_shuttleTransportSpot);
 +}
 +
 +void Mars::init() {	
 +	Neighborhood::init();
 +	
 +	Hotspot *attackSpot = g_allHotspots.findHotspotByID(kAttackRobotHotSpotID);
 +	attackSpot->setMaskedHotspotFlags(kDropItemSpotFlag, kDropItemSpotFlag);
 +	_attackingItem = NULL;
 +	
 +	forceStridingStop(kMars08, kNorth, kAltMarsNormal);
 +
 +	_neighborhoodNotification.notifyMe(this, kMarsNotificationFlags, kMarsNotificationFlags);
 +
 +	_explosionCallBack.setNotification(&_neighborhoodNotification);
 +	_explosionCallBack.setCallBackFlag(kExplosionFinishedFlag);
 +}
 +
 +void Mars::flushGameState() {
 +	g_energyMonitor->saveCurrentEnergyValue();
 +}
 +
 +void Mars::start() {
 +	g_energyMonitor->stopEnergyDraining();
 +	g_energyMonitor->restoreLastEnergyValue();
 +	_vm->resetEnergyDeathReason();
 +	g_energyMonitor->startEnergyDraining();
 +	Neighborhood::start();
 +}
 +
 +class AirMaskCondition : public AICondition {
 +public:
 +	AirMaskCondition(const uint32);
 +	
 +	virtual bool fireCondition();
 +
 +protected:
 +	uint32 _airThreshold;
 +	uint32 _lastAirLevel;
 +};
 +
 +AirMaskCondition::AirMaskCondition(const uint32 airThreshold) {
 +	_airThreshold = airThreshold;
 +	_lastAirLevel = g_airMask->getAirLeft();
 +}
 +
 +bool AirMaskCondition::fireCondition() {
 +	bool result = g_airMask && g_airMask->isAirMaskOn() &&
 +			g_airMask->getAirLeft() <= _airThreshold && _lastAirLevel > _airThreshold;
 +
 +	_lastAirLevel = g_airMask->getAirLeft();
 +	return result;
 +}
 +
 +void Mars::setUpAIRules() {	
 +	Neighborhood::setUpAIRules();
 +
 +	// Don't add these rules if we're going to the robot's shuttle...
 +	if (g_AIArea && !GameState.getMarsReadyForShuttleTransport()) {
 +		AIPlayMessageAction *messageAction = new AIPlayMessageAction("Images/AI/Globals/XGLOB1E", false);
 +		AILocationCondition *locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars47, kSouth));
 +		AIRule *rule = new AIRule(locCondition, messageAction);
 +		g_AIArea->addAIRule(rule);
 +
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM27NB", false);
 +		locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars27, kNorth));
 +		rule = new AIRule(locCondition, messageAction);
 +		g_AIArea->addAIRule(rule);
 +
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM27NB", false);
 +		locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars28, kNorth));
 +		rule = new AIRule(locCondition, messageAction);
 +		g_AIArea->addAIRule(rule);
 +
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM41ED", false);
 +		locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars19, kEast));
 +		rule = new AIRule(locCondition, messageAction);
 +		g_AIArea->addAIRule(rule);
 +
 +		AIDeactivateRuleAction *deactivate = new AIDeactivateRuleAction(rule);
 +		locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars35, kWest));
 +		rule = new AIRule(locCondition, deactivate);
 +		g_AIArea->addAIRule(rule);
 +
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM41ED", false);
 +		locCondition = new AILocationCondition(1);
 +		locCondition->addLocation(MakeRoomView(kMars48, kWest));
 +		rule = new AIRule(locCondition, messageAction);
 +		g_AIArea->addAIRule(rule);
 +
 +		AirMaskCondition *airMask50Condition = new AirMaskCondition(50);
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB1", false);
 +		AIRule *rule50 = new AIRule(airMask50Condition, messageAction);
 +
 +		AirMaskCondition *airMask25Condition = new AirMaskCondition(25);
 +		AICompoundAction *compound = new AICompoundAction();
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB2", false);
 +		compound->addAction(messageAction);
 +		deactivate = new AIDeactivateRuleAction(rule50);
 +		compound->addAction(deactivate);
 +		AIRule *rule25 = new AIRule(airMask25Condition, compound);
 +
 +		AirMaskCondition *airMask5Condition = new AirMaskCondition(5);
 +		compound = new AICompoundAction;
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XMMAZB3", false);
 +		compound->addAction(messageAction);
 +		deactivate = new AIDeactivateRuleAction(rule50);
 +		compound->addAction(deactivate);
 +		deactivate = new AIDeactivateRuleAction(rule25);
 +		compound->addAction(deactivate);
 +		AIRule *rule5 = new AIRule(airMask5Condition, compound);
 +
 +		g_AIArea->addAIRule(rule5);
 +		g_AIArea->addAIRule(rule25);
 +		g_AIArea->addAIRule(rule50);
 +
 +		messageAction = new AIPlayMessageAction("Images/AI/Mars/XM51ND", false);
 +		AIDoorOpenedCondition *doorOpen = new AIDoorOpenedCondition(MakeRoomView(kMars51, kEast));
 +		rule = new AIRule(doorOpen, messageAction);
 +		g_AIArea->addAIRule(rule);
 +	}
 +}
 +
 +uint16 Mars::getDateResID() const {
 +	return kDate2185ID;
 +}
 +
 +TimeValue Mars::getViewTime(const RoomID room, const DirectionConstant direction) {
 +	ExtraTable::Entry extra;
 +	SpotTable::Entry spotEntry;
 +	uint32 extraID = 0xffffffff;
 +
 +	switch (MakeRoomView(room, direction)) {
 +	case MakeRoomView(kMars0A, kNorth):
 +		if (!GameState.getMarsSeenTimeStream()) {
 +			getExtraEntry(kMarsArrivalFromTSA, extra);
 +			return extra.movieStart;
 +		}
 +		break;
 +	case MakeRoomView(kMars31South, kSouth):
 +		if (GameState.isTakenItemID(kMarsCard))
 +			extraID = kMars31SouthZoomViewNoCard;
 +		break;
 +	case MakeRoomView(kMars31, kSouth):
 +		if (GameState.isTakenItemID(kMarsCard))
 +			extraID = kMars31SouthViewNoCard;
 +		break;
 +	case MakeRoomView(kMars34, kSouth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			if (GameState.isTakenItemID(kCrowbar))
 +				extraID = kMars34ViewOpenNoBar;
 +			else
 +				extraID = kMars34ViewOpenWithBar;
 +		}
 +		break;
 +	case MakeRoomView(kMars36, kSouth):
 +	case MakeRoomView(kMars37, kSouth):
 +	case MakeRoomView(kMars38, kSouth):
 +		findSpotEntry(room, direction, kSpotOnTurnMask | kSpotLoopsMask, spotEntry);
 +		return spotEntry.movieStart;
 +	case MakeRoomView(kMars45, kNorth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			if (GameState.isTakenItemID(kCrowbar))
 +				extraID = kMars45ViewOpenNoBar;
 +			else
 +				extraID = kMars45ViewOpenWithBar;
 +		}
 +		break;
 +	case MakeRoomView(kMars48, kEast):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
 +			extraID = kMars48RobotView;
 +		break;
 +	case MakeRoomView(kMars56, kEast):
 +		if (_privateFlags.getFlag(kMarsPrivateBombExposedFlag)) {
 +			if (_privateFlags.getFlag(kMarsPrivateDraggingBombFlag))
 +				extraID = kMars57ViewOpenNoBomb;
 +			else
 +				extraID = kMars57ExposeBomb;
 +		} else if (GameState.getMarsLockBroken()) {
 +			extraID = kMars57OpenPanelChoices;
 +		} else if (GameState.getMarsLockFrozen()) {
 +			extraID = kMars57LockFrozenView;
 +		}
 +		break;
 +	case MakeRoomView(kMarsRobotShuttle, kEast):
 +		if (getCurrentActivation() == kActivationRobotHeadOpen) {
 +			extraID = kMarsRobotHead111;
 +
 +			if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag))
 +				extraID -= 1;
 +			if (_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag))
 +				extraID -= 2;
 +			if (_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag))
 +				extraID -= 4;
 +		}
 +		break;
 +	}
 +
 +	if (extraID == 0xffffffff)
 +		return Neighborhood::getViewTime(room, direction);
 +
 +	getExtraEntry(extraID, extra);
 +	return extra.movieEnd - 1;
 +}
 +
 +void Mars::getZoomEntry(const HotSpotID spotID, ZoomTable::Entry &entry) {
 +	Neighborhood::getZoomEntry(spotID, entry);
 +
 +	uint32 extraID = 0xffffffff;
 +
 +	switch (spotID) {
 +	case kMars31SouthSpotID:
 +		if (GameState.getCurrentDirection() == kSouth && GameState.isTakenItemID(kMarsCard))
 +			extraID = kMars31SouthZoomInNoCard;
 +		break;
 +	case kMars31SouthOutSpotID:
 +		if (GameState.getCurrentDirection() == kSouth && GameState.isTakenItemID(kMarsCard))
 +			extraID = kMars31SouthZoomOutNoCard;
 +		break;
 +	}
 +
 +	if (extraID != 0xffffffff) {
 +		ExtraTable::Entry extra;
 +		getExtraEntry(extraID, extra);
 +		entry.movieStart = extra.movieStart;
 +		entry.movieEnd = extra.movieEnd;
 +	}
 +}
 +
 +void Mars::findSpotEntry(const RoomID room, const DirectionConstant direction, SpotFlags flags, SpotTable::Entry &entry) {
 +	Neighborhood::findSpotEntry(room, direction, flags, entry);
 +
 +	if ((flags & (kSpotOnArrivalMask | kSpotOnTurnMask)) != 0) {
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kMars27, kNorth):
 +			if (GameState.getMarsSeenThermalScan())
 +				entry.clear();
 +			else
 +				GameState.setMarsSeenThermalScan(true);
 +			break;
 +		case MakeRoomView(kMars28, kNorth):
 +			if (GameState.getMarsSeenThermalScan())
 +				entry.clear();
 +			else
 +				GameState.setMarsSeenThermalScan(true);
 +			break;
 +		}
 +	}
 +}
 +
 +CanMoveForwardReason Mars::canMoveForward(ExitTable::Entry &entry) {
 +	CanMoveForwardReason reason = Neighborhood::canMoveForward(entry);
 +
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars48, kEast):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
 +			reason = kCantMoveRobotBlocking;
 +		break;
 +	case MakeRoomView(kMars48, kSouth):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
 +			_utilityFuse.stopFuse();
 +		break;
 +	}
 +
 +	return reason;
 +}
 +
 +void Mars::cantMoveThatWay(CanMoveForwardReason reason) {
 +	if (reason == kCantMoveRobotBlocking) {
 +		startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
 +		loadLoopSound2("");
 +	} else {
 +		Neighborhood::cantMoveThatWay(reason);
 +	}
 +}
 +
 +void Mars::moveForward() {
 +	if (GameState.getCurrentRoom() == kMars02 || (GameState.getCurrentRoom() >= kMars05 && GameState.getCurrentRoom() <= kMars08))
 +		loadLoopSound2("");
 +
 +	Neighborhood::moveForward();
 +}
 +
 +void Mars::bumpIntoWall() {
 +	requestSpotSound(kMarsBumpIntoWallIn, kMarsBumpIntoWallOut, kFilterNoInput, 0);
 +	Neighborhood::bumpIntoWall();
 +}
 +
 +CanOpenDoorReason Mars::canOpenDoor(DoorTable::Entry &entry) {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars05, kEast):
 +	case MakeRoomView(kMars06, kEast):
 +	case MakeRoomView(kMars07, kEast):
 +		if (!GameState.getMarsSecurityDown())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze037, kWest):
 +	case MakeRoomView(kMarsMaze038, kEast):
 +		if (GameState.getMarsMazeDoorPair1())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze050, kNorth):
 +	case MakeRoomView(kMarsMaze058, kSouth):
 +		if (!GameState.getMarsMazeDoorPair1())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze047, kNorth):
 +	case MakeRoomView(kMarsMaze142, kSouth):
 +		if (GameState.getMarsMazeDoorPair2())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze057, kNorth):
 +	case MakeRoomView(kMarsMaze136, kSouth):
 +		if (!GameState.getMarsMazeDoorPair2())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze120, kWest):
 +	case MakeRoomView(kMarsMaze121, kEast):
 +		if (GameState.getMarsMazeDoorPair3())
 +			return kCantOpenLocked;
 +		break;
 +	case MakeRoomView(kMarsMaze081, kNorth):
 +	case MakeRoomView(kMarsMaze083, kSouth):
 +		if (!GameState.getMarsMazeDoorPair3())
 +			return kCantOpenLocked;
 +		break;
 +	}
 +
 +	return Neighborhood::canOpenDoor(entry);
 +}
 +
 +void Mars::cantOpenDoor(CanOpenDoorReason reason) {
 +	switch (GameState.getCurrentRoom()) {
 +	case kMars05:
 +	case kMars06:
 +	case kMars07:
 +		playSpotSoundSync(kMarsCantOpenShuttleIn, kMarsCantOpenShuttleOut);
 +		break;
 +	default:
 +		Neighborhood::cantOpenDoor(reason);
 +		break;
 +	}
 +}
 +
 +void Mars::openDoor() {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars06, kEast):
 +	case MakeRoomView(kMars07, kEast):
 +		if (GameState.getMarsSecurityDown())
 +			playSpotSoundSync(kMarsNoShuttleIn, kMarsNoShuttleOut);
 +		break;
 +	case MakeRoomView(kMars47, kSouth):
 +		if (GameState.isTakenItemID(kAirMask))
 +			setCurrentAlternate(kAltMarsTookMask);
 +		else
 +			setCurrentAlternate(kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars48, kNorth):
 +		if (GameState.getMarsPodAtUpperPlatform())
 +			setCurrentAlternate(kAltMarsNormal);
 +		else
 +			setCurrentAlternate(kAltMarsPodAtMars45);
 +		break;
 +	case MakeRoomView(kMars48, kEast):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
 +			die(kDeathDidntGetOutOfWay);
 +			return;
 +		}
 +		break;
 +	}
 +
 +	Neighborhood::openDoor();
 +}
 +
 +void Mars::doorOpened() {
 +	switch (GameState.getCurrentRoom()) {
 +	case kMars27:
 +	case kMars28:
 +		if (GameState.getCurrentDirection() == kNorth)
 +			_vm->die(kDeathArrestedInMars);
 +		else
 +			Neighborhood::doorOpened();
 +		break;
 +	case kMars41:
 +	case kMars42:
 +		if (GameState.getCurrentDirection() == kEast)
 +			_vm->die(kDeathWrongShuttleLock);
 +		else
 +			Neighborhood::doorOpened();
 +		break;
 +	case kMars51:
 +		Neighborhood::doorOpened();
 +		setUpReactorEnergyDrain();
 +
 +		if (g_AIArea)
 +			g_AIArea->checkRules();
 +		break;
 +	case kMars19:
 +		if (GameState.getCurrentDirection() == kEast)
 +			GameState.setMarsAirlockOpen(true);
 +
 +		Neighborhood::doorOpened();
 +		break;
 +	case kMars48:
 +		if (GameState.getCurrentDirection() == kWest)
 +			GameState.setMarsAirlockOpen(true);
 +
 +		Neighborhood::doorOpened();
 +		break;
 +	default:
 +		Neighborhood::doorOpened();
 +		break;
 +	}
 +}
 +
 +void Mars::setUpReactorEnergyDrain() {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars51, kEast):
 +		if (GameState.isCurrentDoorOpen()) {
 +			if (g_energyMonitor->getEnergyDrainRate() == kEnergyDrainNormal) {
 +				if (GameState.getShieldOn()) {
 +					g_shield->setItemState(kShieldRadiation);
 +					g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainWithShield);
 +				} else {
 +					g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainNoShield);
 +				}
 +				_vm->setEnergyDeathReason(kDeathReactorBurn);
 +			}
 +		} else {
 +			if (g_energyMonitor->getEnergyDrainRate() != kEnergyDrainNormal) {
 +				if (GameState.getShieldOn())
 +					g_shield->setItemState(kShieldNormal);
 +				g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
 +				_vm->resetEnergyDeathReason();
 +			}
 +		}
 +		break;
 +	case MakeRoomView(kMars52, kNorth):
 +	case MakeRoomView(kMars52, kSouth):
 +	case MakeRoomView(kMars52, kEast):
 +	case MakeRoomView(kMars52, kWest):
 +	case MakeRoomView(kMars54, kNorth):
 +	case MakeRoomView(kMars54, kSouth):
 +	case MakeRoomView(kMars54, kEast):
 +	case MakeRoomView(kMars54, kWest):
 +	case MakeRoomView(kMars56, kNorth):
 +	case MakeRoomView(kMars56, kSouth):
 +	case MakeRoomView(kMars56, kEast):
 +	case MakeRoomView(kMars56, kWest):
 +	case MakeRoomView(kMars58, kNorth):
 +	case MakeRoomView(kMars58, kSouth):
 +	case MakeRoomView(kMars58, kEast):
 +	case MakeRoomView(kMars58, kWest):
 +		if (g_energyMonitor->getEnergyDrainRate() == kEnergyDrainNormal) {
 +			if (GameState.getShieldOn()) {
 +				g_shield->setItemState(kShieldRadiation);
 +				g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainWithShield);
 +			} else {
 +				g_energyMonitor->setEnergyDrainRate(kMarsReactorEnergyDrainNoShield);
 +			}
 +			_vm->setEnergyDeathReason(kDeathReactorBurn);
 +		}
 +		break;
 +	default:
 +		if (g_energyMonitor->getEnergyDrainRate() != kEnergyDrainNormal) {
 +			if (GameState.getShieldOn())
 +				g_shield->setItemState(kShieldNormal);
 +			g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
 +			_vm->resetEnergyDeathReason();
 +		}
 +		break;
 +	}
 +}
 +
 +void Mars::closeDoorOffScreen(const RoomID room, const DirectionConstant direction) {
 +	switch (room) {
 +	case kMars51:
 +		playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
 +		if (GameState.getShieldOn())
 +			g_shield->setItemState(kShieldNormal);
 +		g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
 +		_vm->resetEnergyDeathReason();
 +		break;
 +	case kMars05:
 +	case kMars06:
 +	case kMars07:
 +	case kMars13:
 +	case kMars22:
 +	case kMars47:
 +	case kMars52:
 +		playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
 +		break;
 +	case kMars18:
 +	case kMars32:
 +		playSpotSoundSync(kMarsTransportDoorCloseIn, kMarsTransportDoorCloseOut);
 +		break;
 +	case kMars19:
 +		if (GameState.getCurrentRoom() != kMars35) {
 +			playSpotSoundSync(kMarsBigAirlockDoorCloseIn, kMarsBigAirlockDoorCloseOut);
 +			GameState.setMarsAirlockOpen(false);
 +		}
 +		break;
 +	case kMars36:
 +		if (GameState.getCurrentRoom() != kMars35)
 +			playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
 +		break;
 +	case kMars48:
 +		if (direction == kWest) {
 +			if (GameState.getCurrentRoom() != kMars60) {
 +				playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
 +				GameState.setMarsAirlockOpen(false);
 +			}
 +		} else {
 +			playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
 +		}
 +		break;
 +	case kMars41:
 +	case kMars42:
 +	case kMars43:
 +		if (direction == kWest)
 +			playSpotSoundSync(kMarsGantryDoorCloseIn, kMarsGantryDoorCloseOut);
 +		break;
 +	case kMarsMaze037:
 +	case kMarsMaze038:
 +	case kMarsMaze012:
 +	case kMarsMaze066:
 +	case kMarsMaze050:
 +	case kMarsMaze058:
 +	case kMarsMaze057:
 +	case kMarsMaze136:
 +	case kMarsMaze047:
 +	case kMarsMaze142:
 +	case kMarsMaze133:
 +	case kMarsMaze132:
 +	case kMarsMaze113:
 +	case kMarsMaze114:
 +	case kMarsMaze120:
 +	case kMarsMaze121:
 +	case kMarsMaze081:
 +	case kMarsMaze083:
 +	case kMarsMaze088:
 +	case kMarsMaze089:
 +	case kMarsMaze179:
 +	case kMarsMaze180:
 +		playSpotSoundSync(kMarsMazeDoorCloseIn, kMarsMazeDoorCloseOut);
 +		break;
 +	}
 +}
 +
 +void Mars::checkAirlockDoors() {
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars19, kWest):
 +	case MakeRoomView(kMars18, kWest):
 +	case MakeRoomView(kMars17, kWest):
 +	case MakeRoomView(kMars16, kWest):
 +	case MakeRoomView(kMars15, kWest):
 +	case MakeRoomView(kMars14, kWest):
 +	case MakeRoomView(kMars12, kWest):
 +	case MakeRoomView(kMars11, kWest):
 +	case MakeRoomView(kMars10, kWest):
 +		if (GameState.getMarsInAirlock()) {
 +			playSpotSoundSync(kMarsBigAirlockDoorCloseIn, kMarsBigAirlockDoorCloseOut);
 +			GameState.setMarsInAirlock(false);
 +		}
 +		break;
 +	case MakeRoomView(kMars36, kEast):
 +	case MakeRoomView(kMars37, kEast):
 +	case MakeRoomView(kMars38, kEast):
 +	case MakeRoomView(kMars39, kEast):
 +	case MakeRoomView(kMars48, kEast):
 +	case MakeRoomView(kMars50, kEast):
 +	case MakeRoomView(kMars51, kEast):
 +	case MakeRoomView(kMars52, kEast):
 +		if (GameState.getMarsInAirlock()) {
 +			playSpotSoundSync(kMarsSmallAirlockDoorCloseIn, kMarsSmallAirlockDoorCloseOut);
 +			GameState.setMarsInAirlock(false);
 +		}
 +		break;
 +	case MakeRoomView(kMars35, kWest):
 +	case MakeRoomView(kMars35, kEast):
 +	case MakeRoomView(kMars60, kWest):
 +	case MakeRoomView(kMars60, kEast):
 +		GameState.setMarsInAirlock(true);
 +		break;
 +	default:
 +		GameState.setMarsInAirlock(false);
 +		break;
 +	}
 +}
 +
 +int16 Mars::getStaticCompassAngle(const RoomID room, const DirectionConstant dir) {
 +	int16 angle = Neighborhood::getStaticCompassAngle(room, dir);
 +
 +	switch (MakeRoomView(room, dir)) {
 +	case MakeRoomView(kMars0A, kNorth):
 +		angle -= 20;
 +		break;
 +	case MakeRoomView(kMars23, kNorth):
 +	case MakeRoomView(kMars23, kSouth):
 +	case MakeRoomView(kMars23, kEast):
 +	case MakeRoomView(kMars23, kWest):
 +	case MakeRoomView(kMars26, kNorth):
 +	case MakeRoomView(kMars26, kSouth):
 +	case MakeRoomView(kMars26, kEast):
 +	case MakeRoomView(kMars26, kWest):
 +		angle += 30;
 +		break;
 +	case MakeRoomView(kMars24, kNorth):
 +	case MakeRoomView(kMars24, kSouth):
 +	case MakeRoomView(kMars24, kEast):
 +	case MakeRoomView(kMars24, kWest):
 +	case MakeRoomView(kMars25, kNorth):
 +	case MakeRoomView(kMars25, kSouth):
 +	case MakeRoomView(kMars25, kEast):
 +	case MakeRoomView(kMars25, kWest):
 +		angle -= 30;
 +		break;
 +	case MakeRoomView(kMars54, kNorth):
 +	case MakeRoomView(kMars54, kSouth):
 +	case MakeRoomView(kMars54, kEast):
 +	case MakeRoomView(kMars54, kWest):
 +		angle += 90;
 +		break;
 +	case MakeRoomView(kMars56, kNorth):
 +	case MakeRoomView(kMars56, kSouth):
 +	case MakeRoomView(kMars56, kEast):
 +	case MakeRoomView(kMars56, kWest):
 +		angle += 180;
 +		break;
 +	case MakeRoomView(kMars58, kNorth):
 +	case MakeRoomView(kMars58, kSouth):
 +	case MakeRoomView(kMars58, kEast):
 +	case MakeRoomView(kMars58, kWest):
 +		angle -= 90;
 +		break;
 +	}
 +
 +	return angle;
 +}
 +
 +void Mars::getExitCompassMove(const ExitTable::Entry &exitEntry, FaderMoveSpec &compassMove) {
 +	Neighborhood::getExitCompassMove(exitEntry, compassMove);
 +
 +	if (exitEntry.room == kMars43 && exitEntry.direction == kEast) {
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 16 * kMarsFrameDuration, 90);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 32 * kMarsFrameDuration, 270);
 +	} else if (exitEntry.room == kMars46 && exitEntry.direction == kWest && exitEntry.altCode != kAltMarsPodAtMars45) {
 +		compassMove.makeTwoKnotFaderSpec(kMarsMovieScale, exitEntry.movieStart, 270, exitEntry.movieEnd, 360);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 43 * kMarsFrameDuration, 270);
 +		compassMove.insertFaderKnot(exitEntry.movieStart + 58 * kMarsFrameDuration, 360);
 +	}
 +}
 +
 +void Mars::getExtraCompassMove(const ExtraTable::Entry &entry, FaderMoveSpec &compassMove) {
 +	switch (entry.extra) {
 +	case kMarsTakePodToMars45:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 0, entry.movieEnd, 180);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 3), 30);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 11), 10);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 14), 40);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 16), 30);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 23), 100);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 31), 70);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 34), 100);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 37), 85);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 42), 135);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 44), 125);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 46), 145);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 49), 160);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * (kMarsFramesPerSecond * 51), 180);
 +		break;
 +	case kMars35WestSpinAirlockToEast:
 +	case kMars60WestSpinAirlockToEast:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 90, entry.movieEnd, 270);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale, 90);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale * 3, 270);
 +		break;
 +	case kMars35EastSpinAirlockToWest:
 +	case kMars60EastSpinAirlockToWest:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, 270, entry.movieEnd, 90);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale, 270);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsMovieScale * 3, 90);
 +		break;
 +	case kMars52SpinLeft:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass, entry.movieEnd, kMars54Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars54Compass);
 +		break;
 +	case kMars52SpinRight:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass, entry.movieEnd, kMars58Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars58Compass);
 +		break;
 +	case kMars52Extend:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars52Compass,
 +				entry.movieEnd, kMars52Compass + kMarsShieldPanelOffsetAngle);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars52Compass + kMarsShieldPanelOffsetAngle);
 +		break;
 +	case kMars53Retract:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
 +				kMars52Compass + kMarsShieldPanelOffsetAngle, entry.movieEnd, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars52Compass + kMarsShieldPanelOffsetAngle);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars52Compass);
 +		break;
 +	case kMars56ExtendWithBomb:
 +	case kMars56ExtendNoBomb:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass,
 +				entry.movieEnd, kMars56Compass - kMarsShieldPanelOffsetAngle);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars56Compass - kMarsShieldPanelOffsetAngle);
 +		break;
 +	case kMars57RetractWithBomb:
 +	case kMars57RetractNoBomb:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
 +				kMars56Compass - kMarsShieldPanelOffsetAngle, entry.movieEnd, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass - kMarsShieldPanelOffsetAngle);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 60, kMars56Compass);
 +		break;
 +	case kMars54SpinLeft:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars54Compass, entry.movieEnd, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars54Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars56Compass);
 +		break;
 +	case kMars54SpinRight:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars54Compass, entry.movieEnd, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars54Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars52Compass);
 +		break;
 +	case kMars56SpinLeft:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass,
 +				entry.movieEnd, kMars58Compass + 360);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars58Compass + 360);
 +		break;
 +	case kMars56SpinRight:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars56Compass, entry.movieEnd, kMars54Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars54Compass);
 +		break;
 +	case kMars58SpinLeft:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart, kMars58Compass,
 +				entry.movieEnd, kMars52Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars58Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars52Compass);
 +		break;
 +	case kMars58SpinRight:
 +		compassMove.makeTwoKnotFaderSpec(_navMovie.getScale(), entry.movieStart,
 +				kMars58Compass + 360, entry.movieEnd, kMars56Compass);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 10, kMars58Compass + 360);
 +		compassMove.insertFaderKnot(entry.movieStart + kMarsFrameDuration * 110, kMars56Compass);
 +		break;
 +	default:
 +		Neighborhood::getExtraCompassMove(entry, compassMove);
 +	}
 +}
 +
 +void Mars::loadAmbientLoops() {
 +	RoomID room = GameState.getCurrentRoom();
 +
 +	if ((room >= kMars0A && room <= kMars21) || (room >= kMars41 && room <= kMars43)) {
 +		if (GameState.getMarsSeenTimeStream())
 +			loadLoopSound1("Sounds/Mars/Gantry Ambient.22K.8.AIFF");
 +	} else if (room >= kMars22 && room <= kMars31South) {
 +		loadLoopSound1("Sounds/Mars/Reception.02.22K.8.AIFF", 0x100 / 4);
 +	} else if (room >= kMars32 && room <= kMars34) {
 +		loadLoopSound1("Sounds/Mars/Pod Room Ambient.22K.8.AIFF");
 +	} else if (room == kMars35) {
 +		if (getAirQuality(room) == kAirQualityVacuum)
 +			loadLoopSound1("Sounds/Mars/Gear Room Ambient.22K.8.AIFF");
 +		else
 +			loadLoopSound1("Sounds/Mars/Gantry Ambient.22K.8.AIFF", 0x100 / 2);
 +	} else if (room >= kMars36 && room <= kMars39) {
 +		loadLoopSound1("Sounds/Mars/Gear Room Ambient.22K.8.AIFF");
 +	} else if (room >= kMars45 && room <= kMars51) {
 +		loadLoopSound1("Sounds/Mars/Lower Mars Ambient.22K.8.AIFF");
 +	} else if (room >= kMars52 && room <= kMars58) {
 +		loadLoopSound1("Sounds/Mars/ReactorLoop.22K.8.AIFF");
 +	} else if (room == kMars60) {
 +		if (getAirQuality(room) == kAirQualityVacuum)
 +			loadLoopSound1("Sounds/Mars/Mars Maze Ambient.22K.8.AIFF");
 +		else
 +			loadLoopSound1("Sounds/Mars/Lower Mars Ambient.22K.8.AIFF", 0x100 / 2);
 +	} else if (room >= kMarsMaze004 && room <= kMarsMaze200) {
 +		loadLoopSound1("Sounds/Mars/Mars Maze Ambient.22K.8.AIFF");
 +	} else if (room == kMarsRobotShuttle) {
 +		loadLoopSound1("Sounds/Mars/Robot Shuttle.22K.8.AIFF");
 +	}
 +	
 +	if (!_noAirFuse.isFuseLit()) {
 +		switch (room) {
 +		case kMars02:
 +		case kMars05:
 +		case kMars06:
 +		case kMars07:
 +		case kMars08:
 +			loadLoopSound2("Sounds/Mars/Gantry Loop.aiff", 0x100, 0, 0);
 +			break;
 +		// Robot at maze 48
 +		case kMarsMaze037:
 +			if (GameState.isCurrentDoorOpen())
 +				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			else
 +				loadLoopSound2("");
 +			break;
 +		case kMarsMaze038:
 +		case kMarsMaze039:
 +		case kMarsMaze049:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
 +			break;
 +		case kMarsMaze050:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			break;
 +		case kMarsMaze051:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		case kMarsMaze052:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
 +			break;
 +		case kMarsMaze042:
 +		case kMarsMaze053:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 8);
 +			break;
 +		case kMarsMaze058:
 +			if (GameState.isCurrentDoorOpen())
 +				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
 +			else
 +				loadLoopSound2("");
 +			break;
 +		// Robot at 151
 +		case kMarsMaze148:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
 +			break;
 +		case kMarsMaze147:
 +		case kMarsMaze149:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			break;
 +		case kMarsMaze146:
 +		case kMarsMaze152:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		case kMarsMaze145:
 +		case kMarsMaze153:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
 +			break;
 +		// Robots at 80 and 82.
 +		case kMarsMaze079:
 +		case kMarsMaze081:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
 +			break;
 +		case kMarsMaze078:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			break;
 +		case kMarsMaze083:
 +			if (GameState.isCurrentDoorOpen())
 +				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			else
 +				loadLoopSound2("");
 +			break;
 +		case kMarsMaze118:
 +		case kMarsMaze076:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		case kMarsMaze074:
 +		case kMarsMaze117:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
 +			break;
 +		// Robot at 94
 +		case kMarsMaze093:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
 +			break;
 +		case kMarsMaze091:
 +		case kMarsMaze092:
 +		case kMarsMaze098:
 +		case kMarsMaze101:
 +		case kMarsMaze100:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			break;
 +		case kMarsMaze090:
 +		case kMarsMaze099:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		case kMarsMaze089:
 +			if (GameState.isCurrentDoorOpen())
 +				loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		case kMarsMaze178:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 4);
 +			break;
 +		// Robot at 197
 +		case kMarsMaze191:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100);
 +			break;
 +		case kMarsMaze190:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 * 3 / 4);
 +			break;
 +		case kMarsMaze198:
 +		case kMarsMaze189:
 +			loadLoopSound2("Sounds/Mars/Maze Sparks.22K.AIFF", 0x100 / 2);
 +			break;
 +		default:
 +			loadLoopSound2("");
 +			break;
 +		}
 +	}
 +}
 +
 +void Mars::checkContinuePoint(const RoomID room, const DirectionConstant direction) {
 +	switch (MakeRoomView(room, direction)) {
 +	case MakeRoomView(kMars02, kSouth):
 +	case MakeRoomView(kMars19, kEast):
 +	case MakeRoomView(kMars22, kNorth):
 +	case MakeRoomView(kMars43, kEast):
 +	case MakeRoomView(kMars51, kEast):
 +	case MakeRoomView(kMars56, kEast):
 +	case MakeRoomView(kMars60, kWest):
 +	case MakeRoomView(kMarsMaze004, kWest):
 +	case MakeRoomView(kMarsMaze009, kWest):
 +	case MakeRoomView(kMarsMaze012, kWest):
 +	case MakeRoomView(kMarsMaze037, kWest):
 +	case MakeRoomView(kMarsMaze047, kNorth):
 +	case MakeRoomView(kMarsMaze052, kWest):
 +	case MakeRoomView(kMarsMaze057, kNorth):
 +	case MakeRoomView(kMarsMaze071, kWest):
 +	case MakeRoomView(kMarsMaze081, kNorth):
 +	case MakeRoomView(kMarsMaze088, kWest):
 +	case MakeRoomView(kMarsMaze093, kWest):
 +	case MakeRoomView(kMarsMaze115, kNorth):
 +	case MakeRoomView(kMarsMaze120, kWest):
 +	case MakeRoomView(kMarsMaze126, kEast):
 +	case MakeRoomView(kMarsMaze133, kNorth):
 +	case MakeRoomView(kMarsMaze144, kNorth):
 +	case MakeRoomView(kMarsMaze156, kEast):
 +	case MakeRoomView(kMarsMaze162, kNorth):
 +	case MakeRoomView(kMarsMaze177, kWest):
 +	case MakeRoomView(kMarsMaze180, kNorth):
 +	case MakeRoomView(kMarsMaze187, kWest):
 +	case MakeRoomView(kMarsMaze199, kWest):
 +		makeContinuePoint();
 +		break;
 +	case MakeRoomView(kMars05, kEast):
 +	case MakeRoomView(kMars06, kEast):
 +	case MakeRoomView(kMars07, kEast):
 +		if (GameState.getMarsSecurityDown())
 +			makeContinuePoint();
 +		break;
 +	case MakeRoomView(kMars46, kSouth):
 +		if (!GameState.getMarsSeenRobotAtReactor())
 +			makeContinuePoint();
 +		break;
 +	case MakeRoomView(kMars46, kWest):
 +		if (GameState.getMarsAvoidedReactorRobot())
 +			makeContinuePoint();
 +		break;
 +	}
 +}
 +
 +void Mars::launchMaze007Robot() {
 +	startExtraLongSequence(kMarsMaze007RobotApproach, kMarsMaze007RobotDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze007RobotLoopingTime, kMarsMovieScale, kMaze007RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze015Robot() {
 +	startExtraLongSequence(kMarsMaze015SouthRobotApproach, kMarsMaze015SouthRobotDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze015RobotLoopingTime, kMarsMovieScale, kMaze015RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze101Robot() {
 +	startExtraLongSequence(kMarsMaze101EastRobotApproach, kMarsMaze101EastRobotDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze101RobotLoopingTime, kMarsMovieScale, kMaze101RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze104Robot() {
 +	startExtraLongSequence(kMarsMaze104WestLoop, kMarsMaze104WestDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze104RobotLoopingTime, kMarsMovieScale, kMaze104RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze133Robot() {
 +	startExtraLongSequence(kMarsMaze133SouthApproach, kMarsMaze133SouthDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze133RobotLoopingTime, kMarsMovieScale, kMaze133RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze136Robot() {
 +	startExtraLongSequence(kMarsMaze136NorthApproach, kMarsMaze136NorthDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze136RobotLoopingTime, kMarsMovieScale, kMaze136RobotLoopingEvent);
 +}
 +
 +void Mars::launchMaze184Robot() {
 +	startExtraLongSequence(kMarsMaze184WestLoop, kMarsMaze184WestDeath, kExtraCompletedFlag, kFilterAllInput);
 +	scheduleEvent(kMaze184RobotLoopingTime, kMarsMovieScale, kMaze184RobotLoopingEvent);
 +}
 +
 +void Mars::timerExpired(const uint32 eventType) {
 +	switch (eventType) {
 +	case kMaze007RobotLoopingEvent:
 +	case kMaze015RobotLoopingEvent:
 +	case kMaze101RobotLoopingEvent:
 +	case kMaze104RobotLoopingEvent:
 +	case kMaze133RobotLoopingEvent:
 +	case kMaze136RobotLoopingEvent:
 +	case kMaze184RobotLoopingEvent:
 +		_interruptionFilter = kFilterNoInput;
 +		break;
 +	}
 +}
 +
 +void Mars::arriveAt(const RoomID room, const DirectionConstant direction) {
 +	switch (MakeRoomView(room, direction)) {
 +	case MakeRoomView(kMars18, kNorth):
 +		if (GameState.getMarsPodAtUpperPlatform())
 +			setCurrentAlternate(kAltMarsPodAtMars34);
 +		break;
 +	case MakeRoomView(kMars27, kEast):
 +	case MakeRoomView(kMars29, kEast):
 +		if (GameState.isTakenItemID(kMarsCard))
 +			setCurrentAlternate(kAltMarsTookCard);
 +		else
 +			setCurrentAlternate(kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars35, kEast):
 +	case MakeRoomView(kMars35, kWest):
 +		if (GameState.getMarsAirlockOpen())
 +			setCurrentAlternate(kAltMars35AirlockWest);
 +		else
 +			setCurrentAlternate(kAltMars35AirlockEast);
 +		break;
 +	case MakeRoomView(kMars60, kEast):
 +	case MakeRoomView(kMars60, kWest):
 +		if (GameState.getMarsAirlockOpen())
 +			setCurrentAlternate(kAltMars60AirlockEast);
 +		else
 +			setCurrentAlternate(kAltMars60AirlockWest);
 +		break;
 +	case MakeRoomView(kMars45, kNorth):
 +	case MakeRoomView(kMars45, kSouth):
 +	case MakeRoomView(kMars45, kEast):
 +	case MakeRoomView(kMars45, kWest):
 +		GameState.setMarsPodAtUpperPlatform(false);
 +		setCurrentAlternate(kAltMarsPodAtMars45);
 +		break;
 +	case MakeRoomView(kMars46, kNorth):
 +	case MakeRoomView(kMars46, kSouth):
 +	case MakeRoomView(kMars46, kEast):
 +	case MakeRoomView(kMars46, kWest):
 +	case MakeRoomView(kMars47, kNorth):
 +	case MakeRoomView(kMars47, kSouth):
 +	case MakeRoomView(kMars47, kEast):
 +	case MakeRoomView(kMars47, kWest):
 +		if (GameState.getMarsPodAtUpperPlatform())
 +			setCurrentAlternate(kAltMarsNormal);
 +		else
 +			setCurrentAlternate(kAltMarsPodAtMars45);
 +		break;
 +	case MakeRoomView(kMars48, kNorth):
 +	case MakeRoomView(kMars48, kSouth):
 +	case MakeRoomView(kMars48, kEast):
 +	case MakeRoomView(kMars48, kWest):
 +	case MakeRoomView(kMars49, kNorth):
 +	case MakeRoomView(kMars49, kEast):
 +	case MakeRoomView(kMars49, kWest):
 +		if (GameState.isTakenItemID(kAirMask))
 +			setCurrentAlternate(kAltMarsTookMask);
 +		else
 +			setCurrentAlternate(kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars49, kSouth):
 +		if (GameState.getMarsMaskOnFiller())
 +			setCurrentAlternate(kAltMarsMaskOnFiller);
 +		else if (GameState.isTakenItemID(kAirMask))
 +			setCurrentAlternate(kAltMarsTookMask);
 +		else
 +			setCurrentAlternate(kAltMarsNormal);
 +		break;
 +	}
 +
 +	Neighborhood::arriveAt(room, direction);
 +	checkAirlockDoors();
 +	setUpReactorEnergyDrain();
 +
 +	switch (MakeRoomView(room, direction)) {
 +	case MakeRoomView(kMars0A, kNorth):
 +		if (!GameState.getMarsSeenTimeStream())
 +			startExtraLongSequence(kMarsArrivalFromTSA, kMars0AWatchShuttleDepart, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case MakeRoomView(kMars07, kSouth):
 +	case MakeRoomView(kMars13, kNorth):
 +		if (!GameState.getMarsHeardCheckInMessage()) {
 +			playSpotSoundSync(kMarsCheckInRequiredIn, kMarsCheckInRequiredOut);
 +			GameState.setMarsHeardCheckInMessage(true);
 +		}
 +		break;
 +	case MakeRoomView(kMars44, kWest):
 +		if (GameState.getMarsReadyForShuttleTransport())
 +			startUpFromFinishedSpaceChase();
 +		else if (GameState.getMarsFinishedCanyonChase())
 +			startUpFromSpaceChase();
 +		else
 +			_neighborhoodNotification.setNotificationFlags(kTimeForCanyonChaseFlag, kTimeForCanyonChaseFlag);
 +		break;
 +	case MakeRoomView(kMars10, kNorth):
 +		if (!GameState.getMarsRobotThrownPlayer())
 +			startExtraSequence(kRobotThrowsPlayer, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case MakeRoomView(kMars11, kSouth):
 +	case MakeRoomView(kMars12, kSouth):
 +		setCurrentActivation(kActivationReadyForKiosk);
 +		break;
 +	case MakeRoomView(kMars15, kWest):
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown()) {
 +			playSpotSoundSync(kMarsShuttle2DepartedIn, kMarsShuttle2DepartedOut);
 +			restoreStriding(kMars17, kWest, kAltMarsNormal);
 +			GameState.setMarsSecurityDown(true);
 +		}
 +		break;
 +	case MakeRoomView(kMars17, kNorth):
 +	case MakeRoomView(kMars17, kSouth):
 +	case MakeRoomView(kMars17, kEast):
 +	case MakeRoomView(kMars17, kWest):
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
 +			forceStridingStop(kMars17, kWest, kAltMarsNormal);
 +
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave()) {
 +			startExtraSequence(kRobotOnWayToShuttle, kExtraCompletedFlag, kFilterNoInput);
 +			restoreStriding(kMars19, kWest, kAltMarsNormal);
 +			GameState.setMarsSawRobotLeave(true);
 +		}
 +		break;
 +	case MakeRoomView(kMars19, kNorth):
 +	case MakeRoomView(kMars19, kSouth):
 +	case MakeRoomView(kMars19, kWest):
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave())
 +			forceStridingStop(kMars19, kWest, kAltMarsNormal);
 +
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
 +			forceStridingStop(kMars17, kWest, kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars19, kEast):
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSawRobotLeave())
 +			forceStridingStop(kMars19, kWest, kAltMarsNormal);
 +
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
 +			forceStridingStop(kMars17, kWest, kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars32, kNorth):
 +		if (!GameState.getMarsPodAtUpperPlatform()) {
 +			playSpotSoundSync(kMarsPodArrivedUpperPlatformIn, kMarsPodArrivedUpperPlatformOut);
 +			GameState.setMarsPodAtUpperPlatform(true);
 +		}
 +		break;
 +	case MakeRoomView(kMars33North, kNorth):
 +		setCurrentActivation(kActivationTunnelMapReady);
 +		// Fall through...
 +	case MakeRoomView(kMars33, kSouth):
 +	case MakeRoomView(kMars33, kEast):
 +	case MakeRoomView(kMars33, kWest):
 +	case MakeRoomView(kMars32, kSouth):
 +	case MakeRoomView(kMars32, kEast):
 +	case MakeRoomView(kMars32, kWest):
 +		if (!GameState.getMarsPodAtUpperPlatform())
 +			GameState.setMarsPodAtUpperPlatform(true);
 +		break;
 +	case MakeRoomView(kMars34, kNorth):
 +		startExtraSequence(kMars34NorthPodGreeting, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case MakeRoomView(kMars34, kSouth):
 +	case MakeRoomView(kMars45, kNorth):
 +		setCurrentActivation(kActivateMarsPodClosed);
 +		break;
 +	case MakeRoomView(kMars35, kWest):
 +		if (GameState.getMarsThreadedMaze() && !GameState.getMarsSecurityDown())
 +			forceStridingStop(kMars19, kWest, kAltMarsNormal);
 +		// Fall through...
 +	case MakeRoomView(kMars60, kEast):
 +		if (!GameState.getMarsAirlockOpen())
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +		break;
 +	case MakeRoomView(kMars35, kEast):
 +	case MakeRoomView(kMars60, kWest):
 +		if (GameState.getMarsAirlockOpen())
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +		break;
 +	case MakeRoomView(kMars39, kWest):
 +		if (GameState.getLastRoom() == kMarsMaze200)
 +			GameState.setMarsPodAtUpperPlatform(false);
 +		break;
 +	case MakeRoomView(kMars45, kSouth):
 +		// Set up maze doors here.
 +		// Doing it here makes sure that it will be the same if the player comes
 +		// back out of the maze and goes back in, but will vary if
 +		// the player comes back down to the maze a second time.
 +		GameState.setMarsMazeDoorPair1(_vm->getRandomBit());
 +		GameState.setMarsMazeDoorPair2(_vm->getRandomBit());
 +		GameState.setMarsMazeDoorPair3(_vm->getRandomBit());
 +		GameState.setMarsArrivedBelow(true);
 +		break;
 +	case MakeRoomView(kMars48, kEast):
 +		if (!GameState.getMarsSeenRobotAtReactor()) {
 +			// Preload the looping sound...
 +			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0, 0, 0);
 +			startExtraSequence(kMars48RobotApproaches, kExtraCompletedFlag, kFilterNoInput);
 +		} else if (!GameState.getMarsAvoidedReactorRobot()) {
 +			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
 +			loopExtraSequence(kMars48RobotLoops);
 +			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
 +			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
 +			_utilityFuse.lightFuse();
 +		}
 +		break;
 +	case MakeRoomView(kMars48, kSouth):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
 +			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
 +			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
 +			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
 +			_utilityFuse.lightFuse();
 +		}
 +		break;
 +	case MakeRoomView(kMars49, kSouth):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot()) {
 +			playSpotSoundSync(kMarsRobotTakesTransportIn, kMarsRobotTakesTransportOut);
 +			playSpotSoundSync(kMarsPodDepartedLowerPlatformIn, kMarsPodDepartedLowerPlatformOut);
 +			GameState.setMarsAvoidedReactorRobot(true);
 +			GameState.setMarsPodAtUpperPlatform(true);
 +			GameState.getScoringAvoidedRobot();
 +		}
 +
 +		if (GameState.isTakenItemID(kAirMask))
 +			setCurrentActivation(kActivateHotSpotAlways);
 +		else if (GameState.getMarsMaskOnFiller())
 +			setCurrentActivation(kActivateMaskOnFiller);
 +		else
 +			setCurrentActivation(kActivateMaskOnHolder);
 +		break;
 +	case MakeRoomView(kMars51, kWest):
 +	case MakeRoomView(kMars50, kWest):
 +	case MakeRoomView(kMars48, kWest):
 +		if (GameState.getShieldOn())
 +			g_shield->setItemState(kShieldNormal);
 +		g_energyMonitor->setEnergyDrainRate(kEnergyDrainNormal);
 +		_vm->resetEnergyDeathReason();
 +		break;
 +	case MakeRoomView(kMars52, kNorth):
 +	case MakeRoomView(kMars52, kSouth):
 +	case MakeRoomView(kMars52, kEast):
 +	case MakeRoomView(kMars52, kWest):
 +	case MakeRoomView(kMars54, kNorth):
 +	case MakeRoomView(kMars54, kSouth):
 +	case MakeRoomView(kMars54, kEast):
 +	case MakeRoomView(kMars54, kWest):
 +	case MakeRoomView(kMars56, kNorth):
 +	case MakeRoomView(kMars56, kSouth):
 +	case MakeRoomView(kMars56, kWest):
 +	case MakeRoomView(kMars58, kNorth):
 +	case MakeRoomView(kMars58, kSouth):
 +	case MakeRoomView(kMars58, kEast):
 +	case MakeRoomView(kMars58, kWest):
 +		setCurrentActivation(kActivateReactorPlatformOut);
 +		break;
 +	case MakeRoomView(kMars56, kEast):
 +		if (GameState.getMarsLockBroken()) {
 +			setCurrentActivation(kActivateReactorAskOperation);
 +			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
 +		} else if (GameState.getMarsLockFrozen()) {
 +			setCurrentActivation(kActivateReactorReadyForCrowBar);
 +			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
 +			_utilityFuse.primeFuse(kLockFreezeTimeLmit);
 +			_utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
 +			_utilityFuse.lightFuse();
 +		} else {
 +			setCurrentActivation(kActivateReactorPlatformOut);
 +		}
 +		break;
 +	case MakeRoomView(kMarsRobotShuttle, kEast):
 +		setCurrentActivation(kActivationRobotHeadClosed);
 +		break;
 +	case MakeRoomView(kMarsMaze007, kNorth):
 +		launchMaze007Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze015, kSouth):
 +		launchMaze015Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze101, kEast):
 +		launchMaze101Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze104, kWest):
 +		launchMaze104Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze133, kSouth):
 +		launchMaze133Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze136, kNorth):
 +		launchMaze136Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze184, kWest):
 +		launchMaze184Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze199, kSouth):
 +		GameState.setScoringThreadedMaze();
 +		GameState.setMarsThreadedMaze(true);
 +		break;
 +	case MakeRoomView(kMarsDeathRoom, kNorth):
 +	case MakeRoomView(kMarsDeathRoom, kSouth):
 +	case MakeRoomView(kMarsDeathRoom, kEast):
 +	case MakeRoomView(kMarsDeathRoom, kWest):
 +		switch (GameState.getLastRoom()) {
 +		case kMars39:
 +			die(kDeathDidntLeaveBucket);
 +			break;
 +		case kMars46:
 +			die(kDeathRunOverByPod);
 +			break;
 +		}
 +		break;
 +	}
 +
 +	checkAirMask();
 +}
 +
 +void Mars::shieldOn() {
 +	setUpReactorEnergyDrain();
 +}
 +
 +void Mars::shieldOff() {
 +	setUpReactorEnergyDrain();
 +}
 +
 +void Mars::turnTo(const DirectionConstant direction) {
 +	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
 +	case MakeRoomView(kMars27, kNorth):
 +	case MakeRoomView(kMars27, kSouth):
 +	case MakeRoomView(kMars27, kEast):
 +	case MakeRoomView(kMars29, kNorth):
 +	case MakeRoomView(kMars29, kSouth):
 +	case MakeRoomView(kMars29, kEast):
 +		if (GameState.isTakenItemID(kMarsCard))
 +			setCurrentAlternate(kAltMarsTookCard);
 +		break;
 +	case MakeRoomView(kMars35, kNorth):
 +	case MakeRoomView(kMars35, kSouth):
 +	case MakeRoomView(kMars60, kNorth):
 +	case MakeRoomView(kMars60, kSouth):
 +		if (getCurrentActivation() == kActivateAirlockPressurized)
 +			playSpotSoundSync(kMarsAirlockPressurizeIn, kMarsAirlockPressurizeOut);
 +		break;
 +	}
 +
 +	Neighborhood::turnTo(direction);
 +
 +	switch (MakeRoomView(GameState.getCurrentRoom(), direction)) {
 +	case MakeRoomView(kMars11, kSouth):
 +	case MakeRoomView(kMars12, kSouth):
 +		setCurrentActivation(kActivationReadyForKiosk);
 +		break;
 +	case MakeRoomView(kMars18, kNorth):
 +		if (GameState.getMarsPodAtUpperPlatform())
 +			setCurrentAlternate(kAltMarsPodAtMars34);
 +		break;
 +	case MakeRoomView(kMars22, kSouth):
 +		if (!GameState.getMarsHeardCheckInMessage()) {
 +			playSpotSoundSync(kMarsCheckInRequiredIn, kMarsCheckInRequiredOut);
 +			GameState.setMarsHeardCheckInMessage(true);
 +		}
 +		break;
 +	case MakeRoomView(kMars34, kSouth):
 +	case MakeRoomView(kMars45, kNorth):
 +		setCurrentActivation(kActivateMarsPodClosed);
 +		break;
 +	case MakeRoomView(kMars34, kNorth):
 +		startExtraSequence(kMars34NorthPodGreeting, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case MakeRoomView(kMars35, kEast):
 +	case MakeRoomView(kMars60, kWest):
 +		if (GameState.getMarsAirlockOpen())
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +		break;
 +	case MakeRoomView(kMars60, kEast):
 +		if (!GameState.getMarsAirlockOpen())
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +		break;
 +	case MakeRoomView(kMars35, kWest):
 +		if (!GameState.getMarsAirlockOpen())
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +		
 +		// Do this here because this will be called after spinning the airlock after
 +		// going through the gear room.
 +		if (GameState.getMarsThreadedMaze())
 +			GameState.setScoringThreadedGearRoom();
 +		break;
 +	case MakeRoomView(kMars48, kNorth):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
 +			die(kDeathDidntGetOutOfWay);
 +		break;
 +	case MakeRoomView(kMars48, kEast):
 +		if (!GameState.getMarsSeenRobotAtReactor()) {
 +			// Preload the looping sound...
 +			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0, 0, 0);
 +			startExtraSequence(kMars48RobotApproaches, kExtraCompletedFlag, kFilterNoInput);
 +		} else if (!GameState.getMarsAvoidedReactorRobot()) {
 +			loopExtraSequence(kMars48RobotLoops);
 +		} else if (GameState.isTakenItemID(kAirMask)) {
 +			setCurrentAlternate(kAltMarsTookMask);
 +		} else {
 +			setCurrentAlternate(kAltMarsNormal);
 +		}
 +		break;
 +	case MakeRoomView(kMars48, kWest):
 +		if (GameState.getMarsSeenRobotAtReactor() && !GameState.getMarsAvoidedReactorRobot())
 +			die(kDeathDidntGetOutOfWay);
 +		else if (GameState.isTakenItemID(kAirMask))
 +			setCurrentAlternate(kAltMarsTookMask);
 +		else
 +			setCurrentAlternate(kAltMarsNormal);
 +		break;
 +	case MakeRoomView(kMars49, kSouth):
 +		if (GameState.isTakenItemID(kAirMask))
 +			setCurrentActivation(kActivateHotSpotAlways);
 +		else
 +			setCurrentActivation(kActivateMaskOnHolder);
 +		break;
 +	case MakeRoomView(kMars52, kNorth):
 +	case MakeRoomView(kMars52, kSouth):
 +	case MakeRoomView(kMars52, kEast):
 +	case MakeRoomView(kMars52, kWest):
 +	case MakeRoomView(kMars54, kNorth):
 +	case MakeRoomView(kMars54, kSouth):
 +	case MakeRoomView(kMars54, kEast):
 +	case MakeRoomView(kMars54, kWest):
 +	case MakeRoomView(kMars56, kNorth):
 +	case MakeRoomView(kMars56, kSouth):
 +	case MakeRoomView(kMars56, kEast):
 +	case MakeRoomView(kMars56, kWest):
 +	case MakeRoomView(kMars58, kNorth):
 +	case MakeRoomView(kMars58, kSouth):
 +	case MakeRoomView(kMars58, kEast):
 +	case MakeRoomView(kMars58, kWest):
 +		setCurrentActivation(kActivateReactorPlatformOut);
 +		break;
 +	case MakeRoomView(kMarsMaze007, kNorth):
 +		launchMaze007Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze015, kSouth):
 +		launchMaze015Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze101, kEast):
 +		launchMaze101Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze104, kWest):
 +		launchMaze104Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze133, kSouth):
 +		launchMaze133Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze136, kNorth):
 +		launchMaze136Robot();
 +		break;
 +	case MakeRoomView(kMarsMaze184, kWest):
 +		launchMaze184Robot();
 +		break;
 +	}
 +}
 +
 +void Mars::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
 +	switch (hotspot->getObjectID()) {
 +	case kMars57RedMoveSpotID:
 +	case kMars57YellowMoveSpotID:
 +	case kMars57GreenMoveSpotID:
 +		if (!_choiceHighlight.choiceHighlighted(hotspot->getObjectID() - kMars57RedMoveSpotID))
 +			hotspot->setActive();
 +		break;
 +	case kMars57BlueMoveSpotID:
 +		if (_reactorStage >= 2 && !_choiceHighlight.choiceHighlighted(3))
 +			hotspot->setActive();
 +		break;
 +	case kMars57PurpleMoveSpotID:
 +		if (_reactorStage == 3 && !_choiceHighlight.choiceHighlighted(4))
 +			hotspot->setActive();
 +		break;
 +	default:
 +		Neighborhood::activateOneHotspot(entry, hotspot);
 +		break;
 +	}
 +}
 +
 +void Mars::activateHotspots() {
 +	InventoryItem *item;
 +
 +	Neighborhood::activateHotspots();
 +
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars48, kEast):
 +		if ((_navMovie.getFlags() & kLoopTimeBase) != 0 && _vm->getDragType() == kDragInventoryUse)
 +			g_allHotspots.activateOneHotspot(kAttackRobotHotSpotID);
 +		break;
 +	case MakeRoomView(kMars56, kEast):
 +		switch (getCurrentActivation()) {
 +		case kActivateReactorReadyForNitrogen:
 +			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
 +			if (item->getItemState() != kNitrogenFull)
 +				g_allHotspots.deactivateOneHotspot(kMars57DropNitrogenSpotID);
 +			// Fall through...
 +		case kActivateReactorReadyForCrowBar:
 +			g_allHotspots.activateOneHotspot(kMars57CantOpenPanelSpotID);
 +			break;
 +		}
 +		break;
 +	case MakeRoomView(kMarsRobotShuttle, kEast):
 +		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag))
 +			g_allHotspots.deactivateOneHotspot(kRobotShuttleMapChipSpotID);
 +		else
 +			g_allHotspots.activateOneHotspot(kRobotShuttleMapChipSpotID);
 +
 +		if (_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag))
 +			g_allHotspots.deactivateOneHotspot(kRobotShuttleOpticalChipSpotID);
 +		else
 +			g_allHotspots.activateOneHotspot(kRobotShuttleOpticalChipSpotID);
 +
 +		if (_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag))
 +			g_allHotspots.deactivateOneHotspot(kRobotShuttleShieldChipSpotID);
 +		else
 +			g_allHotspots.activateOneHotspot(kRobotShuttleShieldChipSpotID);
 +		break;
 +	default:
 +		if (_privateFlags.getFlag(kMarsPrivateInSpaceChaseFlag)) {
 +			if (GameState.getMarsReadyForShuttleTransport()) {
 +				_shuttleTransportSpot.setActive();
 +			} else {
 +				_energyChoiceSpot.setActive();
 +				_gravitonChoiceSpot.setActive();
 +				_tractorChoiceSpot.setActive();
 +				if (_weaponSelection != kNoWeapon)
 +					_shuttleViewSpot.setActive();
 +			}
 +		}
 +		break;
 +	}
 +}
 +
 +void Mars::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 +	switch (clickedSpot->getObjectID()) {
 +	case kMars11NorthKioskSpotID:
 +	case kMars12NorthKioskSpotID:
 +		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
 +		Neighborhood::clickInHotspot(input, clickedSpot);
 +		break;
 +	case kMars11NorthKioskSightsSpotID:
 +	case kMars12NorthKioskSightsSpotID:
 +		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
 +		if (!startExtraSequenceSync(kMarsSightsInfo, kFilterAllInput))
 +			showExtraView(kMarsInfoKioskIntro);
 +		break;
 +	case kMars11NorthKioskColonySpotID:
 +	case kMars12NorthKioskColonySpotID:
 +		playSpotSoundSync(kMarsKioskBeepIn, kMarsKioskBeepOut);
 +		if (!startExtraSequenceSync(kMarsColonyInfo, kFilterAllInput))
 +			showExtraView(kMarsInfoKioskIntro);
 +		break;
 +	case kMars33NorthMonitorSpotID:
 +		switch (_lastExtra) {
 +		case kMars33SlideShow1:
 +			startExtraSequence(kMars33SlideShow2, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMars33SlideShow2:
 +			startExtraSequence(kMars33SlideShow3, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMars33SlideShow3:
 +			startExtraSequence(kMars33SlideShow4, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMars33SlideShow4:
 +			// Should never happen...
 +		default:
 +			startExtraSequence(kMars33SlideShow1, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		}
 +		break;
 +	case kMars34SouthOpenStorageSpotID:
 +		if (GameState.isTakenItemID(kCrowbar))
 +			startExtraSequence(kMars34SpotOpenNoBar, kExtraCompletedFlag, kFilterNoInput);
 +		else
 +			startExtraSequence(kMars34SpotOpenWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kMars34SouthCloseStorageSpotID:
 +		if (GameState.isTakenItemID(kCrowbar))
 +			startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +		else
 +			startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kMars35WestPressurizeSpotID:
 +	case kMars35EastPressurizeSpotID:
 +	case kMars60WestPressurizeSpotID:
 +	case kMars60EastPressurizeSpotID:
 +		playSpotSoundSync(kMarsAirlockButtonBeepIn, kMarsAirlockButtonBeepOut);
 +		playSpotSoundSync(kMarsAirlockPressurizeIn, kMarsAirlockPressurizeOut);
 +		setCurrentActivation(kActivateAirlockPressurized);
 +		break;
 +	case kMars45NorthOpenStorageSpotID:
 +		if (GameState.isTakenItemID(kCrowbar))
 +			startExtraSequence(kMars45SpotOpenNoBar, kExtraCompletedFlag, kFilterNoInput);
 +		else
 +			startExtraSequence(kMars45SpotOpenWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kMars45NorthCloseStorageSpotID:
 +		if (GameState.isTakenItemID(kCrowbar))
 +			startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +		else
 +			startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		break;
 +	case kMars56ExtractSpotID:
 +		if (GameState.isTakenItemID(kCardBomb)) {
 +			startExtraSequence(kMars56ExtendNoBomb, kExtraCompletedFlag, kFilterNoInput);
 +			setCurrentActivation(kActivateReactorPlatformIn);
 +		} else {
 +			startExtraSequence(kMars56ExtendWithBomb, kExtraCompletedFlag, kFilterNoInput);
 +			setCurrentActivation(kActivateReactorAskLowerScreen);
 +		}
 +		break;
 +	case kMars57UndoMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doUndoOneGuess();
 +		break;
 +	case kMars57RedMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doReactorGuess(0);
 +		break;
 +	case kMars57YellowMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doReactorGuess(1);
 +		break;
 +	case kMars57GreenMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doReactorGuess(2);
 +		break;
 +	case kMars57BlueMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doReactorGuess(3);
 +		break;
 +	case kMars57PurpleMoveSpotID:
 +		playSpotSoundSync(kMarsColorMatchingButtonBeepIn, kMarsColorMatchingButtonBeepOut);
 +		doReactorGuess(4);
 +		break;
 +	case kShuttleEnergySpotID:
 +	case kShuttleGravitonSpotID:
 +	case kShuttleTractorSpotID:
 +	case kShuttleViewSpotID:
 +	case kShuttleTransportSpotID:
 +		spaceChaseClick(input, clickedSpot->getObjectID());
 +		break;
 +	default:
 +		Neighborhood::clickInHotspot(input, clickedSpot);
 +		break;
 +	}
 +}
 +
 +InputBits Mars::getInputFilter() {
 +	InputBits result = Neighborhood::getInputFilter();
 +
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars49, kSouth):
 +		if (GameState.getMarsMaskOnFiller())
 +			// Can't move when mask is on filler.
 +			result &= ~kFilterAllDirections;
 +		break;
 +	case MakeRoomView(kMars52, kNorth):
 +	case MakeRoomView(kMars52, kSouth):
 +	case MakeRoomView(kMars52, kEast):
 +	case MakeRoomView(kMars52, kWest):
 +	case MakeRoomView(kMars54, kNorth):
 +	case MakeRoomView(kMars54, kSouth):
 +	case MakeRoomView(kMars54, kEast):
 +	case MakeRoomView(kMars54, kWest):
 +	case MakeRoomView(kMars56, kNorth):
 +	case MakeRoomView(kMars56, kSouth):
 +	case MakeRoomView(kMars56, kEast):
 +	case MakeRoomView(kMars56, kWest):
 +	case MakeRoomView(kMars58, kNorth):
 +	case MakeRoomView(kMars58, kSouth):
 +	case MakeRoomView(kMars58, kEast):
 +	case MakeRoomView(kMars58, kWest):
 +		if (_privateFlags.getFlag(kMarsPrivatePlatformZoomedInFlag))
 +			// Can't move when platform is extended.
 +			result &= ~kFilterAllDirections;
 +		break;
 +	case MakeRoomView(kMars44, kWest):
 +		if (_canyonChaseMovie.isMovieValid() && _canyonChaseMovie.isRunning())
 +			result &= ~kFilterAllDirections;
 +		break;
 +	}
 +
 +	return result;
 +}
 +
 +// Only called when trying to pick up an item and the player can't (because
 +// the inventory is too full or because the player lets go of the item before
 +// dropping it into the inventory).
 +Hotspot *Mars::getItemScreenSpot(Item *item, DisplayElement *element) {
 +	HotSpotID destSpotID;
 +
 +	switch (item->getObjectID()) {
 +	case kCardBomb:
 +		destSpotID = kMars57GrabBombSpotID;
 +		break;
 +	case kMarsCard:
 +		destSpotID = kMars31SouthCardSpotID;
 +		break;
 +	case kAirMask:
 +		if (GameState.getMarsMaskOnFiller())
 +			destSpotID = kMars49AirFillingDropSpotID;
 +		else
 +			destSpotID = kMars49AirMaskSpotID;
 +		break;
 +	case kCrowbar:
 +		if (GameState.getCurrentRoom() == kMars34)
 +			destSpotID = kMars34SouthCrowbarSpotID;
 +		else
 +			destSpotID = kMars45NorthCrowbarSpotID;
 +		break;
 +	case kMapBiochip:
 +		destSpotID = kRobotShuttleMapChipSpotID;
 +		break;
 +	case kOpticalBiochip:
 +		destSpotID = kRobotShuttleOpticalChipSpotID;
 +		break;
 +	case kShieldBiochip:
 +		destSpotID = kRobotShuttleShieldChipSpotID;
 +		break;
 +	default:
 +		destSpotID = kNoHotSpotID;
 +		break;
 +	}
 +
 +	if (destSpotID == kNoHotSpotID)
 +		return Neighborhood::getItemScreenSpot(item, element);
 +
 +	return g_allHotspots.findHotspotByID(destSpotID);
 +}
 +
 +void Mars::takeItemFromRoom(Item *item) {
 +	switch (item->getObjectID()) {
 +	case kAirMask:
 +		setCurrentAlternate(kAltMarsTookMask);
 +		break;
 +	case kCardBomb:
 +		_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, true);
 +		break;
 +	case kMapBiochip:
 +		_privateFlags.setFlag(kMarsPrivateGotMapChipFlag, true);
 +		break;
 +	case kShieldBiochip:
 +		_privateFlags.setFlag(kMarsPrivateGotShieldChipFlag, true);
 +		break;
 +	case kOpticalBiochip:
 +		_privateFlags.setFlag(kMarsPrivateGotOpticalChipFlag, true);
 +		break;
 +	}
 +
 +	Neighborhood::takeItemFromRoom(item);
 +}
 +
 +void Mars::pickedUpItem(Item *item) {
 +	switch (item->getObjectID()) {
 +	case kAirMask:
 +		setCurrentActivation(kActivateHotSpotAlways);
 +		if (!GameState.getScoringGotOxygenMask()) {
 +			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XM48SB", false, kWarningInterruption);
 +			GameState.setScoringGotOxygenMask();
 +		}
 +		break;
 +	case kCrowbar:
 +		GameState.setScoringGotCrowBar();
 +		g_AIArea->checkMiddleArea();
 +		break;
 +	case kMarsCard:
 +		GameState.setScoringGotMarsCard();
 +		g_AIArea->checkMiddleArea();
 +		break;
 +	case kCardBomb:
 +		GameState.setScoringGotCardBomb();
 +		if (GameState.getMarsLockBroken()) {
 +			startExtraSequence(kMars57BackToNormal, kExtraCompletedFlag, kFilterNoInput);
 +			GameState.setMarsLockBroken(false);
 +		}
 +
 +		_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, false);
 +		break;
 +	case kMapBiochip:
 +		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
 +			GameState.setMarsFinished(true);
 +			GameState.setScoringMarsGandhi();
 +			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	case kShieldBiochip:
 +		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
 +			GameState.setMarsFinished(true);
 +			GameState.setScoringMarsGandhi();
 +			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	case kOpticalBiochip:
 +		g_opticalChip->addAries();
 +		GameState.setScoringGotMarsOpMemChip();
 +			
 +		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag) &&
 +				_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag)) {
 +			GameState.setMarsFinished(true);
 +			GameState.setScoringMarsGandhi();
 +			startExtraSequence(kMarsRobotHeadClose, kExtraCompletedFlag, kFilterNoInput);
 +		}
 +		break;
 +	}
 +}
 +
 +void Mars::dropItemIntoRoom(Item *item, Hotspot *dropSpot) {
 +	if (dropSpot->getObjectID() == kAttackRobotHotSpotID) {
 +		_attackingItem = (InventoryItem *)item;
 +		startExtraSequence(kMars48RobotDefends, kExtraCompletedFlag, kFilterNoInput);
 +		loadLoopSound2("");
 +	} else {
 +		switch (item->getObjectID()) {
 +		case kMarsCard:
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			if (dropSpot && dropSpot->getObjectID() == kMars34NorthCardDropSpotID)
 +				startExtraSequence(kMarsTurnOnPod, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kNitrogenCanister:
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			if (dropSpot && dropSpot->getObjectID() == kMars57DropNitrogenSpotID)
 +				startExtraSequence(kMars57FreezeLock, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kCrowbar:
 +			_utilityFuse.stopFuse();
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			if (dropSpot && dropSpot->getObjectID() == kMars57DropCrowBarSpotID)
 +				startExtraSequence(kMars57BreakLock, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kAirMask:
 +			if (dropSpot) {
 +				if (dropSpot->getObjectID() == kMars49AirFillingDropSpotID) {
 +					if (!GameState.getMarsMaskOnFiller()) {
 +						Neighborhood::dropItemIntoRoom(item, dropSpot);
 +						startExtraSequence(kMars49SouthViewMaskFilling, kExtraCompletedFlag, kFilterNoInput);
 +					} else {
 +						setCurrentActivation(kActivateMaskOnFiller);
 +						setCurrentAlternate(kAltMarsMaskOnFiller);
 +						Neighborhood::dropItemIntoRoom(item, dropSpot);
 +					}
 +				} else if (dropSpot->getObjectID() == kMars49AirMaskSpotID) {
 +					setCurrentAlternate(kAltMarsNormal);
 +					setCurrentActivation(kActivateMaskOnHolder);
 +					Neighborhood::dropItemIntoRoom(item, dropSpot);
 +				}
 +			}
 +			break;
 +		case kCardBomb:
 +			_privateFlags.setFlag(kMarsPrivateDraggingBombFlag, false);
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			break;
 +		case kMapBiochip:
 +			_privateFlags.setFlag(kMarsPrivateGotMapChipFlag, false);
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			break;
 +		case kShieldBiochip:
 +			_privateFlags.setFlag(kMarsPrivateGotShieldChipFlag, false);
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			break;
 +		case kOpticalBiochip:
 +			_privateFlags.setFlag(kMarsPrivateGotOpticalChipFlag, false);
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			break;
 +		default:
 +			Neighborhood::dropItemIntoRoom(item, dropSpot);
 +			break;
 +		}
 +	}
 +}
 +
 +void Mars::robotTiredOfWaiting() {
 +	if (GameState.getCurrentRoomAndView() == MakeRoomView(kMars48, kEast)) {
 +		if (_attackingItem) {
 +			startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
 +			loadLoopSound2("");
 +		} else {
 +			_privateFlags.setFlag(kMarsPrivateRobotTiredOfWaitingFlag, true);
 +		}
 +	} else {
 +		die(kDeathDidntGetOutOfWay);
 +	}
 +}
 +
 +void Mars::turnLeft() {
 +	if (isEventTimerRunning())
 +		cancelEvent();
 +
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars34, kSouth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, true);
 +			if (GameState.isTakenItemID(kCrowbar))
 +				startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +			else
 +				startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			Neighborhood::turnLeft();
 +		}
 +		break;
 +	case MakeRoomView(kMars45, kNorth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, true);
 +			if (GameState.isTakenItemID(kCrowbar))
 +				startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +			else
 +				startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			Neighborhood::turnLeft();
 +		}
 +		break;
 +	default:
 +		Neighborhood::turnLeft();
 +		break;
 +	}
 +}
 +
 +void Mars::turnRight() {
 +	if (isEventTimerRunning())
 +		cancelEvent();
 +
 +	switch (GameState.getCurrentRoomAndView()) {
 +	case MakeRoomView(kMars34, kSouth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, true);
 +			if (GameState.isTakenItemID(kCrowbar))
 +				startExtraSequence(kMars34SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +			else
 +				startExtraSequence(kMars34SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			Neighborhood::turnRight();
 +		}
 +		break;
 +	case MakeRoomView(kMars45, kNorth):
 +		if (_privateFlags.getFlag(kMarsPrivatePodStorageOpenFlag)) {
 +			_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, true);
 +			if (GameState.isTakenItemID(kCrowbar))
 +				startExtraSequence(kMars45SpotCloseNoBar, kExtraCompletedFlag, kFilterNoInput);
 +			else
 +				startExtraSequence(kMars45SpotCloseWithBar, kExtraCompletedFlag, kFilterNoInput);
 +		} else {
 +			Neighborhood::turnRight();
 +		}
 +		break;
 +	default:
 +		Neighborhood::turnRight();
 +		break;
 +	}
 +}
 +
 +void Mars::receiveNotification(Notification *notification, const NotificationFlags flag) {
 +	InventoryItem *item;
 +	
 +	Neighborhood::receiveNotification(notification, flag);
 +
 +	if ((flag & kExtraCompletedFlag) != 0) {
 +		_interruptionFilter = kFilterAllInput;
 +
 +		switch (_lastExtra) {
 +		case kMarsArrivalFromTSA:
 +			GameState.setMarsSeenTimeStream(true);
 +			loadAmbientLoops();
 +			playSpotSoundSync(kMarsShuttle1DepartedIn, kMarsShuttle1DepartedOut);
 +			makeContinuePoint();
 +			break;
 +		case kRobotThrowsPlayer:
 +			GameState.setMarsRobotThrownPlayer(true);
 +			GameState.setScoringThrownByRobot();
 +			restoreStriding(kMars08, kNorth, kAltMarsNormal);
 +			arriveAt(kMars08, kNorth);
 +			if (!GameState.getMarsHeardUpperPodMessage()) {
 +				playSpotSoundSync(kMarsPodDepartedUpperPlatformIn,
 +											kMarsPodDepartedUpperPlatformOut);
 +				GameState.setMarsHeardUpperPodMessage(true);
 +			}
 +			break;
 +		case kMarsInfoKioskIntro:
 +			GameState.setScoringSawMarsKiosk();
 +			setCurrentActivation(kActivationKioskChoice);
 +			break;
 +		case kMars33SlideShow4:
 +			GameState.setScoringSawTransportMap();
 +			setCurrentActivation(kActivateHotSpotAlways);
 +			break;
 +		case kMars34SpotOpenNoBar:
 +		case kMars34SpotOpenWithBar:
 +		case kMars45SpotOpenNoBar:
 +		case kMars45SpotOpenWithBar:
 +			_privateFlags.setFlag(kMarsPrivatePodStorageOpenFlag, true);
 +			setCurrentActivation(kActivateMarsPodOpen);
 +			break;
 +		case kMars34SpotCloseNoBar:
 +		case kMars34SpotCloseWithBar:
 +		case kMars45SpotCloseNoBar:
 +		case kMars45SpotCloseWithBar:
 +			_privateFlags.setFlag(kMarsPrivatePodStorageOpenFlag, false);
 +			setCurrentActivation(kActivateMarsPodClosed);
 +			if (_privateFlags.getFlag(kMarsPrivatePodTurnLeftFlag)) {
 +				_privateFlags.setFlag(kMarsPrivatePodTurnLeftFlag, false);
 +				turnLeft();
 +			} else if (_privateFlags.getFlag(kMarsPrivatePodTurnRightFlag)) {
 +				_privateFlags.setFlag(kMarsPrivatePodTurnRightFlag, false);
 +				turnRight();
 +			}
 +			break;
 +		case kMarsTurnOnPod:
 +			item = (InventoryItem *)g_allItems.findItemByID(kMarsCard);
 +			_vm->addItemToInventory(item);
 +			GameState.setScoringTurnedOnTransport();
 +			loadLoopSound1("");
 +			loadLoopSound2("");
 +			startExtraSequence(kMarsTakePodToMars45, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMarsTakePodToMars45:
 +			arriveAt(kMars45, kSouth);
 +			break;
 +		case kMars35WestSpinAirlockToEast:
 +			GameState.setMarsAirlockOpen(false);
 +			setCurrentAlternate(kAltMars35AirlockEast);
 +			turnTo(kWest);
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +			g_airMask->airQualityChanged();
 +			checkAirMask();
 +			loadAmbientLoops();
 +			break;
 +		case kMars35EastSpinAirlockToWest:
 +			GameState.setMarsAirlockOpen(true);
 +			setCurrentAlternate(kAltMars35AirlockWest);
 +			turnTo(kEast);
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +			g_airMask->airQualityChanged();
 +			checkAirMask();
 +			loadAmbientLoops();
 +			break;
 +		case kMars48RobotApproaches:
 +			loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
 +			GameState.setMarsSeenRobotAtReactor(true);
 +			loopExtraSequence(kMars48RobotLoops);
 +			_utilityFuse.primeFuse(kMarsRobotPatienceLimit);
 +			_utilityFuse.setFunctionPtr(&robotTimerExpiredFunction, (void *)this);
 +			_utilityFuse.lightFuse();
 +			break;
 +		case kMars48RobotDefends:
 +			_vm->addItemToInventory(_attackingItem);
 +			_attackingItem = 0;
 +			if (_privateFlags.getFlag(kMarsPrivateRobotTiredOfWaitingFlag)) {
 +				startExtraSequence(kMars48RobotKillsPlayer, kExtraCompletedFlag, kFilterNoInput);
 +				loadLoopSound2("", 0x100, 0, 0);
 +			} else {
 +				loadLoopSound2("Sounds/Mars/Robot Loop.aiff", 0x100, 0, 0);
 +				loopExtraSequence(kMars48RobotLoops, kExtraCompletedFlag);
 +			}
 +			break;
 +		case kMars48RobotKillsPlayer:
 +			loadLoopSound2("");
 +			die(kDeathDidntGetOutOfWay);
 +			break;
 +		case kMars49SouthViewMaskFilling:
 +			setCurrentActivation(kActivateMaskOnFiller);
 +			setCurrentAlternate(kAltMarsMaskOnFiller);
 +			GameState.setMarsMaskOnFiller(true);
 +			break;
 +		case kMars58SpinLeft:
 +		case kMars54SpinRight:
 +			GameState.setScoringActivatedPlatform();
 +			arriveAt(kMars52, kEast);
 +			break;
 +		case kMars52SpinLeft:
 +		case kMars56SpinRight:
 +			GameState.setScoringActivatedPlatform();
 +			arriveAt(kMars54, kEast);
 +			break;
 +		case kMars54SpinLeft:
 +		case kMars58SpinRight:
 +			GameState.setScoringActivatedPlatform();
 +			arriveAt(kMars56, kEast);
 +			break;
 +		case kMars56SpinLeft:
 +		case kMars52SpinRight:
 +			GameState.setScoringActivatedPlatform();
 +			arriveAt(kMars58, kEast);
 +			break;
 +		case kMars52Extend:
 +		case kMars54Extend:
 +		case kMars56ExtendNoBomb:
 +		case kMars58Extend:
 +			GameState.setScoringActivatedPlatform();
 +			setCurrentActivation(kActivateReactorPlatformIn);
 +			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
 +			break;
 +		case kMars53Retract:
 +		case kMars55Retract:
 +		case kMars57RetractWithBomb:
 +		case kMars57RetractNoBomb:
 +		case kMars59Retract:
 +			GameState.setScoringActivatedPlatform();
 +			setCurrentActivation(kActivateReactorPlatformOut);
 +			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, false);
 +			break;
 +		case kMars56ExtendWithBomb:
 +			playSpotSoundSync(kMustBeUnlockedIn, kMustBeUnlockedOut);
 +			GameState.setScoringActivatedPlatform();
 +			_privateFlags.setFlag(kMarsPrivatePlatformZoomedInFlag, true);
 +			break;
 +		case kMars57CantOpenPanel:
 +			GameState.setScoringActivatedPlatform();
 +			setCurrentActivation(kActivateReactorAskLowerScreen);
 +			break;
 +		case kMars57LowerScreenClosed:
 +		case kMars57ThawLock:
 +			setCurrentActivation(kActivateReactorReadyForNitrogen);
 +			GameState.setMarsLockFrozen(false);
 +			break;
 +		case kMars57FreezeLock:
 +			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
 +			item->setItemState(kNitrogenEmpty);
 +			_vm->addItemToInventory(item);
 +			setCurrentActivation(kActivateReactorReadyForCrowBar);
 +			GameState.setScoringUsedLiquidNitrogen();
 +			GameState.setMarsLockFrozen(true);
 +			showExtraView(kMars57LockFrozenView);
 +			_utilityFuse.primeFuse(kLockFreezeTimeLmit);
 +			_utilityFuse.setFunctionPtr(&lockThawTimerExpiredFunction, (void *)this);
 +			_utilityFuse.lightFuse();
 +			break;
 +		case kMars57BreakLock:
 +			item = (InventoryItem *)g_allItems.findItemByID(kCrowbar);
 +			_vm->addItemToInventory(item);
 +			GameState.setScoringUsedCrowBar();
 +			GameState.setMarsLockBroken(true);
 +			GameState.setMarsLockFrozen(false);
 +			startExtraLongSequence(kMars57OpenPanel, kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMars57OpenPanel:
 +		case kMars57OpenPanelChoices:
 +			setCurrentActivation(kActivateReactorAskOperation);
 +			break;
 +		case kMars57ShieldEvaluation:
 +		case kMars57MeasureOutput:
 +			setCurrentActivation(kActivateReactorRanEvaluation);
 +			loopExtraSequence(kMars57ShieldOkayLoop);
 +			break;
 +		case kMars57RunDiagnostics:
 +			setCurrentActivation(kActivateReactorRanDiagnostics);
 +			GameState.setScoringFoundCardBomb();
 +			break;
 +		case kMars57BombExplodes:
 +		case kMars57BombExplodesInGame:
 +			die(kDeathDidntDisarmMarsBomb);
 +			break;
 +		case kMars57BombAnalysis:
 +			setCurrentActivation(kActivateReactorAnalyzed);
 +			break;
 +		case kMars57DontLink:
 +			startExtraSequence(kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
 +			break;
 +		case kMars57CircuitLink:
 +			setCurrentActivation(kActivateReactorInstructions);
 +			break;
 +		case kMars57GameLevel1:
 +			setUpReactorLevel1();
 +			break;
 +		case kMars57GameLevel2:
 +		case kMars57GameLevel3:
 +			setUpNextReactorLevel();
 +			break;
 +		case kMars57GameSolved:
 +			setCurrentActivation(kActivateReactorBombSafe);
 +			break;
 +		case kMars57ExposeBomb:
 +			setCurrentActivation(kActivateReactorBombExposed);
 +			_privateFlags.setFlag(kMarsPrivateBombExposedFlag, true);
 +			break;
 +		case kMars57BackToNormal:
 +			setCurrentActivation(kActivateReactorPlatformIn);
 +			_privateFlags.setFlag(kMarsPrivateBombExposedFlag, false);
 +			g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XM51SW", false, kWarningInterruption);
 +			break;
 +		case kMars60WestSpinAirlockToEast:
 +			GameState.setMarsAirlockOpen(true);
 +			setCurrentAlternate(kAltMars60AirlockEast);
 +			turnTo(kWest);
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +			g_airMask->airQualityChanged();
 +			checkAirMask();
 +			loadAmbientLoops();
 +			break;
 +		case kMars60EastSpinAirlockToWest:
 +			GameState.setMarsAirlockOpen(false);
 +			setCurrentAlternate(kAltMars60AirlockWest);
 +			turnTo(kEast);
 +			setCurrentActivation(kActivateReadyToPressurizeAirlock);
 +			g_airMask->airQualityChanged();
 +			checkAirMask();
 +			loadAmbientLoops();
 +			break;
 +		case kMarsRobotHeadOpen:
 +			setCurrentActivation(kActivationRobotHeadOpen);
 +			break;
 +		case kMarsRobotHeadClose:
 +			recallToTSASuccess();
 +			break;
 +		case kMarsMaze007RobotApproach:
 +		case kMarsMaze015SouthRobotApproach:
 +		case kMarsMaze101EastRobotApproach:
 +		case kMarsMaze104WestLoop:
 +		case kMarsMaze133SouthApproach:
 +		case kMarsMaze136NorthApproach:
 +		case kMarsMaze184WestLoop:
 +			die(kDeathGroundByMazebot);
 +			break;
 +		}
 +	} else if ((flag & kTimeForCanyonChaseFlag) != 0) {
 +		doCanyonChase();
 +	} else if ((flag & kExplosionFinishedFlag) != 0) {
 +		_explosions.stop();
 +		_explosions.hide();
 +		if (g_robotShip->isDead()) {
 +			GameState.setMarsFinished(true);
 +			_centerShuttleMovie.hide();
 +			_upperRightShuttleMovie.show();
 +			_upperRightShuttleMovie.setTime(kShuttleUpperRightTargetDestroyedTime);
 +			_upperRightShuttleMovie.redrawMovieWorld();
 +			_rightDamageShuttleMovie.hide();
 +			playMovieSegment(&_rightShuttleMovie, kShuttleRightDestroyedStart, kShuttleRightDestroyedStop);
 +			playSpotSoundSync(kShuttleDestroyedIn, kShuttleDestroyedOut);
 +			throwAwayMarsShuttle();
 +			reinstateMonocleInterface();
 +			recallToTSASuccess();
 +		}
 +	} else if ((flag & kTimeToTransportFlag) != 0) {
 +		transportToRobotShip();
 +	}
 +
 +	if (g_AIArea)
 +		g_AIArea->checkMiddleArea();
 +}
 +
 +void Mars::spotCompleted() {
 +	Neighborhood::spotCompleted();
 +
 +	if (GameState.getCurrentRoom() == kMarsRobotShuttle)
 +		g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/Mars/XN59WD", false, kWarningInterruption);
 +}
 +
 +void Mars::doCanyonChase() {	
 +	GameState.setScoringEnteredShuttle();
 +	setNextHandler(_vm);
 +	throwAwayInterface();
 +
 +	_vm->_cursor->hide();
 +	
 +	// Open the spot sounds movie again...
 +	_spotSounds.initFromQuickTime(getSoundSpotsName());
 +	_spotSounds.setVolume(_vm->getSoundFXLevel());
 +
 +	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (!video->loadFile("Images/Mars/M44ESA.movie"))
 +		error("Could not load interface->shuttle transition video");
 +
++	video->start();
++
 +	while (!_vm->shouldQuit() && !video->endOfVideo()) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				_vm->drawScaledFrame(frame, 0, 0);
 +		}
 +
 +		Common::Event event;
 +		while (g_system->getEventManager()->pollEvent(event))
 +			;
 +
 +		g_system->delayMillis(10);
 +	}
 +
 +	delete video;
 +
 +	if (_vm->shouldQuit())
 +		return;
 +
 +	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
 +							kShuttle1Top, true);
 +	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
 +							kShuttle2Top, true);
 +	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
 +							kShuttle3Top, true);
 +	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
 +							kShuttle4Top, true);
 +
 +	initOneMovie(&_canyonChaseMovie, "Images/Mars/Canyon.movie",
 +						kShuttleMonitorOrder, kShuttleWindowLeft, kShuttleWindowTop, true);
 +	_canyonChaseMovie.setVolume(_vm->getSoundFXLevel());
 +
 +	loadLoopSound1("Sounds/Mars/Inside Cockpit.22K.8.AIFF");
 +
 +	// Swing shuttle around...
 +	playMovieSegment(&_canyonChaseMovie, kShuttleSwingStart, kShuttleSwingStop);
 +
 +	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
 +	
 +	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
 +	
 +	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
 +	
 +	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
 +	
 +	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
 +	
 +	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
 +	
 +	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
 +	
 +	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
 +	
 +	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
 +	
 +	_centerShuttleMovie.show();
 +	_centerShuttleMovie.setTime(kShuttleCenterBoardingTime);
 +	playSpotSoundSync(kShuttleCockpitIn, kShuttleCockpitOut);
 +	
 +	_centerShuttleMovie.setTime(kShuttleCenterCheckTime);
 +	playSpotSoundSync(kShuttleOnboardIn, kShuttleOnboardOut);
 +	
 +	_shuttleEnergyMeter.initShuttleEnergyMeter();
 +	_shuttleEnergyMeter.powerUpMeter();
 +	while (_shuttleEnergyMeter.isFading()) {
 +		_vm->checkCallBacks();
 +		_vm->refreshDisplay();
 +		g_system->updateScreen();
 +	}
 +
 +	_leftShuttleMovie.show();
 +	playMovieSegment(&_leftShuttleMovie, kShuttleLeftIntroStart, kShuttleLeftIntroStop);
 +
 +	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
 +	_leftShuttleMovie.redrawMovieWorld();
 +	
 +	_leftDamageShuttleMovie.show();
 +	playMovieSegment(&_leftDamageShuttleMovie);
 +
 +	// Take it down a tick initially. This sets the time to the time of the last tick,
 +	// so that subsequence drops will drop it down a tick.
 +	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
 +	_leftDamageShuttleMovie.redrawMovieWorld();
 +	
 +	_lowerRightShuttleMovie.show();
 +	_lowerRightShuttleMovie.setTime(kShuttleLowerRightOffTime);
 +	_lowerRightShuttleMovie.redrawMovieWorld();
 +	_centerShuttleMovie.setTime(kShuttleCenterNavCompTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttleNavigationIn, kShuttleNavigationOut);
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterCommTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttleCommunicationIn, kShuttleCommunicationOut);
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterAllSystemsTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttleAllSystemsIn, kShuttleAllSystemsOut);
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterSecureLooseTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttleSecureLooseIn, kShuttleSecureLooseOut);
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterAutoTestTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttleAutoTestingIn, kShuttleAutoTestingOut);
 +
 +	_leftShuttleMovie.setTime(kShuttleLeftAutoTestTime);
 +	_leftShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kMarsThrusterAutoTestIn, kMarsThrusterAutoTestOut);
 +	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
 +	_leftShuttleMovie.redrawMovieWorld();
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterLaunchTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +	playSpotSoundSync(kShuttlePrepareForDropIn, kShuttlePrepareForDropOut);
 +
 +	playSpotSoundSync(kShuttleAllClearIn, kShuttleAllClearOut);
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterEnterTubeTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +
 +	_lowerLeftShuttleMovie.show();
 +	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftCollisionTime);
 +
 +	loadLoopSound1("");
 +
 +	_canyonChaseMovie.setSegment(kCanyonChaseStart, kCanyonChaseStop);
 +	_canyonChaseMovie.start();
 +
 +	startMarsTimer(kLaunchTubeReachedTime, kMovieTicksPerSecond, kMarsLaunchTubeReached);
 +}
 +
 +void Mars::startUpFromFinishedSpaceChase() {
 +	setNextHandler(_vm);
 +	throwAwayInterface();
 +
 +	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
 +							kShuttle1Top, true);
 +	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
 +							kShuttle2Top, true);
 +	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
 +							kShuttle3Top, true);
 +	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
 +							kShuttle4Top, true);
 +	
 +	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
 +	
 +	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
 +	
 +	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
 +	
 +	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
 +	
 +	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
 +	
 +	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
 +	
 +	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
 +	
 +	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
 +	
 +	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
 +
 +	_centerShuttleMovie.show();
 +
 +	_shuttleEnergyMeter.initShuttleEnergyMeter();
 +	_shuttleEnergyMeter.setEnergyValue(kFullShuttleEnergy);
 +
 +	_leftShuttleMovie.show();
 +	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
 +	_leftShuttleMovie.redrawMovieWorld();
 +
 +	_leftDamageShuttleMovie.show();
 +	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getDuration() - 40);
 +	_leftDamageShuttleMovie.redrawMovieWorld();
 +
 +	_lowerRightShuttleMovie.show();
 +
 +	_lowerLeftShuttleMovie.show();
 +
 +	loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
 +
 +	initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft,
 +			kShuttleJunkTop, false);
 +
 +	initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
 +	_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
 +
 +	_energyBeam.initShuttleWeapon();
 +	_gravitonCannon.initShuttleWeapon();
 +
 +	_upperLeftShuttleMovie.show();
 +	_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
 +	_upperLeftShuttleMovie.redrawMovieWorld();
 +
 +	_rightShuttleMovie.show();
 +	_rightShuttleMovie.setTime(kShuttleRightIntroStop - 1);
 +	_rightShuttleMovie.redrawMovieWorld();
 +
 +	_rightDamageShuttleMovie.show();
 +	_rightDamageShuttleMovie.setTime(40);
 +	_rightDamageShuttleMovie.redrawMovieWorld();
 +
 +	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
 +	_lowerLeftShuttleMovie.redrawMovieWorld();
 +	
 +	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 +	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_shuttleTransportSpot);
 +
 +	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 +
 +	_upperRightShuttleMovie.show();
 +	_upperRightShuttleMovie.setTime(kShuttleUpperRightOverloadTime);
 +	_upperRightShuttleMovie.redrawMovieWorld();
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterSafeTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +
 +	_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportTime);
 +	_lowerRightShuttleMovie.redrawMovieWorld();
 +
 +	initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
 +			kShuttleWindowLeft, kShuttleWindowTop, true);
 +	_canyonChaseMovie.setTime(_canyonChaseMovie.getDuration());
 +	_canyonChaseMovie.redrawMovieWorld();
 +}
 +
 +void Mars::startUpFromSpaceChase() {
 +	setNextHandler(_vm);
 +	throwAwayInterface();
 +	
 +	// Open the spot sounds movie again...
 +	_spotSounds.initFromQuickTime(getSoundSpotsName());
 +	_spotSounds.setVolume(_vm->getSoundFXLevel());;
 +	
 +	initOnePicture(&_shuttleInterface1, "Images/Mars/MCmain1.pict", kShuttleBackgroundOrder, kShuttle1Left,
 +							kShuttle1Top, true);
 +	initOnePicture(&_shuttleInterface2, "Images/Mars/MCmain2.pict", kShuttleBackgroundOrder, kShuttle2Left,
 +							kShuttle2Top, true);
 +	initOnePicture(&_shuttleInterface3, "Images/Mars/MCmain3.pict", kShuttleBackgroundOrder, kShuttle3Left,
 +							kShuttle3Top, true);
 +	initOnePicture(&_shuttleInterface4, "Images/Mars/MCmain4.pict", kShuttleBackgroundOrder, kShuttle4Left,
 +							kShuttle4Top, true);
 +	
 +	initOneMovie(&_leftShuttleMovie, "Images/Mars/Left Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleLeftLeft, kShuttleLeftTop, false);
 +	
 +	initOneMovie(&_rightShuttleMovie, "Images/Mars/Right Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleRightLeft, kShuttleRightTop, false);
 +	
 +	initOneMovie(&_lowerLeftShuttleMovie, "Images/Mars/Lower Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerLeftLeft, kShuttleLowerLeftTop, false);
 +	
 +	initOneMovie(&_lowerRightShuttleMovie, "Images/Mars/Lower Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleLowerRightLeft, kShuttleLowerRightTop, false);
 +	
 +	initOneMovie(&_centerShuttleMovie, "Images/Mars/Center Shuttle.movie",
 +			kShuttleMonitorOrder, kShuttleCenterLeft, kShuttleCenterTop, false);
 +	
 +	initOneMovie(&_upperLeftShuttleMovie, "Images/Mars/Upper Left Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperLeftLeft, kShuttleUpperLeftTop, false);
 +	
 +	initOneMovie(&_upperRightShuttleMovie, "Images/Mars/Upper Right Shuttle.movie", kShuttleMonitorOrder,
 +			kShuttleUpperRightLeft, kShuttleUpperRightTop, false);
 +	
 +	initOneMovie(&_leftDamageShuttleMovie, "Images/Mars/Left Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleLeftEnergyLeft, kShuttleLeftEnergyTop, false);
 +	
 +	initOneMovie(&_rightDamageShuttleMovie, "Images/Mars/Right Damage Shuttle.movie",
 +			kShuttleStatusOrder, kShuttleRightEnergyLeft, kShuttleRightEnergyTop, false);
 +
 +	_centerShuttleMovie.show();
 +
 +	_shuttleEnergyMeter.initShuttleEnergyMeter();
 +	_shuttleEnergyMeter.setEnergyValue(kFullShuttleEnergy);
 +
 +	_leftShuttleMovie.show();
 +	_leftShuttleMovie.setTime(kShuttleLeftNormalTime);
 +	_leftShuttleMovie.redrawMovieWorld();
 +	
 +	_leftDamageShuttleMovie.show();
 +	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getDuration() - 40);
 +	_leftDamageShuttleMovie.redrawMovieWorld();
 +
 +	_lowerRightShuttleMovie.show();
 +
 +	_lowerLeftShuttleMovie.show();
 +
 +	loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
 +	
 +	initOneMovie(&_planetMovie, "Images/Mars/Planet.movie", kShuttlePlanetOrder,
 +			kPlanetStartLeft, kPlanetStartTop, true);
 +	_planetMovie.setFlags(kLoopTimeBase);
 +
 +	initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft,
 +			kShuttleJunkTop, false);
 +	
 +	initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
 +	_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
 +
 +	_energyBeam.initShuttleWeapon();
 +	_gravitonCannon.initShuttleWeapon();
 +
 +	_upperLeftShuttleMovie.show();
 +
 +	_robotShip.initRobotShip();
 +
 +	_planetMovie.start();
 +	_planetMover.startMoving(&_planetMovie);
 +
 +	_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
 +	_upperLeftShuttleMovie.redrawMovieWorld();
 +
 +	_centerShuttleMovie.setTime(kShuttleCenterTargetSightedTime);
 +	_centerShuttleMovie.redrawMovieWorld();
 +
 +	_lowerRightShuttleMovie.setTime(kShuttleLowerRightTrackingTime);
 +	_lowerRightShuttleMovie.redrawMovieWorld();
 +
 +	_rightShuttleMovie.show();
 +	_rightShuttleMovie.setTime(kShuttleRightIntroStop - 1);
 +	_rightShuttleMovie.redrawMovieWorld();
 +
 +	_rightDamageShuttleMovie.show();
 +	_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getDuration() - 40);
 +	_rightDamageShuttleMovie.redrawMovieWorld();
 +
 +	_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
 +	_lowerLeftShuttleMovie.redrawMovieWorld();
 +
 +	_robotShip.startMoving();
 +
 +	_shuttleHUD.initShuttleHUD();
 +
 +	_tractorBeam.startDisplaying();
 +
 +	_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
 +	_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_energyChoiceSpot);
 +	_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
 +	_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_gravitonChoiceSpot);
 +	_tractorChoiceSpot.setArea(kShuttleTractorBounds);
 +	_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_tractorChoiceSpot);
 +	_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
 +			kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
 +	_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_shuttleViewSpot);
 +	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 +	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +	g_allHotspots.push_back(&_shuttleTransportSpot);
 +
 +	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 +
 +	startMarsTimer(kSpaceChaseTimeLimit, kOneTickPerSecond, kMarsSpaceChaseFinished);
 +}
 +
 +void Mars::setSoundFXLevel(const uint16 level) {
 +	Neighborhood::setSoundFXLevel(level);
 +
 +	if (_canyonChaseMovie.isMovieValid())
 +		_canyonChaseMovie.setVolume(level);
 +
 +	if (_explosions.isMovieValid())
 +		_explosions.setVolume(level);
 +}
 +
 +void Mars::startMarsTimer(TimeValue time, TimeScale scale, MarsTimerCode code) {
 +	_utilityFuse.primeFuse(time, scale);
 +	_marsEvent.mars = this;
 +	_marsEvent.event = code;
 +	_utilityFuse.setFunctionPtr(&marsTimerFunction, (void *)&_marsEvent);
 +	_utilityFuse.lightFuse();
 +}
 +
 +void Mars::marsTimerExpired(MarsTimerEvent &event) {
 +	Common::Rect r;
 +	uint16 x, y;
 +
 +	switch (event.event) {
 +	case kMarsLaunchTubeReached:
 +		_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftTubeTime);
 +		_lowerLeftShuttleMovie.redrawMovieWorld();
 +		startMarsTimer(kCanyonChaseFinishedTime, kMovieTicksPerSecond, kMarsCanyonChaseFinished);
 +		break;
 +	case kMarsCanyonChaseFinished:
 +		GameState.setScoringEnteredLaunchTube();
 +
 +		while (_canyonChaseMovie.isRunning()) {
 +			_vm->checkCallBacks();
 +			_vm->refreshDisplay();
 +			_vm->_system->delayMillis(10);
 +		}
 +
 +		_canyonChaseMovie.stop();
 +		_canyonChaseMovie.stopDisplaying();
 +		_canyonChaseMovie.releaseMovie();
 +
 +		_vm->_gfx->enableErase();
 +
 +		loadLoopSound1("Sounds/Mars/Space Ambient.22K.8.AIFF");
 +
 +		playSpotSoundSync(kShuttleConfiguringIn, kShuttleConfiguringOut);
 +		playSpotSoundSync(kShuttleGeneratingIn, kShuttleGeneratingOut);
 +		playSpotSoundSync(kShuttleBreakawayIn, kShuttleBreakawayOut);
 +		playSpotSoundSync(kMarsAtmosphericBreakawayIn, kMarsAtmosphericBreakawayOut);
 +
 +		initOneMovie(&_planetMovie, "Images/Mars/Planet.movie", kShuttlePlanetOrder, kPlanetStartLeft, kPlanetStartTop, true);
 +		_planetMovie.setFlags(kLoopTimeBase);
 +
 +		initOneMovie(&_junk, "Images/Mars/Junk.movie", kShuttleJunkOrder, kShuttleJunkLeft, kShuttleJunkTop, false);
 +
 +		initOneMovie(&_explosions, "Images/Mars/Explosions.movie", kShuttleWeaponFrontOrder, 0, 0, false);
 +		_explosionCallBack.initCallBack(&_explosions, kCallBackAtExtremes);
 +
 +		_energyBeam.initShuttleWeapon();
 +		_gravitonCannon.initShuttleWeapon();
 +
 +		_centerShuttleMovie.setTime(kShuttleCenterWeaponsTime);
 +		_centerShuttleMovie.redrawMovieWorld();
 +
 +		_upperLeftShuttleMovie.show();
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDampingTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +
 +		_robotShip.initRobotShip();
 +
 +		_planetMovie.start();
 +		_planetMover.startMoving(&_planetMovie);
 +
 +		playSpotSoundSync(kShuttleDamperDescIn, kShuttleDamperDescOut);
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftGravitonTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +
 +		playSpotSoundSync(kShuttleGravitonDescIn, kShuttleGravitonDescOut);
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftTractorTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +
 +		playSpotSoundSync(kShuttleTractorDescIn, kShuttleTractorDescOut);
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDimTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +			
 +		_centerShuttleMovie.setTime(kShuttleCenterTargetSightedTime);
 +		_centerShuttleMovie.redrawMovieWorld();
 +		playSpotSoundSync(kShuttleTargetSightedIn, kShuttleTargetSightedOut);
 +
 +		_lowerRightShuttleMovie.setTime(kShuttleLowerRightTrackingTime);
 +		_lowerRightShuttleMovie.redrawMovieWorld();
 +		_rightShuttleMovie.show();
 +		playMovieSegment(&_rightShuttleMovie, kShuttleRightIntroStart, kShuttleRightIntroStop);
 +
 +		_rightDamageShuttleMovie.show();
 +		playMovieSegment(&_rightDamageShuttleMovie);
 +
 +		// Take it down a tick initially. This sets the time to the time of the last tick,
 +		// so that subsequence drops will drop it down a tick.
 +		_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getTime() - 40);
 +		_rightDamageShuttleMovie.redrawMovieWorld();
 +
 +		_lowerLeftShuttleMovie.setTime(kShuttleLowerLeftAutopilotTime);
 +		_lowerLeftShuttleMovie.redrawMovieWorld();
 +		playSpotSoundSync(kShuttleAutopilotEngagedIn, kShuttleAutopilotEngagedOut);
 +
 +		_robotShip.startMoving();
 +
 +		_shuttleHUD.initShuttleHUD();
 +
 +		_tractorBeam.startDisplaying();
 +
 +		_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
 +		_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +		g_allHotspots.push_back(&_energyChoiceSpot);
 +		_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
 +		_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +		g_allHotspots.push_back(&_gravitonChoiceSpot);
 +		_tractorChoiceSpot.setArea(kShuttleTractorBounds);
 +		_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +		g_allHotspots.push_back(&_tractorChoiceSpot);
 +		_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
 +				kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
 +		_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +		g_allHotspots.push_back(&_shuttleViewSpot);
 +		_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 +		_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
 +		g_allHotspots.push_back(&_shuttleTransportSpot);
 +
 +		_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 +
 +		playSpotSoundSync(kMarsCockpitChatterIn, kMarsCockpitChatterOut);
 +
 +		GameState.setMarsFinishedCanyonChase(true);
 +
 +		startMarsTimer(kSpaceChaseTimeLimit, kOneTickPerSecond, kMarsSpaceChaseFinished);
 +
 +		_vm->_cursor->hideUntilMoved();
 +		break;			
 +	case kMarsSpaceChaseFinished:
 +		// Player failed to stop the robot in time...
 +		_interruptionFilter = kFilterNoInput;
 +
 +		_rightShuttleMovie.setTime(kShuttleRightTargetLockTime);
 +		_rightShuttleMovie.redrawMovieWorld();
 +
 +		_upperRightShuttleMovie.show();
 +		_upperRightShuttleMovie.setTime(kShuttleUpperRightLockedTime);
 +		_upperRightShuttleMovie.redrawMovieWorld();
 +
 +		_rightShuttleMovie.setTime(kShuttleRightGravitonTime);
 +		_rightShuttleMovie.redrawMovieWorld();
 +		_upperRightShuttleMovie.setTime(kShuttleUpperRightArmedTime);
 +		_upperRightShuttleMovie.redrawMovieWorld();
 +
 +		_vm->delayShell(3, 1);
 +
 +		x = _vm->getRandomNumber(19);
 +		y = _vm->getRandomNumber(19);
 +
 +		r = Common::Rect(kShuttleWindowMidH - x, kShuttleWindowMidV - y,
 +				kShuttleWindowMidH - x + 20, kShuttleWindowMidV - y + 20);
 +		showBigExplosion(r, kShuttleAlienShipOrder);
 +			
 +		while (_explosions.isRunning()) {
 +			_vm->checkCallBacks();
 +			_vm->refreshDisplay();
 +			g_system->delayMillis(10);
 +		}
 +
 +		throwAwayMarsShuttle();
 +		reinstateMonocleInterface();
 +		recallToTSAFailure();
 +		break;
 +	default:
 +		break;
 +	}
 +
 +	_interruptionFilter = kFilterAllInput;
 +}
 +
 +void Mars::throwAwayMarsShuttle() {
 +	_shuttleInterface1.deallocateSurface();
 +	_shuttleInterface1.stopDisplaying();
 +	_shuttleInterface2.deallocateSurface();
 +	_shuttleInterface2.stopDisplaying();
 +	_shuttleInterface3.deallocateSurface();
 +	_shuttleInterface3.stopDisplaying();
 +	_shuttleInterface4.deallocateSurface();
 +	_shuttleInterface4.stopDisplaying();
 +
 +	_spotSounds.disposeSound();
 +	
 +	_canyonChaseMovie.releaseMovie();
 +	_canyonChaseMovie.stopDisplaying();
 +	_leftShuttleMovie.releaseMovie();
 +	_leftShuttleMovie.stopDisplaying();
 +	_rightShuttleMovie.releaseMovie();
 +	_rightShuttleMovie.stopDisplaying();
 +	_lowerLeftShuttleMovie.releaseMovie();
 +	_lowerLeftShuttleMovie.stopDisplaying();
 +	_lowerRightShuttleMovie.releaseMovie();
 +	_lowerRightShuttleMovie.stopDisplaying();
 +	_centerShuttleMovie.releaseMovie();
 +	_centerShuttleMovie.stopDisplaying();
 +	_upperLeftShuttleMovie.releaseMovie();
 +	_upperLeftShuttleMovie.stopDisplaying();
 +	_upperRightShuttleMovie.releaseMovie();
 +	_upperRightShuttleMovie.stopDisplaying();
 +	_leftDamageShuttleMovie.releaseMovie();
 +	_leftDamageShuttleMovie.stopDisplaying();
 +	_rightDamageShuttleMovie.releaseMovie();
 +	_rightDamageShuttleMovie.stopDisplaying();
 +
 +	_shuttleEnergyMeter.disposeShuttleEnergyMeter();
 +	_robotShip.cleanUpRobotShip();
 +	_shuttleHUD.cleanUpShuttleHUD();
 +	_tractorBeam.stopDisplaying();
 +	_junk.releaseMovie();
 +	_junk.stopDisplaying();
 +	_energyBeam.cleanUpShuttleWeapon();
 +	_gravitonCannon.cleanUpShuttleWeapon();
 +	g_allHotspots.remove(&_energyChoiceSpot);
 +	g_allHotspots.remove(&_gravitonChoiceSpot);
 +	g_allHotspots.remove(&_tractorChoiceSpot);
 +	g_allHotspots.remove(&_shuttleViewSpot);
 +	g_allHotspots.remove(&_shuttleTransportSpot);
 +	_explosions.releaseMovie();
 +	_explosions.stopDisplaying();
 +
 +	loadLoopSound1("");
 +}
 +
 +void Mars::transportToRobotShip() {
 +	throwAwayMarsShuttle();
 +
 +	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (!video->loadFile("Images/Mars/M98EAE.movie"))
 +		error("Could not load shuttle->interface transition video");
 +
++	video->start();
++
 +	while (!_vm->shouldQuit() && !video->endOfVideo()) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				_vm->drawScaledFrame(frame, 0, 0);
 +		}
 +
 +		Common::Event event;
 +		while (g_system->getEventManager()->pollEvent(event))
 +			;
 +
 +		g_system->delayMillis(10);
 +	}
 +
 +	delete video;
 +
 +	if (_vm->shouldQuit())
 +		return;
 +
 +	reinstateMonocleInterface();
 +
 +	g_energyMonitor->stopEnergyDraining();
 +	g_energyMonitor->restoreLastEnergyValue();
 +	_vm->resetEnergyDeathReason();
 +	g_energyMonitor->startEnergyDraining();
 +
 +	arriveAt(kMarsRobotShuttle, kEast);
 +
 +	_navMovie.stop();
 +	_navMovie.setTime(_navMovie.getStart());
 +	_navMovie.start();
 +}
 +
 +const int kRobotTooStrong = 1;
 +const int kTractorTooWeak = 2;
 +const int kCapturedRobotShip = 3;
 +
 +void Mars::spaceChaseClick(const Input &input, const HotSpotID id) {
 +	Common::Point pt;
 +
 +	switch (id) {
 +	case kShuttleEnergySpotID:
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftDampingTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +		_leftShuttleMovie.setTime(kShuttleLeftDampingTime);
 +		_leftShuttleMovie.redrawMovieWorld();
 +		_shuttleHUD.hide();
 +		_weaponSelection = kEnergyBeam;
 +		playSpotSoundSync(kShuttleDampingBeamIn, kShuttleDampingBeamOut);
 +		break;
 +	case kShuttleGravitonSpotID:
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftGravitonTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +		_leftShuttleMovie.setTime(kShuttleLeftGravitonTime);
 +		_leftShuttleMovie.redrawMovieWorld();
 +		_shuttleHUD.hide();
 +		_weaponSelection = kGravitonCannon;
 +		playSpotSoundSync(kShuttleGravitonIn, kShuttleGravitonOut);
 +		break;
 +	case kShuttleTractorSpotID:
 +		_upperLeftShuttleMovie.setTime(kShuttleUpperLeftTractorTime);
 +		_upperLeftShuttleMovie.redrawMovieWorld();
 +		_leftShuttleMovie.setTime(kShuttleLeftTractorTime);
 +		_leftShuttleMovie.redrawMovieWorld();
 +		_shuttleHUD.show();
 +		_weaponSelection = kTractorBeam;
 +		playSpotSoundSync(kShuttleTractorBeamIn, kShuttleTractorBeamOut);
 +		break;
 +	case kShuttleViewSpotID:
 +		switch (_weaponSelection) {
 +		case kEnergyBeam:
 +			if (_shuttleEnergyMeter.getEnergyValue() < kMinDampingEnergy) {
 +				playSpotSoundSync(kShuttleEnergyTooLowIn, kShuttleEnergyTooLowOut);
 +			} else {
 +				if (_energyBeam.canFireWeapon()) {
 +					_shuttleEnergyMeter.dropEnergyValue(kMinDampingEnergy);
 +					input.getInputLocation(pt);
 +					_energyBeam.fireWeapon(pt.x, pt.y);
 +					playSpotSoundSync(kMarsEDBBlastIn, kMarsEDBBlastOut);
 +				}
 +			}
 +			break;
 +		case kGravitonCannon:
 +			if (_shuttleEnergyMeter.getEnergyValue() < kMinGravitonEnergy) {
 +				playSpotSoundSync(kShuttleEnergyTooLowIn, kShuttleEnergyTooLowOut);
 +			} else {
 +				if (_gravitonCannon.canFireWeapon()) {
 +					_shuttleEnergyMeter.dropEnergyValue(kMinGravitonEnergy);
 +					input.getInputLocation(pt);
 +					_gravitonCannon.fireWeapon(pt.x, pt.y);
 +					playSpotSoundSync(kMarsGravitonBlastIn, kMarsGravitonBlastOut);
 +				}
 +			}
 +			break;
 +		case kTractorBeam:
 +			if (_shuttleHUD.isTargetLocked()) {
 +				// play tractor beam sound?
 +				_utilityFuse.stopFuse();
 +
 +				_tractorBeam.show();
 +
 +				int capture;
 +				if (_rightDamageShuttleMovie.getTime() > 40) {
 +					capture = kRobotTooStrong;
 +				} else if (!_shuttleEnergyMeter.enoughEnergyForTractorBeam()) {
 +					capture = kTractorTooWeak;
 +				} else {
 +					_robotShip.snareByTractorBeam();
 +					capture = kCapturedRobotShip;
 +					_planetMover.dropPlanetOutOfSight();
 +				}
 +
 +				_shuttleEnergyMeter.drainForTractorBeam();
 +
 +				while (_shuttleEnergyMeter.isFading()) {
 +					_vm->checkCallBacks();
 +					_vm->refreshDisplay();
 +					_vm->_system->delayMillis(10);
 +				}
 +
 +				_shuttleEnergyMeter.setEnergyValue(_shuttleEnergyMeter.getEnergyValue());
 +
 +				switch (capture) {
 +				case kRobotTooStrong:
 +					_tractorBeam.hide();
 +					playSpotSoundSync(kShuttleBrokeFreeIn, kShuttleBrokeFreeOut);
 +					_utilityFuse.lightFuse();
 +					break;
 +				case kTractorTooWeak:
 +					playSpotSoundSync(kShuttleCantHoldIn, kShuttleCantHoldOut);
 +					_tractorBeam.hide();
 +					_utilityFuse.lightFuse();
 +					break;
 +				case kCapturedRobotShip:
 +					_tractorBeam.hide();
 +					_shuttleHUD.hide();
 +					_robotShip.cleanUpRobotShip();
 +					_planetMovie.stop();
 +					_planetMovie.stopDisplaying();
 +					_planetMovie.releaseMovie();
 +
 +					// Shameless reuse of a variable :P
 +					initOneMovie(&_canyonChaseMovie, "Images/Mars/M98EAS.movie", kShuttleTractorBeamMovieOrder,
 +							kShuttleWindowLeft, kShuttleWindowTop, true);
 +					_canyonChaseMovie.redrawMovieWorld();
 +					playMovieSegment(&_canyonChaseMovie, 0, _canyonChaseMovie.getDuration());
 +
 +					// wait here until any junk clears...
 +					while (_junk.junkFlying()) {
 +						_vm->checkCallBacks();
 +						_vm->refreshDisplay();
 +						_vm->_system->delayMillis(10);
 +					}
 +
 +					_upperRightShuttleMovie.show();
 +					_upperRightShuttleMovie.setTime(kShuttleUpperRightOverloadTime);
 +					_upperRightShuttleMovie.redrawMovieWorld();
 +
 +					playSpotSoundSync(kShuttleOverloadedIn, kShuttleOverloadedOut);
 +					_centerShuttleMovie.setTime(kShuttleCenterVerifyingTime);
 +					_centerShuttleMovie.redrawMovieWorld();
 +
 +					playSpotSoundSync(kShuttleCoordinatesIn, kShuttleCoordinatesOut);
 +					_centerShuttleMovie.setTime(kShuttleCenterScanningTime);
 +					_centerShuttleMovie.redrawMovieWorld();
 +
 +					playSpotSoundSync(kShuttleScanningIn, kShuttleScanningOut);
 +					_centerShuttleMovie.setTime(kShuttleCenterSafeTime);
 +					_centerShuttleMovie.redrawMovieWorld();
 +
 +					playSpotSoundSync(kShuttleSafeIn, kShuttleSafeOut);
 +					_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportTime);
 +					_lowerRightShuttleMovie.redrawMovieWorld();
 +					GameState.setMarsReadyForShuttleTransport(true);
 +					break;
 +				}
 +			} else {
 +				playSpotSoundSync(kShuttleTractorLimitedIn, kShuttleTractorLimitedOut);
 +			}
 +			break;
 +		default:
 +			break;
 +		}
 +		break;
 +	case kShuttleTransportSpotID:
 +		_lowerRightShuttleMovie.setTime(kShuttleLowerRightTransportHiliteTime);
 +		_lowerRightShuttleMovie.redrawMovieWorld();
 +		_neighborhoodNotification.setNotificationFlags(kTimeToTransportFlag, kTimeToTransportFlag);
 +		break;
 +	}
 +}
 +
 +void Mars::showBigExplosion(const Common::Rect &r, const DisplayOrder order) {
 +	if (_explosions.isMovieValid()) {
 +		_explosions.setDisplayOrder(order);
 +
 +		Common::Rect r2 = r;
 +		int dx = r.width() / 2;
 +		int dy = r.height() / 2;
 +		r2.left -= dx;
 +		r2.right += dx;
 +		r2.top -= dy;
 +		r2.bottom += dy;		
 +
 +		_explosions.setBounds(r2);
 +		_explosions.show();
 +		_explosions.stop();
 +		_explosions.setSegment(kBigExplosionStart, kBigExplosionStop);
 +		_explosions.setTime(kBigExplosionStart);
 +		_explosionCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
 +		_explosions.start();
 +	}
 +}
 +
 +void Mars::showLittleExplosion(const Common::Rect &r, const DisplayOrder order) {	
 +	if (_explosions.isMovieValid()) {
 +		_explosions.setDisplayOrder(order);
 +
 +		Common::Rect r2 = r;
 +		int dx = r.width() / 2;
 +		int dy = r.height() / 2;
 +		r2.left -= dx;
 +		r2.right += dx;
 +		r2.top -= dy;
 +		r2.bottom += dy;
 +		_explosions.setBounds(r2);
 +
 +		_explosions.show();
 +		_explosions.stop();
 +		_explosions.setSegment(kLittleExplosionStart, kLittleExplosionStop);
 +		_explosions.setTime(kLittleExplosionStart);
 +		_explosionCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
 +		_explosions.start();
 +	}
 +}
 +
 +void Mars::hitByJunk() {	
 +	_leftDamageShuttleMovie.setTime(_leftDamageShuttleMovie.getTime() - 40);
 +	_leftDamageShuttleMovie.redrawMovieWorld();
 +
 +	playSpotSoundSync(kMarsJunkCollisionIn, kMarsJunkCollisionOut);
 +
 +	if (_leftDamageShuttleMovie.getTime() == 0) {
 +		die(kDeathRanIntoSpaceJunk);
 +	} else {
 +		TimeValue t = _leftDamageShuttleMovie.getTime() / 40;
 +
 +		if (t == 1)
 +			playSpotSoundSync(kShuttleHullBreachIn, kShuttleHullBreachOut);
 +
 +		t = _leftShuttleMovie.getTime();
 +		_leftShuttleMovie.setTime(kShuttleLeftDamagedTime);
 +		_leftShuttleMovie.redrawMovieWorld();
 +		_vm->delayShell(1, 3);
 +		_leftShuttleMovie.setTime(t);
 +		_leftShuttleMovie.redrawMovieWorld();
 +	}
 +}
 +
 +void Mars::setUpNextDropTime() {
 +	_robotShip.setUpNextDropTime();
 +}
 +
 +void Mars::decreaseRobotShuttleEnergy(const int delta, Common::Point impactPoint) {	
 +	_rightDamageShuttleMovie.setTime(_rightDamageShuttleMovie.getTime() - 40 * delta);
 +	_rightDamageShuttleMovie.redrawMovieWorld();
 +
 +	if (_rightDamageShuttleMovie.getTime() == 0) {
 +		Common::Rect r;
 +		_robotShip.getShuttleBounds(r);
 +		int size = MAX(r.width(), r.height());
 +		r = Common::Rect::center(impactPoint.x, impactPoint.y, size, size);
 +		_robotShip.killRobotShip();
 +		showBigExplosion(r, kShuttleRobotShipOrder);
 +	} else if (delta > 1) {
 +		Common::Rect r;
 +		_robotShip.getShuttleBounds(r);
 +		int size = MIN(r.width(), r.height());
 +		r = Common::Rect::center(impactPoint.x, impactPoint.y, size, size);
 +		showLittleExplosion(r, kShuttleWeaponBackOrder);
 +		TimeValue t = _rightShuttleMovie.getTime();
 +		_rightShuttleMovie.setTime(kShuttleRightDamagedTime);
 +		_rightShuttleMovie.redrawMovieWorld();
 +		_vm->delayShell(1, 3);
 +		_rightShuttleMovie.setTime(t);
 +		_rightShuttleMovie.redrawMovieWorld();
 +	}
 +
 +	if (_rightDamageShuttleMovie.getTime() <= 40) {
 +		GameState.setScoringStoppedRobotsShuttle();
 +		if (!GameState.getMarsHitRobotWithCannon())
 +			GameState.setScoringMarsGandhi();
 +	}
 +}
 +
 +void Mars::updateCursor(const Common::Point cursorLocation, const Hotspot *cursorSpot) {
 +	if (cursorSpot && cursorSpot->getObjectID() == kShuttleViewSpotID) {
 +		if (_weaponSelection != kNoWeapon)
 +			_vm->_cursor->setCurrentFrameIndex(6);
 +		else
 +			_vm->_cursor->setCurrentFrameIndex(0);
 +	} else {
 +		Neighborhood::updateCursor(cursorLocation, cursorSpot);
 +	}
 +}
 +
 +AirQuality Mars::getAirQuality(const RoomID room) {
 +	if ((room >= kMars36 && room <= kMars39) || (room >= kMarsMaze004 && room <= kMarsMaze200))
 +		return kAirQualityVacuum;
 +	if (room == kMars35 && !GameState.getMarsAirlockOpen())
 +		return kAirQualityVacuum;
 +	if (room == kMars60 && !GameState.getMarsAirlockOpen())
 +		return kAirQualityVacuum;
 +
 +	return Neighborhood::getAirQuality(room);
 +}
 +
 +// Start up panting sound if necessary.
 +
 +void Mars::checkAirMask() {
 +	Neighborhood::checkAirMask();
 +
 +	if (getAirQuality(GameState.getCurrentRoom()) == kAirQualityVacuum) {
 +		if (g_airMask->isAirMaskOn()) {
 +			if (_noAirFuse.isFuseLit()) {
 +				_noAirFuse.stopFuse();
 +				loadLoopSound2("");
 +				loadAmbientLoops();
 +				playSpotSoundSync(kMarsOxyMaskOnIn, kMarsOxyMaskOnOut);
 +			}
 +		} else {
 +			if (!_noAirFuse.isFuseLit()) {
 +				loadLoopSound2("Sounds/Mars/SukWind1.22K.AIFF");
 +				_noAirFuse.primeFuse(kVacuumSurvivalTimeLimit);
 +				_noAirFuse.lightFuse();
 +			}
 +		}
 +	} else {
 +		if (_noAirFuse.isFuseLit()) {
 +			_noAirFuse.stopFuse();
 +			loadLoopSound2("");
 +			loadAmbientLoops();
 +		}
 +	}
 +}
 +
 +void Mars::airStageExpired() {
 +	if (((PegasusEngine *)g_engine)->playerHasItemID(kAirMask))
 +		die(kDeathNoAirInMaze);
 +	else
 +		die(kDeathNoMaskInMaze);
 +}
 +
 +void Mars::lockThawed() {
 +	startExtraSequence(kMars57ThawLock, kExtraCompletedFlag, kFilterNoInput);
 +}
 +
 +void Mars::setUpReactorLevel1() {
 +	_reactorStage = 1;
 +	makeColorSequence();
 +	_guessObject.initReactorGuess();
 +	_undoPict.initFromPICTResource(_vm->_resFork, kReactorUndoHilitePICTID);
 +	_undoPict.setDisplayOrder(kMonitorLayer);
 +	_undoPict.moveElementTo(kUndoHiliteLeft, kUndoHiliteTop);
 +	_undoPict.startDisplaying();
 +	_guessHistory.initReactorHistory();
 +	_choiceHighlight.initReactorChoiceHighlight();
 +	setCurrentActivation(kActivateReactorInGame);
 +	_bombFuse.primeFuse(kColorMatchingTimeLimit);
 +	_bombFuse.setFunctionPtr(&bombTimerExpiredInGameFunction, (void *)this);
 +	_bombFuse.lightFuse();
 +}
 +
 +void Mars::setUpNextReactorLevel() {
 +	_guessObject.show();
 +	_guessHistory.show();
 +	_guessHistory.clearHistory();
 +	_choiceHighlight.show();
 +	_reactorStage++;
 +	makeColorSequence();
 +}
 +
 +void Mars::makeColorSequence() {
 +	int32 code[5];
 +	int32 highest = _reactorStage + 2;
 +
 +	for (int32 i = 0; i < highest; i++)
 +		code[i] = i;
 +
 +	_vm->shuffleArray(code, highest);
 +	_currentGuess[0] = -1;
 +	_currentGuess[1] = -1;
 +	_currentGuess[2] = -1;
 +	_nextGuess = 0;
 +	_guessObject.setGuess(-1, -1, -1);
 +	_guessHistory.setAnswer(code[0], code[1], code[2]);
 +}
 +
 +void Mars::doUndoOneGuess() {
 +	if (_nextGuess > 0) {
 +		_undoPict.show();
 +		_vm->delayShell(1, 2);
 +		_undoPict.hide();
 +		_nextGuess--;
 +		_currentGuess[_nextGuess] = -1;
 +		_guessObject.setGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
 +		_choiceHighlight.resetHighlight();
 +
 +		if (_currentGuess[0] != -1) {
 +			_choiceHighlight.highlightChoice(_currentGuess[0]);
 +
 +			if (_currentGuess[1] != -1) {
 +				_choiceHighlight.highlightChoice(_currentGuess[1]);
 +
 +				if (_currentGuess[2] != -1)
 +					_choiceHighlight.highlightChoice(_currentGuess[2]);
 +			}
 +		}
 +	}
 +}
 +
 +void Mars::doReactorGuess(int32 guess) {
 +	_choiceHighlight.highlightChoice(guess);
 +	_currentGuess[_nextGuess] = guess;
 +	_guessObject.setGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
 +
 +	switch (guess) {
 +	case 0:
 +		playSpotSoundSync(kColorMatchRedIn, kColorMatchRedOut);
 +		break;
 +	case 1:
 +		playSpotSoundSync(kColorMatchYellowIn, kColorMatchYellowOut);
 +		break;
 +	case 2:
 +		playSpotSoundSync(kColorMatchGreenIn, kColorMatchGreenOut);
 +		break;
 +	case 3:
 +		playSpotSoundSync(kColorMatchBlueIn, kColorMatchBlueOut);
 +		break;
 +	case 4:
 +		playSpotSoundSync(kColorMatchPurpleIn, kColorMatchPurpleOut);
 +		break;
 +	}
 +
 +	_nextGuess++;
 +
 +	if (_nextGuess == 3) {
 +		_vm->delayShell(1, 2);
 +		_nextGuess = 0;
 +		_guessHistory.addGuess(_currentGuess[0], _currentGuess[1], _currentGuess[2]);
 +
 +		switch (_guessHistory.getCurrentNumCorrect()) {
 +		case 0:
 +			playSpotSoundSync(kColorMatchZeroNodesIn, kColorMatchZeroNodesOut);
 +			break;
 +		case 1:
 +			playSpotSoundSync(kColorMatchOneNodeIn, kColorMatchOneNodeOut);
 +			break;
 +		case 2:
 +			playSpotSoundSync(kColorMatchTwoNodesIn, kColorMatchTwoNodesOut);
 +			break;
 +		case 3:
 +			playSpotSoundSync(kColorMatchThreeNodesIn, kColorMatchThreeNodesOut);
 +			break;
 +		}
 +
 +		_currentGuess[0] = -1;
 +		_currentGuess[1] = -1;
 +		_currentGuess[2] = -1;
 +		_guessObject.setGuess(-1, -1, -1);
 +		_choiceHighlight.resetHighlight();
 +
 +		if (_guessHistory.isSolved()) {
 +			_guessHistory.showAnswer();
 +			_vm->delayShell(1, 2);
 +			_guessObject.hide();
 +			_guessHistory.hide();
 +			_choiceHighlight.hide();
 +
 +			switch (_reactorStage) {
 +			case 1:
 +				startExtraSequence(kMars57GameLevel2, kExtraCompletedFlag, kFilterNoInput);
 +				break;
 +			case 2:
 +				startExtraSequence(kMars57GameLevel3, kExtraCompletedFlag, kFilterNoInput);
 +				break;
 +			case 3:
 +				_bombFuse.stopFuse();
 +				_guessObject.disposeReactorGuess();
 +				_undoPict.deallocateSurface();
 +				_guessHistory.disposeReactorHistory();
 +				_choiceHighlight.disposeReactorChoiceHighlight();
 +				GameState.setScoringDisarmedCardBomb();
 +				startExtraSequence(kMars57GameSolved, kExtraCompletedFlag, kFilterNoInput);
 +				break;
 +			}
 +		} else if (_guessHistory.getNumGuesses() >= 5) {
 +			_vm->delayShell(2, 1);
 +			bombExplodesInGame();
 +		}
 +	}
 +}
 +
 +void Mars::bombExplodesInGame() {
 +	_guessObject.disposeReactorGuess();
 +	_undoPict.deallocateSurface();
 +	_guessHistory.disposeReactorHistory();
 +	_choiceHighlight.disposeReactorChoiceHighlight();
 +	startExtraSequence(kMars57BombExplodesInGame, kExtraCompletedFlag, kFilterNoInput);
 +}
 +
 +void Mars::didntFindBomb() {
 +	die(kDeathDidntFindMarsBomb);
 +}
 +
 +Common::String Mars::getBriefingMovie() {
 +	Common::String movieName = Neighborhood::getBriefingMovie();
 +
 +	if (!movieName.empty())
 +		return movieName;
 +
 +	return "Images/AI/Mars/XM01";
 +}
 +
 +Common::String Mars::getEnvScanMovie() {
 +	Common::String movieName = Neighborhood::getEnvScanMovie();
 +
 +	if (movieName.empty()) {
 +		RoomID room = GameState.getCurrentRoom();
 +
 +		if (room >= kMars0A && room <= kMars21)
 +			return "Images/AI/Mars/XME1";
 +		else if (room >= kMars22 && room <= kMars31South)
 +			return "Images/AI/Mars/XME2";
 +		else if (room >= kMars52 && room <= kMars58)
 +			return "Images/AI/Mars/XMREACE";
 +
 +		return "Images/AI/Mars/XME3";
 +	}
 +
 +	return movieName;
 +}
 +
 +uint Mars::getNumHints() {
 +	uint numHints = Neighborhood::getNumHints();
 +
 +	if (numHints == 0) {
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kMars27, kNorth):
 +		case MakeRoomView(kMars28, kNorth):
 +		case MakeRoomView(kMars49, kSouth):
 +			numHints = 1;
 +			break;
 +		case MakeRoomView(kMars31, kSouth):
 +		case MakeRoomView(kMars31South, kSouth):
 +			if (!GameState.isTakenItemID(kMarsCard))
 +				numHints = 1;
 +			break;
 +		case MakeRoomView(kMars34, kNorth):
 +			if (!GameState.isTakenItemID(kMarsCard))
 +				numHints = 2;
 +			break;
 +		case MakeRoomView(kMars34, kSouth):
 +		case MakeRoomView(kMars45, kNorth):
 +			if (!GameState.isTakenItemID(kCrowbar))
 +				numHints = 1;
 +			break;
 +		case MakeRoomView(kMars51, kEast):
 +			if (GameState.isCurrentDoorOpen() && !GameState.getShieldOn()) {
 +				if (GameState.isTakenItemID(kShieldBiochip))
 +					numHints = 1;
 +				else
 +					numHints = 2;
 +			}
 +			break;
 +		case MakeRoomView(kMars52, kNorth):
 +		case MakeRoomView(kMars52, kSouth):
 +		case MakeRoomView(kMars52, kEast):
 +		case MakeRoomView(kMars52, kWest):
 +		case MakeRoomView(kMars54, kNorth):
 +		case MakeRoomView(kMars54, kSouth):
 +		case MakeRoomView(kMars54, kEast):
 +		case MakeRoomView(kMars54, kWest):
 +		case MakeRoomView(kMars56, kNorth):
 +		case MakeRoomView(kMars56, kSouth):
 +		case MakeRoomView(kMars56, kWest):
 +		case MakeRoomView(kMars58, kNorth):
 +		case MakeRoomView(kMars58, kSouth):
 +		case MakeRoomView(kMars58, kEast):
 +		case MakeRoomView(kMars58, kWest):
 +			if (!GameState.getShieldOn()) {
 +				if (GameState.isTakenItemID(kShieldBiochip))
 +					numHints = 1;
 +				else
 +					numHints = 2;
 +			}
 +			break;
 +		case MakeRoomView(kMars56, kEast):
 +			if (getCurrentActivation() == kActivateReactorReadyForNitrogen) {
 +				if ((ExtraID)_lastExtra == kMars57LowerScreenClosed)
 +					numHints = 3;
 +			} else if (getCurrentActivation() == kActivateReactorPlatformOut) {
 +				if (!GameState.getShieldOn()) {
 +					if (GameState.isTakenItemID(kShieldBiochip))
 +						numHints = 1;
 +					else
 +						numHints = 2;
 +				}
 +			}
 +			break;
 +		}
 +	}
 +
 +	return numHints;
 +}
 +
 +Common::String Mars::getHintMovie(uint hintNum) {
 +	Common::String movieName = Neighborhood::getHintMovie(hintNum);
 +
 +	if (movieName.empty()) {
 +		switch (GameState.getCurrentRoomAndView()) {
 +		case MakeRoomView(kMars27, kNorth):
 +		case MakeRoomView(kMars28, kNorth):
 +			return "Images/AI/Globals/XGLOB5C";
 +		case MakeRoomView(kMars31, kSouth):
 +		case MakeRoomView(kMars31South, kSouth):
 +		case MakeRoomView(kMars34, kSouth):
 +		case MakeRoomView(kMars45, kNorth):
 +			return "Images/AI/Globals/XGLOB1C";
 +		case MakeRoomView(kMars34, kNorth):
 +			if (hintNum == 1)
 +				return "Images/AI/Globals/XGLOB2C";
 +
 +			return "Images/AI/Globals/XGLOB3G";
 +		case MakeRoomView(kMars49, kSouth):
 +			if (GameState.isTakenItemID(kAirMask))
 +				return "Images/AI/Globals/XGLOB3E";
 +
 +			return "Images/AI/Globals/XGLOB1C";
 +		case MakeRoomView(kMars51, kEast):
 +			if (GameState.isTakenItemID(kShieldBiochip))
 +				return "Images/AI/Mars/XM52NW";
 +
 +			if (hintNum == 1)
 +				return "Images/AI/Globals/XGLOB2D";
 +
 +			return "Images/AI/Globals/XGLOB3F";
 +		case MakeRoomView(kMars52, kNorth):
 +		case MakeRoomView(kMars52, kSouth):
 +		case MakeRoomView(kMars52, kEast):
 +		case MakeRoomView(kMars52, kWest):
 +		case MakeRoomView(kMars54, kNorth):
 +		case MakeRoomView(kMars54, kSouth):
 +		case MakeRoomView(kMars54, kEast):
 +		case MakeRoomView(kMars54, kWest):
 +		case MakeRoomView(kMars56, kNorth):
 +		case MakeRoomView(kMars56, kSouth):
 +		case MakeRoomView(kMars56, kWest):
 +		case MakeRoomView(kMars58, kNorth):
 +		case MakeRoomView(kMars58, kSouth):
 +		case MakeRoomView(kMars58, kEast):
 +		case MakeRoomView(kMars58, kWest):
 +			if (hintNum == 1) {
 +				if (GameState.isTakenItemID(kShieldBiochip))
 +					return "Images/AI/Mars/XM52NW";
 +
 +				return "Images/AI/Globals/XGLOB2D";
 +			}
 +
 +			return "Images/AI/Globals/XGLOB3F";
 +		case MakeRoomView(kMars56, kEast):
 +			if (getCurrentActivation() == kActivateReactorReadyForNitrogen)
 +				return Common::String::format("Images/AI/Mars/XM57SD%d", hintNum);
 +
 +			if (hintNum == 1) {
 +				if (GameState.isTakenItemID(kShieldBiochip))
 +					return "Images/AI/Mars/XM52NW";
 +
 +				return "Images/AI/Globals/XGLOB2D";
 +			}
 +
 +			return "Images/AI/Globals/XGLOB3F";
 +		}
 +	}
 +
 +	return movieName;
 +}
 +
 +bool Mars::inColorMatchingGame() {
 +	return _guessObject.isDisplaying();
 +}
 +
 +bool Mars::canSolve() {
 +	return GameState.getCurrentRoomAndView() == MakeRoomView(kMars56, kEast) && (getCurrentActivation() == kActivateReactorReadyForNitrogen ||
 +			getCurrentActivation() == kActivateReactorReadyForCrowBar || inColorMatchingGame());
 +}
 +
 +void Mars::doSolve() {
 +	if (getCurrentActivation() == kActivateReactorReadyForNitrogen || getCurrentActivation() == kActivateReactorReadyForCrowBar) {
 +		_utilityFuse.stopFuse();
 +		GameState.setMarsLockBroken(true);
 +		GameState.setMarsLockFrozen(false);
 +		startExtraLongSequence(kMars57OpenPanel, kMars57OpenPanelChoices, kExtraCompletedFlag, kFilterNoInput);
 +	} else if (inColorMatchingGame()) {
 +		_bombFuse.stopFuse();
 +		_guessObject.disposeReactorGuess();
 +		_undoPict.deallocateSurface();
 +		_guessHistory.disposeReactorHistory();
 +		_choiceHighlight.disposeReactorChoiceHighlight();
 +		startExtraSequence(kMars57GameSolved, kExtraCompletedFlag, kFilterNoInput);
 +	}
 +}
 +
 +Common::String Mars::getSoundSpotsName() {
 +	return "Sounds/Mars/Mars Spots";
 +}
 +
 +Common::String Mars::getNavMovieName() {
 +	return "Images/Mars/Mars.movie";
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/pegasus.cpp
index 0e426a2,0000000..bbe2e0e
mode 100644,000000..100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@@ -1,2298 -1,0 +1,2305 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/config-manager.h"
 +#include "common/error.h"
 +#include "common/events.h"
 +#include "common/fs.h"
 +#include "common/file.h"
 +#include "common/memstream.h"
 +#include "common/savefile.h"
 +#include "common/textconsole.h"
 +#include "common/translation.h"
 +#include "common/random.h"
 +#include "base/plugins.h"
 +#include "base/version.h"
 +#include "gui/saveload.h"
 +#include "video/qt_decoder.h"
 +
 +#include "pegasus/console.h"
 +#include "pegasus/cursor.h"
 +#include "pegasus/energymonitor.h"
 +#include "pegasus/gamestate.h"
 +#include "pegasus/interface.h"
 +#include "pegasus/menu.h"
 +#include "pegasus/movie.h"
 +#include "pegasus/pegasus.h"
 +#include "pegasus/timers.h"
 +#include "pegasus/ai/ai_area.h"
 +#include "pegasus/items/itemlist.h"
 +#include "pegasus/items/biochips/aichip.h"
 +#include "pegasus/items/biochips/biochipitem.h"
 +#include "pegasus/items/biochips/mapchip.h"
 +#include "pegasus/items/biochips/opticalchip.h"
 +#include "pegasus/items/biochips/pegasuschip.h"
 +#include "pegasus/items/biochips/retscanchip.h"
 +#include "pegasus/items/biochips/shieldchip.h"
 +#include "pegasus/items/inventory/airmask.h"
 +#include "pegasus/items/inventory/gascanister.h"
 +#include "pegasus/items/inventory/inventoryitem.h"
 +#include "pegasus/items/inventory/keycard.h"
 +#include "pegasus/neighborhood/neighborhood.h"
 +#include "pegasus/neighborhood/caldoria/caldoria.h"
 +#include "pegasus/neighborhood/mars/mars.h"
 +#include "pegasus/neighborhood/norad/constants.h"
 +#include "pegasus/neighborhood/norad/alpha/noradalpha.h"
 +#include "pegasus/neighborhood/norad/delta/noraddelta.h"
 +#include "pegasus/neighborhood/prehistoric/prehistoric.h"
 +#include "pegasus/neighborhood/tsa/fulltsa.h"
 +#include "pegasus/neighborhood/tsa/tinytsa.h"
 +#include "pegasus/neighborhood/wsc/wsc.h"
 +
 +namespace Pegasus {
 +
 +PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc) : Engine(syst), InputHandler(0), _gameDescription(gamedesc),
 +		_shellNotification(kJMPDCShellNotificationID, this), _returnHotspot(kInfoReturnSpotID), _itemDragger(this), _bigInfoMovie(kNoDisplayElement),
 +		_smallInfoMovie(kNoDisplayElement) {
 +	_continuePoint = 0;
 +	_saveAllowed = _loadAllowed = true;
 +	_saveRequested = _loadRequested = false;
 +	_gameMenu = 0;
 +	_deathReason = kDeathStranded;
 +	_neighborhood = 0;
 +	_FXLevel = 0x80;
 +	_ambientLevel = 0x80;
 +	_gameMode = kNoMode;
 +	_switchModesSync = false;
 +	_draggingItem = 0;
 +	_dragType = kDragNoDrag;
 +	_idlerHead = 0;
 +	_currentCD = 1;
 +	_introTimer = 0;
 +	_aiSaveStream = 0;
 +}
 +
 +PegasusEngine::~PegasusEngine() {
 +	delete _resFork;
 +	delete _console;
 +	delete _cursor;
 +	delete _continuePoint;
 +	delete _gameMenu;
 +	delete _neighborhood;
 +	delete _rnd;
 +	delete _introTimer;
 +	delete _aiSaveStream;
 +	InputDeviceManager::destroy();
 +
 +	// NOTE: This must be deleted last!
 +	delete _gfx;
 +}
 +
 +void introTimerExpiredFunction(FunctionPtr *, void *) {
 +	((PegasusEngine *)g_engine)->introTimerExpired();
 +}
 +
 +Common::Error PegasusEngine::run() {
 +	_console = new PegasusConsole(this);
 +	_gfx = new GraphicsManager(this);
 +	_resFork = new Common::MacResManager();
 +	_cursor = new Cursor();
 +	_rnd = new Common::RandomSource("Pegasus");
 +	
 +	if (!_resFork->open("JMP PP Resources") || !_resFork->hasResFork())
 +		error("Could not load JMP PP Resources");
 +
 +	// Initialize items
 +	createItems();
 +
 +	// Initialize cursors
 +	_cursor->addCursorFrames(0x80); // Main
 +	_cursor->addCursorFrames(900);  // Mars Shuttle
 +
 +	// Initialize the item dragger bounds
 +	_itemDragger.setHighlightBounds();
 +
 +	if (!isDemo() && !detectOpeningClosingDirectory()) {
 +		Common::String message = "Missing intro directory. ";
 +
 +		// Give Mac OS X a more specific message because we can
 +#ifdef MACOSX
 +		message += "Make sure \"Opening/Closing\" is present.";
 +#else
 +		message += "Be sure to rename \"Opening/Closing\" to \"Opening_Closing\".";
 +#endif
 +
 +		GUIErrorMessage(message);
 +		warning("%s", message.c_str());
 +		return Common::kNoGameDataFoundError;
 +	}
 +
 +	// Set up input
 +	InputHandler::setInputHandler(this);
 +	allowInput(true);
 +
 +	// Set up inventories
 +	_items.setWeightLimit(9);
 +	_items.setOwnerID(kPlayerID);
 +	_biochips.setWeightLimit(8);
 +	_biochips.setOwnerID(kPlayerID);
 +
 +	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 +	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
 +	g_allHotspots.push_back(&_returnHotspot);
 +
 +	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 +	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
 +
 +	// Load from the launcher/cli if requested (and don't show the intro in those cases)
 +	bool doIntro = true;
 +	if (ConfMan.hasKey("save_slot")) {
 +		uint32 gameToLoad = ConfMan.getInt("save_slot");
 +		doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError);
 +	}
 +
 +	_shellNotification.notifyMe(this, kJMPShellNotificationFlags, kJMPShellNotificationFlags);
 +
 +	if (doIntro)
 +		// Start up the first notification
 +		_shellNotification.setNotificationFlags(kGameStartingFlag, kGameStartingFlag);
 +
 +	if (!isDemo()) {
 +		_introTimer = new FuseFunction();
 +		_introTimer->setFunctionPtr(&introTimerExpiredFunction, 0);
 +	}
 +
 +	while (!shouldQuit()) {
 +		processShell();
 +		_system->delayMillis(10); // Ease off the CPU
 +	}
 +
 +	return Common::kNoError;
 +}
 +
 +bool PegasusEngine::detectOpeningClosingDirectory() {
 +	// We need to detect what our Opening/Closing directory is listed as
 +	// On the original disc, it was 'Opening/Closing' but only HFS(+) supports the slash
 +	// Mac OS X will display this as 'Opening:Closing' and we can use that directly
 +	// On other systems, users will need to rename to "Opening_Closing"
 +
 +	Common::FSNode gameDataDir(ConfMan.get("path"));
 +	gameDataDir = gameDataDir.getChild("Images");
 +
 +	if (!gameDataDir.exists())
 +		return false;
 +
 +	Common::FSList fsList;
 +	if (!gameDataDir.getChildren(fsList, Common::FSNode::kListDirectoriesOnly, true))
 +		return false;
 +
 +	for (uint i = 0; i < fsList.size() && _introDirectory.empty(); i++) {
 +		Common::String name = fsList[i].getName();
 +
 +		if (name.equalsIgnoreCase("Opening:Closing"))
 +			_introDirectory = name;
 +		else if (name.equalsIgnoreCase("Opening_Closing"))
 +			_introDirectory = name;
 +	}
 +
 +	if (_introDirectory.empty())
 +		return false;
 +
 +	debug(0, "Detected intro location as '%s'", _introDirectory.c_str());
 +	_introDirectory = Common::String("Images/") + _introDirectory;
 +	return true;
 +}
 +
 +void PegasusEngine::createItems() {
 +	Common::SeekableReadStream *res = _resFork->getResource(MKTAG('N', 'I', 't', 'm'), 0x80);
 +
 +	uint16 entryCount = res->readUint16BE();
 +
 +	for (uint16 i = 0; i < entryCount; i++) {
 +		ItemID itemID = res->readUint16BE();
 +		NeighborhoodID neighborhoodID = res->readUint16BE();
 +		RoomID roomID = res->readUint16BE();
 +		DirectionConstant direction = res->readByte();
 +		res->readByte(); // alignment
 +
 +		createItem(itemID, neighborhoodID, roomID, direction);
 +	}
 +
 +	delete res;
 +}
 +
 +void PegasusEngine::createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction) {
 +	switch (itemID) {
 +	case kInterfaceBiochip:
 +		// Unused in game, but still in the data and we need to create
 +		// it because it's saved/loaded from save files.
 +		new BiochipItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kAIBiochip:
 +		new AIChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kPegasusBiochip:
 +		new PegasusChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kOpticalBiochip:
 +		new OpticalChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kMapBiochip:
 +		new MapChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kRetinalScanBiochip:
 +		new RetScanChip(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kShieldBiochip:
 +		new ShieldChip(itemID, neighborhoodID, roomID, direction);
 +		break;		
 +	case kAirMask:
 +		new AirMask(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kKeyCard:
 +		new KeyCard(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	case kGasCanister:
 +		new GasCanister(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	default:
 +		// Everything else is a normal inventory item
 +		new InventoryItem(itemID, neighborhoodID, roomID, direction);
 +		break;
 +	}
 +}
 +
 +void PegasusEngine::runIntro() {
 +	stopIntroTimer();
 +
 +	bool skipped = false;
 +
- 	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
++	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (video->loadFile(_introDirectory + "/BandaiLogo.movie")) {
++		video->start();
++
 +		while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +			if (video->needsUpdate()) {
 +				const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +				if (frame) {
 +					_system->copyRectToScreen((byte *)frame->pixels, frame->pitch, 0, 0, frame->w, frame->h);
 +					_system->updateScreen();
 +				}
 +			}
 +
 +			Input input;
 +			InputDevice.getInput(input, kFilterAllInput);
 +			if (input.anyInput())
 +				skipped = true;
 +
 +			_system->delayMillis(10);
 +		}
 +	}
 +
 +	delete video;
 +
 +	if (shouldQuit() || skipped)
 +		return;
 +
 +	video = new Video::QuickTimeDecoder();
 +
 +	if (!video->loadFile(_introDirectory + "/Big Movie.movie"))
 +		error("Could not load intro movie");
 +
- 	video->seekToTime(Audio::Timestamp(0, 10 * 600, 600));
++	video->seek(Audio::Timestamp(0, 10 * 600, 600));
++	video->start();
 +
 +	playMovieScaled(video, 0, 0);
 +
 +	delete video;
 +}
 +
 +Common::Error PegasusEngine::showLoadDialog() {
 +	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (loadGameState(slot).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	return result;
 +}
 +
 +Common::Error PegasusEngine::showSaveDialog() {
 +	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
 +
 +	Common::String gameId = ConfMan.get("gameid");
 +
 +	const EnginePlugin *plugin = 0;
 +	EngineMan.findGame(gameId, &plugin);
 +
 +	int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName());
 +
 +	Common::Error result;
 +
 +	if (slot >= 0) {
 +		if (saveGameState(slot, slc.getResultString()).getCode() == Common::kNoError)
 +			result = Common::kNoError;
 +		else
 +			result = Common::kUnknownError;
 +	} else {
 +		result = Common::kUserCanceled;
 +	}
 +
 +	return result;
 +}
 +
 +GUI::Debugger *PegasusEngine::getDebugger() {
 +	return _console;
 +}
 +
 +void PegasusEngine::addIdler(Idler *idler) {
 +	idler->_nextIdler = _idlerHead;
 +	if (_idlerHead)
 +		_idlerHead->_prevIdler = idler;
 +	idler->_prevIdler = 0;
 +	_idlerHead = idler;
 +}
 +
 +void PegasusEngine::removeIdler(Idler *idler) {
 +	if (idler->_prevIdler)
 +		idler->_prevIdler->_nextIdler = idler->_nextIdler;
 +	if (idler->_nextIdler)
 +		idler->_nextIdler->_prevIdler = idler->_prevIdler;
 +	if (idler == _idlerHead)
 +		_idlerHead = idler->_nextIdler;
 +	idler->_nextIdler = 0;
 +	idler->_prevIdler = 0;
 +}
 +
 +void PegasusEngine::giveIdleTime() {
 +	for (Idler *idler = _idlerHead; idler != 0; idler = idler->_nextIdler)
 +		idler->useIdleTime();
 +}
 +
 +void PegasusEngine::addTimeBase(TimeBase *timeBase) {
 +	_timeBases.push_back(timeBase);
 +}
 +
 +void PegasusEngine::removeTimeBase(TimeBase *timeBase) {
 +	_timeBases.remove(timeBase);
 +}
 +
 +bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 +	// Dispose currently running stuff
 +	useMenu(0);
 +	useNeighborhood(0);
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +	_currentItemID = kNoItemID;
 +	_currentBiochipID = kNoItemID;
 +
 +	if (!g_interface)
 +		createInterface();
 +
 +	// Signature
 +	uint32 creator = stream->readUint32BE();
 +	if (creator != kPegasusPrimeCreator) {
 +		warning("Bad save creator '%s'", tag2str(creator));
 +		return false;
 +	}
 +
 +	uint32 gameType = stream->readUint32BE();
 +	int saveType;
 +
 +	switch (gameType) {
 +	case kPegasusPrimeDisk1GameType:
 +	case kPegasusPrimeDisk2GameType:
 +	case kPegasusPrimeDisk3GameType:
 +	case kPegasusPrimeDisk4GameType:
 +		_currentCD = gameType - kPegasusPrimeDisk1GameType + 1;
 +		saveType = kNormalSave;
 +		break;
 +	case kPegasusPrimeContinueType:
 +		saveType = kContinueSave;
 +		break;
 +	default:
 +		// There are five other possible game types on the Pippin
 +		// version, but hopefully we don't see any of those here
 +		warning("Unhandled pegasus game type '%s'", tag2str(gameType));
 +		return false;
 +	}
 +
 +	uint32 version = stream->readUint32BE();
 +	if (version != kPegasusPrimeVersion) {
 +		warning("Where did you get this save? It's a beta (v%04x)!", version & 0x7fff);
 +		return false;
 +	}
 +
 +	// Game State
 +	GameState.readGameState(stream);
 +
 +	// Energy
 +	setLastEnergyValue(stream->readUint32BE());
 +
 +	// Death reason
 +	setEnergyDeathReason(stream->readByte());
 +
 +	// Items
 +	g_allItems.readFromStream(stream);
 +
 +	// Inventory
 +	byte itemCount = stream->readByte();
 +
 +	if (itemCount > 0) {
 +		for (byte i = 0; i < itemCount; i++) {
 +			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToInventory(inv);
 +		}
 +
 +		g_interface->setCurrentInventoryItemID((ItemID)stream->readUint16BE());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = stream->readByte();
 +
 +	if (biochipCount > 0) {
 +		for (byte i = 0; i < biochipCount; i++) {
 +			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
 +			addItemToBiochips(biochip);
 +		}
 +
 +		g_interface->setCurrentBiochipID((ItemID)stream->readUint16BE());
 +	}
 +
 +
 +	// TODO: Disc check
 +
 +	// Jump to environment
 +	jumpToNewEnvironment(GameState.getCurrentNeighborhood(), GameState.getCurrentRoom(), GameState.getCurrentDirection());
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	performJump(GameState.getCurrentNeighborhood());
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->readAIRules(stream);
 +
 +	startNeighborhood();
 +
 +	// Make a new continue point if this isn't already one
 +	if (saveType == kNormalSave)
 +		makeContinuePoint();
 +
 +	return true;
 +}
 +
 +bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 +	if (g_neighborhood)
 +		g_neighborhood->flushGameState();
 +
 +	// Signature
 +	stream->writeUint32BE(kPegasusPrimeCreator);
 +
 +	if (saveType == kNormalSave)
 +		stream->writeUint32BE(kPegasusPrimeDisk1GameType + _currentCD - 1);
 +	else // Continue
 +		stream->writeUint32BE(kPegasusPrimeContinueType);
 +
 +	stream->writeUint32BE(kPegasusPrimeVersion);
 +
 +	// Game State
 +	GameState.writeGameState(stream);
 +
 +	// Energy
 +	stream->writeUint32BE(getSavedEnergyValue());
 +
 +	// Death reason
 +	stream->writeByte(getEnergyDeathReason());
 +
 +	// Items
 +	g_allItems.writeToStream(stream);
 +
 +	// Inventory
 +	byte itemCount = _items.getNumItems();
 +	stream->writeByte(itemCount);
 +
 +	if (itemCount > 0) {
 +		for (uint32 i = 0; i < itemCount; i++)
 +			stream->writeUint16BE(_items.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentInventoryItem()->getObjectID());
 +	}
 +
 +	// Biochips
 +	byte biochipCount = _biochips.getNumItems();
 +	stream->writeByte(biochipCount);
 +
 +	if (biochipCount > 0) {
 +		for (uint32 i = 0; i < biochipCount; i++)
 +			stream->writeUint16BE(_biochips.getItemIDAt(i));
 +
 +		stream->writeUint16BE(g_interface->getCurrentBiochip()->getObjectID());
 +	}
 +
 +	// AI rules
 +	if (g_AIArea)
 +		g_AIArea->writeAIRules(stream);
 +
 +	return true;
 +}
 +
 +void PegasusEngine::makeContinuePoint() {
 +	// WORKAROUND: Do not attempt to make a continue point if the interface is not set
 +	// up. The original did *not* do this and attempting to restore the game using the pause
 +	// menu during the canyon/space chase sequence would segfault the game and crash the
 +	// system. Nice!
 +	if (!g_interface)
 +		return;
 +
 +	delete _continuePoint;
 +
 +	Common::MemoryWriteStreamDynamic newPoint(DisposeAfterUse::NO);
 +	writeToStream(&newPoint, kContinueSave);
 +	_continuePoint = new Common::MemoryReadStream(newPoint.getData(), newPoint.size(), DisposeAfterUse::YES);
 +}
 +
 +void PegasusEngine::loadFromContinuePoint() {
 +	// Failure to load a continue point is fatal
 +
 +	if (!_continuePoint)
 +		error("Attempting to load from non-existant continue point");
 +
 +	if (!loadFromStream(_continuePoint))
 +		error("Failed loading continue point");
 +}
 +
 +Common::Error PegasusEngine::loadGameState(int slot) {
 +	Common::StringArray filenames = _saveFileMan->listSavefiles("pegasus-*.sav");
 +	Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filenames[slot]);
 +	if (!loadFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = loadFromStream(loadFile);
 +	delete loadFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
 +	Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
 +	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
 +	if (!saveFile)
 +		return Common::kUnknownError;
 +
 +	bool valid = writeToStream(saveFile, kNormalSave);
 +	delete saveFile;
 +
 +	return valid ? Common::kNoError : Common::kUnknownError;
 +}
 +
 +void PegasusEngine::receiveNotification(Notification *notification, const NotificationFlags flags) {
 +	if (&_shellNotification == notification) {
 +		switch (flags) {
 +		case kGameStartingFlag: {
 +			useMenu(new MainMenu());
 +
 +			if (!isDemo()) {
 +				runIntro();
 +				resetIntroTimer();
 +			} else {
 +				showTempScreen("Images/Demo/NGsplashScrn.pict");
 +			}
 +
 +			if (shouldQuit())
 +				return;
 +
 +			_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +			_gfx->updateDisplay();
 +			((MainMenu *)_gameMenu)->startMainMenuLoop();
 +			break;
 +		}
 +		case kPlayerDiedFlag:
 +			doDeath();
 +			break;
 +		case kNeedNewJumpFlag:
 +			performJump(GameState.getNextNeighborhood());
 +			startNeighborhood();
 +			break;
 +		default:
 +			break;
 +		}
 +	}
 +}
 +
 +void PegasusEngine::checkCallBacks() {
 +	for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +		(*it)->checkCallBacks();
 +}
 +
 +void PegasusEngine::resetIntroTimer() {
 +	if (!isDemo() && _gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		_introTimer->stopFuse();
 +		_introTimer->primeFuse(kIntroTimeOut);
 +		_introTimer->lightFuse();
 +	}
 +}
 +
 +void PegasusEngine::introTimerExpired() {
 +	if (_gameMenu && _gameMenu->getObjectID() == kMainMenuID) {
 +		((MainMenu *)_gameMenu)->stopMainMenuLoop();
 +
 +		bool skipped = false;
 +
- 		Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
++		Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +		if (!video->loadFile(_introDirectory + "/LilMovie.movie"))
 +			error("Failed to load little movie");
 +
 +		bool saveAllowed = swapSaveAllowed(false);
 +		bool openAllowed = swapLoadAllowed(false);
 +
++		video->start();
 +		skipped = playMovieScaled(video, 0, 0);
 +
 +		delete video;
 +
 +		if (shouldQuit())
 +			return;
 +
 +		if (!skipped) {
 +			runIntro();
 +
 +			if (shouldQuit())
 +				return;
 +		}
 +
 +		resetIntroTimer();
 +		_gfx->invalRect(Common::Rect(0, 0, 640, 480));
 +
 +		swapSaveAllowed(saveAllowed);
 +		swapLoadAllowed(openAllowed);
 +
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	}
 +}
 +
 +void PegasusEngine::stopIntroTimer() {
 +	if (_introTimer)
 +		_introTimer->stopFuse();
 +}
 +
 +void PegasusEngine::delayShell(TimeValue time, TimeScale scale) {
 +	if (time == 0 || scale == 0)
 +		return;
 +
 +	uint32 startTime = g_system->getMillis();
 +	uint32 timeInMillis = time * 1000 / scale;
 +
 +	while (g_system->getMillis() < startTime + timeInMillis) {
 +		checkCallBacks();
 +		_gfx->updateDisplay();
 +	}
 +}
 +
 +void PegasusEngine::useMenu(GameMenu *newMenu) {
 +	if (_gameMenu) {
 +		_gameMenu->restorePreviousHandler();
 +		delete _gameMenu;
 +	}
 +
 +	_gameMenu = newMenu;
 +
 +	if (_gameMenu)
 +		_gameMenu->becomeCurrentHandler();
 +}
 +
 +bool PegasusEngine::checkGameMenu() {
 +	GameMenuCommand command = kMenuCmdNoCommand;
 +
 +	if (_gameMenu) {
 +		command = _gameMenu->getLastCommand();
 +		if (command != kMenuCmdNoCommand) {
 +			_gameMenu->clearLastCommand();
 +			doGameMenuCommand(command);
 +		}
 +	}
 +
 +	return command != kMenuCmdNoCommand;
 +}
 +
 +void PegasusEngine::doGameMenuCommand(const GameMenuCommand command) {
 +	Common::Error result;
 +
 +	switch (command) {
 +	case kMenuCmdStartAdventure:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(false);
 +		startNewGame();
 +		break;
 +	case kMenuCmdCredits:
 +		if (isDemo()) {
 +			showTempScreen("Images/Demo/DemoCredits.pict");
 +			_gfx->doFadeOutSync();
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		} else {
 +			stopIntroTimer();
 +			_gfx->doFadeOutSync();
 +			useMenu(new CreditsMenu());
 +			_gfx->updateDisplay();
 +			_gfx->doFadeInSync();
 +		}
 +		break;
 +	case kMenuCmdQuit:
 +	case kMenuCmdDeathQuitDemo:
 +		if (isDemo())
 +			showTempScreen("Images/Demo/NGquitScrn.pict");
 +		_system->quit();
 +		break;
 +	case kMenuCmdOverview:
 +		stopIntroTimer();
 +		doInterfaceOverview();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdStartWalkthrough:
 +		stopIntroTimer();
 +		GameState.setWalkthroughMode(true);
 +		startNewGame();
 +		break;
 +	case kMenuCmdRestore:
 +		stopIntroTimer();
 +		// fall through
 +	case kMenuCmdDeathRestore:
 +		result = showLoadDialog();
 +		if (command == kMenuCmdRestore && result.getCode() != Common::kNoError)
 +			resetIntroTimer();
 +		break;
 +	case kMenuCmdCreditsMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdDeathContinue:
 +		if (((DeathMenu *)_gameMenu)->playerWon()) {
 +			if (isDemo()) {
 +				showTempScreen("Images/Demo/DemoCredits.pict");
 +				_gfx->doFadeOutSync();
 +				_gfx->updateDisplay();
 +				_gfx->doFadeInSync();
 +			} else {
 +				_gfx->doFadeOutSync();
 +				useMenu(0);
 +				_gfx->clearScreen();
 +				_gfx->updateDisplay();
 +
- 				Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
++				Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +				if (!video->loadFile(_introDirectory + "/Closing.movie"))
 +					error("Could not load closing movie");
 +
 +				uint16 x = (640 - video->getWidth() * 2) / 2;
 +				uint16 y = (480 - video->getHeight() * 2) / 2;
 +
++				video->start();
 +				playMovieScaled(video, x, y);
 +
 +				delete video;
 +
 +				if (shouldQuit())
 +					return;
 +
 +				useMenu(new MainMenu());
 +				_gfx->updateDisplay();
 +				((MainMenu *)_gameMenu)->startMainMenuLoop();
 +				_gfx->doFadeInSync();
 +				resetIntroTimer();
 +			}
 +		} else {
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdDeathMainMenuDemo:
 +	case kMenuCmdDeathMainMenu:
 +		_gfx->doFadeOutSync();
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdPauseSave:
 +		if (showSaveDialog().getCode() != Common::kUserCanceled)
 +			pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseContinue:
 +		pauseMenu(false);
 +		break;
 +	case kMenuCmdPauseRestore:
 +		makeContinuePoint();
 +		result = showLoadDialog();
 +
 +		if (result.getCode() == Common::kNoError) {
 +			// Successfully loaded, unpause the game
 +			pauseMenu(false);
 +		} else if (result.getCode() != Common::kUserCanceled) {
 +			// Try to get us back to a sane state
 +			loadFromContinuePoint();
 +		}
 +		break;
 +	case kMenuCmdPauseQuit:
 +		_gfx->doFadeOutSync();
 +		throwAwayEverything();
 +		pauseMenu(false);
 +		useMenu(new MainMenu());
 +		_gfx->updateDisplay();
 +		((MainMenu *)_gameMenu)->startMainMenuLoop();
 +		_gfx->doFadeInSync();
 +		resetIntroTimer();
 +		break;
 +	case kMenuCmdNoCommand:
 +		break;
 +	default:
 +		error("Unknown menu command %d", command);
 +	}
 +}
 +
 +void PegasusEngine::handleInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (!checkGameMenu())
 +		shellGameInput(input, cursorSpot);
 +
 +	// Handle the console here
 +	if (input.isConsoleRequested()) {
 +		_console->attach();
 +		_console->onFrame();
 +	}
 +
 +	// Handle save requests here
 +	if (_saveRequested && _saveAllowed) {
 +		_saveRequested = false;
 +
 +		// Can only save during a game and not in the demo
 +		if (g_neighborhood && !isDemo()) {
 +			pauseEngine(true);
 +			showSaveDialog();
 +			pauseEngine(false);
 +		}
 +	}
 +
 +	// Handle load requests here
 +	if (_loadRequested && _loadAllowed) {
 +		_loadRequested = false;
 +
 +		// WORKAROUND: Do not entertain load requests when the pause menu is up
 +		// The original did and the game entered a bad state after loading.
 +		// It's theoretically possible to make it so it does work while the
 +		// pause menu is up, but the pause state of the engine is just too weird.
 +		// Just use the pause menu's restore button since it's there for that
 +		// for you to load anyway.
 +		if (!isDemo() && !(_gameMenu && _gameMenu->getObjectID() == kPauseMenuID)) {
 +			pauseEngine(true);
 +
 +			if (g_neighborhood) {
 +				makeContinuePoint();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError && result.getCode() != Common::kUserCanceled)
 +					loadFromContinuePoint();
 +			} else {
 +				if (_introTimer)
 +					_introTimer->stopFuse();
 +
 +				Common::Error result = showLoadDialog();
 +				if (result.getCode() != Common::kNoError) {
 +					if (!_gameMenu) {
 +						useMenu(new MainMenu());
 +						((MainMenu *)_gameMenu)->startMainMenuLoop();
 +					}
 +
 +					resetIntroTimer();
 +				}
 +			}
 +
 +			pauseEngine(false);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::doInterfaceOverview() {
 +	static const short kNumOverviewSpots = 11;
 +	static const Common::Rect overviewSpots[kNumOverviewSpots] = {
 +		Common::Rect(354, 318, 354 + 204, 318 + 12),
 +		Common::Rect(211, 34, 211 + 114, 34 + 28),
 +		Common::Rect(502, 344, 502 + 138, 344 + 120),
 +		Common::Rect(132, 40, 132 + 79, 40 + 22),
 +		Common::Rect(325, 40, 332 + 115, 40 + 22),
 +		Common::Rect(70, 318, 70 + 284, 318 + 12),
 +		Common::Rect(76, 334, 76 + 96, 334 + 96),
 +		Common::Rect(64, 64, 64 + 512, 64 + 256),
 +		Common::Rect(364, 334, 364 + 96, 334 + 96),
 +		Common::Rect(172, 334, 172 + 192, 334 + 96),
 +		Common::Rect(542, 36, 542 + 58, 36 + 20)
 +	};
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +
 +	Picture leftBackground(kNoDisplayElement);
 +	leftBackground.initFromPICTFile("Images/Interface/OVLeft.mac");
 +	leftBackground.setDisplayOrder(0);
 +	leftBackground.moveElementTo(kBackground1Left, kBackground1Top);
 +	leftBackground.startDisplaying();
 +	leftBackground.show();
 +
 +	Picture topBackground(kNoDisplayElement);
 +	topBackground.initFromPICTFile("Images/Interface/OVTop.mac");
 +	topBackground.setDisplayOrder(0);
 +	topBackground.moveElementTo(kBackground2Left, kBackground2Top);
 +	topBackground.startDisplaying();
 +	topBackground.show();
 +
 +	Picture rightBackground(kNoDisplayElement);
 +	rightBackground.initFromPICTFile("Images/Interface/OVRight.mac");
 +	rightBackground.setDisplayOrder(0);
 +	rightBackground.moveElementTo(kBackground3Left, kBackground3Top);
 +	rightBackground.startDisplaying();
 +	rightBackground.show();
 +
 +	Picture bottomBackground(kNoDisplayElement);
 +	bottomBackground.initFromPICTFile("Images/Interface/OVBottom.mac");
 +	bottomBackground.setDisplayOrder(0);
 +	bottomBackground.moveElementTo(kBackground4Left, kBackground4Top);
 +	bottomBackground.startDisplaying();
 +	bottomBackground.show();
 +
 +	Picture controllerHighlight(kNoDisplayElement);
 +	controllerHighlight.initFromPICTFile("Images/Interface/OVcontrollerHilite.mac");
 +	controllerHighlight.setDisplayOrder(0);
 +	controllerHighlight.moveElementTo(kOverviewControllerLeft, kOverviewControllerTop);
 +	controllerHighlight.startDisplaying();
 +
 +	Movie overviewText(kNoDisplayElement);
 +	overviewText.initFromMovieFile("Images/Interface/Overview Mac.movie");
 +	overviewText.setDisplayOrder(0);
 +	overviewText.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +	overviewText.startDisplaying();
 +	overviewText.show();
 +	overviewText.redrawMovieWorld();
 +
 +	DropHighlight highlight(kNoDisplayElement);
 +	highlight.setDisplayOrder(1);
 +	highlight.startDisplaying();
 +	highlight.setHighlightThickness(4);
 +	highlight.setHighlightColor(g_system->getScreenFormat().RGBToColor(239, 239, 0));
 +	highlight.setHighlightCornerDiameter(8);
 +
 +	Input input;
 +	InputDevice.getInput(input, kFilterAllInput);
 +
 +	Common::Point cursorLoc;
 +	input.getInputLocation(cursorLoc);
 +
 +	uint16 i;
 +	for (i = 0; i < kNumOverviewSpots; ++i)
 +		if (overviewSpots[i].contains(cursorLoc))
 +			break;
 +
 +	TimeValue time;
 +	if (i == kNumOverviewSpots)
 +		time = 5;
 +	else if (i > 4)
 +		time = i + 1;
 +	else
 +		time = i;
 +
 +	if (time == 2) {
 +		highlight.hide();
 +		controllerHighlight.show();
 +	} else if (i != kNumOverviewSpots) {
 +		controllerHighlight.hide();
 +		Common::Rect r = overviewSpots[i];
 +		r.grow(5);
 +		highlight.setBounds(r);
 +		highlight.show();
 +	} else {
 +		highlight.hide();
 +		controllerHighlight.hide();
 +	}
 +
 +	overviewText.setTime(time * 3 + 2, 15);
 +	overviewText.redrawMovieWorld();
 +
 +	_cursor->setCurrentFrameIndex(3);
 +	_cursor->show();
 +
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +
 +	for (;;) {
 +		InputDevice.getInput(input, kFilterAllInput);
 +
 +		if (input.anyInput() || shouldQuit() || _loadRequested || _saveRequested)
 +			break;
 +
 +		input.getInputLocation(cursorLoc);
 +		for (i = 0; i < kNumOverviewSpots; ++i)
 +			if (overviewSpots[i].contains(cursorLoc))
 +				break;
 +
 +		if (i == kNumOverviewSpots)
 +			time = 5;
 +		else if (i > 4)
 +			time = i + 1;
 +		else
 +			time = i;
 +
 +		if (time == 2) {
 +			highlight.hide();
 +			controllerHighlight.show();
 +		} else if (i != kNumOverviewSpots) {
 +			controllerHighlight.hide();
 +			Common::Rect r = overviewSpots[i];
 +			r.grow(5);
 +			highlight.setBounds(r);
 +			highlight.show();
 +		} else {
 +			highlight.hide();
 +			controllerHighlight.hide();
 +		}
 +
 +		overviewText.setTime(time * 3 + 2, 15);
 +		overviewText.redrawMovieWorld();
 +
 +		refreshDisplay();
 +	}
 +
 +	if (shouldQuit())
 +		return;
 +
 +	highlight.hide();
 +	_cursor->hide();
 +
 +	_gfx->doFadeOutSync();
 +	useMenu(new MainMenu());
 +	_gfx->updateDisplay();
 +	((MainMenu *)_gameMenu)->startMainMenuLoop();
 +	_gfx->doFadeInSync();
 +
 +	_saveRequested = false;
 +	_loadRequested = false;
 +}
 +
 +void PegasusEngine::showTempScreen(const Common::String &fileName) {
 +	_gfx->doFadeOutSync();
 +
 +	Picture picture(0);
 +	picture.initFromPICTFile(fileName);
 +	picture.setDisplayOrder(kMaxAvailableOrder);
 +	picture.startDisplaying();
 +	picture.show();
 +	_gfx->updateDisplay();
 +
 +	_gfx->doFadeInSync();
 +
 +	// Wait for the next event
 +	bool done = false;
 +	while (!shouldQuit() && !done) {
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event)) {
 +			switch (event.type) {
 +			case Common::EVENT_LBUTTONUP:
 +			case Common::EVENT_RBUTTONUP:
 +			case Common::EVENT_KEYDOWN:
 +				done = true;
 +				break;
 +			default:
 +				break;
 +			}
 +		}
 +
 +		_system->delayMillis(10);
 +	}
 +}
 +
 +void PegasusEngine::refreshDisplay() {
 +	giveIdleTime();
 +	_gfx->updateDisplay();
 +}
 +
 +void PegasusEngine::resetEnergyDeathReason() {
 +	switch (getCurrentNeighborhoodID()) {
 +	case kMarsID:
 +		_deathReason = kDeathArrestedInMars;
 +		break;
 +	case kNoradAlphaID:
 +	case kNoradDeltaID:
 +		_deathReason = kDeathArrestedInNorad;
 +		break;
 +	case kWSCID:
 +		_deathReason = kDeathArrestedInWSC;
 +		break;
 +	default:
 +		_deathReason = kDeathStranded;
 +		break;
 +	}
 +}
 +
 +bool PegasusEngine::playerHasItem(const Item *item) {
 +	return playerHasItemID(item->getObjectID());
 +}
 +
 +bool PegasusEngine::playerHasItemID(const ItemID itemID) {
 +	return itemInInventory(itemID) || itemInBiochips(itemID);
 +}
 +
 +InventoryItem *PegasusEngine::getCurrentInventoryItem() {
 +	if (g_interface)
 +		return g_interface->getCurrentInventoryItem();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInInventory(InventoryItem *item) {
 +	return _items.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInInventory(ItemID id) {
 +	return _items.itemInInventory(id);
 +}
 +
 +BiochipItem *PegasusEngine::getCurrentBiochip() {
 +	if (g_interface)
 +		return g_interface->getCurrentBiochip();
 +
 +	return 0;
 +}
 +
 +bool PegasusEngine::itemInBiochips(BiochipItem *item) {
 +	return _biochips.itemInInventory(item);
 +}
 +
 +bool PegasusEngine::itemInBiochips(ItemID id) {
 +	return _biochips.itemInInventory(id);
 +}
 +
 +bool PegasusEngine::playerAlive() {
 +	return (_shellNotification.getNotificationFlags() & kPlayerDiedFlag) == 0;
 +}
 +
 +Common::String PegasusEngine::getBriefingMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getBriefingMovie();
 +
 +	return Common::String();
 +}
 +
 +Common::String PegasusEngine::getEnvScanMovie() {
 +	if (_neighborhood)
 +		return _neighborhood->getEnvScanMovie();
 +
 +	return Common::String();
 +}
 +
 +uint PegasusEngine::getNumHints() {
 +	if (_neighborhood)
 +		return _neighborhood->getNumHints();
 +
 +	return 0;
 +}
 +
 +Common::String PegasusEngine::getHintMovie(uint hintNum) {
 +	if (_neighborhood)
 +		return _neighborhood->getHintMovie(hintNum);
 +
 +	return Common::String();
 +}
 +
 +bool PegasusEngine::canSolve() {
 +	if (_neighborhood)
 +		return _neighborhood->canSolve();
 +
 +	return false;
 +}
 +
 +void PegasusEngine::prepareForAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->prepareForAIHint(movieName);
 +}
 +
 +void PegasusEngine::cleanUpAfterAIHint(const Common::String &movieName) {
 +	if (g_neighborhood)
 +		g_neighborhood->cleanUpAfterAIHint(movieName);
 +}
 +
 +void PegasusEngine::jumpToNewEnvironment(const NeighborhoodID neighborhoodID, const RoomID roomID, const DirectionConstant direction) {
 +	GameState.setNextLocation(neighborhoodID, roomID, direction);
 +	_shellNotification.setNotificationFlags(kNeedNewJumpFlag, kNeedNewJumpFlag);
 +}
 +
 +void PegasusEngine::checkFlashlight() {
 +	if (_neighborhood)
 +		_neighborhood->checkFlashlight();
 +}
 +
- bool PegasusEngine::playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y) {
++bool PegasusEngine::playMovieScaled(Video::VideoDecoder *video, uint16 x, uint16 y) {
 +	bool skipped = false;
 +
 +	while (!shouldQuit() && !video->endOfVideo() && !skipped) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, x, y);
 +		}
 +
 +		Input input;
 +		InputDevice.getInput(input, kFilterAllInput);
 +		if (input.anyInput() || _saveRequested || _loadRequested)
 +			skipped = true;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	return skipped;
 +}
 +
 +void PegasusEngine::die(const DeathReason reason) {
 +	Input dummy;
 +	if (isDragging())
 +		_itemDragger.stopTracking(dummy);
 +
 +	_deathReason = reason;
 +	_shellNotification.setNotificationFlags(kPlayerDiedFlag, kPlayerDiedFlag);
 +}
 +
 +void PegasusEngine::doDeath() {
 +	_gfx->doFadeOutSync();
 +	throwAwayEverything();
 +	useMenu(new DeathMenu(_deathReason));
 +	_gfx->updateDisplay();
 +	_gfx->doFadeInSync();
 +}
 +
 +void PegasusEngine::throwAwayEverything() {
 +	if (_items.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentInventoryItem()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	if (_biochips.getNumItems() != 0 && g_interface)
 +		_currentItemID = g_interface->getCurrentBiochip()->getObjectID();
 +	else
 +		_currentItemID = kNoItemID;
 +
 +	useMenu(0);
 +	useNeighborhood(0);
 +
 +	delete g_interface;
 +	g_interface = 0;
 +}
 +
 +void PegasusEngine::processShell() {
 +	checkCallBacks();
 +	checkNotifications();
 +	InputHandler::pollForInput();
 +	refreshDisplay();
 +}
 +
 +void PegasusEngine::createInterface() {
 +	if (!g_interface)
 +		new Interface();
 +
 +	g_interface->createInterface();
 +}
 +
 +void PegasusEngine::setGameMode(const GameMode newMode) {
 +	if (newMode != _gameMode && canSwitchGameMode(newMode, _gameMode)) {
 +		switchGameMode(newMode, _gameMode);
 +		_gameMode = newMode;
 +	}
 +}
 +
 +void PegasusEngine::switchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	// Start raising panels before lowering panels, to give the activating panel time
 +	// to set itself up without cutting into the lowering panel's animation time.
 +	
 +	if (_switchModesSync) {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawerSync();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawerSync();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawerSync();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawerSync();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	} else {
 +		if (newMode == kModeInventoryPick)
 +			raiseInventoryDrawer();
 +		else if (newMode == kModeBiochipPick)
 +			raiseBiochipDrawer();
 +		else if (newMode == kModeInfoScreen)
 +			showInfoScreen();
 +		
 +		if (oldMode == kModeInventoryPick)
 +			lowerInventoryDrawer();
 +		else if (oldMode == kModeBiochipPick)
 +			lowerBiochipDrawer();
 +		else if (oldMode == kModeInfoScreen)
 +			hideInfoScreen();
 +	}
 +}
 +
 +bool PegasusEngine::canSwitchGameMode(const GameMode newMode, const GameMode oldMode) {
 +	if (newMode == kModeInventoryPick && oldMode == kModeBiochipPick)
 +		return false;
 +	if (newMode == kModeBiochipPick && oldMode == kModeInventoryPick)
 +		return false;
 +	return true;
 +}
 +
 +bool PegasusEngine::itemInLocation(const ItemID itemID, const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction) {
 +	NeighborhoodID itemNeighborhood;
 +	RoomID itemRoom;
 +	DirectionConstant itemDirection;
 +	
 +	Item *item = g_allItems.findItemByID(itemID);
 +	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 +
 +	return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
 +}
 +
 +InventoryResult PegasusEngine::addItemToInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	do {
 +		if (g_interface)
 +			result = g_interface->addInventoryItem(item);
 +		else
 +			result = _items.addItem(item);
 +
 +		if (result == kTooMuchWeight)
 +			destroyInventoryItem(pickItemToDestroy());
 +	} while (result != kInventoryOK);
 +
 +	GameState.setTakenItem(item, true);
 +	if (g_neighborhood)
 +			g_neighborhood->pickedUpItem(item);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::useNeighborhood(Neighborhood *neighborhood) {
 +	delete _neighborhood;
 +	_neighborhood = neighborhood;
 +
 +	if (_neighborhood) {
 +		InputHandler::setInputHandler(_neighborhood);
 +		_neighborhood->init();
 +		_neighborhood->moveNavTo(kNavAreaLeft, kNavAreaTop);
 +		g_interface->setDate(_neighborhood->getDateResID());
 +	} else {
 +		InputHandler::setInputHandler(this);
 +	}
 +}
 +
 +void PegasusEngine::performJump(NeighborhoodID neighborhoodID) {
 +	if (_neighborhood)
 +		useNeighborhood(0);
 +
 +	// Sub chase is special
 +	if (neighborhoodID == kNoradSubChaseID) {
 +		throwAwayEverything();
 +		doSubChase();
 +
 +		if (shouldQuit())
 +			return;
 +
 +		neighborhoodID = kNoradDeltaID;
 +		GameState.setNextRoom(kNorad41);
 +		GameState.setNextDirection(kEast);
 +	}
 +
 +	Neighborhood *neighborhood;
 +	makeNeighborhood(neighborhoodID, neighborhood);
 +	useNeighborhood(neighborhood);
 +
 +	// Update the CD variable (used just for saves currently)
 +	_currentCD = getNeighborhoodCD(neighborhoodID);
 +}
 +
 +void PegasusEngine::startNeighborhood() {
 +	if (g_interface && _currentItemID != kNoItemID)
 +		g_interface->setCurrentInventoryItemID(_currentItemID);
 +	
 +	if (g_interface && _currentBiochipID != kNoItemID)
 +		g_interface->setCurrentBiochipID(_currentBiochipID);
 +	
 +	setGameMode(kModeNavigation);
 +	
 +	if (_neighborhood)
 +		_neighborhood->start();
 +}
 +
 +void PegasusEngine::startNewGame() {
 +	// WORKAROUND: The original game ignored the menu difficulty
 +	// setting. We're going to pass it through here so that
 +	// the menu actually makes sense now.
 +	bool isWalkthrough = GameState.getWalkthroughMode();
 +	GameState.resetGameState();
 +	GameState.setWalkthroughMode(isWalkthrough);
 +
 +	// TODO: Enable erase
 +	_gfx->doFadeOutSync();
 +	useMenu(0);
 +	_gfx->updateDisplay();
 +	_gfx->enableUpdates();
 +
 +	createInterface();
 +
 +	if (isDemo()) {
 +		setLastEnergyValue(kFullEnergy);
 +		jumpToNewEnvironment(kPrehistoricID, kPrehistoric02, kSouth);
 +		GameState.setPrehistoricSeenTimeStream(false);
 +		GameState.setPrehistoricSeenFlyer1(false);
 +		GameState.setPrehistoricSeenFlyer2(false);
 +		GameState.setPrehistoricSeenBridgeZoom(false);
 +		GameState.setPrehistoricBreakerThrown(false);
 +	} else {
 +		jumpToNewEnvironment(kCaldoriaID, kCaldoria00, kEast);
 +	}
 +
 +	removeAllItemsFromInventory();
 +	removeAllItemsFromBiochips();
 +
 +	BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
 +	addItemToBiochips(biochip);
 +
 +	if (isDemo()) {
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
 +		addItemToBiochips(biochip);
 +		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
 +		addItemToBiochips(biochip);
 +		InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
 +		addItemToInventory(item);
 +		item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
 +		addItemToInventory(item);
 +		_currentItemID = kJourneymanKey;
 +	} else {
 +		_currentItemID = kNoItemID;
 +	}
 +
 +	_currentBiochipID = kAIBiochip;
 +
 +	// Clear jump notification flags and just perform the jump...
 +	_shellNotification.setNotificationFlags(0, kNeedNewJumpFlag);
 +	
 +	performJump(GameState.getNextNeighborhood());
 +	
 +	startNeighborhood();
 +}
 +
 +void PegasusEngine::makeNeighborhood(NeighborhoodID neighborhoodID, Neighborhood *&neighborhood) {
 +	// TODO: CD check
 +
 +	switch (neighborhoodID) {
 +	case kCaldoriaID:
 +		neighborhood = new Caldoria(g_AIArea, this);
 +		break;
 +	case kMarsID:
 +		neighborhood = new Mars(g_AIArea, this);
 +		break;
 +	case kPrehistoricID:
 +		neighborhood = new Prehistoric(g_AIArea, this);
 +		break;
 +	case kFullTSAID:
 +		neighborhood = new FullTSA(g_AIArea, this);
 +		break;
 +	case kTinyTSAID:
 +		neighborhood = new TinyTSA(g_AIArea, this);
 +		break;
 +	case kWSCID:
 +		neighborhood = new WSC(g_AIArea, this);
 +		break;
 +	case kNoradAlphaID:
 +		neighborhood = new NoradAlpha(g_AIArea, this);
 +		break;
 +	case kNoradDeltaID:
 +		createInterface();
 +		neighborhood = new NoradDelta(g_AIArea, this);
 +		break;
 +	default:
 +		error("Unknown neighborhood %d", neighborhoodID);
 +	}
 +}
 +
 +bool PegasusEngine::wantsCursor() {
 +	return _gameMenu == 0;
 +}
 +
 +void PegasusEngine::updateCursor(const Common::Point, const Hotspot *cursorSpot) {	
 +	if (_itemDragger.isTracking()) {
 +		_cursor->setCurrentFrameIndex(5);
 +	} else {
 +		if (!cursorSpot) {
 +			_cursor->setCurrentFrameIndex(0);
 +		} else {
 +			uint32 id = cursorSpot->getObjectID();
 +
 +			switch (id) {
 +			case kCurrentItemSpotID:
 +				if (countInventoryItems() != 0)
 +					_cursor->setCurrentFrameIndex(4);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +				break;
 +			default:
 +				HotSpotFlags flags = cursorSpot->getHotspotFlags();
 +
 +				if (flags & kZoomInSpotFlag)
 +					_cursor->setCurrentFrameIndex(1);
 +				else if (flags & kZoomOutSpotFlag)
 +					_cursor->setCurrentFrameIndex(2);
 +				else if (flags & (kPickUpItemSpotFlag | kPickUpBiochipSpotFlag))
 +					_cursor->setCurrentFrameIndex(4);
 +				else if (flags & kJMPClickingSpotFlags)
 +					_cursor->setCurrentFrameIndex(3);
 +				else
 +					_cursor->setCurrentFrameIndex(0);
 +			}
 +		}
 +	}
 +}
 +
 +void PegasusEngine::toggleInventoryDisplay() {
 +	if (_gameMode == kModeInventoryPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeInventoryPick);
 +}
 +
 +void PegasusEngine::toggleBiochipDisplay() {
 +	if (_gameMode == kModeBiochipPick)
 +		setGameMode(kModeNavigation);
 +	else
 +		setGameMode(kModeBiochipPick);
 +}
 +
 +void PegasusEngine::showInfoScreen() {	
 +	if (g_neighborhood) {
 +		// Break the input handler chain...
 +		_savedHandler = InputHandler::getCurrentHandler();
 +		InputHandler::setInputHandler(this);
 +		
 +		Picture *pushPicture = ((Neighborhood *)g_neighborhood)->getTurnPushPicture();
 +		
 +		_bigInfoMovie.shareSurface(pushPicture);
 +		_smallInfoMovie.shareSurface(pushPicture);
 +
 +		g_neighborhood->hideNav();
 +
 +		_smallInfoMovie.initFromMovieFile("Images/Items/Info Right Movie");
 +		_smallInfoMovie.setDisplayOrder(kInfoSpinOrder);
 +		_smallInfoMovie.moveElementTo(kNavAreaLeft + 304, kNavAreaTop + 8);
 +		_smallInfoMovie.moveMovieBoxTo(304, 8);
 +		_smallInfoMovie.startDisplaying();
 +		_smallInfoMovie.show();
 +
 +		TimeValue startTime, stopTime;
 +		g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +		_smallInfoMovie.setSegment(startTime, stopTime);
 +		_smallInfoMovie.setTime(startTime);
 +		_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +		_bigInfoMovie.initFromMovieFile("Images/Items/Info Left Movie");
 +		_bigInfoMovie.setDisplayOrder(kInfoBackgroundOrder);
 +		_bigInfoMovie.moveElementTo(kNavAreaLeft, kNavAreaTop);
 +		_bigInfoMovie.startDisplaying();
 +		_bigInfoMovie.show();
 +		_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +
 +		_bigInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.redrawMovieWorld();
 +		_smallInfoMovie.start();
 +	}
 +}
 +
 +void PegasusEngine::hideInfoScreen() {
 +	if (g_neighborhood) {
 +		InputHandler::setInputHandler(_savedHandler);
 +
 +		_bigInfoMovie.hide();
 +		_bigInfoMovie.stopDisplaying();
 +		_bigInfoMovie.releaseMovie();
 +
 +		_smallInfoMovie.hide();
 +		_smallInfoMovie.stopDisplaying();
 +		_smallInfoMovie.stop();
 +		_smallInfoMovie.releaseMovie();
 +
 +		g_neighborhood->showNav();
 +	}
 +}
 +
 +void PegasusEngine::raiseInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawer();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawer();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawer() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawer();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawer() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawer();
 +}
 +
 +void PegasusEngine::raiseInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::raiseBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->raiseBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::lowerInventoryDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerInventoryDrawerSync();
 +}
 +
 +void PegasusEngine::lowerBiochipDrawerSync() {
 +	if (g_interface)
 +		g_interface->lowerBiochipDrawerSync();
 +}
 +
 +void PegasusEngine::toggleInfo() {
 +	if (_gameMode == kModeInfoScreen)
 +		setGameMode(kModeNavigation);
 +	else if (_gameMode == kModeNavigation)
 +		setGameMode(kModeInfoScreen);
 +}
 +
 +void PegasusEngine::dragTerminated(const Input &) {
 +	Hotspot *finalSpot = _itemDragger.getLastHotspot();
 +	InventoryResult result;
 +
 +	if (_dragType == kDragInventoryPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kInventoryDropSpotID)
 +			result = addItemToInventory((InventoryItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragBiochipPickup) {
 +		if (finalSpot && finalSpot->getObjectID() == kBiochipDropSpotID)
 +			result = addItemToBiochips((BiochipItem *)_draggingItem);
 +		else
 +			result = kTooMuchWeight;
 +
 +		if (result != kInventoryOK)
 +			autoDragItemIntoRoom(_draggingItem, _draggingSprite);
 +		else
 +			delete _draggingSprite;
 +	} else if (_dragType == kDragInventoryUse) {
 +		if (finalSpot && (finalSpot->getHotspotFlags() & kDropItemSpotFlag) != 0) {
 +			// *** Need to decide on a case by case basis what to do here.
 +			// the crowbar should break the cover off the Mars reactor if its frozen, the
 +			// global transport card should slide through the slot, the oxygen mask should
 +			// attach to the filling station, and so on...
 +			_neighborhood->dropItemIntoRoom(_draggingItem, finalSpot);
 +			delete _draggingSprite;
 +		} else {
 +			autoDragItemIntoInventory(_draggingItem, _draggingSprite);
 +		}
 +	}
 +
 +	_dragType = kDragNoDrag;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +
 +void PegasusEngine::dragItem(const Input &input, Item *item, DragType type) {	
 +	_draggingItem = item;
 +	_dragType = type;
 +
 +	// Create the sprite.
 +	_draggingSprite = _draggingItem->getDragSprite(kDraggingSpriteID);
 +	Common::Point where;
 +	input.getInputLocation(where);
 +	Common::Rect r1;
 +	_draggingSprite->getBounds(r1);
 +	r1 = Common::Rect::center(where.x, where.y, r1.width(), r1.height());
 +	_draggingSprite->setBounds(r1);
 +
 +	// Set up drag constraints.
 +	DisplayElement *navMovie = _gfx->findDisplayElement(kNavMovieID);
 +	Common::Rect r2;
 +	navMovie->getBounds(r2);
 +	r2.left -= r1.width() / 3;
 +	r2.right += r1.width() / 3;
 +	r2.top -= r1.height() / 3;
 +	r2.bottom += r2.height() / 3;
 +
 +	r1 = Common::Rect(-30000, -30000, 30000, 30000);
 +	_itemDragger.setDragConstraints(r2, r1);
 +
 +	// Start dragging.
 +	_draggingSprite->setDisplayOrder(kDragSpriteOrder);
 +	_draggingSprite->startDisplaying();
 +	_draggingSprite->show();
 +	_itemDragger.setDragSprite(_draggingSprite);
 +	_itemDragger.setNextHandler(_neighborhood);
 +	_itemDragger.startTracking(input);
 +
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +}
 +
 +void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_gameMode == kModeInfoScreen) {
 +		if (JMPPPInput::isToggleAIMiddleInput(input)) {
 +			LowerClientSignature middleOwner = g_AIArea->getMiddleAreaOwner();
 +			g_AIArea->toggleMiddleAreaOwner();
 +
 +			if (middleOwner != g_AIArea->getMiddleAreaOwner()) {
 +				_bigInfoMovie.setTime(g_AIArea->getBigInfoTime());
 +				_smallInfoMovie.stop();
 +				_smallInfoMovie.setFlags(0);
 +
 +				TimeValue startTime, stopTime;
 +				g_AIArea->getSmallInfoSegment(startTime, stopTime);
 +				_smallInfoMovie.setSegment(startTime, stopTime);
 +				_smallInfoMovie.setTime(startTime);
 +				_smallInfoMovie.setFlags(kLoopTimeBase);
 +
 +				_bigInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.redrawMovieWorld();
 +				_smallInfoMovie.start();
 +			}
 +		}
 +	} else {
 +		if (JMPPPInput::isRaiseInventoryInput(input))
 +			toggleInventoryDisplay();
 +
 +		if (JMPPPInput::isRaiseBiochipsInput(input))
 +			toggleBiochipDisplay();
 +
 +		if (JMPPPInput::isTogglePauseInput(input) && _neighborhood)
 +			pauseMenu(!isPaused());
 +	}
 +
 +	if (JMPPPInput::isToggleInfoInput(input))
 +		toggleInfo();
 +}
 +
 +void PegasusEngine::activateHotspots() {
 +	if (_gameMode == kModeInfoScreen) {
 +		g_allHotspots.activateOneHotspot(kInfoReturnSpotID);
 +	} else {
 +		// Set up hot spots.
 +		if (_dragType == kDragInventoryPickup)
 +			g_allHotspots.activateOneHotspot(kInventoryDropSpotID);
 +		else if (_dragType == kDragBiochipPickup)
 +			g_allHotspots.activateOneHotspot(kBiochipDropSpotID);
 +		else if (_dragType == kDragNoDrag)
 +			g_allHotspots.activateMaskedHotspots(kShellSpotFlag);
 +	}
 +}
 +
 +bool PegasusEngine::isClickInput(const Input &input, const Hotspot *cursorSpot) {
 +	if (_cursor->isVisible() && cursorSpot)
 +		return JMPPPInput::isClickInput(input);
 +	else
 +		return false;
 +}
 +
 +InputBits PegasusEngine::getClickFilter() {
 +	return JMPPPInput::getClickInputFilter();
 +}
 +
 +void PegasusEngine::clickInHotspot(const Input &input, const Hotspot *clickedSpot) {
 +	if (clickedSpot->getObjectID() == kCurrentItemSpotID) {
 +		InventoryItem *currentItem = getCurrentInventoryItem();
 +		if (currentItem) {
 +			removeItemFromInventory(currentItem);
 +			dragItem(input, currentItem, kDragInventoryUse);
 +		}
 +	} else if (clickedSpot->getObjectID() == kInfoReturnSpotID) {
 +		toggleInfo();
 +	}
 +}
 +
 +InventoryResult PegasusEngine::removeItemFromInventory(InventoryItem *item) {
 +	InventoryResult result;
 +	
 +	if (g_interface)
 +		result = g_interface->removeInventoryItem(item);
 +	else
 +		result = _items.removeItem(item);
 +
 +	// This should never happen
 +	assert(result == kInventoryOK);
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromInventory() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromInventory();
 +	else
 +		_items.removeAllItems();
 +}
 +
 +/////////////////////////////////////////////
 +//
 +// Biochip handling.
 +
 +// Adding biochips to the biochip drawer is a little funny, because of two things:
 +//      --  We get the map biochip and pegasus biochip at the same time by dragging
 +//          one sprite in TSA
 +//      --  We can drag in more than one copy of the various biochips.
 +// Because of this we need to make sure that no more than one copy of each biochip
 +// is ever added.
 +
 +InventoryResult PegasusEngine::addItemToBiochips(BiochipItem *biochip) {
 +	InventoryResult result;
 +
 +	if (g_interface)
 +		result = g_interface->addBiochip(biochip);
 +	else
 +		result = _biochips.addItem(biochip);
 +
 +	// This can never happen
 +	assert(result == kInventoryOK);
 +
 +	GameState.setTakenItem(biochip, true);
 +
 +	if (g_neighborhood)
 +		g_neighborhood->pickedUpItem(biochip);
 +
 +	g_AIArea->checkMiddleArea();
 +
 +	return result;
 +}
 +
 +void PegasusEngine::removeAllItemsFromBiochips() {
 +	if (g_interface)
 +		g_interface->removeAllItemsFromBiochips();
 +	else
 +		_biochips.removeAllItems();
 +}
 +
 +void PegasusEngine::setSoundFXLevel(uint16 fxLevel) {
 +	_FXLevel = fxLevel;
 +	if (_neighborhood)
 +		_neighborhood->setSoundFXLevel(fxLevel);
 +	if (g_AIArea)
 +		g_AIArea->setAIVolume(fxLevel);
 +}
 +
 +void PegasusEngine::setAmbienceLevel(uint16 ambientLevel) {
 +	_ambientLevel = ambientLevel;
 +	if (_neighborhood)
 +		_neighborhood->setAmbienceLevel(ambientLevel);
 +}
 +
 +void PegasusEngine::pauseMenu(bool menuUp) {
 +	if (menuUp) {
 +		pauseEngine(true);
 +		_screenDimmer.startDisplaying();
 +		_screenDimmer.show();
 +		_gfx->updateDisplay();
 +		useMenu(new PauseMenu());
 +	} else {
 +		pauseEngine(false);
 +		_screenDimmer.hide();
 +		_screenDimmer.stopDisplaying();
 +		useMenu(0);
 +		g_AIArea->checkMiddleArea();
 +	}
 +}
 +
 +void PegasusEngine::autoDragItemIntoRoom(Item *item, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start, stop;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Hotspot *dropSpot = _neighborhood->getItemScreenSpot(item, draggingSprite);
 +
 +	if (dropSpot) {
 +		dropSpot->getCenter(stop.x, stop.y);
 +	} else {
 +		stop.x = kNavAreaLeft + 256;
 +		stop.y = kNavAreaTop + 128;
 +	}
 +
 +	Common::Rect bounds;
 +	draggingSprite->getBounds(bounds);
 +	stop.x -= bounds.width() >> 1;
 +	stop.y -= bounds.height() >> 1;
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	_neighborhood->dropItemIntoRoom(_draggingItem, dropSpot);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +void PegasusEngine::autoDragItemIntoInventory(Item *, Sprite *draggingSprite) {	
 +	if (g_AIArea)
 +		g_AIArea->lockAIOut();
 +
 +	Common::Point start;
 +	draggingSprite->getLocation(start.x, start.y);
 +
 +	Common::Rect r;
 +	draggingSprite->getBounds(r);
 +
 +	Common::Point stop((76 + 172 - r.width()) / 2, 334 - (2 * r.height() / 3));
 +
 +	int dx = ABS(stop.x - start.x);
 +	int dy = ABS(stop.y - start.y);
 +	TimeValue time = MAX(dx, dy);
 +
 +	allowInput(false);
 +	_autoDragger.autoDrag(draggingSprite, start, stop, time, kDefaultTimeScale);
 +
 +	while (_autoDragger.isDragging()) {
 +		checkCallBacks();
 +		refreshDisplay();
 +		_system->delayMillis(10);
 +	}
 +
 +	addItemToInventory((InventoryItem *)_draggingItem);
 +	allowInput(true);
 +	delete _draggingSprite;
 +
 +	if (g_AIArea)
 +		g_AIArea->unlockAI();
 +}
 +
 +NeighborhoodID PegasusEngine::getCurrentNeighborhoodID() const {
 +	if (_neighborhood)
 +		return _neighborhood->getObjectID();
 +
 +	return kNoNeighborhoodID;
 +}
 +
 +void PegasusEngine::pauseEngineIntern(bool pause) {
 +	Engine::pauseEngineIntern(pause);
 +
 +	if (pause) {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->pause();
 +	} else {
 +		for (Common::List<TimeBase *>::iterator it = _timeBases.begin(); it != _timeBases.end(); it++)
 +			(*it)->resume();
 +	}
 +}
 +
 +uint PegasusEngine::getRandomBit() {
 +	return _rnd->getRandomBit();
 +}
 +
 +uint PegasusEngine::getRandomNumber(uint max) {
 +	return _rnd->getRandomNumber(max);
 +}
 +
 +void PegasusEngine::shuffleArray(int32 *arr, int32 count) {	
 +	if (count > 1) {
 +		for (int32 i = 1; i < count; ++i) {
 +			int32 j = _rnd->getRandomNumber(i);
 +			if (j != i)
 +				SWAP(arr[i], arr[j]);
 +		}
 +	}
 +}
 +
 +void PegasusEngine::playEndMessage() {
 +	if (g_interface) {
 +		allowInput(false);
 +		g_interface->playEndMessage();
 +		allowInput(true);
 +	}
 +
 +	die(kPlayerWonGame);
 +}
 +
 +void PegasusEngine::doSubChase() {
 +	static const uint32 endTime = 133200 * 1000 / 600;
 +
- 	Video::SeekableVideoDecoder *video = new Video::QuickTimeDecoder();
++	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 +	if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie"))
 +		error("Failed to load sub chase");
 +
++	video->start();
++
 +	while (!shouldQuit() && !video->endOfVideo() && video->getTime() < endTime) {
 +		if (video->needsUpdate()) {
 +			const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +			if (frame)
 +				drawScaledFrame(frame, 0, 0);
 +		}
 +
 +		Common::Event event;
 +		while (_eventMan->pollEvent(event))
 +			;
 +
 +		_system->delayMillis(10);
 +	}
 +
 +	delete video;
 +}
 +
 +template<typename PixelInt>
 +static void scaleFrame(const PixelInt *src, PixelInt *dst, int w, int h, int srcPitch) {
 +	assert((srcPitch % sizeof(PixelInt)) == 0); // sanity check; allows some simpler code
 +
 +	PixelInt *dst1 = dst;
 +	PixelInt *dst2 = dst + w * 2;
 +
 +	int srcInc = (srcPitch / sizeof(PixelInt)) - w;
 +	int dstInc = w * 2;
 +
 +	while (h--) {
 +		for (int x = 0; x < w; x++) {
 +			PixelInt pixel = *src++;
 +			*dst1++ = pixel;
 +			*dst1++ = pixel;
 +			*dst2++ = pixel;
 +			*dst2++ = pixel;
 +		}
 +
 +		src += srcInc;
 +		dst1 += dstInc;
 +		dst2 += dstInc;
 +	}
 +}
 +
 +void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y) {
 +	// Scale up the frame doing some simple scaling
 +	Graphics::Surface scaledFrame;
 +	scaledFrame.create(frame->w * 2, frame->h * 2, frame->format);
 +
 +	if (frame->format.bytesPerPixel == 2)
 +		scaleFrame<uint16>((uint16 *)frame->pixels, (uint16 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
 +	else
 +		scaleFrame<uint32>((uint32 *)frame->pixels, (uint32 *)scaledFrame.pixels, frame->w, frame->h, frame->pitch);
 +
 +	_system->copyRectToScreen((byte *)scaledFrame.pixels, scaledFrame.pitch, x, y, scaledFrame.w, scaledFrame.h);
 +	_system->updateScreen();
 +	scaledFrame.free();
 +}
 +
 +void PegasusEngine::destroyInventoryItem(const ItemID itemID) {
 +	InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
 +
 +	ItemExtraEntry entry;
 +
 +	switch (itemID) {
 +	case kAirMask:
 +		item->findItemExtra(kRemoveAirMask, entry);
 +		item->setItemRoom(kMarsID, kMars49, kSouth);
 +		break;
 +	case kArgonCanister:
 +		item->findItemExtra(kRemoveArgon, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	case kCrowbar:
 +		item->findItemExtra(kRemoveCrowbar, entry);
 +		item->setItemRoom(kMarsID, kMars34, kSouth);
 +		break;
 +	case kJourneymanKey:
 +		item->findItemExtra(kRemoveJourneymanKey, entry);
 +		item->setItemRoom(kFullTSAID, kTSA22Red, kEast);
 +		break;
 +	case kMarsCard:
 +		item->findItemExtra(kRemoveMarsCard, entry);
 +		item->setItemRoom(kMarsID, kMars31South, kSouth);
 +		break;
 +	case kNitrogenCanister:
 +		item->findItemExtra(kRemoveNitrogen, entry);
 +		item->setItemRoom(kWSCID, kWSC02Messages, kSouth);
 +		break;
 +	case kOrangeJuiceGlassEmpty:
 +		item->findItemExtra(kRemoveGlass, entry);
 +		item->setItemRoom(kCaldoriaID, kCaldoriaReplicator, kNorth);
 +		break;
 +	case kPoisonDart:
 +		item->findItemExtra(kRemoveDart, entry);
 +		item->setItemRoom(kWSCID, kWSC01, kWest);
 +		break;
 +	case kSinclairKey:
 +		item->findItemExtra(kRemoveSinclairKey, entry);
 +		item->setItemRoom(kWSCID, kWSC02Morph, kSouth);
 +		break;
 +	default:
 +		return;
 +	}
 +
 +	g_interface->setCurrentInventoryItemID(itemID);
 +	g_AIArea->playAIAreaSequence(kInventorySignature, kMiddleAreaSignature, entry.extraStart, entry.extraStop);
 +	removeItemFromInventory(item);
 +}
 +
 +ItemID PegasusEngine::pickItemToDestroy() {
 +/*
 +	Must pick an item to destroy
 +	
 +	Part I: Polite -- try to find an item that's been used
 +	Part II: Desperate -- return the first available item.
 +*/
 +
 +	// Polite:
 +	if (playerHasItemID(kOrangeJuiceGlassEmpty))
 +		return kOrangeJuiceGlassEmpty;
 +	if (playerHasItemID(kPoisonDart)) {
 +		if (GameState.getCurrentNeighborhood() != kWSCID ||
 +				GameState.getWSCAnalyzedDart())
 +			return kPoisonDart;
 +	}
 +	if (playerHasItemID(kJourneymanKey)) {
 +		if (GameState.getTSAState() >= kTSAPlayerGotHistoricalLog &&
 +				GameState.getTSAState() != kPlayerOnWayToPrehistoric &&
 +				GameState.getTSAState() != kPlayerWentToPrehistoric)
 +			return kJourneymanKey;
 +	}
 +	if (playerHasItemID(kMarsCard)) {
 +		if (GameState.getCurrentNeighborhood() != kMarsID || GameState.getMarsArrivedBelow())
 +			return kMarsCard;
 +	}
 +
 +	// Don't want to deal with deleting the sinclair key and argon canister, since it's
 +	// impossible to pick them up one at a time.
 +
 +	if (playerHasItemID(kNitrogenCanister)) {
 +		if (GameState.getScoringGotCardBomb() && GameState.getCurrentNeighborhood() != kMarsID)
 +			return kNitrogenCanister;
 +	}
 +	if (playerHasItemID(kCrowbar)) {
 +		if (GameState.getCurrentNeighborhood() == kWSCID) {
 +			if (GameState.getCurrentRoom() >= kWSC62)
 +				return kCrowbar;
 +		} else if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (GameState.getScoringGotCardBomb())
 +				return kCrowbar;
 +		} else
 +			return kCrowbar;
 +	}
 +	if (playerHasItemID(kAirMask)) {
 +		if (GameState.getCurrentNeighborhood() == kMarsID) {
 +			if (g_neighborhood->getAirQuality(GameState.getCurrentRoom()) == kAirQualityGood)
 +				return kAirMask;
 +		} else if (GameState.getCurrentNeighborhood() != kNoradAlphaID &&
 +				GameState.getCurrentNeighborhood() != kNoradDeltaID) {
 +			return kAirMask;
 +		}
 +	}
 +
 +	// Desperate:
 +	if (playerHasItemID(kPoisonDart))
 +		return kPoisonDart;
 +	if (playerHasItemID(kJourneymanKey))
 +		return kJourneymanKey;
 +	if (playerHasItemID(kMarsCard))
 +		return kMarsCard;
 +	if (playerHasItemID(kNitrogenCanister))
 +		return kNitrogenCanister;
 +	if (playerHasItemID(kCrowbar))
 +		return kCrowbar;
 +	if (playerHasItemID(kAirMask))
 +		return kAirMask;
 +
 +	// Should never get this far...
 +	error("Could not find item to delete");
 +
 +	return kNoItemID;
 +}
 +
 +uint PegasusEngine::getNeighborhoodCD(const NeighborhoodID neighborhood) const {
 +	switch (neighborhood) {
 +	case kCaldoriaID:
 +	case kNoradAlphaID:
 +	case kNoradSubChaseID:
 +		return 1;
 +	case kFullTSAID:
 +	case kPrehistoricID:
 +		return 2;
 +	case kMarsID:
 +		return 3;
 +	case kWSCID:
 +	case kNoradDeltaID:
 +		return 4;
 +	case kTinyTSAID:
 +		// Tiny TSA exists on three of the CD's, so just continue
 +		// with the CD we're on
 +		return _currentCD;
 +	}
 +
 +	// Can't really happen, but it's a good fallback anyway :P
 +	return 1;
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/pegasus.h
index a1b4cff,0000000..1ee0136
mode 100644,000000..100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@@ -1,322 -1,0 +1,322 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#ifndef PEGASUS_H
 +#define PEGASUS_H
 +
 +#include "common/list.h"
 +#include "common/macresman.h"
 +#include "common/rect.h"
 +#include "common/scummsys.h"
 +#include "common/system.h"
 +#include "common/util.h"
 +
 +#include "engines/engine.h"
 +
 +#include "pegasus/graphics.h"
 +#include "pegasus/hotspot.h"
 +#include "pegasus/input.h"
 +#include "pegasus/notification.h"
 +#include "pegasus/timers.h"
 +#include "pegasus/items/autodragger.h"
 +#include "pegasus/items/inventory.h"
 +#include "pegasus/items/itemdragger.h"
 +#include "pegasus/neighborhood/neighborhood.h"
 +
 +namespace Common {
 +	class RandomSource;
 +}
 +
 +namespace Video {
- 	class SeekableVideoDecoder;
++	class VideoDecoder;
 +}
 +
 +namespace Pegasus {
 +
 +class PegasusConsole;
 +struct PegasusGameDescription;
 +class SoundManager;
 +class GraphicsManager;
 +class Idler;
 +class Cursor;
 +class TimeBase;
 +class GameMenu;
 +class InventoryItem;
 +class BiochipItem;
 +class Neighborhood;
 +
 +class PegasusEngine : public ::Engine, public InputHandler, public NotificationManager {
 +friend class InputHandler;
 +
 +public:
 +	PegasusEngine(OSystem *syst, const PegasusGameDescription *gamedesc);
 +	virtual ~PegasusEngine();
 +
 +	// Engine stuff
 +	const PegasusGameDescription *_gameDescription;
 +	bool hasFeature(EngineFeature f) const;
 +	GUI::Debugger *getDebugger();
 +	bool canLoadGameStateCurrently() { return _loadAllowed && !isDemo(); }
 +	bool canSaveGameStateCurrently() { return _saveAllowed && !isDemo(); }
 +	Common::Error loadGameState(int slot);
 +	Common::Error saveGameState(int slot, const Common::String &desc);
 +
 +	// Base classes
 +	GraphicsManager *_gfx;
 +	Common::MacResManager *_resFork;
 +	Cursor *_cursor;
 +
 +	// Menu
 +	void useMenu(GameMenu *menu);
 +	bool checkGameMenu();
 +
 +	// Misc.
 +	bool isDemo() const;
 +	void addIdler(Idler *idler);
 +	void removeIdler(Idler *idler);
 +	void addTimeBase(TimeBase *timeBase);
 +	void removeTimeBase(TimeBase *timeBase);
 +	void delayShell(TimeValue time, TimeScale scale);
 +	void resetIntroTimer();
 +	void introTimerExpired();
 +	void refreshDisplay();
 +	bool playerAlive();
 +	void processShell();
 +	void checkCallBacks();
 +	void createInterface();
 +	void setGameMode(const GameMode);
 +	GameMode getGameMode() const { return _gameMode; }
 +	uint getRandomBit();
 +	uint getRandomNumber(uint max);
 +	void shuffleArray(int32 *arr, int32 count);
 +	void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
 +
 +	// Energy
 +	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
 +	int32 getSavedEnergyValue() { return _savedEnergyValue; }
 +
 +	// Death
 +	void setEnergyDeathReason(const DeathReason reason) { _deathReason = reason; } 
 +	DeathReason getEnergyDeathReason() { return _deathReason; }
 +	void resetEnergyDeathReason();
 +	void die(const DeathReason);
 +	void playEndMessage();
 +
 +	// Volume
 +	uint16 getSoundFXLevel() { return _FXLevel; }
 +	void setSoundFXLevel(uint16);
 +	uint16 getAmbienceLevel() { return _ambientLevel; }
 +	void setAmbienceLevel(uint16);
 +
 +	// Items
 +	bool playerHasItem(const Item *);
 +	bool playerHasItemID(const ItemID);
 +	void checkFlashlight();
 +	bool itemInLocation(const ItemID, const NeighborhoodID, const RoomID, const DirectionConstant);
 +
 +	// Inventory Items
 +	InventoryItem *getCurrentInventoryItem();
 +	bool itemInInventory(InventoryItem *);
 +	bool itemInInventory(ItemID);
 +	Inventory *getItemsInventory() { return &_items; }
 +	InventoryResult addItemToInventory(InventoryItem *);
 +	void removeAllItemsFromInventory();
 +	InventoryResult removeItemFromInventory(InventoryItem *);
 +	uint32 countInventoryItems() { return _items.getNumItems(); }
 +
 +	// Biochips
 +	BiochipItem *getCurrentBiochip();
 +	bool itemInBiochips(BiochipItem *);
 +	bool itemInBiochips(ItemID);
 +	Inventory *getBiochipsInventory() { return &_biochips; }
 +	void removeAllItemsFromBiochips();
 +	InventoryResult addItemToBiochips(BiochipItem *);
 +
 +	// AI
 +	Common::String getBriefingMovie();
 +	Common::String getEnvScanMovie();
 +	uint getNumHints();
 +	Common::String getHintMovie(uint);
 +	bool canSolve();
 +	void prepareForAIHint(const Common::String &);
 +	void cleanUpAfterAIHint(const Common::String &);
 +	Common::SeekableReadStream *_aiSaveStream;
 +
 +	// Neighborhood
 +	void jumpToNewEnvironment(const NeighborhoodID, const RoomID, const DirectionConstant);
 +	NeighborhoodID getCurrentNeighborhoodID() const;
 +
 +	// Dragging
 +	void dragItem(const Input &, Item *, DragType);
 +	bool isDragging() const { return _dragType != kDragNoDrag; }
 +	DragType getDragType() const { return _dragType; }
 +	Item *getDraggingItem() const { return _draggingItem; }
 +	void dragTerminated(const Input &);
 +	void autoDragItemIntoRoom(Item *, Sprite *);
 +	void autoDragItemIntoInventory(Item *, Sprite*);
 +
 +	// Save/Load
 +	void makeContinuePoint();
 +	bool swapSaveAllowed(bool allow) {
 +		bool old = _saveAllowed;
 +		_saveAllowed = allow;
 +		return old;
 +	}
 +	bool swapLoadAllowed(bool allow) {
 +		bool old = _loadAllowed;
 +		_loadAllowed = allow;
 +		return old;
 +	}
 +	void requestSave() { _saveRequested = true; }
 +	bool saveRequested() const { return _saveRequested; }
 +	void requestLoad() { _loadRequested = true; }
 +	bool loadRequested() const { return _loadRequested; }
 +
 +protected:
 +	Common::Error run();
 +	void pauseEngineIntern(bool pause);
 +
 +	Notification _shellNotification;
 +	virtual void receiveNotification(Notification *notification, const NotificationFlags flags);
 +
 +	void handleInput(const Input &input, const Hotspot *cursorSpot);
 +	virtual bool isClickInput(const Input &, const Hotspot *);
 +	virtual InputBits getClickFilter();
 +
 +	void clickInHotspot(const Input &, const Hotspot *);
 +	void activateHotspots(void);
 +
 +	void updateCursor(const Common::Point, const Hotspot *);
 +	bool wantsCursor();
 +
 +private:
 +	// Console
 +	PegasusConsole *_console;
 +
 +	// Intro
 +	void runIntro();
 +	void stopIntroTimer();
 +	bool detectOpeningClosingDirectory();
 +	Common::String _introDirectory;
 +	FuseFunction *_introTimer;
 +
 +	// Idlers
 +	Idler *_idlerHead;
 +	void giveIdleTime();
 +
 +	// Items
 +	void createItems();
 +	void createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction);
 +	Inventory _items;
 +	Inventory _biochips;
 +	ItemID _currentItemID;
 +	ItemID _currentBiochipID;
 +	void destroyInventoryItem(const ItemID itemID);
 +	ItemID pickItemToDestroy();
 +
 +	// TimeBases
 +	Common::List<TimeBase *> _timeBases;
 +
 +	// Save/Load
 +	bool loadFromStream(Common::ReadStream *stream);
 +	bool writeToStream(Common::WriteStream *stream, int saveType);
 +	void loadFromContinuePoint();
 +	Common::ReadStream *_continuePoint;
 +	bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P
 +	Common::Error showLoadDialog();
 +	Common::Error showSaveDialog();
 +	bool _saveRequested, _loadRequested;
 +
 +	// Misc.
 +	Hotspot _returnHotspot;
 +	InputHandler *_savedHandler;
 +	void showTempScreen(const Common::String &fileName);
- 	bool playMovieScaled(Video::SeekableVideoDecoder *video, uint16 x, uint16 y);
++	bool playMovieScaled(Video::VideoDecoder *video, uint16 x, uint16 y);
 +	void throwAwayEverything();
 +	void shellGameInput(const Input &input, const Hotspot *cursorSpot);
 +	Common::RandomSource *_rnd;
 +	void doSubChase();
 +	uint getNeighborhoodCD(const NeighborhoodID neighborhood) const;
 +	uint _currentCD;
 +
 +	// Menu
 +	GameMenu *_gameMenu;
 +	void doGameMenuCommand(const GameMenuCommand);
 +	void doInterfaceOverview();
 +	ScreenDimmer _screenDimmer;
 +	void pauseMenu(bool menuUp);
 +
 +	// Energy
 +	int32 _savedEnergyValue;
 +
 +	// Death
 +	DeathReason _deathReason;
 +	void doDeath();
 +
 +	// Neighborhood
 +	Neighborhood *_neighborhood;
 +	void useNeighborhood(Neighborhood *neighborhood);
 +	void performJump(NeighborhoodID start);
 +	void startNewGame();
 +	void startNeighborhood();
 +	void makeNeighborhood(NeighborhoodID, Neighborhood *&);
 +
 +	// Sound
 +	uint16 _ambientLevel;
 +	uint16 _FXLevel;
 +
 +	// Game Mode
 +	GameMode _gameMode;
 +	bool _switchModesSync;
 +	void switchGameMode(const GameMode, const GameMode);
 +	bool canSwitchGameMode(const GameMode, const GameMode);
 +
 +	// Dragging
 +	ItemDragger _itemDragger;
 +	Item *_draggingItem;
 +	Sprite *_draggingSprite;
 +	DragType _dragType;
 +	AutoDragger _autoDragger;
 +
 +	// Interface
 +	void toggleInventoryDisplay();
 +	void toggleBiochipDisplay();
 +	void raiseInventoryDrawer();
 +	void raiseBiochipDrawer();
 +	void lowerInventoryDrawer();
 +	void lowerBiochipDrawer();
 +	void raiseInventoryDrawerSync();
 +	void raiseBiochipDrawerSync();
 +	void lowerInventoryDrawerSync();
 +	void lowerBiochipDrawerSync();
 +	void showInfoScreen();
 +	void hideInfoScreen();
 +	void toggleInfo();
 +	Movie _bigInfoMovie, _smallInfoMovie;
 +};
 +
 +} // End of namespace Pegasus
 +
 +#endif
diff --cc engines/pegasus/surface.cpp
index 897305f,0000000..343bc41
mode 100644,000000..100644
--- a/engines/pegasus/surface.cpp
+++ b/engines/pegasus/surface.cpp
@@@ -1,392 -1,0 +1,392 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#include "common/file.h"
 +#include "common/macresman.h"
 +#include "common/stream.h"
 +#include "common/system.h"
 +#include "graphics/surface.h"
 +#include "graphics/decoders/pict.h"
 +#include "video/video_decoder.h"
 +
 +#include "pegasus/pegasus.h"
 +#include "pegasus/surface.h"
 +
 +namespace Pegasus {
 +
 +Surface::Surface() {
 +	_ownsSurface = false;
 +	_surface = 0;
 +}
 +
 +Surface::~Surface() {
 +	deallocateSurface();
 +}
 +
 +void Surface::deallocateSurface() {
 +	if (_surface) {
 +		if (_ownsSurface) {
 +			_surface->free();
 +			delete _surface;
 +		}
 +
 +		_surface = 0;
 +		_bounds = Common::Rect();
 +		_ownsSurface = false;
 +	}
 +}
 +
 +void Surface::shareSurface(Surface *surface) {
 +	deallocateSurface();
 +
 +	if (surface) {
 +		_ownsSurface = false;
 +		_surface = surface->getSurface();
 +		surface->getSurfaceBounds(_bounds);
 +	}
 +}
 +
 +void Surface::allocateSurface(const Common::Rect &bounds) {
 +	deallocateSurface();
 +
 +	if (bounds.isEmpty())
 +		return;
 +
 +	_bounds = bounds;
 +	_surface = new Graphics::Surface();
 +	_surface->create(bounds.width(), bounds.height(), g_system->getScreenFormat());
 +	_ownsSurface = true;
 +}
 +
 +void Surface::getImageFromPICTFile(const Common::String &fileName) {
 +	Common::File pict;
 +	if (!pict.open(fileName))
 +		error("Could not open picture '%s'", fileName.c_str());
 +
 +	getImageFromPICTStream(&pict);
 +}
 +
 +void Surface::getImageFromPICTResource(Common::MacResManager *resFork, uint16 id) {
 +	Common::SeekableReadStream *res = resFork->getResource(MKTAG('P', 'I', 'C', 'T'), id);
 +	if (!res)
 +		error("Could not open PICT resource %d from '%s'", id, resFork->getBaseFileName().c_str());
 +	
 +	getImageFromPICTStream(res);
 +	delete res;
 +}
 +
 +void Surface::getImageFromPICTStream(Common::SeekableReadStream *stream) {
 +	Graphics::PICTDecoder pict;
 +
 +	if (!pict.loadStream(*stream))
 +		error("Failed to load PICT image");
 +
 +	_surface = pict.getSurface()->convertTo(g_system->getScreenFormat(), pict.getPalette());
 +	_ownsSurface = true;
 +	_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
 +}
 +
- void Surface::getImageFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time) {
- 	video->seekToTime(Audio::Timestamp(0, time, 600));
++void Surface::getImageFromMovieFrame(Video::VideoDecoder *video, TimeValue time) {
++	video->seek(Audio::Timestamp(0, time, 600));
 +	const Graphics::Surface *frame = video->decodeNextFrame();
 +
 +	if (frame) {
 +		if (!_surface)
 +			_surface = new Graphics::Surface();
 +
 +		_surface->copyFrom(*frame);
 +		_ownsSurface = true;
 +		_bounds = Common::Rect(0, 0, _surface->w, _surface->h);
 +	} else {
 +		deallocateSurface();
 +	}
 +}
 +
 +void Surface::copyToCurrentPort() const {
 +	copyToCurrentPort(_bounds);
 +}
 +
 +void Surface::copyToCurrentPortTransparent() const {
 +	copyToCurrentPortTransparent(_bounds);
 +}
 +
 +void Surface::copyToCurrentPort(const Common::Rect &rect) const {
 +	copyToCurrentPort(rect, rect);
 +}
 +
 +void Surface::copyToCurrentPortTransparent(const Common::Rect &rect) const {
 +	copyToCurrentPortTransparent(rect, rect);
 +}
 +
 +void Surface::copyToCurrentPort(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		memcpy(dst, src, lineSize);
 +		src += _surface->pitch;
 +		dst += screen->pitch;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortTransparent(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(src);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 2);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(src);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 4);
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortMasked(const Common::Rect &srcRect, const Common::Rect &dstRect, const Surface *mask) const {
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		byte *maskSrc = (byte *)mask->getSurface()->getBasePtr(0, y);
 +
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(maskSrc);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 2);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(maskSrc);
 +				if (!isTransparent(color))
 +					memcpy(dst, src, 4);
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			maskSrc += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
 +	// pixel all the way up.
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
 +	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);
 +
 +	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;
 +
 +	for (int y = 0; y < srcRect.height(); y++) {
 +		for (int x = 0; x < srcRect.width(); x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16(src);
 +				if (!isTransparent(color))
 +					WRITE_UINT16(dst, getGlowColor(color));
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32(src);
 +				if (!isTransparent(color))
 +					WRITE_UINT32(dst, getGlowColor(color));
 +			}
 +
 +			src += g_system->getScreenFormat().bytesPerPixel;
 +			dst += g_system->getScreenFormat().bytesPerPixel;
 +		}
 +
 +		src += _surface->pitch - lineSize;
 +		dst += screen->pitch - lineSize;
 +	}
 +}
 +
 +void Surface::scaleTransparentCopy(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// I'm doing simple linear scaling here
 +	// dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH);
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +
 +	int srcW = srcRect.width();
 +	int srcH = srcRect.height();
 +	int dstW = dstRect.width();
 +	int dstH = dstRect.height();
 +
 +	for (int y = 0; y < dstH; y++) {
 +		for (int x = 0; x < dstW; x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
 +			}
 +		}
 +	}
 +}
 +
 +void Surface::scaleTransparentCopyGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
 +	// This is the same as scaleTransparentCopy(), but turns the red value of each
 +	// pixel all the way up.
 +
 +	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
 +
 +	int srcW = srcRect.width();
 +	int srcH = srcRect.height();
 +	int dstW = dstRect.width();
 +	int dstH = dstRect.height();
 +
 +	for (int y = 0; y < dstH; y++) {
 +		for (int x = 0; x < dstW; x++) {
 +			if (g_system->getScreenFormat().bytesPerPixel == 2) {
 +				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
 +			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
 +				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
 +						x * srcW / dstW + srcRect.left,
 +						y * srcH / dstH + srcRect.top));
 +				if (!isTransparent(color))
 +					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
 +			}
 +		}
 +	}
 +}
 +
 +uint32 Surface::getGlowColor(uint32 color) const {
 +	// Can't just 'or' it on like the original did :P
 +	byte r, g, b;
 +	g_system->getScreenFormat().colorToRGB(color, r, g, b);
 +	return g_system->getScreenFormat().RGBToColor(0xff, g, b);
 +}
 +
 +bool Surface::isTransparent(uint32 color) const {
 +	// HACK: Seems we're truncating some color data somewhere...
 +	uint32 transColor1 = g_system->getScreenFormat().RGBToColor(0xff, 0xff, 0xff);
 +	uint32 transColor2 = g_system->getScreenFormat().RGBToColor(0xf8, 0xf8, 0xf8);
 +
 +	return color == transColor1 || color == transColor2;
 +}
 +
 +PixelImage::PixelImage() {
 +	_transparent = false;
 +}
 +
 +void PixelImage::drawImage(const Common::Rect &sourceBounds, const Common::Rect &destBounds) {
 +	if (!isSurfaceValid())
 +		return;
 +
 +	// Draw from sourceBounds to destBounds based on _transparent
 +	if (_transparent)
 +		copyToCurrentPortTransparent(sourceBounds, destBounds);
 +	else
 +		copyToCurrentPort(sourceBounds, destBounds);
 +}
 +
 +void Frame::initFromPICTFile(const Common::String &fileName, bool transparent) {
 +	getImageFromPICTFile(fileName);
 +	_transparent = transparent;
 +}
 +
 +void Frame::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
 +	getImageFromPICTResource(resFork, id);
 +	_transparent = transparent;
 +}
 +
- void Frame::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
++void Frame::initFromMovieFrame(Video::VideoDecoder *video, TimeValue time, bool transparent) {
 +	getImageFromMovieFrame(video, time);
 +	_transparent = transparent;
 +}
 +
 +void Picture::draw(const Common::Rect &r) {
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	Common::Rect r1 = r;
 +
 +	Common::Rect bounds;
 +	getBounds(bounds);
 +	surfaceBounds.moveTo(bounds.left, bounds.top);
 +	r1 = r1.findIntersectingRect(surfaceBounds);
 +	getSurfaceBounds(surfaceBounds);
 +
 +	Common::Rect r2 = r1;
 +	r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
 +	drawImage(r2, r1);
 +}
 +
 +void Picture::initFromPICTFile(const Common::String &fileName, bool transparent) {
 +	Frame::initFromPICTFile(fileName, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
 +void Picture::initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent) {
 +	Frame::initFromPICTResource(resFork, id, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
- void Picture::initFromMovieFrame(Video::SeekableVideoDecoder *video, TimeValue time, bool transparent) {
++void Picture::initFromMovieFrame(Video::VideoDecoder *video, TimeValue time, bool transparent) {
 +	Frame::initFromMovieFrame(video, time, transparent);
 +
 +	Common::Rect surfaceBounds;
 +	getSurfaceBounds(surfaceBounds);
 +	sizeElement(surfaceBounds.width(), surfaceBounds.height());
 +}
 +
 +} // End of namespace Pegasus
diff --cc engines/pegasus/surface.h
index 34a88db,0000000..311fb50
mode 100644,000000..100644
--- a/engines/pegasus/surface.h
+++ b/engines/pegasus/surface.h
@@@ -1,140 -1,0 +1,140 @@@
 +/* ScummVM - Graphic Adventure Engine
 + *
 + * ScummVM is the legal property of its developers, whose names
 + * are too numerous to list here. Please refer to the COPYRIGHT
 + * file distributed with this source distribution.
 + *
 + * Additional copyright for this file:
 + * Copyright (C) 1995-1997 Presto Studios, Inc.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * as published by the Free Software Foundation; either version 2
 + * of the License, or (at your option) any later version.
 +
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + * GNU General Public License for more details.
 +
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 + *
 + */
 +
 +#ifndef PEGASUS_SURFACE_H
 +#define PEGASUS_SURFACE_H
 +
 +#include "common/rect.h"
 +#include "common/str.h"
 +
 +#include "pegasus/elements.h"
 +#include "pegasus/types.h"
 +
 +namespace Common {
 +	class MacResManager;
 +}
 +
 +namespace Graphics {
 +	struct Surface;
 +}
 +
 +namespace Video {
- 	class SeekableVideoDecoder;
++	class VideoDecoder;
 +}
 +
 +namespace Pegasus {
 +
 +// Surface bounds are always normalized.
 +
 +class Surface {
 +public:
 +	Surface();
 +	virtual ~Surface();
 +	
 +	virtual void allocateSurface(const Common::Rect &);
 +	virtual void deallocateSurface();
 +	virtual void shareSurface(Surface *surface);
 +	bool isSurfaceValid() const { return _surface != 0; }
 +
 +	Graphics::Surface *getSurface() const { return _surface; }
 +	void getSurfaceBounds(Common::Rect &r) { r = _bounds; }
 +
 +	// None of the copyToCurrentPort* functions do any sanity checks.
 +	// It's up to clients to make sure that the Surface is valid.
 +	void copyToCurrentPort() const;
 +	void copyToCurrentPortTransparent() const;
 +	void copyToCurrentPort(const Common::Rect &) const;
 +	void copyToCurrentPortTransparent(const Common::Rect &) const;
 +	void copyToCurrentPort(const Common::Rect &, const Common::Rect &) const;
 +	void copyToCurrentPortTransparent(const Common::Rect &, const Common::Rect &) const;
 +	void copyToCurrentPortMasked(const Common::Rect &, const Common::Rect &, const Surface *) const;
 +	void copyToCurrentPortTransparentGlow(const Common::Rect &, const Common::Rect &) const;
 +	void scaleTransparentCopy(const Common::Rect &, const Common::Rect &) const;
 +	void scaleTransparentCopyGlow(const Common::Rect &, const Common::Rect &) const;
 +
 +	virtual void getImageFromPICTFile(const Common::String &fileName);
 +	virtual void getImageFromPICTResource(Common::MacResManager *resFork, uint16 id);
- 	virtual void getImageFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue);
++	virtual void getImageFromMovieFrame(Video::VideoDecoder *, TimeValue);
 +
 +protected:
 +	bool _ownsSurface;
 +	Graphics::Surface *_surface;
 +	Common::Rect _bounds;
 +
 +private:
 +	void getImageFromPICTStream(Common::SeekableReadStream *stream);
 +
 +	uint32 getGlowColor(uint32 color) const;
 +	bool isTransparent(uint32 color) const;
 +};
 +
 +class PixelImage : public Surface {
 +public:
 +	PixelImage();
 +	virtual ~PixelImage() {}
 +
 +	void drawImage(const Common::Rect &, const Common::Rect &);
 +
 +protected:
 +	virtual void setTransparent(bool transparent) { _transparent = transparent; }
 +	
 +	bool _transparent;
 +};
 +
 +class Frame : public PixelImage {
 +public:
 +	Frame() {}
 +	virtual ~Frame() {}
 +
 +	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
 +	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
- 	virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);
++	virtual void initFromMovieFrame(Video::VideoDecoder *, TimeValue, bool transparent = false);
 +};
 +
 +class SpriteFrame : public Frame {
 +friend class Sprite;
 +public:
 +	SpriteFrame() { _referenceCount = 0; }
 +	virtual ~SpriteFrame() {}
 +
 +protected:
 +	uint32 _referenceCount;
 +};
 +
 +class Picture : public DisplayElement, public Frame {
 +public:
 +	Picture(const DisplayElementID id) : DisplayElement(id) {}
 +	virtual ~Picture() {}
 +
 +	virtual void initFromPICTFile(const Common::String &fileName, bool transparent = false);
 +	virtual void initFromPICTResource(Common::MacResManager *resFork, uint16 id, bool transparent = false);
- 	virtual void initFromMovieFrame(Video::SeekableVideoDecoder *, TimeValue, bool transparent = false);
++	virtual void initFromMovieFrame(Video::VideoDecoder *, TimeValue, bool transparent = false);
 +
 +	virtual void draw(const Common::Rect &);
 +};
 +
 +} // End of namespace Pegasus
 +
 +#endif
diff --cc gui/credits.h
index 928799e,34c6f21..f19002a
--- a/gui/credits.h
+++ b/gui/credits.h
@@@ -713,7 -712,9 +715,11 @@@ static const char *credits[] = 
  "C0""",
  "C0""Broken Sword 2.5 team for providing sources of their engine and their great support.",
  "C0""",
+ "C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.",
+ "C0""",
+ "C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us to redistribute the game.",
+ "C0""",
 +"C0""Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing the source code of The Journeyman Project: Pegasus Prime.",
 +"C0""",
  "",
  };


Commit: c15369c26f49204dc3a49d8215c1c21660a781f9
    https://github.com/scummvm/scummvm/commit/c15369c26f49204dc3a49d8215c1c21660a781f9
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-26T20:05:33-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
    video/coktel_decoder.cpp
    video/coktel_decoder.h





Commit: 81e7c9a0c1599786a1aeb73d243609a2d280335f
    https://github.com/scummvm/scummvm/commit/81e7c9a0c1599786a1aeb73d243609a2d280335f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-28T13:36:50-07:00

Commit Message:
PEGASUS: Remove g_allHotspots global construction

Changed paths:
    engines/pegasus/hotspot.cpp
    engines/pegasus/hotspot.h
    engines/pegasus/items/biochips/opticalchip.cpp
    engines/pegasus/items/inventory/airmask.cpp
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
    engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
    engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
    engines/pegasus/neighborhood/norad/pressuretracker.cpp
    engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/wsc/wsc.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/hotspot.cpp b/engines/pegasus/hotspot.cpp
index 84731b7..d8b07a9 100644
--- a/engines/pegasus/hotspot.cpp
+++ b/engines/pegasus/hotspot.cpp
@@ -29,8 +29,6 @@
 
 namespace Pegasus {
 
-HotspotList g_allHotspots;
-
 Region::Region(Common::ReadStream *stream) {
 	uint16 length = stream->readUint16BE();
 
diff --git a/engines/pegasus/hotspot.h b/engines/pegasus/hotspot.h
index bc1d054..623609d 100644
--- a/engines/pegasus/hotspot.h
+++ b/engines/pegasus/hotspot.h
@@ -145,8 +145,7 @@ public:
 
 typedef HotspotList::iterator HotspotIterator;
 
-// FIXME: Remove global construction
-extern HotspotList g_allHotspots;
+#define g_allHotspots (((PegasusEngine *)g_engine)->getAllHotspots())
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/items/biochips/opticalchip.cpp b/engines/pegasus/items/biochips/opticalchip.cpp
index 0f60981..7b8858e 100644
--- a/engines/pegasus/items/biochips/opticalchip.cpp
+++ b/engines/pegasus/items/biochips/opticalchip.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/biochips/opticalchip.h"
 
diff --git a/engines/pegasus/items/inventory/airmask.cpp b/engines/pegasus/items/inventory/airmask.cpp
index 56f9d6f..559410f 100644
--- a/engines/pegasus/items/inventory/airmask.cpp
+++ b/engines/pegasus/items/inventory/airmask.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/items/inventory/airmask.h"
 #include "pegasus/neighborhood/neighborhood.h"
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index a6806d5..6421195 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -1292,42 +1292,42 @@ void Caldoria::activateHotspots() {
 	case kCaldoriaDrawers:
 		if (getCurrentActivation() == kActivateRightOpen) {
 			if (GameState.isTakenItemID(kKeyCard)) {
-				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
-				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
 			} else {
-				g_allHotspots.activateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
-				g_allHotspots.deactivateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kCaldoriaRightDrawerWithKeysCloseSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRightDrawerNoKeysCloseSpotID);
 			}
 		}
 	case kCaldoriaReplicator:
 		if (GameState.getCaldoriaMadeOJ())
-			g_allHotspots.deactivateOneHotspot(kCaldoriaMakeOJSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaMakeOJSpotID);
 		break;
 	case kCaldoria27:
 		if (GameState.isCurrentDoorOpen()) {
-			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator1);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator2);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator3);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator4);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaFourthFloorElevator5);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaFourthFloorElevator1);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaFourthFloorElevator2);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaFourthFloorElevator3);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaFourthFloorElevator4);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaFourthFloorElevator5);
 		}
 		break;
 	case kCaldoria28:
 		if (GameState.isCurrentDoorOpen()) {
-			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator1);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator2);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator3);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator4);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaGroundElevator5);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaGroundElevator1);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaGroundElevator2);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaGroundElevator3);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaGroundElevator4);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaGroundElevator5);
 		}
 		break;
 	case kCaldoria45:
 		if (GameState.isCurrentDoorOpen()) {
-			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator1);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator2);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator3);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator4);
-			g_allHotspots.deactivateOneHotspot(kCaldoriaRoofElevator5);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRoofElevator1);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRoofElevator2);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRoofElevator3);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRoofElevator4);
+			_vm->getAllHotspots().deactivateOneHotspot(kCaldoriaRoofElevator5);
 		}
 		break;
 	}
@@ -1576,7 +1576,7 @@ Hotspot *Caldoria::getItemScreenSpot(Item *item, DisplayElement *element) {
 	if (destSpotID == kNoHotSpotID)
 		return Neighborhood::getItemScreenSpot(item, element);
 
-	return g_allHotspots.findHotspotByID(destSpotID);
+	return _vm->getAllHotspots().findHotspotByID(destSpotID);
 }
 
 void Caldoria::pickedUpItem(Item *item) {
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
index d8ac3b0..21ad7db 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
@@ -23,6 +23,7 @@
  *
  */
 
+#include "pegasus/pegasus.h"
 #include "pegasus/ai/ai_area.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/caldoria/caldoria4dsystem.h"
diff --git a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
index 2b70ead..ff4d181 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/gamestate.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/neighborhood/neighborhood.h"
 #include "pegasus/neighborhood/caldoria/caldoria.h"
 #include "pegasus/neighborhood/caldoria/caldoriamirror.h"
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 816a13f..8c1098a 100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -128,17 +128,17 @@ Mars::Mars(InputHandler *nextHandler, PegasusEngine *owner) : Neighborhood(nextH
 }
 
 Mars::~Mars() {
-	g_allHotspots.remove(&_energyChoiceSpot);
-	g_allHotspots.remove(&_gravitonChoiceSpot);
-	g_allHotspots.remove(&_tractorChoiceSpot);
-	g_allHotspots.remove(&_shuttleViewSpot);
-	g_allHotspots.remove(&_shuttleTransportSpot);
+	_vm->getAllHotspots().remove(&_energyChoiceSpot);
+	_vm->getAllHotspots().remove(&_gravitonChoiceSpot);
+	_vm->getAllHotspots().remove(&_tractorChoiceSpot);
+	_vm->getAllHotspots().remove(&_shuttleViewSpot);
+	_vm->getAllHotspots().remove(&_shuttleTransportSpot);
 }
 
 void Mars::init() {	
 	Neighborhood::init();
 	
-	Hotspot *attackSpot = g_allHotspots.findHotspotByID(kAttackRobotHotSpotID);
+	Hotspot *attackSpot = _vm->getAllHotspots().findHotspotByID(kAttackRobotHotSpotID);
 	attackSpot->setMaskedHotspotFlags(kDropItemSpotFlag, kDropItemSpotFlag);
 	_attackingItem = NULL;
 	
@@ -1627,35 +1627,35 @@ void Mars::activateHotspots() {
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kMars48, kEast):
 		if ((_navMovie.getFlags() & kLoopTimeBase) != 0 && _vm->getDragType() == kDragInventoryUse)
-			g_allHotspots.activateOneHotspot(kAttackRobotHotSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kAttackRobotHotSpotID);
 		break;
 	case MakeRoomView(kMars56, kEast):
 		switch (getCurrentActivation()) {
 		case kActivateReactorReadyForNitrogen:
 			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
 			if (item->getItemState() != kNitrogenFull)
-				g_allHotspots.deactivateOneHotspot(kMars57DropNitrogenSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kMars57DropNitrogenSpotID);
 			// Fall through...
 		case kActivateReactorReadyForCrowBar:
-			g_allHotspots.activateOneHotspot(kMars57CantOpenPanelSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kMars57CantOpenPanelSpotID);
 			break;
 		}
 		break;
 	case MakeRoomView(kMarsRobotShuttle, kEast):
 		if (_privateFlags.getFlag(kMarsPrivateGotMapChipFlag))
-			g_allHotspots.deactivateOneHotspot(kRobotShuttleMapChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kRobotShuttleMapChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kRobotShuttleMapChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kRobotShuttleMapChipSpotID);
 
 		if (_privateFlags.getFlag(kMarsPrivateGotOpticalChipFlag))
-			g_allHotspots.deactivateOneHotspot(kRobotShuttleOpticalChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kRobotShuttleOpticalChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kRobotShuttleOpticalChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kRobotShuttleOpticalChipSpotID);
 
 		if (_privateFlags.getFlag(kMarsPrivateGotShieldChipFlag))
-			g_allHotspots.deactivateOneHotspot(kRobotShuttleShieldChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kRobotShuttleShieldChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kRobotShuttleShieldChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kRobotShuttleShieldChipSpotID);
 		break;
 	default:
 		if (_privateFlags.getFlag(kMarsPrivateInSpaceChaseFlag)) {
@@ -1868,7 +1868,7 @@ Hotspot *Mars::getItemScreenSpot(Item *item, DisplayElement *element) {
 	if (destSpotID == kNoHotSpotID)
 		return Neighborhood::getItemScreenSpot(item, element);
 
-	return g_allHotspots.findHotspotByID(destSpotID);
+	return _vm->getAllHotspots().findHotspotByID(destSpotID);
 }
 
 void Mars::takeItemFromRoom(Item *item) {
@@ -2635,7 +2635,7 @@ void Mars::startUpFromFinishedSpaceChase() {
 	
 	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_shuttleTransportSpot);
+	_vm->getAllHotspots().push_back(&_shuttleTransportSpot);
 
 	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 
@@ -2766,20 +2766,20 @@ void Mars::startUpFromSpaceChase() {
 
 	_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
 	_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_energyChoiceSpot);
+	_vm->getAllHotspots().push_back(&_energyChoiceSpot);
 	_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
 	_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_gravitonChoiceSpot);
+	_vm->getAllHotspots().push_back(&_gravitonChoiceSpot);
 	_tractorChoiceSpot.setArea(kShuttleTractorBounds);
 	_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_tractorChoiceSpot);
+	_vm->getAllHotspots().push_back(&_tractorChoiceSpot);
 	_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
 			kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
 	_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_shuttleViewSpot);
+	_vm->getAllHotspots().push_back(&_shuttleViewSpot);
 	_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 	_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-	g_allHotspots.push_back(&_shuttleTransportSpot);
+	_vm->getAllHotspots().push_back(&_shuttleTransportSpot);
 
 	_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 
@@ -2900,20 +2900,20 @@ void Mars::marsTimerExpired(MarsTimerEvent &event) {
 
 		_energyChoiceSpot.setArea(kShuttleEnergyBeamBounds);
 		_energyChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-		g_allHotspots.push_back(&_energyChoiceSpot);
+		_vm->getAllHotspots().push_back(&_energyChoiceSpot);
 		_gravitonChoiceSpot.setArea(kShuttleGravitonBounds);
 		_gravitonChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-		g_allHotspots.push_back(&_gravitonChoiceSpot);
+		_vm->getAllHotspots().push_back(&_gravitonChoiceSpot);
 		_tractorChoiceSpot.setArea(kShuttleTractorBounds);
 		_tractorChoiceSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-		g_allHotspots.push_back(&_tractorChoiceSpot);
+		_vm->getAllHotspots().push_back(&_tractorChoiceSpot);
 		_shuttleViewSpot.setArea(kShuttleWindowLeft, kShuttleWindowTop,
 				kShuttleWindowLeft + kShuttleWindowWidth, kShuttleWindowTop + kShuttleWindowHeight);
 		_shuttleViewSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-		g_allHotspots.push_back(&_shuttleViewSpot);
+		_vm->getAllHotspots().push_back(&_shuttleViewSpot);
 		_shuttleTransportSpot.setArea(kShuttleTransportBounds);
 		_shuttleTransportSpot.setHotspotFlags(kNeighborhoodSpotFlag | kClickSpotFlag);
-		g_allHotspots.push_back(&_shuttleTransportSpot);
+		_vm->getAllHotspots().push_back(&_shuttleTransportSpot);
 
 		_privateFlags.setFlag(kMarsPrivateInSpaceChaseFlag, true);
 
@@ -3008,11 +3008,11 @@ void Mars::throwAwayMarsShuttle() {
 	_junk.stopDisplaying();
 	_energyBeam.cleanUpShuttleWeapon();
 	_gravitonCannon.cleanUpShuttleWeapon();
-	g_allHotspots.remove(&_energyChoiceSpot);
-	g_allHotspots.remove(&_gravitonChoiceSpot);
-	g_allHotspots.remove(&_tractorChoiceSpot);
-	g_allHotspots.remove(&_shuttleViewSpot);
-	g_allHotspots.remove(&_shuttleTransportSpot);
+	_vm->getAllHotspots().remove(&_energyChoiceSpot);
+	_vm->getAllHotspots().remove(&_gravitonChoiceSpot);
+	_vm->getAllHotspots().remove(&_tractorChoiceSpot);
+	_vm->getAllHotspots().remove(&_shuttleViewSpot);
+	_vm->getAllHotspots().remove(&_shuttleTransportSpot);
 	_explosions.releaseMovie();
 	_explosions.stopDisplaying();
 
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index 3378459..a93dd7e 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -73,7 +73,7 @@ Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const C
 
 Neighborhood::~Neighborhood() {
 	for (HotspotIterator it = _neighborhoodHotspots.begin(); it != _neighborhoodHotspots.end(); it++)
-		g_allHotspots.remove(*it);
+		_vm->getAllHotspots().remove(*it);
 
 	_neighborhoodHotspots.deleteHotspots();
 	g_neighborhood = 0;
@@ -381,7 +381,7 @@ void Neighborhood::createNeighborhoodSpots() {
 		hotspot->setHotspotFlags(flags);
 		hotspot->setArea(region);
 
-		g_allHotspots.push_back(hotspot);
+		_vm->getAllHotspots().push_back(hotspot);
 		_neighborhoodHotspots.push_back(hotspot);
 	}
 
@@ -655,7 +655,7 @@ void Neighborhood::activateHotspots() {
 
 		if (entry.hotspotRoom == GameState.getCurrentRoom() && entry.hotspotDirection == GameState.getCurrentDirection()
 				&& (entry.hotspotActivation == _currentActivation || entry.hotspotActivation == kActivateHotSpotAlways)) {
-			Hotspot *hotspot = g_allHotspots.findHotspotByID(entry.hotspot);
+			Hotspot *hotspot = _vm->getAllHotspots().findHotspotByID(entry.hotspot);
 			if (hotspot)
 				activateOneHotspot(entry, hotspot);
 		}
@@ -1242,7 +1242,7 @@ void Neighborhood::throwAwayInterface() {
 	_turnPush.disposeAllCallBacks();
 
 	for (HotspotList::iterator it = _neighborhoodHotspots.begin(); it != _neighborhoodHotspots.end(); it++)
-		g_allHotspots.remove(*it);
+		_vm->getAllHotspots().remove(*it);
 
 	_neighborhoodHotspots.deleteHotspots();
 	_spotSounds.disposeSound();
@@ -1428,7 +1428,7 @@ void Neighborhood::bumpIntoWall() {
 void Neighborhood::zoomUpOrBump() {
 	Hotspot *zoomSpot = 0;
 
-	for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) {
+	for (HotspotList::iterator it = _vm->getAllHotspots().begin(); it != _vm->getAllHotspots().end(); it++) {
 		Hotspot *hotspot = *it;
 
 		if ((hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomInSpotFlag)) == (kNeighborhoodSpotFlag | kZoomInSpotFlag)) {
@@ -1652,7 +1652,7 @@ void Neighborhood::handleInput(const Input &input, const Hotspot *cursorSpot) {
 }
 
 void Neighborhood::setHotspotFlags(const HotSpotID id, const HotSpotFlags flags) {
-	Hotspot *hotspot = g_allHotspots.findHotspotByID(id);
+	Hotspot *hotspot = _vm->getAllHotspots().findHotspotByID(id);
 	hotspot->setMaskedHotspotFlags(flags, flags);
 }
 
@@ -1674,10 +1674,10 @@ void Neighborhood::rightButton(const Input &) {
 
 void Neighborhood::downButton(const Input &) {
 	if (_inputHandler->wantsCursor()) {
-		g_allHotspots.deactivateAllHotspots();
+		_vm->getAllHotspots().deactivateAllHotspots();
 		_inputHandler->activateHotspots();
 
-		for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) {
+		for (HotspotList::iterator it = _vm->getAllHotspots().begin(); it != _vm->getAllHotspots().end(); it++) {
 			Hotspot *hotspot = *it;
 
 			if (hotspot->isSpotActive() && (hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) == (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) {
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index 8391a3f..2d050d9 100644
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -100,27 +100,27 @@ NoradAlpha::NoradAlpha(InputHandler *nextHandler, PegasusEngine *owner) : Norad(
 void NoradAlpha::init() {
 	Norad::init();
 	
-	Hotspot *hotspot = g_allHotspots.findHotspotByID(kN01GasCanisterSpotID);
+	Hotspot *hotspot = _vm->getAllHotspots().findHotspotByID(kN01GasCanisterSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
 	HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kN01GasCanisterSpotID);
 	hotspotEntry->hotspotItem = kGasCanister;
 	
-	hotspot = g_allHotspots.findHotspotByID(kN01ArgonCanisterSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kN01ArgonCanisterSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
 	hotspotEntry = findHotspotEntry(kN01ArgonCanisterSpotID);
 	hotspotEntry->hotspotItem = kArgonCanister;
 	
-	hotspot = g_allHotspots.findHotspotByID(kN01NitrogenCanisterSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kN01NitrogenCanisterSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
 	hotspotEntry = findHotspotEntry(kN01NitrogenCanisterSpotID);
 	hotspotEntry->hotspotItem = kNitrogenCanister;
 	
-	hotspot = g_allHotspots.findHotspotByID(kN01AirMaskSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kN01AirMaskSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpItemSpotFlag, kPickUpItemSpotFlag);
 	hotspotEntry = findHotspotEntry(kN01AirMaskSpotID);
 	hotspotEntry->hotspotItem = kAirMask;
 	
-	hotspot = g_allHotspots.findHotspotByID(kN01GasOutletSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kN01GasOutletSpotID);
 	hotspot->setMaskedHotspotFlags(kDropItemSpotFlag, kDropItemSpotFlag);
 }
 
@@ -514,7 +514,7 @@ void NoradAlpha::activateHotspots() {
 				ItemID itemID = _vm->getDraggingItem()->getObjectID();
 				if (itemID == kArgonCanister || itemID == kGasCanister || itemID == kAirMask ||
 						itemID == kNitrogenCanister)
-					g_allHotspots.activateOneHotspot(kN01GasOutletSpotID);
+					_vm->getAllHotspots().activateOneHotspot(kN01GasOutletSpotID);
 			}
 		} else {
 			HotSpotID spotID;
@@ -523,35 +523,35 @@ void NoradAlpha::activateHotspots() {
 				switch (_fillingStationItem->getObjectID()) {
 				case kArgonCanister:
 					spotID = kN01ArgonCanisterSpotID;
-					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					_vm->getAllHotspots().deactivateOneHotspot(kNorad01GasOutSpotID);
 					break;
 				case kGasCanister:
 					spotID = kN01GasCanisterSpotID;
 					break;
 				case kAirMask:
 					spotID = kN01AirMaskSpotID;
-					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					_vm->getAllHotspots().deactivateOneHotspot(kNorad01GasOutSpotID);
 					break;
 				case kNitrogenCanister:
 					spotID = kN01NitrogenCanisterSpotID;
-					g_allHotspots.deactivateOneHotspot(kNorad01GasOutSpotID);
+					_vm->getAllHotspots().deactivateOneHotspot(kNorad01GasOutSpotID);
 					break;
 				default:
 					// Should never happen.
 					spotID = kNoHotSpotID;
 					break;
 				}
-				g_allHotspots.activateOneHotspot(spotID);
+				_vm->getAllHotspots().activateOneHotspot(spotID);
 			}
 		}
 		break;
 	case MakeRoomView(kNorad10, kEast):
 		if (GameState.isCurrentDoorOpen())
-			g_allHotspots.deactivateOneHotspot(kNorad10DoorSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kNorad10DoorSpotID);
 		break;
 	case MakeRoomView(kNorad21, kWest):
 		if (GameState.isCurrentDoorOpen())
-			g_allHotspots.deactivateOneHotspot(kNorad21WestSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kNorad21WestSpotID);
 		break;
 	}
 }
@@ -616,13 +616,13 @@ void NoradAlpha::getClawInfo(HotSpotID &outSpotID, HotSpotID &prepSpotID, HotSpo
 Hotspot *NoradAlpha::getItemScreenSpot(Item *item, DisplayElement *element) {
 	switch (item->getObjectID()) {
 	case kGasCanister:
-		return g_allHotspots.findHotspotByID(kN01GasCanisterSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kN01GasCanisterSpotID);
 	case kAirMask:
-		return g_allHotspots.findHotspotByID(kN01AirMaskSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kN01AirMaskSpotID);
 	case kArgonCanister:
-		return g_allHotspots.findHotspotByID(kN01ArgonCanisterSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kN01ArgonCanisterSpotID);
 	case kNitrogenCanister:
-		return g_allHotspots.findHotspotByID(kN01NitrogenCanisterSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kN01NitrogenCanisterSpotID);
 	}
 
 	return Norad::getItemScreenSpot(item, element);
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
index 2b208aa..cf21f77 100644
--- a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
@@ -102,38 +102,38 @@ void NoradDelta::init() {
 	Norad::init();
 
 	// Little fix for the retinal scan zoom in spot...
-	Hotspot *hotspot = g_allHotspots.findHotspotByID(kNorad68WestSpotID);
+	Hotspot *hotspot = _vm->getAllHotspots().findHotspotByID(kNorad68WestSpotID);
 	hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag);
 	
-	hotspot = g_allHotspots.findHotspotByID(kNorad79WestSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kNorad79WestSpotID);
 	hotspot->setMaskedHotspotFlags(kZoomInSpotFlag, kZoomInSpotFlag | kZoomOutSpotFlag);
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotShieldBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotShieldBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	HotspotInfoTable::Entry *hotspotEntry = findHotspotEntry(kDelta59RobotShieldBiochipSpotID);
 	hotspotEntry->hotspotItem = kShieldBiochip;
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotOpMemBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotOpMemBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	hotspotEntry = findHotspotEntry(kDelta59RobotOpMemBiochipSpotID);
 	hotspotEntry->hotspotItem = kOpticalBiochip;
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta59RobotRetinalBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta59RobotRetinalBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	hotspotEntry = findHotspotEntry(kDelta59RobotRetinalBiochipSpotID);
 	hotspotEntry->hotspotItem = kRetinalScanBiochip;
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotShieldBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotShieldBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	hotspotEntry = findHotspotEntry(kDelta60RobotShieldBiochipSpotID);
 	hotspotEntry->hotspotItem = kShieldBiochip;
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotOpMemBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotOpMemBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	hotspotEntry = findHotspotEntry(kDelta60RobotOpMemBiochipSpotID);
 	hotspotEntry->hotspotItem = kOpticalBiochip;
 	
-	hotspot = g_allHotspots.findHotspotByID(kDelta60RobotRetinalBiochipSpotID);
+	hotspot = _vm->getAllHotspots().findHotspotByID(kDelta60RobotRetinalBiochipSpotID);
 	hotspot->setMaskedHotspotFlags(kPickUpBiochipSpotFlag, kPickUpBiochipSpotFlag);
 	hotspotEntry = findHotspotEntry(kDelta60RobotRetinalBiochipSpotID);
 	hotspotEntry->hotspotItem = kRetinalScanBiochip;
@@ -508,7 +508,7 @@ TimeValue NoradDelta::getViewTime(const RoomID room, const DirectionConstant dir
 void NoradDelta::openDoor() {	
 	if (GameState.getCurrentRoom() == kNorad59 && GameState.getCurrentDirection() == kWest && GameState.getNoradPlayedGlobeGame()) {
 		Input scratch;
-		InputHandler::_inputHandler->clickInHotspot(scratch, g_allHotspots.findHotspotByID(kNorad59WestSpotID));
+		InputHandler::_inputHandler->clickInHotspot(scratch, _vm->getAllHotspots().findHotspotByID(kNorad59WestSpotID));
 	} else {
 		Norad::openDoor();
 	}
@@ -518,53 +518,53 @@ void NoradDelta::activateHotspots() {
 	Norad::activateHotspots();
 
 	if (GameState.getCurrentRoom() == kNorad59West && GameState.getCurrentDirection() == kWest && GameState.getNoradBeatRobotWithDoor()) {
-		g_allHotspots.deactivateOneHotspot(kNorad59WestOutSpotID);
+		_vm->getAllHotspots().deactivateOneHotspot(kNorad59WestOutSpotID);
 
 		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
 			if (!_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta59RobotShieldBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta59RobotShieldBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta59RobotShieldBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta59RobotShieldBiochipSpotID);
 
 			if (!_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta59RobotOpMemBiochipSpotID);
 
 			if (!_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta59RobotRetinalBiochipSpotID);
 		} else
-			g_allHotspots.activateOneHotspot(kDelta59RobotHeadSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kDelta59RobotHeadSpotID);
 	} else if (GameState.getCurrentRoom() == kNorad60West && GameState.getCurrentDirection() == kWest &&
 			GameState.getNoradBeatRobotWithClaw()) {
-		g_allHotspots.deactivateOneHotspot(kNorad60MonitorOutSpotID);
+		_vm->getAllHotspots().deactivateOneHotspot(kNorad60MonitorOutSpotID);
 
 		if (_privateFlags.getFlag(kNoradPrivateRobotHeadOpenFlag)) {
 			if (!_privateFlags.getFlag(kNoradPrivateGotShieldChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta60RobotShieldBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta60RobotShieldBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta60RobotShieldBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta60RobotShieldBiochipSpotID);
 
 			if (!_privateFlags.getFlag(kNoradPrivateGotOpticalChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta60RobotOpMemBiochipSpotID);
 
 			if (!_privateFlags.getFlag(kNoradPrivateGotRetScanChipFlag))
-				g_allHotspots.activateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
 			else
-				g_allHotspots.deactivateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
+				_vm->getAllHotspots().deactivateOneHotspot(kDelta60RobotRetinalBiochipSpotID);
 		} else {
-			g_allHotspots.activateOneHotspot(kDelta60RobotHeadSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kDelta60RobotHeadSpotID);
 		}
 	} else if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad50, kEast)) {
 		if (GameState.isCurrentDoorOpen())
-			g_allHotspots.deactivateOneHotspot(kNorad50DoorSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kNorad50DoorSpotID);
 	} else if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad59, kWest)) {
 		if (GameState.isCurrentDoorOpen())
-			g_allHotspots.deactivateOneHotspot(kNorad59WestSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kNorad59WestSpotID);
 	}
 }
 
@@ -726,7 +726,7 @@ Hotspot *NoradDelta::getItemScreenSpot(Item *item, DisplayElement *element) {
 	}
 
 	if (id != kNoHotSpotID)
-		return g_allHotspots.findHotspotByID(id);
+		return _vm->getAllHotspots().findHotspotByID(id);
 
 	return Norad::getItemScreenSpot(item, element);
 }
@@ -852,7 +852,7 @@ void NoradDelta::doSolve() {
 		if (biochip != 0 && biochip->getObjectID() != kRetinalScanBiochip && g_interface)
 			g_interface->setCurrentBiochipID(kRetinalScanBiochip);
 
-		Hotspot *spot = g_allHotspots.findHotspotByID(kNorad68WestSpotID);
+		Hotspot *spot = _vm->getAllHotspots().findHotspotByID(kNorad68WestSpotID);
 		Input scratch;
 		InputHandler::_inputHandler->clickInHotspot(scratch, spot);
 	}
diff --git a/engines/pegasus/neighborhood/norad/pressuretracker.cpp b/engines/pegasus/neighborhood/norad/pressuretracker.cpp
index 60521a4..5aac19d 100644
--- a/engines/pegasus/neighborhood/norad/pressuretracker.cpp
+++ b/engines/pegasus/neighborhood/norad/pressuretracker.cpp
@@ -24,6 +24,7 @@
  */
 
 #include "pegasus/hotspot.h"
+#include "pegasus/pegasus.h"
 #include "pegasus/neighborhood/norad/pressuredoor.h"
 #include "pegasus/neighborhood/norad/pressuretracker.h"
 
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
index b67d31a..dcc00ab 100644
--- a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
@@ -493,10 +493,10 @@ void Prehistoric::activateHotspots() {
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kPrehistoric18, kEast):
 		if (!_privateFlags.getFlag(kPrehistoricPrivateExtendedBridgeFlag))
-			g_allHotspots.activateOneHotspot(kPre18EastSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kPre18EastSpotID);
 		break;
 	case MakeRoomView(kPrehistoric22North, kNorth):
-		g_allHotspots.activateOneHotspot(kPre22NorthBreakerSpotID);
+		_vm->getAllHotspots().activateOneHotspot(kPre22NorthBreakerSpotID);
 		break;
 	}
 }
@@ -639,7 +639,7 @@ void Prehistoric::doSolve() {
 
 Hotspot *Prehistoric::getItemScreenSpot(Item *item, DisplayElement *element) {
 	if (item->getObjectID() == kHistoricalLog)
-		return g_allHotspots.findHotspotByID(kPrehistoricHistoricalLogSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kPrehistoricHistoricalLogSpotID);
 
 	return Neighborhood::getItemScreenSpot(item, element);
 }
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index ccc0834..bb7a701 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -1329,7 +1329,7 @@ void FullTSA::activateHotspots() {
 	switch (MakeRoomView(GameState.getCurrentRoom(), GameState.getCurrentDirection())) {
 	case MakeRoomView(kTSA02, kNorth):
 		if (!GameState.getTSAFrontDoorUnlockedOutside())
-			g_allHotspots.activateOneHotspot(kTSA02DoorSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kTSA02DoorSpotID);
 		break;
 	case MakeRoomView(kTSA0B, kEast):
 		if (GameState.getTSA0BZoomedIn())
@@ -1340,10 +1340,10 @@ void FullTSA::activateHotspots() {
 			case kRobotsAtFrontDoor:
 			case kRobotsAtReadyRoom:
 				if (getCurrentActivation() != kActivateTSA0BComparisonVideo) {
-					g_allHotspots.activateOneHotspot(kTSA0BEastCompareNoradSpotID);
-					g_allHotspots.activateOneHotspot(kTSA0BEastCompareMarsSpotID);
-					g_allHotspots.activateOneHotspot(kTSA0BEastCompareCaldoriaSpotID);
-					g_allHotspots.activateOneHotspot(kTSA0BEastCompareWSCSpotID);
+					_vm->getAllHotspots().activateOneHotspot(kTSA0BEastCompareNoradSpotID);
+					_vm->getAllHotspots().activateOneHotspot(kTSA0BEastCompareMarsSpotID);
+					_vm->getAllHotspots().activateOneHotspot(kTSA0BEastCompareCaldoriaSpotID);
+					_vm->getAllHotspots().activateOneHotspot(kTSA0BEastCompareWSCSpotID);
 				}
 				break;
 			}
@@ -1354,9 +1354,9 @@ void FullTSA::activateHotspots() {
 			case kRobotsAtCommandCenter:
 			case kRobotsAtFrontDoor:
 			case kRobotsAtReadyRoom:
-				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToCommandCenterSpotID);
-				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToReadyRoomSpotID);
-				g_allHotspots.activateOneHotspot(kTSA0BNorthRobotsToFrontDoorSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kTSA0BNorthRobotsToCommandCenterSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kTSA0BNorthRobotsToReadyRoomSpotID);
+				_vm->getAllHotspots().activateOneHotspot(kTSA0BNorthRobotsToFrontDoorSpotID);
 				break;
 			}
 		break;
@@ -2814,10 +2814,10 @@ void FullTSA::initializePegasusButtons(bool resolved) {
 Hotspot *FullTSA::getItemScreenSpot(Item *item, DisplayElement *element) {
 	switch (item->getObjectID()) {
 	case kJourneymanKey:
-		return g_allHotspots.findHotspotByID(kTSA22EastKeySpotID);
+		return _vm->getAllHotspots().findHotspotByID(kTSA22EastKeySpotID);
 		break;
 	case kPegasusBiochip:
-		return g_allHotspots.findHotspotByID(kTSA23WestChipsSpotID);
+		return _vm->getAllHotspots().findHotspotByID(kTSA23WestChipsSpotID);
 		break;
 	}
 
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index 1f00999..39fbe37 100644
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -1572,7 +1572,7 @@ void WSC::arriveAt(const RoomID room, const DirectionConstant dir) {
 		} else {
 			if (GameState.getWSCCatwalkDark()) {
 				//	Change the gun hot spot...
-				g_allHotspots.setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft,
+				_vm->getAllHotspots().setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft,
 						99 + kNavAreaTop,372 + kNavAreaLeft, 149 + kNavAreaTop));
 			}
 			setCurrentActivation(kActivationRobotGone);
@@ -1906,7 +1906,7 @@ void WSC::receiveNotification(Notification *notification, const NotificationFlag
 		case kW98RobotShocked:
 			GameState.setWSCCatwalkDark(true);
 			// Change the gun hot spot...
-			g_allHotspots.setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft, 99 + kNavAreaTop,
+			_vm->getAllHotspots().setHotspotRect(kW98StunGunSpotID, Common::Rect(181 + kNavAreaLeft, 99 + kNavAreaTop,
 					372 + kNavAreaLeft, 149 + kNavAreaTop));
 			setCurrentActivation(kActivationRobotDead);
 			GameState.setWSCRobotDead(true);
@@ -2124,19 +2124,19 @@ void WSC::activateHotspots() {
 
 	if (GameState.getCurrentRoomAndView() == MakeRoomView(kWSC98, kWest) && _privateFlags.getFlag(kWSCPrivateRobotHeadOpenFlag)) {
 		if (_privateFlags.getFlag(kWSCPrivateGotRetScanChipFlag))
-			g_allHotspots.deactivateOneHotspot(kW98RetinalChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kW98RetinalChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kW98RetinalChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kW98RetinalChipSpotID);
 
 		if (_privateFlags.getFlag(kWSCPrivateGotMapChipFlag))
-			g_allHotspots.deactivateOneHotspot(kW98MapChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kW98MapChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kW98MapChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kW98MapChipSpotID);
 
 		if (_privateFlags.getFlag(kWSCPrivateGotOpticalChipFlag))
-			g_allHotspots.deactivateOneHotspot(kW98OpticalChipSpotID);
+			_vm->getAllHotspots().deactivateOneHotspot(kW98OpticalChipSpotID);
 		else
-			g_allHotspots.activateOneHotspot(kW98OpticalChipSpotID);
+			_vm->getAllHotspots().activateOneHotspot(kW98OpticalChipSpotID);
 	}
 }
 
@@ -2324,7 +2324,7 @@ Hotspot *WSC::getItemScreenSpot(Item *item, DisplayElement *element) {
 	if (destSpotID == kNoHotSpotID)
 		return Neighborhood::getItemScreenSpot(item, element);
 
-	return g_allHotspots.findHotspotByID(destSpotID);
+	return _vm->getAllHotspots().findHotspotByID(destSpotID);
 }
 
 void WSC::pickedUpItem(Item *item) {	
@@ -2346,7 +2346,7 @@ void WSC::pickedUpItem(Item *item) {
 		_vm->addItemToInventory((InventoryItem *)item);
 		item = (Item *)g_allItems.findItemByID(kSinclairKey);
 		_vm->addItemToInventory((InventoryItem *)item);
-		g_allHotspots.setHotspotRect(kWSC02SouthMorphOutSpotID,
+		_vm->getAllHotspots().setHotspotRect(kWSC02SouthMorphOutSpotID,
 				Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 		break;
 	case kArgonCanister:
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index bbe2e0e..ad0abc2 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -161,7 +161,7 @@ Common::Error PegasusEngine::run() {
 
 	_returnHotspot.setArea(Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
 	_returnHotspot.setHotspotFlags(kInfoReturnSpotFlag);
-	g_allHotspots.push_back(&_returnHotspot);
+	_allHotspots.push_back(&_returnHotspot);
 
 	_screenDimmer.setBounds(Common::Rect(0, 0, 640, 480));
 	_screenDimmer.setDisplayOrder(kScreenDimmerOrder);
@@ -1839,15 +1839,15 @@ void PegasusEngine::shellGameInput(const Input &input, const Hotspot *cursorSpot
 
 void PegasusEngine::activateHotspots() {
 	if (_gameMode == kModeInfoScreen) {
-		g_allHotspots.activateOneHotspot(kInfoReturnSpotID);
+		_allHotspots.activateOneHotspot(kInfoReturnSpotID);
 	} else {
 		// Set up hot spots.
 		if (_dragType == kDragInventoryPickup)
-			g_allHotspots.activateOneHotspot(kInventoryDropSpotID);
+			_allHotspots.activateOneHotspot(kInventoryDropSpotID);
 		else if (_dragType == kDragBiochipPickup)
-			g_allHotspots.activateOneHotspot(kBiochipDropSpotID);
+			_allHotspots.activateOneHotspot(kBiochipDropSpotID);
 		else if (_dragType == kDragNoDrag)
-			g_allHotspots.activateMaskedHotspots(kShellSpotFlag);
+			_allHotspots.activateMaskedHotspots(kShellSpotFlag);
 	}
 }
 
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 1ee0136..7f4fae5 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -112,6 +112,7 @@ public:
 	uint getRandomNumber(uint max);
 	void shuffleArray(int32 *arr, int32 count);
 	void drawScaledFrame(const Graphics::Surface *frame, uint16 x, uint16 y);
+	HotspotList &getAllHotspots() { return _allHotspots; }
 
 	// Energy
 	void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; }
@@ -251,6 +252,7 @@ private:
 
 	// Misc.
 	Hotspot _returnHotspot;
+	HotspotList _allHotspots;
 	InputHandler *_savedHandler;
 	void showTempScreen(const Common::String &fileName);
 	bool playMovieScaled(Video::VideoDecoder *video, uint16 x, uint16 y);


Commit: f61146f32791831211c7b9399ec681aed109f03b
    https://github.com/scummvm/scummvm/commit/f61146f32791831211c7b9399ec681aed109f03b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-28T13:50:15-07:00

Commit Message:
PEGASUS: Remove g_allItems global construction

Changed paths:
    engines/pegasus/items/itemlist.cpp
    engines/pegasus/items/itemlist.h
    engines/pegasus/neighborhood/caldoria/caldoria.cpp
    engines/pegasus/neighborhood/mars/mars.cpp
    engines/pegasus/neighborhood/neighborhood.cpp
    engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
    engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
    engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
    engines/pegasus/neighborhood/tsa/fulltsa.cpp
    engines/pegasus/neighborhood/wsc/wsc.cpp
    engines/pegasus/pegasus.cpp
    engines/pegasus/pegasus.h



diff --git a/engines/pegasus/items/itemlist.cpp b/engines/pegasus/items/itemlist.cpp
index 4c30975..ff8cae5 100644
--- a/engines/pegasus/items/itemlist.cpp
+++ b/engines/pegasus/items/itemlist.cpp
@@ -26,14 +26,12 @@
 #include "common/error.h"
 #include "common/stream.h"
 
-#include "engines/pegasus/items/item.h"
-#include "engines/pegasus/items/itemlist.h"
+#include "pegasus/pegasus.h"
+#include "pegasus/items/item.h"
+#include "pegasus/items/itemlist.h"
 
 namespace Pegasus {
 
-// TODO: Don't use global construction!
-ItemList g_allItems;
-
 ItemList::ItemList() {
 }
 
diff --git a/engines/pegasus/items/itemlist.h b/engines/pegasus/items/itemlist.h
index b5a1d48..173a541 100644
--- a/engines/pegasus/items/itemlist.h
+++ b/engines/pegasus/items/itemlist.h
@@ -52,8 +52,7 @@ public:
 
 typedef ItemList::iterator ItemIterator;
 
-// TODO: Don't use global construction!
-extern ItemList g_allItems;
+#define g_allItems (((PegasusEngine *)g_engine)->getAllItems())
 
 } // End of namespace Pegasus
 
diff --git a/engines/pegasus/neighborhood/caldoria/caldoria.cpp b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
index 6421195..8c31deb 100644
--- a/engines/pegasus/neighborhood/caldoria/caldoria.cpp
+++ b/engines/pegasus/neighborhood/caldoria/caldoria.cpp
@@ -1175,7 +1175,7 @@ void Caldoria::receiveNotification(Notification *notification, const Notificatio
 			arriveAt(kCaldoria27, GameState.getCurrentDirection());
 			break;
 		case kCaGTCardSwipe:
-			item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kKeyCard);
 			_vm->addItemToInventory(item);
 			setCurrentActivation(kActivateReadyToTransport);
 			break;
@@ -1212,7 +1212,7 @@ void Caldoria::receiveNotification(Notification *notification, const Notificatio
 			}
 			break;
 		case kCa53EastShootSinclair:
-			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kStunGun));
+			_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kStunGun));
 			startExtraSequence(kCa53EastZoomOutFromSinclair, kExtraCompletedFlag, false);
 			GameState.setScoringStunnedSinclair(true);
 			break;
@@ -1769,8 +1769,8 @@ void Caldoria::openElevatorMovie() {
 void Caldoria::emptyOJGlass() {
 	GameState.setTakenItemID(kOrangeJuiceGlassFull, false);
 	GameState.setTakenItemID(kOrangeJuiceGlassEmpty, true);
-	_vm->removeItemFromInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassFull));
-	_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kOrangeJuiceGlassEmpty));
+	_vm->removeItemFromInventory((InventoryItem *)_vm->getAllItems().findItemByID(kOrangeJuiceGlassFull));
+	_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kOrangeJuiceGlassEmpty));
 }
 
 void Caldoria::doorBombTimerExpired() {
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp
index 8c1098a..9cc8ab6 100644
--- a/engines/pegasus/neighborhood/mars/mars.cpp
+++ b/engines/pegasus/neighborhood/mars/mars.cpp
@@ -1632,7 +1632,7 @@ void Mars::activateHotspots() {
 	case MakeRoomView(kMars56, kEast):
 		switch (getCurrentActivation()) {
 		case kActivateReactorReadyForNitrogen:
-			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kNitrogenCanister);
 			if (item->getItemState() != kNitrogenFull)
 				_vm->getAllHotspots().deactivateOneHotspot(kMars57DropNitrogenSpotID);
 			// Fall through...
@@ -2151,7 +2151,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
 			}
 			break;
 		case kMarsTurnOnPod:
-			item = (InventoryItem *)g_allItems.findItemByID(kMarsCard);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kMarsCard);
 			_vm->addItemToInventory(item);
 			GameState.setScoringTurnedOnTransport();
 			loadLoopSound1("");
@@ -2259,7 +2259,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
 			GameState.setMarsLockFrozen(false);
 			break;
 		case kMars57FreezeLock:
-			item = (InventoryItem *)g_allItems.findItemByID(kNitrogenCanister);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kNitrogenCanister);
 			item->setItemState(kNitrogenEmpty);
 			_vm->addItemToInventory(item);
 			setCurrentActivation(kActivateReactorReadyForCrowBar);
@@ -2271,7 +2271,7 @@ void Mars::receiveNotification(Notification *notification, const NotificationFla
 			_utilityFuse.lightFuse();
 			break;
 		case kMars57BreakLock:
-			item = (InventoryItem *)g_allItems.findItemByID(kCrowbar);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kCrowbar);
 			_vm->addItemToInventory(item);
 			GameState.setScoringUsedCrowBar();
 			GameState.setMarsLockBroken(true);
diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp
index a93dd7e..bb2c648 100644
--- a/engines/pegasus/neighborhood/neighborhood.cpp
+++ b/engines/pegasus/neighborhood/neighborhood.cpp
@@ -676,7 +676,7 @@ void Neighborhood::clickInHotspot(const Input &input, const Hotspot *clickedSpot
 		}
 
 		if (itemID != kNoItemID) {
-			Item *draggingItem = g_allItems.findItemByID(itemID);
+			Item *draggingItem = _vm->getAllItems().findItemByID(itemID);
 
 			if (draggingItem) {
 				takeItemFromRoom(draggingItem);
@@ -1157,7 +1157,7 @@ void Neighborhood::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *h
 		break;
 	default:
 		if ((hotspot->getHotspotFlags() & kPickUpBiochipSpotFlag) != 0) {
-			Item *item = g_allItems.findItemByID(entry.hotspotItem);
+			Item *item = _vm->getAllItems().findItemByID(entry.hotspotItem);
 			if (item &&	item->getItemNeighborhood() == getObjectID())
 				hotspot->setActive();
 		} else {
diff --git a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
index 2d050d9..793d8ff 100644
--- a/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
@@ -136,25 +136,25 @@ void NoradAlpha::start() {
 	RoomID itemRoom;
 	DirectionConstant itemDirection;
 
-	Item *item = (Item *)g_allItems.findItemByID(kGasCanister);
+	Item *item = (Item *)_vm->getAllItems().findItemByID(kGasCanister);
 	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 
 	if (itemNeighborhood == getObjectID()) {
 		_fillingStationItem = item;
 	} else {
-		item = (Item *)g_allItems.findItemByID(kAirMask);
+		item = (Item *)_vm->getAllItems().findItemByID(kAirMask);
 		item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 
 		if (itemNeighborhood == getObjectID()) {
 			_fillingStationItem = item;
 		} else {
-			item = (Item *)g_allItems.findItemByID(kNitrogenCanister);
+			item = (Item *)_vm->getAllItems().findItemByID(kNitrogenCanister);
 			item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 
 			if (itemNeighborhood == getObjectID()) {
 				_fillingStationItem = item;
 			} else {
-				item = (Item *)g_allItems.findItemByID(kArgonCanister);
+				item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
 				item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 				if (itemNeighborhood == getObjectID())
 					_fillingStationItem = item;
diff --git a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
index cf21f77..0153002 100644
--- a/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
+++ b/engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
@@ -846,7 +846,7 @@ void NoradDelta::doSolve() {
 
 	if (GameState.getCurrentRoomAndView() == MakeRoomView(kNorad68, kWest)) {
 		if (!_vm->playerHasItemID(kRetinalScanBiochip))
-			_vm->addItemToBiochips((BiochipItem *)g_allItems.findItemByID(kRetinalScanBiochip));
+			_vm->addItemToBiochips((BiochipItem *)_vm->getAllItems().findItemByID(kRetinalScanBiochip));
 
 		BiochipItem *biochip = _vm->getCurrentBiochip();
 		if (biochip != 0 && biochip->getObjectID() != kRetinalScanBiochip && g_interface)
diff --git a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
index dcc00ab..11e28f0 100644
--- a/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
+++ b/engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
@@ -284,7 +284,7 @@ void Prehistoric::turnTo(const DirectionConstant newDirection) {
 		break;
 	case MakeRoomView(kPrehistoric16, kNorth):
 	case MakeRoomView(kPrehistoric21, kWest):
-		keyCard = g_allItems.findItemByID(kKeyCard);
+		keyCard = _vm->getAllItems().findItemByID(kKeyCard);
 		if (keyCard->getItemState() == kFlashlightOff) {
 			keyCard->setItemState(kFlashlightOn);
 			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
@@ -294,7 +294,7 @@ void Prehistoric::turnTo(const DirectionConstant newDirection) {
 	case MakeRoomView(kPrehistoric16, kWest):
 	case MakeRoomView(kPrehistoric21, kNorth):
 	case MakeRoomView(kPrehistoric21, kSouth):
-		keyCard = g_allItems.findItemByID(kKeyCard);
+		keyCard = _vm->getAllItems().findItemByID(kKeyCard);
 		if (keyCard->getItemState() == kFlashlightOn) {
 			keyCard->setItemState(kFlashlightOff);
 			playSpotSoundSync(kPrehistoricFlashlightClickIn, kPrehistoricFlashlightClickOut);
@@ -356,7 +356,7 @@ void Prehistoric::arriveAt(const RoomID room, const DirectionConstant direction)
 		zoomToVault();
 		break;
 	case MakeRoomView(kPrehistoric16, kNorth):
-		keyCard = g_allItems.findItemByID(kKeyCard);
+		keyCard = _vm->getAllItems().findItemByID(kKeyCard);
 
 		if (keyCard->getItemState() == kFlashlightOff) {
 			keyCard->setItemState(kFlashlightOn);
@@ -383,7 +383,7 @@ void Prehistoric::arriveAt(const RoomID room, const DirectionConstant direction)
 	case MakeRoomView(kPrehistoric19, kNorth):
 	case MakeRoomView(kPrehistoric20, kNorth):
 	case MakeRoomView(kPrehistoric21, kEast):
-		keyCard = g_allItems.findItemByID(kKeyCard);
+		keyCard = _vm->getAllItems().findItemByID(kKeyCard);
 
 		if (keyCard->getItemState() == kFlashlightOn) {
 			keyCard->setItemState(kFlashlightOff);
@@ -554,7 +554,7 @@ void Prehistoric::receiveNotification(Notification *notification, const Notifica
 			break;
 		case kPre25EastUnlockingVaultNoLog:
 		case kPre25EastUnlockingVaultWithLog:
-			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kJourneymanKey));
+			_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kJourneymanKey));
 			break;
 		}
 	}
diff --git a/engines/pegasus/neighborhood/tsa/fulltsa.cpp b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
index bb7a701..2269ea7 100644
--- a/engines/pegasus/neighborhood/tsa/fulltsa.cpp
+++ b/engines/pegasus/neighborhood/tsa/fulltsa.cpp
@@ -1108,7 +1108,7 @@ void FullTSA::pickedUpItem(Item *item) {
 		GameState.setScoringGotJourneymanKey(true);
 		break;
 	case kPegasusBiochip:
-		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
+		biochip = (BiochipItem *)_vm->getAllItems().findItemByID(kMapBiochip);
 		_vm->addItemToBiochips(biochip);
 		GameState.setScoringGotPegasusBiochip(true);
 		break;
@@ -2373,7 +2373,7 @@ void FullTSA::receiveNotification(Notification *notification, const Notification
 
 		switch (lastExtra) {
 		case kTSAGTCardSwipe:
-			item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+			item = (InventoryItem *)_vm->getAllItems().findItemByID(kKeyCard);
 			_vm->addItemToInventory(item);
 			setCurrentActivation(kActivateTSAReadyToTransport);
 			break;
diff --git a/engines/pegasus/neighborhood/wsc/wsc.cpp b/engines/pegasus/neighborhood/wsc/wsc.cpp
index 39fbe37..e3a0eff 100644
--- a/engines/pegasus/neighborhood/wsc/wsc.cpp
+++ b/engines/pegasus/neighborhood/wsc/wsc.cpp
@@ -1098,7 +1098,7 @@ void WSC::closeDoorOffScreen(const RoomID room, const DirectionConstant) {
 	case kWSC82:
 	case kWSC92:
 	case kWSC93:
-		keyCard = g_allItems.findItemByID(kKeyCard);
+		keyCard = _vm->getAllItems().findItemByID(kKeyCard);
 		if (keyCard->getItemState() == kFlashlightOn && (GameState.getCurrentRoom() == kWSC81 ||
 				GameState.getCurrentRoom() == kWSC93)) {
 			keyCard->setItemState(kFlashlightOff);
@@ -1166,11 +1166,11 @@ void WSC::doorOpened() {
 
 	switch (GameState.getCurrentRoomAndView()) {
 	case MakeRoomView(kWSC42, kEast):
-		_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kSinclairKey));
+		_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kSinclairKey));
 		break;
 	case MakeRoomView(kWSC58, kSouth):
 		GameState.setScoringUsedCrowBarInWSC();
-		_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kCrowbar));
+		_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kCrowbar));
 		break;
 	case MakeRoomView(kWSC06, kNorth):
 	case MakeRoomView(kWSC79, kWest):
@@ -1663,7 +1663,7 @@ void WSC::receiveNotification(Notification *notification, const NotificationFlag
 			makeContinuePoint();
 			break;
 		case kWSCDartScan2:
-			_vm->addItemToInventory((InventoryItem *)g_allItems.findItemByID(kPoisonDart));
+			_vm->addItemToInventory((InventoryItem *)_vm->getAllItems().findItemByID(kPoisonDart));
 			GameState.setScoringRemovedDart();
 			GameState.setWSCRemovedDart(true);
 			setUpPoison();
@@ -1915,7 +1915,7 @@ void WSC::receiveNotification(Notification *notification, const NotificationFlag
 			//g_AIArea->playAIMovie(kRightAreaSignature, "Images/AI/WSC/XN59WD", false, kWarningInterruption);
 			break;
 		case kW98RobotGassed:
-			item = (Item *)g_allItems.findItemByID(kArgonCanister);
+			item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
 			_vm->addItemToInventory((InventoryItem *)item);
 			setCurrentActivation(kActivationRobotDead);
 			GameState.setWSCRobotDead(true);
@@ -2112,7 +2112,7 @@ void WSC::activateOneHotspot(HotspotInfoTable::Entry &entry, Hotspot *hotspot) {
 			hotspot->setActive();
 		break;
 	case kW98DropArgonSpotID:
-		argonCanister = g_allItems.findItemByID(kArgonCanister);
+		argonCanister = _vm->getAllItems().findItemByID(kArgonCanister);
 		if (argonCanister->getItemState() != kArgonFull)
 			hotspot->setInactive();
 		break;
@@ -2342,9 +2342,9 @@ void WSC::pickedUpItem(Item *item) {
 		break;
 	case kArgonPickup:
 		_vm->removeItemFromInventory((InventoryItem *)item);
-		item = (Item *)g_allItems.findItemByID(kArgonCanister);
+		item = (Item *)_vm->getAllItems().findItemByID(kArgonCanister);
 		_vm->addItemToInventory((InventoryItem *)item);
-		item = (Item *)g_allItems.findItemByID(kSinclairKey);
+		item = (Item *)_vm->getAllItems().findItemByID(kSinclairKey);
 		_vm->addItemToInventory((InventoryItem *)item);
 		_vm->getAllHotspots().setHotspotRect(kWSC02SouthMorphOutSpotID,
 				Common::Rect(kNavAreaLeft, kNavAreaTop, 512 + kNavAreaLeft, 256 + kNavAreaTop));
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index ad0abc2..efa57d5 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -470,14 +470,14 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 	setEnergyDeathReason(stream->readByte());
 
 	// Items
-	g_allItems.readFromStream(stream);
+	_allItems.readFromStream(stream);
 
 	// Inventory
 	byte itemCount = stream->readByte();
 
 	if (itemCount > 0) {
 		for (byte i = 0; i < itemCount; i++) {
-			InventoryItem *inv = (InventoryItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
+			InventoryItem *inv = (InventoryItem *)_allItems.findItemByID((ItemID)stream->readUint16BE());
 			addItemToInventory(inv);
 		}
 
@@ -489,7 +489,7 @@ bool PegasusEngine::loadFromStream(Common::ReadStream *stream) {
 
 	if (biochipCount > 0) {
 		for (byte i = 0; i < biochipCount; i++) {
-			BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID((ItemID)stream->readUint16BE());
+			BiochipItem *biochip = (BiochipItem *)_allItems.findItemByID((ItemID)stream->readUint16BE());
 			addItemToBiochips(biochip);
 		}
 
@@ -541,7 +541,7 @@ bool PegasusEngine::writeToStream(Common::WriteStream *stream, int saveType) {
 	stream->writeByte(getEnergyDeathReason());
 
 	// Items
-	g_allItems.writeToStream(stream);
+	_allItems.writeToStream(stream);
 
 	// Inventory
 	byte itemCount = _items.getNumItems();
@@ -1392,7 +1392,7 @@ bool PegasusEngine::itemInLocation(const ItemID itemID, const NeighborhoodID nei
 	RoomID itemRoom;
 	DirectionConstant itemDirection;
 	
-	Item *item = g_allItems.findItemByID(itemID);
+	Item *item = _allItems.findItemByID(itemID);
 	item->getItemRoom(itemNeighborhood, itemRoom, itemDirection);
 
 	return itemNeighborhood == neighborhood && itemRoom == room && itemDirection == direction;
@@ -1503,17 +1503,17 @@ void PegasusEngine::startNewGame() {
 	removeAllItemsFromInventory();
 	removeAllItemsFromBiochips();
 
-	BiochipItem *biochip = (BiochipItem *)g_allItems.findItemByID(kAIBiochip);
+	BiochipItem *biochip = (BiochipItem *)_allItems.findItemByID(kAIBiochip);
 	addItemToBiochips(biochip);
 
 	if (isDemo()) {
-		biochip = (BiochipItem *)g_allItems.findItemByID(kPegasusBiochip);
+		biochip = (BiochipItem *)_allItems.findItemByID(kPegasusBiochip);
 		addItemToBiochips(biochip);
-		biochip = (BiochipItem *)g_allItems.findItemByID(kMapBiochip);
+		biochip = (BiochipItem *)_allItems.findItemByID(kMapBiochip);
 		addItemToBiochips(biochip);
-		InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(kKeyCard);
+		InventoryItem *item = (InventoryItem *)_allItems.findItemByID(kKeyCard);
 		addItemToInventory(item);
-		item = (InventoryItem *)g_allItems.findItemByID(kJourneymanKey);
+		item = (InventoryItem *)_allItems.findItemByID(kJourneymanKey);
 		addItemToInventory(item);
 		_currentItemID = kJourneymanKey;
 	} else {
@@ -2154,7 +2154,7 @@ void PegasusEngine::drawScaledFrame(const Graphics::Surface *frame, uint16 x, ui
 }
 
 void PegasusEngine::destroyInventoryItem(const ItemID itemID) {
-	InventoryItem *item = (InventoryItem *)g_allItems.findItemByID(itemID);
+	InventoryItem *item = (InventoryItem *)_allItems.findItemByID(itemID);
 
 	ItemExtraEntry entry;
 
diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h
index 7f4fae5..661f8e0 100644
--- a/engines/pegasus/pegasus.h
+++ b/engines/pegasus/pegasus.h
@@ -132,6 +132,7 @@ public:
 	void setAmbienceLevel(uint16);
 
 	// Items
+	ItemList &getAllItems() { return _allItems; }
 	bool playerHasItem(const Item *);
 	bool playerHasItemID(const ItemID);
 	void checkFlashlight();
@@ -228,6 +229,7 @@ private:
 	void giveIdleTime();
 
 	// Items
+	ItemList _allItems;
 	void createItems();
 	void createItem(ItemID itemID, NeighborhoodID neighborhoodID, RoomID roomID, DirectionConstant direction);
 	Inventory _items;


Commit: 790a74ab9df5eae7bcf9d923b0d5ec26569771b2
    https://github.com/scummvm/scummvm/commit/790a74ab9df5eae7bcf9d923b0d5ec26569771b2
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-31T18:58:58-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A graphics/decoders/tga.cpp
  A graphics/decoders/tga.h
  A po/gl_ES.po
    AUTHORS
    NEWS
    backends/events/openpandora/op-events.cpp
    backends/platform/openpandora/op-options.cpp
    configure
    devtools/credits.pl
    engines/configure.engines
    engines/lastexpress/data/background.cpp
    engines/lastexpress/data/subtitle.cpp
    engines/lastexpress/debug.cpp
    engines/lastexpress/debug.h
    engines/lastexpress/entities/abbot.cpp
    engines/lastexpress/entities/abbot.h
    engines/lastexpress/entities/august.cpp
    engines/lastexpress/entities/chapters.cpp
    engines/lastexpress/entities/chapters.h
    engines/lastexpress/entities/entity.cpp
    engines/lastexpress/entities/entity.h
    engines/lastexpress/entities/verges.cpp
    engines/lastexpress/entities/verges.h
    engines/lastexpress/fight/fight.cpp
    engines/lastexpress/game/action.cpp
    engines/lastexpress/game/beetle.cpp
    engines/lastexpress/game/entities.cpp
    engines/lastexpress/game/entities.h
    engines/lastexpress/game/inventory.cpp
    engines/lastexpress/game/logic.cpp
    engines/lastexpress/game/savegame.cpp
    engines/lastexpress/game/savegame.h
    engines/lastexpress/game/savepoint.cpp
    engines/lastexpress/game/scenes.cpp
    engines/lastexpress/game/scenes.h
    engines/lastexpress/menu/menu.cpp
    engines/lastexpress/sound/entry.cpp
    engines/lastexpress/sound/queue.cpp
    engines/scumm/proc3ARM.s
    graphics/module.mk
    gui/credits.h
    gui/themes/translations.dat
    po/ca_ES.po
    video/avi_decoder.cpp
    video/codecs/svq1.cpp
    video/codecs/svq1_cb.h
    video/video_decoder.cpp
    video/video_decoder.h





Commit: 1043283e535a3870b557ef428223a99e9e3b5be5
    https://github.com/scummvm/scummvm/commit/1043283e535a3870b557ef428223a99e9e3b5be5
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-31T19:06:56-07:00

Commit Message:
PEGASUS: Use setEndTime()

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index fc722e5..6187d87 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -81,7 +81,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 		allocateSurface(bounds);
 
 	setStart(0, getScale());
-	setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale());
+	TimeBase::setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale());
 }
 
 void Movie::redrawMovieWorld() {
@@ -132,6 +132,13 @@ void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 	_movieBox.moveTo(h, v);
 }
 
+void Movie::setStop(const TimeValue stopTime, const TimeScale scale) {
+	TimeBase::setStop(stopTime, scale);
+
+	if (_video)
+		_video->setEndTime(Audio::Timestamp(0, _stopTime, _stopScale));
+}
+
 void Movie::setVolume(uint16 volume) {
 	if (_video)
 		_video->setVolume(MIN<uint>(volume, 0xFF));
@@ -205,12 +212,18 @@ TimeValue Movie::getDuration(const TimeScale scale) const {
 void Movie::updateTime() {
 	// The reason why we overrode TimeBase's updateTime():
 	// Again, avoiding timers and handling it here
-	if (_video && !_video->isPaused()) {
+	if (_video && _video->isPlaying() && !_video->isPaused()) {
 		redrawMovieWorld();
 
 		uint32 startTime = _startTime * getScale() / _startScale;
 		uint32 stopTime = _stopTime * getScale() / _stopScale;
 		uint32 actualTime = CLIP<int>(_video->getTime() * getScale() / 1000, startTime, stopTime);
+
+		// HACK: Due to the inaccuracy of the time, we won't actually allow us to hit
+		// the stop time unless we've actually reached the end of the segment.
+		if (actualTime == stopTime && !_video->endOfVideo())
+			actualTime--;
+
 		_time = Common::Rational(actualTime, getScale());
 	}
 }
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index efe4a7c..9b9cc2b 100644
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -62,6 +62,8 @@ public:
 
 	virtual void moveMovieBoxTo(const CoordType, const CoordType);
 
+	virtual void setStop(const TimeValue, const TimeScale = 0);
+
 	virtual TimeValue getDuration(const TimeScale = 0) const;
 
 	// *** HACK ALERT
diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index efa57d5..423d321 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -2087,15 +2087,14 @@ void PegasusEngine::playEndMessage() {
 }
 
 void PegasusEngine::doSubChase() {
-	static const uint32 endTime = 133200 * 1000 / 600;
-
 	Video::VideoDecoder *video = new Video::QuickTimeDecoder();
 	if (!video->loadFile("Images/Norad Alpha/Sub Chase Movie"))
 		error("Failed to load sub chase");
 
+	video->setEndTime(Audio::Timestamp(0, 133200, 600));
 	video->start();
 
-	while (!shouldQuit() && !video->endOfVideo() && video->getTime() < endTime) {
+	while (!shouldQuit() && !video->endOfVideo()) {
 		if (video->needsUpdate()) {
 			const Graphics::Surface *frame = video->decodeNextFrame();
 


Commit: 2f9b1b67b08f1b70cd95795aaf7816ca7f991649
    https://github.com/scummvm/scummvm/commit/2f9b1b67b08f1b70cd95795aaf7816ca7f991649
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-08-31T19:26:02-07:00

Commit Message:
ALL: Mark off some things as used by Pegasus

Changed paths:
    audio/decoders/aiff.h
    audio/decoders/quicktime.h
    common/macresman.h
    graphics/decoders/pict.h
    video/qt_decoder.h



diff --git a/audio/decoders/aiff.h b/audio/decoders/aiff.h
index 59664bb..afcdb6a 100644
--- a/audio/decoders/aiff.h
+++ b/audio/decoders/aiff.h
@@ -23,6 +23,7 @@
 /**
  * @file
  * Sound decoder used in engines:
+ *  - pegasus
  *  - saga
  *  - sci
  *  - sword1
diff --git a/audio/decoders/quicktime.h b/audio/decoders/quicktime.h
index 4dd1a57..4c0b934 100644
--- a/audio/decoders/quicktime.h
+++ b/audio/decoders/quicktime.h
@@ -25,6 +25,7 @@
  * Sound decoder used in engines:
  *  - groovie
  *  - mohawk
+ *  - pegasus
  *  - sci
  */
 
diff --git a/common/macresman.h b/common/macresman.h
index f334405..ed74da9 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -25,6 +25,7 @@
  * Macintosh resource fork manager used in engines:
  * - groovie
  * - mohawk
+ * - pegasus
  * - sci
  * - scumm
  */
diff --git a/graphics/decoders/pict.h b/graphics/decoders/pict.h
index 417a7c5..7497e39 100644
--- a/graphics/decoders/pict.h
+++ b/graphics/decoders/pict.h
@@ -24,6 +24,7 @@
  * @file
  * Image decoder used in engines:
  *  - mohawk
+ *  - pegasus
  *  - sci
  */
 
diff --git a/video/qt_decoder.h b/video/qt_decoder.h
index 71d3371..45ab155 100644
--- a/video/qt_decoder.h
+++ b/video/qt_decoder.h
@@ -53,6 +53,7 @@ class Codec;
  *
  * Video decoder used in engines:
  *  - mohawk
+ *  - pegasus
  *  - sci
  */
 class QuickTimeDecoder : public VideoDecoder, public Audio::QuickTimeAudioDecoder {


Commit: f35e820e9f2f4c2f8b9c6d3b572d588fccf99f19
    https://github.com/scummvm/scummvm/commit/f35e820e9f2f4c2f8b9c6d3b572d588fccf99f19
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-05T08:45:25-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Changed paths:
  A common/installshield_cab.cpp
  A common/installshield_cab.h
  A devtools/create_tony/create_tony.cpp
  A devtools/create_tony/create_tony.h
  A devtools/create_tony/module.mk
  A devtools/create_tony/staticdata.h
  A dists/engine-data/tony.dat
  A engines/tony/custom.cpp
  A engines/tony/custom.h
  A engines/tony/debugger.cpp
  A engines/tony/debugger.h
  A engines/tony/detection.cpp
  A engines/tony/detection_tables.h
  A engines/tony/font.cpp
  A engines/tony/font.h
  A engines/tony/game.cpp
  A engines/tony/game.h
  A engines/tony/gfxcore.cpp
  A engines/tony/gfxcore.h
  A engines/tony/gfxengine.cpp
  A engines/tony/gfxengine.h
  A engines/tony/globals.cpp
  A engines/tony/globals.h
  A engines/tony/input.cpp
  A engines/tony/input.h
  A engines/tony/inventory.cpp
  A engines/tony/inventory.h
  A engines/tony/loc.cpp
  A engines/tony/loc.h
  A engines/tony/module.mk
  A engines/tony/mpal/expr.cpp
  A engines/tony/mpal/expr.h
  A engines/tony/mpal/loadmpc.cpp
  A engines/tony/mpal/loadmpc.h
  A engines/tony/mpal/lzo.cpp
  A engines/tony/mpal/lzo.h
  A engines/tony/mpal/memory.cpp
  A engines/tony/mpal/memory.h
  A engines/tony/mpal/mpal.cpp
  A engines/tony/mpal/mpal.h
  A engines/tony/mpal/mpaldll.h
  A engines/tony/mpal/mpalutils.cpp
  A engines/tony/mpal/mpalutils.h
  A engines/tony/resid.h
  A engines/tony/sound.cpp
  A engines/tony/sound.h
  A engines/tony/tony.cpp
  A engines/tony/tony.h
  A engines/tony/tonychar.cpp
  A engines/tony/tonychar.h
  A engines/tony/utils.cpp
  A engines/tony/utils.h
  A engines/tony/window.cpp
  A engines/tony/window.h
  A engines/wintermute/ad/ad_actor.cpp
  A engines/wintermute/ad/ad_actor.h
  A engines/wintermute/ad/ad_entity.cpp
  A engines/wintermute/ad/ad_entity.h
  A engines/wintermute/ad/ad_game.cpp
  A engines/wintermute/ad/ad_game.h
  A engines/wintermute/ad/ad_inventory.cpp
  A engines/wintermute/ad/ad_inventory.h
  A engines/wintermute/ad/ad_inventory_box.cpp
  A engines/wintermute/ad/ad_inventory_box.h
  A engines/wintermute/ad/ad_item.cpp
  A engines/wintermute/ad/ad_item.h
  A engines/wintermute/ad/ad_layer.cpp
  A engines/wintermute/ad/ad_layer.h
  A engines/wintermute/ad/ad_node_state.cpp
  A engines/wintermute/ad/ad_node_state.h
  A engines/wintermute/ad/ad_object.cpp
  A engines/wintermute/ad/ad_object.h
  A engines/wintermute/ad/ad_path.cpp
  A engines/wintermute/ad/ad_path.h
  A engines/wintermute/ad/ad_path_point.cpp
  A engines/wintermute/ad/ad_path_point.h
  A engines/wintermute/ad/ad_region.cpp
  A engines/wintermute/ad/ad_region.h
  A engines/wintermute/ad/ad_response.cpp
  A engines/wintermute/ad/ad_response.h
  A engines/wintermute/ad/ad_response_box.cpp
  A engines/wintermute/ad/ad_response_box.h
  A engines/wintermute/ad/ad_response_context.cpp
  A engines/wintermute/ad/ad_response_context.h
  A engines/wintermute/ad/ad_rot_level.cpp
  A engines/wintermute/ad/ad_rot_level.h
  A engines/wintermute/ad/ad_scale_level.cpp
  A engines/wintermute/ad/ad_scale_level.h
  A engines/wintermute/ad/ad_scene.cpp
  A engines/wintermute/ad/ad_scene.h
  A engines/wintermute/ad/ad_scene_node.cpp
  A engines/wintermute/ad/ad_scene_node.h
  A engines/wintermute/ad/ad_scene_state.cpp
  A engines/wintermute/ad/ad_scene_state.h
  A engines/wintermute/ad/ad_sentence.cpp
  A engines/wintermute/ad/ad_sentence.h
  A engines/wintermute/ad/ad_sprite_set.cpp
  A engines/wintermute/ad/ad_sprite_set.h
  A engines/wintermute/ad/ad_talk_def.cpp
  A engines/wintermute/ad/ad_talk_def.h
  A engines/wintermute/ad/ad_talk_holder.cpp
  A engines/wintermute/ad/ad_talk_holder.h
  A engines/wintermute/ad/ad_talk_node.cpp
  A engines/wintermute/ad/ad_talk_node.h
  A engines/wintermute/ad/ad_types.h
  A engines/wintermute/ad/ad_waypoint_group.cpp
  A engines/wintermute/ad/ad_waypoint_group.h
  A engines/wintermute/base/base.cpp
  A engines/wintermute/base/base.h
  A engines/wintermute/base/base_active_rect.cpp
  A engines/wintermute/base/base_active_rect.h
  A engines/wintermute/base/base_dynamic_buffer.cpp
  A engines/wintermute/base/base_dynamic_buffer.h
  A engines/wintermute/base/base_engine.cpp
  A engines/wintermute/base/base_engine.h
  A engines/wintermute/base/base_fader.cpp
  A engines/wintermute/base/base_fader.h
  A engines/wintermute/base/base_file_manager.cpp
  A engines/wintermute/base/base_file_manager.h
  A engines/wintermute/base/base_frame.cpp
  A engines/wintermute/base/base_frame.h
  A engines/wintermute/base/base_game.cpp
  A engines/wintermute/base/base_game.h
  A engines/wintermute/base/base_keyboard_state.cpp
  A engines/wintermute/base/base_keyboard_state.h
  A engines/wintermute/base/base_named_object.cpp
  A engines/wintermute/base/base_named_object.h
  A engines/wintermute/base/base_object.cpp
  A engines/wintermute/base/base_object.h
  A engines/wintermute/base/base_parser.cpp
  A engines/wintermute/base/base_parser.h
  A engines/wintermute/base/base_persistence_manager.cpp
  A engines/wintermute/base/base_persistence_manager.h
  A engines/wintermute/base/base_point.cpp
  A engines/wintermute/base/base_point.h
  A engines/wintermute/base/base_quick_msg.cpp
  A engines/wintermute/base/base_quick_msg.h
  A engines/wintermute/base/base_region.cpp
  A engines/wintermute/base/base_region.h
  A engines/wintermute/base/base_save_thumb_helper.cpp
  A engines/wintermute/base/base_save_thumb_helper.h
  A engines/wintermute/base/base_script_holder.cpp
  A engines/wintermute/base/base_script_holder.h
  A engines/wintermute/base/base_scriptable.cpp
  A engines/wintermute/base/base_scriptable.h
  A engines/wintermute/base/base_sprite.cpp
  A engines/wintermute/base/base_sprite.h
  A engines/wintermute/base/base_string_table.cpp
  A engines/wintermute/base/base_string_table.h
  A engines/wintermute/base/base_sub_frame.cpp
  A engines/wintermute/base/base_sub_frame.h
  A engines/wintermute/base/base_surface_storage.cpp
  A engines/wintermute/base/base_surface_storage.h
  A engines/wintermute/base/base_transition_manager.cpp
  A engines/wintermute/base/base_transition_manager.h
  A engines/wintermute/base/base_viewport.cpp
  A engines/wintermute/base/base_viewport.h
  A engines/wintermute/base/file/base_disk_file.cpp
  A engines/wintermute/base/file/base_disk_file.h
  A engines/wintermute/base/file/base_file.cpp
  A engines/wintermute/base/file/base_file.h
  A engines/wintermute/base/file/base_file_entry.cpp
  A engines/wintermute/base/file/base_file_entry.h
  A engines/wintermute/base/file/base_package.cpp
  A engines/wintermute/base/file/base_package.h
  A engines/wintermute/base/file/base_resources.cpp
  A engines/wintermute/base/file/base_resources.h
  A engines/wintermute/base/file/base_save_thumb_file.cpp
  A engines/wintermute/base/file/base_save_thumb_file.h
  A engines/wintermute/base/file/dcpackage.h
  A engines/wintermute/base/font/base_font.cpp
  A engines/wintermute/base/font/base_font.h
  A engines/wintermute/base/font/base_font_bitmap.cpp
  A engines/wintermute/base/font/base_font_bitmap.h
  A engines/wintermute/base/font/base_font_storage.cpp
  A engines/wintermute/base/font/base_font_storage.h
  A engines/wintermute/base/font/base_font_truetype.cpp
  A engines/wintermute/base/font/base_font_truetype.h
  A engines/wintermute/base/gfx/base_image.cpp
  A engines/wintermute/base/gfx/base_image.h
  A engines/wintermute/base/gfx/base_renderer.cpp
  A engines/wintermute/base/gfx/base_renderer.h
  A engines/wintermute/base/gfx/base_surface.cpp
  A engines/wintermute/base/gfx/base_surface.h
  A engines/wintermute/base/gfx/osystem/base_render_osystem.cpp
  A engines/wintermute/base/gfx/osystem/base_render_osystem.h
  A engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
  A engines/wintermute/base/gfx/osystem/base_surface_osystem.h
  A engines/wintermute/base/particles/part_emitter.cpp
  A engines/wintermute/base/particles/part_emitter.h
  A engines/wintermute/base/particles/part_force.cpp
  A engines/wintermute/base/particles/part_force.h
  A engines/wintermute/base/particles/part_particle.cpp
  A engines/wintermute/base/particles/part_particle.h
  A engines/wintermute/base/saveload.cpp
  A engines/wintermute/base/saveload.h
  A engines/wintermute/base/scriptables/dcscript.h
  A engines/wintermute/base/scriptables/script.cpp
  A engines/wintermute/base/scriptables/script.h
  A engines/wintermute/base/scriptables/script_engine.cpp
  A engines/wintermute/base/scriptables/script_engine.h
  A engines/wintermute/base/scriptables/script_ext_array.cpp
  A engines/wintermute/base/scriptables/script_ext_array.h
  A engines/wintermute/base/scriptables/script_ext_date.cpp
  A engines/wintermute/base/scriptables/script_ext_date.h
  A engines/wintermute/base/scriptables/script_ext_file.cpp
  A engines/wintermute/base/scriptables/script_ext_file.h
  A engines/wintermute/base/scriptables/script_ext_math.cpp
  A engines/wintermute/base/scriptables/script_ext_math.h
  A engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp
  A engines/wintermute/base/scriptables/script_ext_mem_buffer.h
  A engines/wintermute/base/scriptables/script_ext_object.cpp
  A engines/wintermute/base/scriptables/script_ext_object.h
  A engines/wintermute/base/scriptables/script_ext_string.cpp
  A engines/wintermute/base/scriptables/script_ext_string.h
  A engines/wintermute/base/scriptables/script_stack.cpp
  A engines/wintermute/base/scriptables/script_stack.h
  A engines/wintermute/base/scriptables/script_value.cpp
  A engines/wintermute/base/scriptables/script_value.h
  A engines/wintermute/base/sound/base_sound.cpp
  A engines/wintermute/base/sound/base_sound.h
  A engines/wintermute/base/sound/base_sound_buffer.cpp
  A engines/wintermute/base/sound/base_sound_buffer.h
  A engines/wintermute/base/sound/base_sound_manager.cpp
  A engines/wintermute/base/sound/base_sound_manager.h
  A engines/wintermute/coll_templ.h
  A engines/wintermute/dcgf.h
  A engines/wintermute/dctypes.h
  A engines/wintermute/detection.cpp
  A engines/wintermute/detection_tables.h
  A engines/wintermute/graphics/transparent_surface.cpp
  A engines/wintermute/graphics/transparent_surface.h
  A engines/wintermute/math/math_util.cpp
  A engines/wintermute/math/math_util.h
  A engines/wintermute/math/matrix4.cpp
  A engines/wintermute/math/matrix4.h
  A engines/wintermute/math/rect32.h
  A engines/wintermute/math/vector2.cpp
  A engines/wintermute/math/vector2.h
  A engines/wintermute/module.mk
  A engines/wintermute/persistent.cpp
  A engines/wintermute/persistent.h
  A engines/wintermute/platform_osystem.cpp
  A engines/wintermute/platform_osystem.h
  A engines/wintermute/readme.txt
  A engines/wintermute/system/sys_class.cpp
  A engines/wintermute/system/sys_class.h
  A engines/wintermute/system/sys_class_registry.cpp
  A engines/wintermute/system/sys_class_registry.h
  A engines/wintermute/system/sys_instance.cpp
  A engines/wintermute/system/sys_instance.h
  A engines/wintermute/ui/ui_button.cpp
  A engines/wintermute/ui/ui_button.h
  A engines/wintermute/ui/ui_edit.cpp
  A engines/wintermute/ui/ui_edit.h
  A engines/wintermute/ui/ui_entity.cpp
  A engines/wintermute/ui/ui_entity.h
  A engines/wintermute/ui/ui_object.cpp
  A engines/wintermute/ui/ui_object.h
  A engines/wintermute/ui/ui_text.cpp
  A engines/wintermute/ui/ui_text.h
  A engines/wintermute/ui/ui_tiled_image.cpp
  A engines/wintermute/ui/ui_tiled_image.h
  A engines/wintermute/ui/ui_window.cpp
  A engines/wintermute/ui/ui_window.h
  A engines/wintermute/utils/convert_utf.cpp
  A engines/wintermute/utils/convert_utf.h
  A engines/wintermute/utils/crc.cpp
  A engines/wintermute/utils/crc.h
  A engines/wintermute/utils/path_util.cpp
  A engines/wintermute/utils/path_util.h
  A engines/wintermute/utils/string_util.cpp
  A engines/wintermute/utils/string_util.h
  A engines/wintermute/utils/utils.cpp
  A engines/wintermute/utils/utils.h
  A engines/wintermute/video/video_player.cpp
  A engines/wintermute/video/video_player.h
  A engines/wintermute/video/video_theora_player.cpp
  A engines/wintermute/video/video_theora_player.h
  A engines/wintermute/wintermute.cpp
  A engines/wintermute/wintermute.h
  A engines/wintermute/wintypes.h
  R engines/agos/installshield_cab.cpp
  R engines/agos/installshield_cab.h
    backends/events/openpandora/op-events.cpp
    backends/platform/openpandora/op-options.cpp
    backends/timer/bada/timer.cpp
    backends/timer/bada/timer.h
    common/coroutines.cpp
    common/module.mk
    common/zlib.cpp
    common/zlib.h
    configure
    engines/agos/module.mk
    engines/agos/res.cpp
    engines/cge/cge_main.cpp
    engines/configure.engines
    engines/engines.mk
    engines/plugins_table.h
    engines/sci/sound/drivers/adlib.cpp
    engines/sci/sound/music.cpp
    engines/scumm/costume.cpp
    engines/tinsel/scene.cpp
    engines/tsage/sound.cpp
    engines/tsage/sound.h
    graphics/scaler/aspect.cpp
    video/qt_decoder.cpp
    video/video_decoder.cpp
    video/video_decoder.h





Commit: b8bcbb46b47b30c87a0267211ae4aae4c61c4c78
    https://github.com/scummvm/scummvm/commit/b8bcbb46b47b30c87a0267211ae4aae4c61c4c78
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-07T10:22:08-07:00

Commit Message:
PEGASUS: Make setting the start time of a movie also seek

Better mirrors QuickTime behavior

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index 6187d87..fcceee1 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -80,7 +80,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 	if (!isSurfaceValid())
 		allocateSurface(bounds);
 
-	setStart(0, getScale());
+	TimeBase::setStart(0, getScale());
 	TimeBase::setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale());
 }
 
@@ -132,6 +132,13 @@ void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 	_movieBox.moveTo(h, v);
 }
 
+void Movie::setStart(const TimeValue startTime, const TimeScale scale) {
+	TimeBase::setStart(startTime, scale);
+
+	if (_video)
+		_video->seek(Audio::Timestamp(0, _startTime, _startScale));
+}
+
 void Movie::setStop(const TimeValue stopTime, const TimeScale scale) {
 	TimeBase::setStop(stopTime, scale);
 
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 9b9cc2b..275deec 100644
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -62,6 +62,8 @@ public:
 
 	virtual void moveMovieBoxTo(const CoordType, const CoordType);
 
+	virtual void setStart(const TimeValue, const TimeScale = 0);
+
 	virtual void setStop(const TimeValue, const TimeScale = 0);
 
 	virtual TimeValue getDuration(const TimeScale = 0) const;


Commit: 9855f7b5d8a5d6ae0537313ea1f3737f25e4d97f
    https://github.com/scummvm/scummvm/commit/9855f7b5d8a5d6ae0537313ea1f3737f25e4d97f
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-09T13:21:29-07:00

Commit Message:
PEGASUS: Fix some memory leaks

Thanks to fuzzie for spotting

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index 423d321..b307a19 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -104,7 +104,12 @@ PegasusEngine::~PegasusEngine() {
 	delete _rnd;
 	delete _introTimer;
 	delete _aiSaveStream;
+
+	for (ItemIterator it = _allItems.begin(); it != _allItems.end(); it++)
+		delete *it;
+
 	InputDeviceManager::destroy();
+	GameStateManager::destroy();
 
 	// NOTE: This must be deleted last!
 	delete _gfx;


Commit: 428702ca49a1fa25d0d439cb764ee9c88a54ee1e
    https://github.com/scummvm/scummvm/commit/428702ca49a1fa25d0d439cb764ee9c88a54ee1e
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-09T13:25:45-07:00

Commit Message:
PEGASUS: Fix some formatting issues

Changed paths:
    engines/pegasus/gamestate.h
    engines/pegasus/transition.cpp



diff --git a/engines/pegasus/gamestate.h b/engines/pegasus/gamestate.h
index 7812003..14ff533 100644
--- a/engines/pegasus/gamestate.h
+++ b/engines/pegasus/gamestate.h
@@ -313,7 +313,7 @@ public:
 	RoomViewID getCurrentRoomAndView();
 	
 	void getNextLocation(NeighborhoodID &neighborhood, RoomID &room, DirectionConstant &direction);
-	void	setNextLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
+	void setNextLocation(const NeighborhoodID neighborhood, const RoomID room, const DirectionConstant direction);
 
 	NeighborhoodID getNextNeighborhood();
 	void setNextNeighborhood(const NeighborhoodID neighborhood);
diff --git a/engines/pegasus/transition.cpp b/engines/pegasus/transition.cpp
index 0de63d6..4bcc4f0 100644
--- a/engines/pegasus/transition.cpp
+++ b/engines/pegasus/transition.cpp
@@ -163,36 +163,37 @@ void Slide::drawSlideElement(const Common::Rect &drawRect, const Common::Rect &o
 
 void Push::adjustSlideRects(Common::Rect &oldBounds, Common::Rect &newBounds) {
 	switch (_direction & kSlideHorizMask) {
-		case kSlideLeftMask:
-			newBounds.left = oldBounds.right = _bounds.right - pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
-			newBounds.right = newBounds.left + _boundsWidth;
-			oldBounds.left = oldBounds.right - _boundsWidth;
-			break;
-		case kSlideRightMask:
-			oldBounds.left = newBounds.right = _bounds.left + pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
-			oldBounds.right = oldBounds.left + _boundsWidth;
-			newBounds.left = newBounds.right - _boundsWidth;
-			break;
-		default:
-			newBounds.left = oldBounds.left = _bounds.left;
-			newBounds.right = oldBounds.right = _bounds.right;
-			break;
+	case kSlideLeftMask:
+		newBounds.left = oldBounds.right = _bounds.right - pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
+		newBounds.right = newBounds.left + _boundsWidth;
+		oldBounds.left = oldBounds.right - _boundsWidth;
+		break;
+	case kSlideRightMask:
+		oldBounds.left = newBounds.right = _bounds.left + pegasusRound(getFaderValue() * _boundsWidth, kTransitionRange);
+		oldBounds.right = oldBounds.left + _boundsWidth;
+		newBounds.left = newBounds.right - _boundsWidth;
+		break;
+	default:
+		newBounds.left = oldBounds.left = _bounds.left;
+		newBounds.right = oldBounds.right = _bounds.right;
+		break;
 	}
+
 	switch (_direction & kSlideVertMask) {
-		case kSlideDownMask:
-			oldBounds.top = newBounds.bottom = _bounds.top + pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
-			oldBounds.bottom = oldBounds.top + _boundsHeight;
-			newBounds.top = newBounds.bottom - _boundsHeight;
-			break;
-		case kSlideUpMask:
-			newBounds.top = oldBounds.bottom = _bounds.bottom - pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
-			newBounds.bottom = newBounds.top + _boundsHeight;
-			oldBounds.top = oldBounds.bottom - _boundsHeight;
-			break;
-		default:
-			newBounds.top = oldBounds.top = _bounds.top;
-			newBounds.bottom = oldBounds.bottom = _bounds.bottom;
-			break;
+	case kSlideDownMask:
+		oldBounds.top = newBounds.bottom = _bounds.top + pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
+		oldBounds.bottom = oldBounds.top + _boundsHeight;
+		newBounds.top = newBounds.bottom - _boundsHeight;
+		break;
+	case kSlideUpMask:
+		newBounds.top = oldBounds.bottom = _bounds.bottom - pegasusRound(getFaderValue() * _boundsHeight, kTransitionRange);
+		newBounds.bottom = newBounds.top + _boundsHeight;
+		oldBounds.top = oldBounds.bottom - _boundsHeight;
+		break;
+	default:
+		newBounds.top = oldBounds.top = _bounds.top;
+		newBounds.bottom = oldBounds.bottom = _bounds.bottom;
+		break;
 	}
 }
 


Commit: ff51a7661d7a2cb296b987edfc3d81727160e627
    https://github.com/scummvm/scummvm/commit/ff51a7661d7a2cb296b987edfc3d81727160e627
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-11T13:50:40-07:00

Commit Message:
PEGASUS: Fix minor filling station glitch

Changed paths:
    engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp



diff --git a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
index 61d77bf..53f12ba 100644
--- a/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
+++ b/engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
@@ -162,6 +162,7 @@ void NoradAlphaFillingStation::setStaticState(TimeValue time, int16 state) {
 	_rightSideMovie.stop();
 	_rightSideMovie.setSegment(0, _rightSideMovie.getDuration());
 	_rightSideMovie.setTime(time);
+	_rightSideMovie.redrawMovieWorld();
 	_state = state;
 	allowInput(true);
 }


Commit: d5ed8b1901b88e361a2a420a9daf586f6089a36b
    https://github.com/scummvm/scummvm/commit/d5ed8b1901b88e361a2a420a9daf586f6089a36b
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-12T17:18:13-07:00

Commit Message:
Merge remote branch 'upstream/master' into pegasus

Conflicts:
	AUTHORS

Changed paths:
  R engines/wintermute/readme.txt
    AUTHORS
    audio/midiparser.cpp
    audio/midiparser.h
    audio/midiparser_smf.cpp
    audio/midiparser_xmidi.cpp
    audio/softsynth/mt32/TVA.cpp
    backends/platform/maemo/debian/rules
    configure
    devtools/create_project/config.h
    devtools/create_project/create_project.cpp
    devtools/create_project/create_project.h
    devtools/create_project/msbuild.cpp
    devtools/create_project/msvc.cpp
    devtools/create_project/msvc.h
    devtools/create_project/scripts/postbuild.cmd
    devtools/create_project/visualstudio.cpp
    devtools/credits.pl
    dists/engine-data/README
    dists/scummvm.rc
    engines/agos/midiparser_s1d.cpp
    engines/cine/anim.cpp
    engines/cine/cine.cpp
    engines/cine/cine.h
    engines/cine/console.cpp
    engines/cine/gfx.cpp
    engines/cine/gfx.h
    engines/cine/main_loop.cpp
    engines/cine/object.cpp
    engines/cine/pal.cpp
    engines/cine/part.cpp
    engines/cine/saveload.cpp
    engines/cine/saveload.h
    engines/cine/script.h
    engines/cine/script_fw.cpp
    engines/cine/sound.cpp
    engines/cine/sound.h
    engines/cine/texte.cpp
    engines/cine/texte.h
    engines/cine/various.cpp
    engines/configure.engines
    engines/groovie/roq.cpp
    engines/mohawk/bitmap.cpp
    engines/parallaction/sound_br.cpp
    engines/sci/sound/midiparser_sci.cpp
    engines/sci/sound/midiparser_sci.h
    engines/scumm/midiparser_ro.cpp
    engines/toltecs/menu.cpp
    engines/toltecs/menu.h
    engines/toltecs/movie.cpp
    engines/toltecs/music.cpp
    engines/toltecs/music.h
    engines/toltecs/saveload.cpp
    engines/toltecs/screen.cpp
    engines/toltecs/script.cpp
    engines/toltecs/script.h
    engines/toltecs/sound.cpp
    engines/toltecs/sound.h
    engines/toltecs/toltecs.cpp
    engines/toltecs/toltecs.h
    engines/tony/custom.cpp
    engines/tony/custom.h
    engines/tony/detection_tables.h
    engines/tony/font.cpp
    engines/tony/font.h
    engines/tony/game.cpp
    engines/tony/gfxcore.cpp
    engines/tony/gfxcore.h
    engines/tony/gfxengine.cpp
    engines/tony/inventory.cpp
    engines/tony/loc.cpp
    engines/tony/loc.h
    engines/tony/mpal/expr.cpp
    engines/tony/mpal/expr.h
    engines/tony/mpal/loadmpc.cpp
    engines/tony/mpal/memory.cpp
    engines/tony/mpal/memory.h
    engines/tony/mpal/mpal.cpp
    engines/tony/mpal/mpal.h
    engines/tony/sound.cpp
    engines/tony/sound.h
    engines/tony/tony.cpp
    engines/tony/utils.cpp
    engines/wintermute/ad/ad_entity.cpp
    engines/wintermute/ad/ad_game.cpp
    engines/wintermute/ad/ad_inventory_box.cpp
    engines/wintermute/ad/ad_item.cpp
    engines/wintermute/ad/ad_layer.cpp
    engines/wintermute/ad/ad_object.cpp
    engines/wintermute/ad/ad_region.cpp
    engines/wintermute/ad/ad_response.cpp
    engines/wintermute/ad/ad_response_box.cpp
    engines/wintermute/ad/ad_rot_level.cpp
    engines/wintermute/ad/ad_scale_level.cpp
    engines/wintermute/ad/ad_scene.cpp
    engines/wintermute/ad/ad_scene_state.cpp
    engines/wintermute/ad/ad_sentence.cpp
    engines/wintermute/ad/ad_sprite_set.cpp
    engines/wintermute/ad/ad_talk_def.cpp
    engines/wintermute/ad/ad_talk_holder.cpp
    engines/wintermute/ad/ad_talk_node.cpp
    engines/wintermute/ad/ad_waypoint_group.cpp
    engines/wintermute/base/base_active_rect.cpp
    engines/wintermute/base/base_fader.cpp
    engines/wintermute/base/base_game.h
    engines/wintermute/base/base_save_thumb_helper.cpp
    engines/wintermute/base/base_sub_frame.cpp
    engines/wintermute/base/base_surface_storage.cpp
    engines/wintermute/base/base_transition_manager.cpp
    engines/wintermute/base/base_viewport.cpp
    engines/wintermute/base/file/base_save_thumb_file.cpp
    engines/wintermute/base/font/base_font_bitmap.cpp
    engines/wintermute/base/font/base_font_storage.cpp
    engines/wintermute/base/font/base_font_truetype.cpp
    engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp
    engines/wintermute/base/particles/part_emitter.cpp
    engines/wintermute/base/saveload.cpp
    engines/wintermute/base/scriptables/script_engine.cpp
    engines/wintermute/base/scriptables/script_ext_file.cpp
    engines/wintermute/base/sound/base_sound_buffer.cpp
    engines/wintermute/base/sound/base_sound_manager.cpp
    engines/wintermute/system/sys_class_registry.cpp
    engines/wintermute/ui/ui_button.cpp
    engines/wintermute/ui/ui_edit.cpp
    engines/wintermute/ui/ui_object.cpp
    engines/wintermute/ui/ui_tiled_image.cpp
    engines/wintermute/ui/ui_window.cpp
    engines/wintermute/video/video_theora_player.cpp
    engines/wintermute/wintermute.cpp
    graphics/decoders/image_decoder.h
    graphics/decoders/pict.cpp
    graphics/decoders/pict.h
    graphics/decoders/png.cpp
    gui/credits.h
    video/bink_decoder.cpp
    video/bink_decoder.h
    video/video_decoder.cpp
    video/video_decoder.h



diff --cc AUTHORS
index de78526,e8f0b83..2900d1c
--- a/AUTHORS
+++ b/AUTHORS
@@@ -139,12 -141,9 +141,12 @@@ ScummVM Tea
      Parallaction:
         peres
  
 +    Pegasus:
 +       Matthew Hoops
 +
      Queen:
-        David Eriksson        - (retired)
-        Gregory Montoir       - (retired)
+        David Eriksson          - (retired)
+        Gregory Montoir         - (retired)
         Joost Peters
  
      SAGA:
@@@ -609,9 -615,9 +618,12 @@@ Special thanks t
     of Dreamweb and for their tremendous support.
  
     Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe
-    Avalon for providing full source code for Soltys and letting us to
+    Avalon for providing full source code for Soltys and letting us
     redistribute the game.
  
+    Jan Nedoma for providing the sources to the Wintermute-engine, and for his
+    support while porting the engine to ScummVM.
+ 
 +   Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing
 +   the source code of The Journeyman Project: Pegasus Prime.
 +
diff --cc devtools/credits.pl
index 1ff051a,f7efa59..7e1985f
--- a/devtools/credits.pl
+++ b/devtools/credits.pl
@@@ -1145,12 -1147,12 +1151,16 @@@ begin_credits("Credits")
  
  	add_paragraph(
      "Janusz Wiśniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon ".
-     "for providing full source code for Sołtys and letting us to redistribute the game.");
+     "for providing full source code for Sołtys and letting us redistribute the game.");
+ 
+ 	add_paragraph(
+     "Jan Nedoma for providing the sources to the Wintermute-engine, and for his ".
+     "support while porting the engine to ScummVM.");
  
 +	add_paragraph(
 +    "Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for ".
 +    "providing the source code of The Journeyman Project: Pegasus Prime.");
 +
  	end_section();
  
  end_credits();
diff --cc engines/configure.engines
index 364e10b,404992b..96c46c7
--- a/engines/configure.engines
+++ b/engines/configure.engines
@@@ -27,12 -28,11 +28,12 @@@ add_engine cstime "Where in Time is Car
  add_engine riven "Riven: The Sequel to Myst" no
  add_engine myst "Myst" no
  add_engine parallaction "Parallaction" yes
 +add_engine pegasus "The Journeyman Project: Pegasus Prime" no
  add_engine queen "Flight of the Amazon Queen" yes
- add_engine saga "SAGA" yes "ihnm saga2"
+ add_engine saga "SAGA" yes "ihnm saga2" "ITE"
  add_engine ihnm "IHNM" yes
  add_engine saga2 "SAGA 2 games" no
- add_engine sci "SCI" yes "sci32"
+ add_engine sci "SCI" yes "sci32" "SCI 0-1.1 games"
  add_engine sci32 "SCI32 games" no
  add_engine sky "Beneath a Steel Sky" yes
  add_engine sword1 "Broken Sword" yes
diff --cc gui/credits.h
index 88d4920,35b5dcf..43b9292
--- a/gui/credits.h
+++ b/gui/credits.h
@@@ -720,9 -720,9 +723,11 @@@ static const char *credits[] = 
  "C0""",
  "C0""Neil Dodwell and David Dew from Creative Reality for providing the source of Dreamweb and for their tremendous support.",
  "C0""",
- "C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us to redistribute the game.",
+ "C0""Janusz Wisniewski and Miroslaw Liminowicz from Laboratorium Komputerowe Avalon for providing full source code for Soltys and letting us redistribute the game.",
+ "C0""",
+ "C0""Jan Nedoma for providing the sources to the Wintermute-engine, and for his support while porting the engine to ScummVM.",
  "C0""",
 +"C0""Bob Bell, Michel Kripalani, Tommy Yune, from Presto Studios for providing the source code of The Journeyman Project: Pegasus Prime.",
 +"C0""",
  "",
  };


Commit: 483989f72bb132d187112ec65b9a5bd3607f9252
    https://github.com/scummvm/scummvm/commit/483989f72bb132d187112ec65b9a5bd3607f9252
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-12T17:18:53-07:00

Commit Message:
Revert "PEGASUS: Make setting the start time of a movie also seek"

This reverts commit b8bcbb46b47b30c87a0267211ae4aae4c61c4c78.

8808393b3a3428df2946d7967e52aba084c8ffe5 was the proper fix for the issue

Changed paths:
    engines/pegasus/movie.cpp
    engines/pegasus/movie.h



diff --git a/engines/pegasus/movie.cpp b/engines/pegasus/movie.cpp
index fcceee1..6187d87 100644
--- a/engines/pegasus/movie.cpp
+++ b/engines/pegasus/movie.cpp
@@ -80,7 +80,7 @@ void Movie::initFromMovieFile(const Common::String &fileName, bool transparent)
 	if (!isSurfaceValid())
 		allocateSurface(bounds);
 
-	TimeBase::setStart(0, getScale());
+	setStart(0, getScale());
 	TimeBase::setStop(_video->getDuration().convertToFramerate(getScale()).totalNumberOfFrames(), getScale());
 }
 
@@ -132,13 +132,6 @@ void Movie::moveMovieBoxTo(const CoordType h, const CoordType v) {
 	_movieBox.moveTo(h, v);
 }
 
-void Movie::setStart(const TimeValue startTime, const TimeScale scale) {
-	TimeBase::setStart(startTime, scale);
-
-	if (_video)
-		_video->seek(Audio::Timestamp(0, _startTime, _startScale));
-}
-
 void Movie::setStop(const TimeValue stopTime, const TimeScale scale) {
 	TimeBase::setStop(stopTime, scale);
 
diff --git a/engines/pegasus/movie.h b/engines/pegasus/movie.h
index 275deec..9b9cc2b 100644
--- a/engines/pegasus/movie.h
+++ b/engines/pegasus/movie.h
@@ -62,8 +62,6 @@ public:
 
 	virtual void moveMovieBoxTo(const CoordType, const CoordType);
 
-	virtual void setStart(const TimeValue, const TimeScale = 0);
-
 	virtual void setStop(const TimeValue, const TimeScale = 0);
 
 	virtual TimeValue getDuration(const TimeScale = 0) const;


Commit: 167768669283620a2a951dcf212890a37cf1d6b8
    https://github.com/scummvm/scummvm/commit/167768669283620a2a951dcf212890a37cf1d6b8
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-09-12T20:04:46-07:00

Commit Message:
PEGASUS: Disable save compression by default

So they can be used by the original interpreter more easily (the type/creator codes still need to be set, though -- pegasus_save_types can handle that)

Changed paths:
    engines/pegasus/pegasus.cpp



diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp
index b307a19..cbe2222 100644
--- a/engines/pegasus/pegasus.cpp
+++ b/engines/pegasus/pegasus.cpp
@@ -616,7 +616,7 @@ Common::Error PegasusEngine::loadGameState(int slot) {
 
 Common::Error PegasusEngine::saveGameState(int slot, const Common::String &desc) {
 	Common::String output = Common::String::format("pegasus-%s.sav", desc.c_str());
-	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output);
+	Common::OutSaveFile *saveFile = _saveFileMan->openForSaving(output, false);
 	if (!saveFile)
 		return Common::kUnknownError;
 


Commit: 2e4ee0b2d0f687deb16ca18691042de1a21d7410
    https://github.com/scummvm/scummvm/commit/2e4ee0b2d0f687deb16ca18691042de1a21d7410
Author: clone2727 (clone2727 at gmail.com)
Date: 2012-09-20T13:17:39-07:00

Commit Message:
Merge pull request #275 from clone2727/pegasus

Pegasus engine (The Journeyman Project: Pegasus Prime)

Changed paths:
  A engines/pegasus/ai/ai_action.cpp
  A engines/pegasus/ai/ai_action.h
  A engines/pegasus/ai/ai_area.cpp
  A engines/pegasus/ai/ai_area.h
  A engines/pegasus/ai/ai_condition.cpp
  A engines/pegasus/ai/ai_condition.h
  A engines/pegasus/ai/ai_rule.cpp
  A engines/pegasus/ai/ai_rule.h
  A engines/pegasus/compass.cpp
  A engines/pegasus/compass.h
  A engines/pegasus/console.cpp
  A engines/pegasus/console.h
  A engines/pegasus/constants.h
  A engines/pegasus/cursor.cpp
  A engines/pegasus/cursor.h
  A engines/pegasus/detection.cpp
  A engines/pegasus/elements.cpp
  A engines/pegasus/elements.h
  A engines/pegasus/energymonitor.cpp
  A engines/pegasus/energymonitor.h
  A engines/pegasus/fader.cpp
  A engines/pegasus/fader.h
  A engines/pegasus/gamestate.cpp
  A engines/pegasus/gamestate.h
  A engines/pegasus/graphics.cpp
  A engines/pegasus/graphics.h
  A engines/pegasus/hotspot.cpp
  A engines/pegasus/hotspot.h
  A engines/pegasus/input.cpp
  A engines/pegasus/input.h
  A engines/pegasus/interaction.h
  A engines/pegasus/interface.cpp
  A engines/pegasus/interface.h
  A engines/pegasus/items/autodragger.cpp
  A engines/pegasus/items/autodragger.h
  A engines/pegasus/items/biochips/aichip.cpp
  A engines/pegasus/items/biochips/aichip.h
  A engines/pegasus/items/biochips/biochipitem.cpp
  A engines/pegasus/items/biochips/biochipitem.h
  A engines/pegasus/items/biochips/mapchip.cpp
  A engines/pegasus/items/biochips/mapchip.h
  A engines/pegasus/items/biochips/mapimage.cpp
  A engines/pegasus/items/biochips/mapimage.h
  A engines/pegasus/items/biochips/opticalchip.cpp
  A engines/pegasus/items/biochips/opticalchip.h
  A engines/pegasus/items/biochips/pegasuschip.cpp
  A engines/pegasus/items/biochips/pegasuschip.h
  A engines/pegasus/items/biochips/retscanchip.cpp
  A engines/pegasus/items/biochips/retscanchip.h
  A engines/pegasus/items/biochips/shieldchip.cpp
  A engines/pegasus/items/biochips/shieldchip.h
  A engines/pegasus/items/inventory.cpp
  A engines/pegasus/items/inventory.h
  A engines/pegasus/items/inventory/airmask.cpp
  A engines/pegasus/items/inventory/airmask.h
  A engines/pegasus/items/inventory/gascanister.cpp
  A engines/pegasus/items/inventory/gascanister.h
  A engines/pegasus/items/inventory/inventoryitem.cpp
  A engines/pegasus/items/inventory/inventoryitem.h
  A engines/pegasus/items/inventory/keycard.cpp
  A engines/pegasus/items/inventory/keycard.h
  A engines/pegasus/items/inventorypicture.cpp
  A engines/pegasus/items/inventorypicture.h
  A engines/pegasus/items/item.cpp
  A engines/pegasus/items/item.h
  A engines/pegasus/items/itemdragger.cpp
  A engines/pegasus/items/itemdragger.h
  A engines/pegasus/items/itemlist.cpp
  A engines/pegasus/items/itemlist.h
  A engines/pegasus/menu.cpp
  A engines/pegasus/menu.h
  A engines/pegasus/module.mk
  A engines/pegasus/movie.cpp
  A engines/pegasus/movie.h
  A engines/pegasus/neighborhood/caldoria/caldoria.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria.h
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.cpp
  A engines/pegasus/neighborhood/caldoria/caldoria4dsystem.h
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriabomb.h
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamessages.h
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.cpp
  A engines/pegasus/neighborhood/caldoria/caldoriamirror.h
  A engines/pegasus/neighborhood/door.cpp
  A engines/pegasus/neighborhood/door.h
  A engines/pegasus/neighborhood/exit.cpp
  A engines/pegasus/neighborhood/exit.h
  A engines/pegasus/neighborhood/extra.cpp
  A engines/pegasus/neighborhood/extra.h
  A engines/pegasus/neighborhood/hotspotinfo.cpp
  A engines/pegasus/neighborhood/hotspotinfo.h
  A engines/pegasus/neighborhood/mars/constants.h
  A engines/pegasus/neighborhood/mars/energybeam.cpp
  A engines/pegasus/neighborhood/mars/energybeam.h
  A engines/pegasus/neighborhood/mars/gravitoncannon.cpp
  A engines/pegasus/neighborhood/mars/gravitoncannon.h
  A engines/pegasus/neighborhood/mars/hermite.cpp
  A engines/pegasus/neighborhood/mars/hermite.h
  A engines/pegasus/neighborhood/mars/mars.cpp
  A engines/pegasus/neighborhood/mars/mars.h
  A engines/pegasus/neighborhood/mars/planetmover.cpp
  A engines/pegasus/neighborhood/mars/planetmover.h
  A engines/pegasus/neighborhood/mars/reactor.cpp
  A engines/pegasus/neighborhood/mars/reactor.h
  A engines/pegasus/neighborhood/mars/robotship.cpp
  A engines/pegasus/neighborhood/mars/robotship.h
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.cpp
  A engines/pegasus/neighborhood/mars/shuttleenergymeter.h
  A engines/pegasus/neighborhood/mars/shuttlehud.cpp
  A engines/pegasus/neighborhood/mars/shuttlehud.h
  A engines/pegasus/neighborhood/mars/shuttleweapon.cpp
  A engines/pegasus/neighborhood/mars/shuttleweapon.h
  A engines/pegasus/neighborhood/mars/spacechase3d.cpp
  A engines/pegasus/neighborhood/mars/spacechase3d.h
  A engines/pegasus/neighborhood/mars/spacejunk.cpp
  A engines/pegasus/neighborhood/mars/spacejunk.h
  A engines/pegasus/neighborhood/mars/tractorbeam.cpp
  A engines/pegasus/neighborhood/mars/tractorbeam.h
  A engines/pegasus/neighborhood/neighborhood.cpp
  A engines/pegasus/neighborhood/neighborhood.h
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.cpp
  A engines/pegasus/neighborhood/norad/alpha/ecrmonitor.h
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.cpp
  A engines/pegasus/neighborhood/norad/alpha/fillingstation.h
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.cpp
  A engines/pegasus/neighborhood/norad/alpha/noradalpha.h
  A engines/pegasus/neighborhood/norad/alpha/panorama.cpp
  A engines/pegasus/neighborhood/norad/alpha/panorama.h
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.cpp
  A engines/pegasus/neighborhood/norad/alpha/panoramascroll.h
  A engines/pegasus/neighborhood/norad/constants.h
  A engines/pegasus/neighborhood/norad/delta/globegame.cpp
  A engines/pegasus/neighborhood/norad/delta/globegame.h
  A engines/pegasus/neighborhood/norad/delta/noraddelta.cpp
  A engines/pegasus/neighborhood/norad/delta/noraddelta.h
  A engines/pegasus/neighborhood/norad/norad.cpp
  A engines/pegasus/neighborhood/norad/norad.h
  A engines/pegasus/neighborhood/norad/noradelevator.cpp
  A engines/pegasus/neighborhood/norad/noradelevator.h
  A engines/pegasus/neighborhood/norad/pressuredoor.cpp
  A engines/pegasus/neighborhood/norad/pressuredoor.h
  A engines/pegasus/neighborhood/norad/pressuretracker.cpp
  A engines/pegasus/neighborhood/norad/pressuretracker.h
  A engines/pegasus/neighborhood/norad/subcontrolroom.cpp
  A engines/pegasus/neighborhood/norad/subcontrolroom.h
  A engines/pegasus/neighborhood/norad/subplatform.cpp
  A engines/pegasus/neighborhood/norad/subplatform.h
  A engines/pegasus/neighborhood/prehistoric/prehistoric.cpp
  A engines/pegasus/neighborhood/prehistoric/prehistoric.h
  A engines/pegasus/neighborhood/spot.cpp
  A engines/pegasus/neighborhood/spot.h
  A engines/pegasus/neighborhood/tsa/fulltsa.cpp
  A engines/pegasus/neighborhood/tsa/fulltsa.h
  A engines/pegasus/neighborhood/tsa/tinytsa.cpp
  A engines/pegasus/neighborhood/tsa/tinytsa.h
  A engines/pegasus/neighborhood/turn.cpp
  A engines/pegasus/neighborhood/turn.h
  A engines/pegasus/neighborhood/view.cpp
  A engines/pegasus/neighborhood/view.h
  A engines/pegasus/neighborhood/wsc/moleculebin.cpp
  A engines/pegasus/neighborhood/wsc/moleculebin.h
  A engines/pegasus/neighborhood/wsc/wsc.cpp
  A engines/pegasus/neighborhood/wsc/wsc.h
  A engines/pegasus/neighborhood/zoom.cpp
  A engines/pegasus/neighborhood/zoom.h
  A engines/pegasus/notification.cpp
  A engines/pegasus/notification.h
  A engines/pegasus/pegasus.cpp
  A engines/pegasus/pegasus.h
  A engines/pegasus/scoring.h
  A engines/pegasus/sound.cpp
  A engines/pegasus/sound.h
  A engines/pegasus/surface.cpp
  A engines/pegasus/surface.h
  A engines/pegasus/timers.cpp
  A engines/pegasus/timers.h
  A engines/pegasus/transition.cpp
  A engines/pegasus/transition.h
  A engines/pegasus/types.h
  A engines/pegasus/util.cpp
  A engines/pegasus/util.h
    AUTHORS
    audio/decoders/aiff.h
    audio/decoders/quicktime.h
    backends/events/sdl/sdl-events.cpp
    common/keyboard.h
    common/macresman.cpp
    common/macresman.h
    common/rational.h
    common/rect.h
    devtools/credits.pl
    engines/configure.engines
    engines/engines.mk
    engines/plugins_table.h
    engines/scumm/he/wiz_he.cpp
    graphics/decoders/pict.h
    graphics/primitives.cpp
    graphics/primitives.h
    graphics/surface.cpp
    graphics/surface.h
    gui/credits.h
    video/qt_decoder.h









More information about the Scummvm-git-logs mailing list